Maven assembly plugin error reading assemblies no assembly descriptors found

Maven assembly-Ошибка чтения сборок Я определил персонализированный дескриптор сборки jar-with-dependencies. Однако, когда я выполняю его с помощью mvn assembly: assembly, я получаю: мой jar-with-dependencies.в XML находится в src / main / ресурсы / сборки/. мой дескриптор сборки следующий: и мой проект pom.xml: когда выполняется сборка mvn: сборка, зависимости распаковываются, и я получаю предыдущая ошибка […]

Содержание

  1. Maven assembly-Ошибка чтения сборок
  2. 2 ответов
  3. How to Create Executable JAR file with resources and dependencies using Maven in Eclipse
  4. References:
  5. Related Tutorials:
  6. Other Java Coding Tutorials:
  7. About the Author:

Maven assembly-Ошибка чтения сборок

Я определил персонализированный дескриптор сборки jar-with-dependencies. Однако, когда я выполняю его с помощью mvn assembly: assembly, я получаю:

мой jar-with-dependencies.в XML находится в src / main / ресурсы / сборки/.

мой дескриптор сборки следующий:

и мой проект pom.xml:

когда выполняется сборка mvn: сборка, зависимости распаковываются, и я получаю предыдущая ошибка по завершении распаковки.

более того, если я выполняю сборку mvn-e:assembly, говорят, что дескрипторы не найдены, однако он пытается распаковать зависимости и создается JAR с зависимостями, но он не содержит META-INF/services/* как указано в дескрипторе :

Я не вижу своей ошибки. У кого-то есть решение ?

2 ответов

здесь есть две проблемы. Во-первых, при использовании собственного дескриптора необходимо указать путь свой настроенный файл дескриптора (кстати, вы можете использовать любое место, но поставив в дескриптор src/main/resources возможно, это не лучший выбор, вы действительно не хотите, чтобы дескриптор был упакован в вашем приложении, я бы использовал стандартное местоположение, которое src/main/assembly как говорится в на этой странице).

во-вторых, ваш configuration элемент в настоящее время внутри execution блок и, таким образом, характерные для этой исполнения. Другими словами, он не будет применяться, если вы запустите assembly:assembly в командной строке. Итак, если вы хотите позвонить assembly:assembly с пользовательским дескриптором используйте:

или переместить configuration за пределами execution элемент (чтобы сделать конфигурацию глобальной):

Источник

How to Create Executable JAR file with resources and dependencies using Maven in Eclipse

As you can see, this Java project contains resource files like images and XML, and dependencies for Hibernate framework. So what we are going to show you is how to generate the executable JAR file of this project in a manner that the JAR file contains all the resources and dependencies (uber-JAR or fat JAR file).

And you know, creating such JAR file is not possible with Eclipse’s Export function (File > Export > Java > Runnable JAR file). But the good news is that Maven provides a great plugin that is dedicated for creating executable JAR files with resources and dependencies. This plugin is called Maven Assembly Plugin.

To use the Maven Assembly Plugin, declare the following XML code in the

section which is under the section of the pom.xml file:

That makes the pom.xml file looks like the following:

Here, there are two noteworthy points:

    The packaging type of the project must be jar:
  • The element specifies the main class of your application in form of fully qualified name. For example, in the above XML we specify the main class is com.inventory.gui.InventoryApp

mvn clean install assembly:single

In Eclipse, right click on the project and select Run As > Maven build, and specify the goal assembly:single in the dialog, then click Run:

Wait a moment for the build to complete, and then check the JAR file generated under the project’s target directory. Note that the JAR file contains all the resources and dependencies (fat JAR or uber-JAR).

References:

Other Java Coding Tutorials:

Nam Ha Minh is certified Java programmer (SCJP and SCWCD). He started programming with Java in the time of Java 1.4 and has been falling in love with Java since then. Make friend with him on Facebook and watch his Java videos you YouTube.

Источник


  • Type:


    Bug

  • Status:

    Closed


  • Priority:


    Major

  • Resolution:

    Not A Problem


  • Affects Version/s:


    None

  • Fix Version/s:



    None


  • Component/s:


    None

While trying to build this project https://sourceforge.net/p/tuxguitar/ on FreeBSD, maven fails:

«`

[INFO] ————————————————————————
[INFO] BUILD FAILURE
[INFO] ————————————————————————
[INFO] Total time: 10.235 s
[INFO] Finished at: 2019-02-23T08:54:38-08:00
[INFO] ————————————————————————
[ERROR] Failed to execute goal org.apache.maven.plugins:maven-assembly-plugin:2.2-beta-5:assembly (default-cli) on project tuxguitar-pom: Error reading assemblies: No assembly descriptors found. -> [Help 1]
[ERROR]
[ERROR] To see the full stack trace of the errors, re-run Maven with the -e switch.
[ERROR] Re-run Maven using the -X switch to enable full debug logging.
[ERROR]
[ERROR] For more information about the errors and possible solutions, please read the following articles:
[ERROR] [Help 1] http://cwiki.apache.org/confluence/display/MAVEN/MojoExecutionException

«`

The TuxGuitar bug report: https://sourceforge.net/p/tuxguitar/bugs/106/

я получил Error reading assemblies: No assembly descriptors found при сборке моего проекта. Я пытаюсь установить разрешения для своего .sh файлы и исключить неприятный .jar файл, из-за которого мое приложение вылетает … Я не думаю, что проблема в этом ….

Мой плагин maven-assembly добавлен в мой файл pom.xml следующим образом:

<plugin>
       <artifactId>maven-assembly-plugin</artifactId>
       <version>2.2.1</version>
       <executions>
       <execution>
           <id>make-assembly</id>
           <phase>package</phase>
           <goals>
             <goal>single</goal>
           </goals>
           <configuration>
           <descriptors>
             <descriptor>src/main/assembly/src.xml</descriptor>
           </descriptors>
           </configuration>
      </execution>
      </executions> 
</plugin>

Мой дескриптор сборки выглядит так:

<assembly xmlns="http://maven.apache.org/plugins/maven-assembly-plugin/assembly/1.1.2" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
  xsi:schemaLocation="http://maven.apache.org/plugins/maven-assembly-plugin/assembly/1.1.2 http://maven.apache.org/xsd/assembly-1.1.2.xsd">
  <id>my-assembly-descriptor</id>
  <formats>
    <format>jar</format>
    <format>war</format>
  </formats>
  <fileSets>
        <fileSet>
            <directory>${project.build.directory}</directory>
            <outputDirectory>${project.build.directory}</outputDirectory>
            <includes>
                <include>*.sh</include>
            </includes>
            <fileMode>0755</fileMode>
        </fileSet>
  </fileSets>
  <dependencySets>
    <dependencySet>
        <excludes>
        <exclude>spring-2.5.4.jar</exclude>
      </excludes>
    </dependencySet>
  </dependencySets>
</assembly>

Структура моего проекта:

Interface - src - main - assembly - src.xml

          - pom.xml

При попытке выполнить «Запуск от имени» -> «Отладка как» ->, а затем при установке цели
assembly:single

Я получаю ту же ошибку. Я пробовал в консоли, с assembly:assembly, и я ничего не получил. Я даже пытался указать неверный путь к дескриптору сборки, но ошибка не изменилась. При установке ${basedir}/ перед путем к моему дескриптору сборки я получаю то же самое.

У меня Ubuntu 10.10 Maverick Meerkat, и я работаю с Eclipse EE, …

Благодаря!

Details
Written by  
Last Updated on 02 July 2019   |   Print  Email

In this article, we are going to guide you how to create an executable JAR file from a Java project which uses Maven build system. It’s worth mentioning that the project contains resource files (XML configuration, images, etc) that are in a directory different from the Java source files directory. And the project also contains some dependencies as well. The following screenshot illustrates such a Java project:

Java Maven Project

 

As you can see, this Java project contains resource files like images and XML, and dependencies for Hibernate framework. So what we are going to show you is how to generate the executable JAR file of this project in a manner that the JAR file contains all the resources and dependencies (uber-JAR or fat JAR file).

And you know, creating such JAR file is not possible with Eclipse’s Export function (File > Export > Java > Runnable JAR file). But the good news is that Maven provides a great plugin that is dedicated for creating executable JAR files with resources and dependencies. This plugin is called Maven Assembly Plugin.

To use the Maven Assembly Plugin, declare the following XML code in the <plugins> section which is under the <build>section of the pom.xml file:

<plugin>
	<artifactId>maven-assembly-plugin</artifactId>
	<configuration>
		<archive>
			<manifest>
				<mainClass>com.inventory.gui.InventoryApp</mainClass>
			</manifest>
		</archive>
		<descriptorRefs>
			<descriptorRef>jar-with-dependencies</descriptorRef>
		</descriptorRefs>
	</configuration>
</plugin>

 

That makes the pom.xml file looks like the following:

<project ....>
	<modelVersion>4.0.0</modelVersion>
	<groupId>com.inventory</groupId>
	<artifactId>Inventory</artifactId>
	<packaging>jar</packaging>
	<version>0.0.1-SNAPSHOT</version>
	<name>Inventory Management</name>
	

	<dependencies>
		....
		
	</dependencies>

	<build>
		<plugins>
			<plugin>
				<artifactId>maven-assembly-plugin</artifactId>
				<configuration>
					<archive>
						<manifest>
							<mainClass>com.inventory.gui.InventoryApp</mainClass>
						</manifest>
					</archive>
					<descriptorRefs>
						<descriptorRef>jar-with-dependencies</descriptorRef>
					</descriptorRefs>
				</configuration>
			</plugin>
		</plugins>
	</build>
</project>

Here, there are two noteworthy points:

  • The packaging type of the project must be jar: <packaging>jar</packaging>
  • The <mainClass> element specifies the main class of your application in form of fully qualified name. For example, in the above XML we specify the main class is com.inventory.gui.InventoryApp

And to generate the JAR file from the project, run Maven with the goal assembly:single. For example, in the command line:

mvn clean install assembly:single

 

In Eclipse, right click on the project and select Run As > Maven build, and specify the goal assembly:single in the dialog, then click Run:

Assembly Single Goal Maven

Wait a moment for the build to complete, and then check the JAR file generated under the project’s target directory. Note that the JAR file contains all the resources and dependencies (fat JAR or uber-JAR).

References:

  • Maven Assembly Plugin

 

Related Tutorials:

  • How to create JAR file in Eclipse
  • How to create Java web project with Maven in Eclipse

Other Java Coding Tutorials:

  • 10 Common Mistakes Every Beginner Java Programmer Makes
  • 10 Java Core Best Practices Every Java Programmer Should Know
  • How to become a good programmer? 13 tasks you should practice now
  • How to calculate MD5 and SHA hash values in Java
  • How to generate random numbers in Java

About the Author:

Nam Ha Minh is certified Java programmer (SCJP and SCWCD). He started programming with Java in the time of Java 1.4 and has been falling in love with Java since then. Make friend with him on Facebook and watch his Java videos you YouTube.

Add comment

Почему я получаю «Не найдены дескрипторы сборки». ошибка при создании этого проекта?

Вопрос:

У меня есть небольшой проект, написанный в Котлине. Когда я запускаю clean compile assembly:single install, я получаю следующее сообщение об ошибке:

Failed to execute goal org.apache.maven.plugins:maven-assembly-plugin:2.2-beta-5:single
(default-cli) on project alma-econsim: Error reading assemblies: No assembly
descriptors found. -> [Help 1]

Мой jar-with-dependencies.xml находится в src/main/assembly и указан в pom.xml следующим образом:

<plugin>
<artifactId>maven-assembly-plugin</artifactId>
<version>2.2-beta-5</version>
<executions>
<execution>
<id>assembly</id>
<goals>
<goal>single</goal>
</goals>
<phase>package</phase>
<configuration>
<descriptors>
<descriptor>src/main/assembly/jar-with-dependencies.xml</descriptor>
</descriptors>
</configuration>
</execution>
</executions>
</plugin>

Но я все еще получаю ошибку. Как я могу исправить свой проект, чтобы иметь возможность упаковать его в виде банки с зависимостями?

Лучший ответ:

Сначала используйте uptodate версию maven-assembly-plugin, а не старую версию… Кроме того, вы должны называть это через mvn clean package потому что вы привязали maven-assembly-plugin к фазе жизненного цикла package… если вы попытаетесь do mvn... assembly:single вы не называете жизненный цикл… Помимо этого вы хотели бы использовать дескриптор jar-with-dependencies чем вы должны сделать это следующим образом:

<project>
  [...]
  <build>
    [...]
    <plugins>
      <plugin>
        <!-- NOTE: We don't need a groupId specification because the group is
             org.apache.maven.plugins ...which is assumed by default.
         -->
        <artifactId>maven-assembly-plugin</artifactId>
        <version>2.6</version>
        <configuration>
          <descriptorRefs>
            <descriptorRef>jar-with-dependencies</descriptorRef>
          </descriptorRefs>
        </configuration>
        [...]
</project>

Кроме того, если вы называете Maven следующим образом:

mvn clean compile assembly:single install

Чем вы называете фазу компиляции двойной, просто просто:

mvn clean install 

достаточно. Я могу порекомендовать прочитать документ о жизни.

Понравилась статья? Поделить с друзьями:
  • Mats error code 00000003
  • Mats error code 000000000229
  • Mats error code 000000000220
  • Maximum permissible error
  • Mats 33 ошибки