views:

94

answers:

2

I would like to generate a .jar application from a project made in Maven.

I am working in Eclipse, and I made: run as/Maven assembly:assembly

This is the error message:

[ERROR] Failed to execute goal org.apache.maven.plugins:maven-assembly-plugin:2.2-beta-4:assembly (default-cli) on project FeelIndexer: Error reading assemblies: No assembly descriptors found.

This is my assamble.xml

<assembly>
  <id>exe</id>
  <formats>
        <format>jar</format>
  </formats>
  <includeBaseDirectory>false</includeBaseDirectory>
  <dependencySets>
        <dependencySet>
          <outputDirectory></outputDirectory>
          <outputFileNameMapping></outputFileNameMapping>
          <unpack>true</unpack>
          <scope>runtime</scope>
          <includes>
            <include>commons-lang:commons-lang</include>
            <include>commons-cli:commons-cli</include>
          </includes>
        </dependencySet>
  </dependencySets>
  <fileSets>
        <fileSet>
          <directory>target/classes</directory>
          <outputDirectory></outputDirectory>
        </fileSet>
  </fileSets>
</assembly>

I think i have to include something else for adding the dependencies of muy project, but i don't know how to do it!! suggestions??

Update: Below my assembly.xml

<assembly>
      <id>exe</id>
      <formats>
        <format>jar</format>
      </formats>
      <includeBaseDirectory>false</includeBaseDirectory>
      <dependencySets>
        <dependencySet>
          <outputDirectory></outputDirectory>
          <outputFileNameMapping></outputFileNameMapping>
          <unpack>true</unpack>
          <scope>runtime</scope>
          <includes>
            <include>commons-lang:commons-lang</include>
            <include>commons-cli:commons-cli</include>
          </includes>
        </dependencySet>
      </dependencySets>
      <fileSets>
        <fileSet>
          <directory>target/classes</directory>
          <outputDirectory></outputDirectory>
        </fileSet>
      </fileSets>
    <plugins>
          <plugin>
        <artifactId>maven-assembly-plugin</artifactId>
        <version>2.2-beta-5</version>
        <configuration>
          <descriptors>
            <descriptor>src/main/assembly/src.xml</descriptor>
          </descriptors>
        </configuration>
          </plugin>
    </plugins>
    </assembly>

Where could i find my maven-assembly-plugin configuration??

I tried two options you told me:

  • Using predefined assembly.xml
  • Inserting plugin

I had the same result :s

+1  A: 

To use a custom assembly descriptor, you have to declare it in the plugin configuration:

<project>
  [...]
  <build>
    [...]
    <plugins>
      <plugin>
        <artifactId>maven-assembly-plugin</artifactId>
        <version>2.2-beta-5</version>
        <configuration>
          <descriptors>
            <descriptor>src/main/assembly/src.xml</descriptor>
          </descriptors>
        </configuration>
        [...]
      </plugin>
   </plugins>
</project>

By the way, wouldn't the predefined assembly jar-with-dependencies suit your needs? I don't see much differences with your custom assembly and my suggestion would be to use the predefined one:

<project>
  [...]
  <build>
    [...]
    <plugins>
      <plugin>
        <artifactId>maven-assembly-plugin</artifactId>
        <version>2.2-beta-5</version>
        <configuration>
          <descriptorRefs>
            <descriptorRef>jar-with-dependencies</descriptorRef>
          </descriptorRefs>
        </configuration>
        [...]
     </plugin>
  </plugins>
</project>

Update: I don't understand what you're doing and I'm not sure you understood how the assembly plugin works.

  1. The Maven Assembly Plugin configuration (the above samples, enclosed by <plugin>) goes in the pom.xml, not in the assembly descriptor.
  2. If you configure the Maven Assembly Plugin to use src/main/assembly/src.xml as assembly descriptor, the file must exist (so either rename your assembly descriptor or change the configuration, the above sample was just... an example).
  3. From what I see, you don't need a custom assembly descriptor. You could simply use the second snippet I gave in my initial answer (put it in your pom.xml).
Pascal Thivent
A: 

-- Content Moved to original question --

Blanca