views:

3287

answers:

2

Hello I am trying to create a custom descriptor ref in my parent pom which packages all dependencies with sources. I got the assembly.xml nailed down pretty well, but when I add it to my base POM assembly:assembly fails like so:

[INFO] [assembly:assembly]
[INFO] ------------------------------------------------------------------------
[ERROR] BUILD ERROR
[INFO] ------------------------------------------------------------------------
[INFO] Error reading assemblies: No assembly descriptors found.

[INFO] ------------------------------------------------------------------------
[INFO] Trace
org.apache.maven.lifecycle.LifecycleExecutionException: Error reading assemblies: No assembly descriptors found.

But assembly:single seems to work correctly. I've tried adding the jar-with-dependencies ref into the POM as well, but I am not sure if this is even possible.

Here is what I have in my base pom:

<plugin>
 <artifactId>maven-assembly-plugin</artifactId>
 <version>2.2-beta-3</version>
 <dependencies>
  <dependency>
   <groupId>mycompany.jar.assembly</groupId>
   <artifactId>jar-with-dependencies-and-sources-test</artifactId>
   <version>1.0.0-SNAPSHOT</version>
  </dependency>
 </dependencies>
 <executions>
  <execution>
   <id>make-assembly</id>
   <phase>package</phase>
   <goals>
    <goal>single</goal>
   </goals>
   <configuration>
    <descriptors>
     <descriptor>assembly.xml</descriptor>
    </descriptors>
   </configuration>
  </execution>
 </executions>
</plugin>

Does anyone out there know who to get this to work when I invoke mvn assembly:assembly from the command line?

Thanks in advance.

A: 

Where do you have your assembly.xml? Maven's working directory is the directory of a module (the one which contains pom.xml). If your assembly.xml is no in the same directory as this pom.xml, you should specify the path

artemb
assembly.xml is in src/main/resources/assemblies of: mycompany.jar.assemblyjar-with-dependencies-and-sources-testjar
javamonkey79
+3  A: 

I'm not sure, but I have a suspicion. You define assembly:single as part of the package phase, and identify the descriptor there in the execution element. This may mean the plugin doesn't know where to look for the descriptor when you run assembly:assembly. Try copying your <configuration> element to outside of the <executions> element.

One of my poms looks like this, and I use assembly:assembly all the time:

<plugin>
  <artifactId>maven-assembly-plugin</artifactId>
  <version>2.1</version> 
  <configuration>
    <finalName>myJar</finalname>
    <descriptors>
      <descriptor>src/main/config/descriptor.xml</descriptor>
    </descriptors>
    <archive>
      <manifest>
        <mainClass>org.foo.Bar</mainClass>
      </manifest>
    </archive>
  </configuration>
</plugin>

Note src/main/config isn't a Maven standard path, but I haven't defined any special handling of it.

super_aardvark
That did it! Thanks so much :)
javamonkey79
The reason why the <configuration> element is inside the <executions> element is because the plugin's page does it like that. See: http://maven.apache.org/plugins/maven-assembly-plugin/examples/sharing-descriptors.html. I wonder that page is outdated.
aberrant80