tags:

views:

173

answers:

1

Hi My assembly descriptor for module (APP1) is:

         <?xml version="1.0" encoding="UTF-8"?><assembly>
  <id>report</id>
    <formats>
    <format>jar</format>
  </formats>
  <includeBaseDirectory>false</includeBaseDirectory>
  <moduleSets>
    <moduleSet>
      <includes>
    <include>*-APP2</include>[trying to refer to another module ie module-APP2]
      </includes>
      <sources>
    <fileSets>
      <fileSet>
        <directory>/</directory>
        <includes>
          <include>**/target</include>
        </includes>
      </fileSet>
    </fileSets>
    <excludeSubModuleDirectories>false</excludeSubModuleDirectories>
    <outputDirectoryMapping>/</outputDirectoryMapping>
      </sources>
    </moduleSet>
  </moduleSets>
</assembly>

When I am running the mvn install cmd , I'm getting

[WARNING] The following patterns were never triggered in this artifact inclusion filter:
o  '*-APP2'

where have I gone wrong?

I modified as :

<?xml version="1.0" encoding="UTF-8"?><assembly>
  <id>report</id>
  <formats>
    <format>jar</format>
  </formats>
  <includeBaseDirectory>false</includeBaseDirectory>
  <moduleSets>
    <moduleSet>
      <includes>
    <include>sampleMaven:module-APP2</include>
      </includes>
      <sources>
    <fileSets>
      <fileSet>
        <directory>/</directory>
        <includes>
          <include>target/*</include>
        </includes>
      </fileSet>
    </fileSets>
    <excludeSubModuleDirectories>false</excludeSubModuleDirectories>
    <outputDirectoryMapping>/</outputDirectoryMapping>
      </sources>
    </moduleSet>
  </moduleSets>
</assembly>

still getting :

[WARNING] The following patterns were never triggered in this artifact inclusion filter:
o  'sampleMaven:module-APP2'

Updated on 18/sep: Main proj pom.xml-->

http://maven.apache.org/maven-v4_0_0.xsd"> 4.0.0 sampleMaven anu 0.0.1-SNAPSHOT pom

APP1

<module>APP2</module>

2)For APP1, the pom.xml is-->

   <project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd"&gt;

anu sampleMaven 0.0.1-SNAPSHOT 4.0.0 sampleMaven APP1 APP1 0.0.1-SNAPSHOT pom

../APP2

 <plugins>
  <plugin>
   <artifactId>maven-assembly-plugin</artifactId>
   <version>2.2-beta-3</version>
   <executions>
    <execution>
     <id>assemblyone</id>
     <phase>compile</phase>
     <goals>
      <goal>single</goal>
     </goals>
     <configuration>
      <finalName>App1</finalName>
      <appendAssemblyId>false</appendAssemblyId>
      <descriptors>
       <descriptor>${basedir}/src/main/resources/assemblies/report.xml</descriptor>
      </descriptors>

     </configuration>

    </execution>
    </executions>
    </plugin>
    </plugins>
    </build>

3)Assembly descriptor is -->

       <?xml version="1.0" encoding="UTF-8"?>

report jar false


<sources>
<fileSets>
  <fileSet>
    <directory>/</directory>
    <includes>
      <include>target/*</include>
    </includes>
  </fileSet>
</fileSets>
<excludeSubModuleDirectories>false</excludeSubModuleDirectories>
<outputDirectoryMapping>/</outputDirectoryMapping>
  </sources>


  <binaries>
    <outputDirectory>
      ${module.artifactId}-${module.version}
    </outputDirectory>
    <dependencySets>
      <dependencySet/>
    </dependencySets>
  </binaries>
</moduleSet>

On running gettting-->Error stacktrace: org.apache.maven.project.DuplicateProjectException: Project 'sampleMaven:APP2' is duplicated in the reactor

+3  A: 

Update: The Maven book has a section on including moduleSets in assemblies. The approach you have in your example is deprecated. There is also a problem with build order when defining moduleSets from the parent. The parent must be built first so the child can inherit from it, but the child must be built so that the parent can includ it in its assembly. The following approach addresses that cycle.

Define a parent pom that references an assembly module.

<?xml version="1.0" encoding="UTF-8"?>
<project>
  <modelVersion>4.0.0</modelVersion>
  <groupId>name.seller.rich</groupId>
  <artifactId>test-parent</artifactId>
  <packaging>pom</packaging>
  <version>1.0.0</version>
  <modules>
    <module>test-assembly</module>
  </modules>
  <dependencies>
</project>

In the assembly module, define a module with a relative path to the actual application module(s), and define the assembly plugin configuration:

<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd"&gt;
  <modelVersion>4.0.0</modelVersion>
  <groupId>name.seller.rich</groupId>
  <artifactId>test-assembly</artifactId>
  <packaging>pom</packaging>
  <version>1.0.0-SNAPSHOT</version>
  <modules>
    <module>../my-app2</module>
  </modules>
  <build>
    <plugins>
      <plugin>
    <artifactId>maven-assembly-plugin</artifactId>
    <version>2.2-beta-4</version>
    <executions>
      <execution>
        <id>assembly</id>
        <phase>package</phase>
        <goals>
          <goal>single</goal>
        </goals>
        <configuration>
          <finalName>App1</finalName>
          <appendAssemblyId>false</appendAssemblyId>
          <descriptors>
            <descriptor>src/main/assembly/my-assembly.xml</descriptor>
          </descriptors>
        </configuration>
      </execution>
    </executions>
      </plugin>
    </plugins>
  </build>
</project>

and my-assembly.xml is defined as follows:

<?xml version="1.0" encoding="UTF-8"?><assembly>
  <id>my-assembly</id>
  <formats>
    <format>jar</format>
  </formats>
  <includeBaseDirectory>false</includeBaseDirectory>
  <moduleSets>  
    <moduleSet>
      <binaries>
        <outputDirectory>
          ${module.artifactId}-${module.version}
        </outputDirectory>
        <dependencySets>
          <dependencySet/>
        </dependencySets>
      </binaries>
    </moduleSet>
  </moduleSets>
</assembly>

Building the parent module will then result in a build order of:

  1. test-parent
  2. my-app2
  3. test-assembly

So when the assembly comes to be packaged, my-app2 is built, and is available for inclusion. The binaries declaration will include the jars.

Rich Seller
i tried as per your suggestion.still getting same error.pls chk my edited section in the main question
+1 I was watching your response, as you didn't entirely solve his problem. I knew you would improve your answer. Glad you did, I'll try to learn about it, as I'm currently having troubles with assembly too...
KLE
@KLE thanks. The Maven book chapter on assembly modules is really pretty good and worth a read. Though neither the book or the assembly plugin docs make it clear that parents can't include children because of the cycle.
Rich Seller
@Richseller..thanks for the valuable inputs.i did as you mentioned.I have put my configuration files in the edited section of my question.I m getting :[ERROR] Duplicated project detected.Project: sampleMaven:APP2File: /Users/anu/EclipseWorks3.4/anu/APP2/pom.xmlFile: /Users/anu/EclipseWorks3.4/anu/APP2/pom.xmlNOTE: Each project in a Maven build must have a unique combination of groupId and artifactId.
I think you get this because you've got APP2 declared as a module in both the parent and the assembly. Remove it from the parent so it is included only once
Rich Seller
Bfore I select this module Implementation for my project, i want to know if assembly in mod-1 can inlude the .class files of mod-2/parent project.If so, how should i go about it? i didn't find any satisfactory results while searching google.pls help me out
A parent project can't have anything but pom packaging, so really shouldn't have any code in it, you should move the code into another module so it can be declared as a dependency by the other modules. You can then use the assembly plugin to copy the jar into your lib directory, or unpack the dependency classes if needed.
Rich Seller