During assemby, I want include all files from a release directory into the root of my assembly.
If I do the following:
<fileSet>
<directory>${basedir}/</directory>
<outputDirectory>/</outputDirectory>
<includes>
<include>src/main/resources/release/**</include>
</includes>
</fileSet>
Then all of the files get added to a folder named src/main/resources/release/ inside my release.
Is there a way to not include the folder path when including the fields?
I'm using the 2.3 version of the assembly plugin. If there is not a way to do this with the assembly plugin is there a way to do this with other plugins? (preferably without resorting to the ant plugin).
You have to do the configuration a little bit different like this:
<fileSet>
<directory>src/main/resources/release/</directory>
<outputDirectory>/</outputDirectory>
<includes>
<include>**</include>
</includes>
</fileSet>
Related
I've multi module project and using maven's assembly plugin to zip the project's artifact.
Proj
+Module A
pom.xml
+Module B
pom.xml
pom.xml
When i build main module, it will produce following things
Proj
+Module A
target\A.jar
target\A-source.jar
target\A-javadoc.jar
+Module B
target\B.jar
target\B-source.jar
target\B-javadoc.jar
1) I've added assembly plugin under ModuleB pom file and I'm using ModuleSet in assembly discriptor file
<moduleSets>
<moduleSet>
<useAllReactorProjects>true</useAllReactorProjects>
<includes>
<include>groupA:A:jar</include>
<include>groupA:A:javadoc</include>
<include>groupA:A:source</include>
</includes>
<binaries>
<outputDirectory>moduleA</outputDirectory>
<unpack>false</unpack>
</binaries>
</moduleSet>
<moduleSet>
<useAllReactorProjects>true</useAllReactorProjects>
<includes>
<include>groupB:B:jar</include>
<include>groupB:B:javadoc</include>
<include>groupB:B:source</include>
</includes>
<binaries>
<outputDirectory>moduleB</outputDirectory>
<unpack>false</unpack>
</binaries>
</moduleSet>
</moduleSets>
But i'm getting only A.jar and B.Jar under zip file. I'm not getting javadoc and source in zip file. Is it downloading it from m2 repo, i'm suspecting if it does so, because sources and java doc wouldn't be there in maven reporee artifact. How can i add all three artifact in a zip file ?
2) I want to add assembly plugin in my parent pom rather than in ModuleB's pom but if i do so, i get an exception "Please ensure the package phase is run before the assembly is generated". After googling, i found few suggetion to add assembly as module. Is there any other way to handle this ?
I used dependecySet to solve this problem, we can use wildcard to add all binaries.
<assembly xmlns="http://maven.apache.org/plugins/maven-assembly-plugin/assembly/1.1.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/plugins/maven-assembly-plugin/assembly/1.1.0 http://maven.apache.org/xsd/assembly-1.1.0.xsd">
<id>bin</id>
<includeBaseDirectory>false</includeBaseDirectory>
<formats>
<format>zip</format>
</formats>
<dependencySets>
<dependencySet>
<includes>
<include>groupA:*:*:*</include>
</includes>
</dependencySet>
</dependencySets>
</assembly>
This will add all binary artifacts of project. One more thing to note is the id used in assembly descriptor. It should be bin for binary artifact.
Posting here in case if anybody runs into similar kind of issue, this might help.
I have a mavenized java project (Maven2) which I want to build into a jar, which is easy enough by supplying the jar-with-dependencies descriptorRef in the pom.xml.
However I also need to deploy my project in a zip with some .exe and .bat files, among others, from a bin folder that call the jar. (I am using Tanuki but it does not matter for the use case I think)
In other words, I need a build in which first my sources (and dependencies) are packaged into a jar and that jar is then put into a zip with some additional files from the bin folder.
What should I put in my pom.xml and 'assembly'.xml?
Maven-assembly-plugin is the right tool to do that.
You have to declare this plugin in the "build" section of your pom, and to create another configuration file "assembly.xml" at the root of your project. In this file, your will define the content of your zip file.
The configuration options are described on the official site: http://maven.apache.org/plugins/maven-assembly-plugin/
Here is a basic configuration example of this plugin that should suit your needs.
POM config :
<plugin>
<artifactId>maven-assembly-plugin</artifactId>
<configuration>
<finalName>zipfile</finalName>
<descriptors>
<descriptor>${basedir}/assembly.xml</descriptor>
</descriptors>
</configuration>
<executions>
<execution>
<id>make-assembly</id>
<phase>package</phase>
<goals>
<goal>single</goal>
</goals>
</execution>
</executions>
</plugin>
Assembly config :
<assembly>
<formats>
<format>zip</format>
</formats>
<fileSets>
<fileSet>
<directory>to_complete</directory>
<outputDirectory />
<includes>
<include>**/*.jar</include>
<include>**/*.bat</include>
<include>**/*.exe</include>
</includes>
</fileSet>
</fileSets>
</assembly>
I am trying to add specific directories from Maven modules into my build. I believe that fileSets are the way to go back this.
I would appreciate a clear and concise way of using fileSets to obtain necessary directories from Maven modules that just simply contain a directory with some necessary resources.
If you want to include entire modules, use moduleSets, but if you want to pick and choose which files to add you can use fileSets in an assembly config file from the top level project like this:
<fileSets>
<fileSet>
<directory>${basedir}/myModule/src/main/resources</directory>
<includes>
<include>*.txt</include>
</includes>
</fileSet>
</fileSets>
I have a Maven project, where under src/main directory there is a sub dir called output. this folder needs to be packaged into tar.gz. when using the assembly plugin as follows:
From the pom.xml:
<build>
<finalName>front</finalName>
<plugins>
<plugin>
<artifactId>maven-assembly-plugin</artifactId>
<version>2.2-beta-5</version>
<configuration>
<descriptors>
<descriptor>src/main/assembly/assembly.xml</descriptor>
</descriptors>
</configuration>
</plugin>
</plugins>
</build>
the assembly.xml:
<assembly>
<id>bundle</id>
<formats>
<format>tar.gz</format>
</formats>
<fileSets>
<fileSet>
<directory>src/main/output</directory>
</fileSet>
</fileSets>
</assembly>
My problem is that I am trying the outcome will be as running the tar utility itself, meaning when extracting to get output directory and all its content. what I get is the output folder wrapped with all the project path - name/src/main/output.
You need to configure the assembly descriptor to not include the base directory and to configure an output directory for the fileSet:
<assembly>
<id>bundle</id>
<formats>
<format>tar.gz</format>
</formats>
<includeBaseDirectory>false</includeBaseDirectory>
<fileSets>
<fileSet>
<directory>src/main/output</directory>
<outputDirectory>output</outputDirectory>
</fileSet>
</fileSets>
</assembly>
With the above assembly descriptor, I get the following result (when running on a project reproducing the structure):
$ mvn clean assembly:assembly
...
$ cd target
$ tar zxvf Q3330855-1.0-SNAPSHOT-bundle.tar.gz
output/
output/hello.txt
See also
The Assembly Descriptor Format reference
Try setting outputDirectory in the fileSet. That should remove the src/main/output directories.
<fileSet>
<directory>src/main/output</directory>
<outputDirectory>.</outputDirectory>
</fileSet>
You may also need to set includeBaseDirectory to false. That would remove the name directory.
<assembly>
<id>bundle</id>
<includeBaseDirectory>false</includeBaseDirectory>
<!-- ... -->
I am using Assembly plugin for maven to create an installation package.
For my packaging requirement, I need to split artifacts generated during the build and all dependencies into separate folders.
My current Assembly manifest is as follows:
<moduleSets>
<moduleSet>
<includes>
<include>test:test</include>
</includes>
<binaries>
<includeDependencies>false</includeDependencies>
<outputDirectory>lib/custom/${artifactId}</outputDirectory>
<unpack>false</unpack>
</binaries>
</moduleSet>
<moduleSet>
<includes>
<include>test:test</include>
</includes>
<binaries>
<includeDependencies>true</includeDependencies>
<excludes>
<exclude>test:test</exclude>
</excludes>
<outputDirectory>lib/thirdParty/</outputDirectory>
<unpack>false</unpack>
</binaries>
</moduleSet>
</moduleSets>
First moduleset correctly generates only currently built assembly.
However, thirdParty includes the currently built assembly as well. How would I go about excluding the files already included in the first set?
Thanks
What about using dependency:copy-dependencies? I use that to copy all deps to target/lib .
One kludgy way to do it is with the maven-antrun-plugin and an ant task. Iterate the contents of lib/custom/${artifactId} and remove any files from lib/thirdParty.
You might want to look at appassembler-maven-plugin. It lets you dump all your runtime dependency jars in a directory. You might be able to hack that up to put your main jar in one folder and then dump the dependencies into another.