I want to be able to zip files in folder '${project.basedir}/src/main/resources/docker' to folder target/docker-files/docker-files.zip but currently they are getting saved in 'target/project-artifactId-1.0-SNAPSHOT.zip'
I have written the following zip.xml file
<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>docker_files</id>
<formats>
<format>zip</format>
</formats>
<includeBaseDirectory>false</includeBaseDirectory>
<fileSets>
<fileSet>
<directory>${project.basedir}/src/main/resources/docker</directory>
<filtered>true</filtered>
<outputDirectory>/docker-files-zip</outputDirectory>
</fileSet>
</fileSets>
</assembly>
My pom.xml has the following plugin:
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-assembly-plugin</artifactId>
<executions>
<execution>
<id>make-assembly</id>
<phase>package</phase>
<goals>
<goal>single</goal>
</goals>
<configuration>
<fileName>docker-files</fileName>
<appendAssemblyId>false</appendAssemblyId>
<descriptors>
<descriptor>src/assembly/zip.xml</descriptor>
</descriptors>
</configuration>
</execution>
</executions>
</plugin>
Any leads would be really helpful.
Related
I want to copy the content of a directorymodule maven project.
Here is the hierarchy
I want to copy the content of dist directory into Tourism/Tourism-Services/src/main/webapp directory
For this purpose, I tried to use maven-assembly-plugin
here is the extract of the relative pom.xml
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-assembly-plugin</artifactId>
<configuration>
<finalName>./</finalName>
<appendAssemblyId>false</appendAssemblyId>
</configuration>
<executions>
<execution>
<id>cfg-main-resources</id>
<goals>
<goal>single</goal>
</goals>
<phase>package</phase>
<configuration>
<descriptors>
<descriptor>${basedir}/src/main/angular5/tourism/assembly.xml</descriptor>
</descriptors>
</configuration>
</execution>
</executions>
</plugin>
Here is the extract of assembly.xml file
<assembly xmlns="http://maven.apache.org/plugins/maven-assembly-plugin/assembly/1.1.3"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/plugins/maven-assembly-plugin/assembly/1.1.3 http://maven.apache.org/xsd/assembly-1.1.3.xsd">
<id>distribution</id>
<formats>
<format>dir</format>
</formats>
<includeBaseDirectory>false</includeBaseDirectory>
<fileSets>
<fileSet>
<outputDirectory>./</outputDirectory>
<directory>src/main/angular5/tourism/dist</directory>
<includes>
<include>**/*</include>
</includes>
</fileSet>
</fileSets>
</assembly>
The problem is that the content of dist directory is copied in Tourism/Tourism-Web/target directory. I would like to copy this content in another module, in Tourism/Tourism-Services/src/main/weapp directory. Thank you for your help
I succeded in configuring the pom.xml's
Here is an extract of pom.xml within Tourism-Web sub-module
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-assembly-plugin</artifactId>
<configuration>
<appendAssemblyId>true</appendAssemblyId>
</configuration>
<executions>
<execution>
<id>cfg-main-resources</id>
<goals>
<goal>single</goal>
</goals>
<phase>package</phase>
<configuration>
<descriptors>
<descriptor>${basedir}/src/main/angular5/tourism/assembly.xml</descriptor>
</descriptors>
</configuration>
</execution>
</executions>
</plugin>
Here is an extract of assembly descriptor file
<assembly xmlns="http://maven.apache.org/plugins/maven-assembly-plugin/assembly/1.1.3"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/plugins/maven-assembly-plugin/assembly/1.1.3 http://maven.apache.org/xsd/assembly-1.1.3.xsd">
<id>assembly</id>
<formats>
<format>zip</format>
</formats>
<includeBaseDirectory>false</includeBaseDirectory>
<fileSets>
<fileSet>
<outputDirectory>./</outputDirectory>
<directory>src/main/angular5/tourism/dist</directory>
<includes>
<include>**/*</include>
</includes>
</fileSet>
</fileSets>
Here is an extract of pom.xml of Tourism-Services sub-module
<dependencies>
<dependency>
<groupId>tourism-guide</groupId>
<artifactId>tourism-web</artifactId>
<version>${project.version}</version>
<classifier>assembly</classifier>
<type>zip</type>
<scope>compile</scope>
</dependency>
..................
's..................
</dependencies>
<build>
<!-- Set the name of the war, used as the context root when the app is
deployed -->
<finalName>${project.artifactId}</finalName>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-dependency-plugin</artifactId>
<executions>
<execution>
<id>unpack-angular-dist-resources</id>
<goals>
<goal>unpack-dependencies</goal>
</goals>
<phase>compile</phase>
<configuration>
<outputDirectory>${basedir}/src/main/webapp</outputDirectory>
<includeArtifactIds>tourism-web</includeArtifactIds>
<includeGroupIds>${project.groupId}</includeGroupIds>
<excludeTransitive>true</excludeTransitive>
<excludeTypes>pom</excludeTypes>
<scope>compile</scope>
</configuration>
</execution>
</executions>
</plugin>
</plugins>
</build>
Thank you for reading
I want to collect the project module using, Maven
I have a directory structure. Folders can be added dirN:
project-module
|
|-dir1
|-dir2
|-dir3
|-...
|-dirN
|-bin.xml
|-pom.xml
I tried the maven-assembly-plugin
pom.xml
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-assembly-plugin</artifactId>
<configuration>
<descriptors>
<descriptor>bin.xml</descriptor>
</descriptors>
</configuration>
<executions>
<execution>
<id>sql dir</id>
<goals>
<goal>single</goal>
</goals>
<phase>package</phase>
</execution>
</executions>
</plugin>
</plugins>
bin.xml
<?xml version="1.0" encoding="UTF-8"?>
<assembly xmlns="http://maven.apache.org/plugins/maven-assembly-plugin/assembly/1.1.3"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/plugins/maven-assembly-plugin/assembly/1.1.3 http://maven.apache.org/xsd/assembly-1.1.3.xsd">
<id>bin</id>
<formats>
<format>zip</format>
</formats>
<includeBaseDirectory>false</includeBaseDirectory>
<fileSets>
<fileSet>
<directory>../mspost-db</directory>
<excludes>
<exclude>*.*</exclude>
</excludes>
<useDefaultExcludes>false</useDefaultExcludes>
<!--<outputDirectory>/</outputDirectory>-->
</fileSet>
</fileSets>
</assembly>
DESIRED OUTCOME
Each directory to be packaged into a single zip archive folder with the same name, that is.
project-module
|
|-targer
|-dir1.zip
|-dir2.zip
|-dir3.zip
|-...
|-dirN.zip
help me please.
The iterator-maven-plugin could be used to work with a single assembly descriptor:
<plugin>
<groupId>com.soebes.maven.plugins</groupId>
<artifactId>iterator-maven-plugin</artifactId>
<executions>
<execution>
<phase>package</phase>
<goals>
<goal>iterator</goal>
</goals>
<configuration>
<items>
<item>dir1</item>
<item>dir2</item>
<item>dir3</item>
</items>
<pluginExecutors>
<pluginExecutor>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-assembly-plugin</artifactId>
</plugin>
<goal>single</goal>
<configuration>
<descriptors>
<descriptor>${project.basedir}/bin.xml</descriptor>
</descriptors>
<finalName>${item}</finalName>
<appendAssemblyId>false</appendAssemblyId>
</configuration>
</pluginExecutor>
</pluginExecutors>
</configuration>
</execution>
</executions>
</plugin>
Then reference ${item} in the bin.xml:
<?xml version="1.0" encoding="UTF-8"?>
<assembly xmlns="http://maven.apache.org/plugins/maven-assembly-plugin/assembly/1.1.3"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/plugins/maven-assembly-plugin/assembly/1.1.3 http://maven.apache.org/xsd/assembly-1.1.3.xsd">
<id>${item}</id>
<formats>
<format>zip</format>
</formats>
<includeBaseDirectory>false</includeBaseDirectory>
<fileSets>
<fileSet>
<directory>${project.basedir}/${item}</directory>
<outputDirectory>/</outputDirectory>
</fileSet>
</fileSets>
</assembly>
This results in target/dir1.zip etc.
Instead of listing the <items> explicitly, it can also iterate over a <folder>, though I don't see a way that could be restricted to such as dir*.
(Edit start)
E.g. to iterate the (immediate) subdirectories of parentDir:
<configuration>
<folder>${project.basedir}/parentDir</folder>
<pluginExecutors>
... as above ...
The assembly descriptor (bin.xml) can then reference something like <directory>${project.basedir}/parentDir/${item}</directory>, much as before.
The lack of a filter would still be an issue if iterating over <folder>${project.basedir}</folder> though - this would zip up the target directory too.
I have one project that using maven assembly plugin for merging two jar,without using maven assembly ,create jar package have meta-inf/maven that contain pom.properties and pom.xml . but after merge by Assembly this folder not exists.
i search it and found that this can make that OK but dose not work .
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-assembly-plugin</artifactId>
<version>2.6</version>
<configuration>
<descriptors>
<descriptor>src/assembly/frm-assembly.xml</descriptor>
</descriptors>
<appendAssemblyId>false</appendAssemblyId>
<archive>
**<addMavenDescriptor>true</addMavenDescriptor>**
</archive>
</configuration>
<executions>
<execution>
<phase>package</phase>
<goals>
<goal>single</goal>
</goals>
</execution>
</executions>
</plugin>
and descriptor is this
<assembly>
<id>uberjar</id>
<formats>
<format>jar</format>
</formats>
<includeBaseDirectory>false</includeBaseDirectory>
<fileSets>
<fileSet>
<directory>${project.build.outputDirectory}</directory>
<outputDirectory>/</outputDirectory>
</fileSet>
<fileSet>
<directory>src/main/webapp</directory>
<outputDirectory>/META-INF/resources</outputDirectory>
</fileSet>
</fileSets>
</assembly>
I'm using the maven assembly plugin to package a few directories into a zip file.
The following is the zip.xml.
<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">
<baseDirectory>${project.build.directory}</baseDirectory>
<formats>
<format>zip</format>
</formats>
<fileSets>
<fileSet>
<directory>${project.build.directory}/bin</directory>
<outputDirectory>bin</outputDirectory>
</fileSet>
<fileSet>
<directory>${project.build.directory}/config</directory>
<outputDirectory>config</outputDirectory>
</fileSet>
<fileSet>
<directory>${project.build.directory}/lib</directory>
<outputDirectory>lib</outputDirectory>
</fileSet>
</fileSets>
</assembly>
Following is the plugin configuration in pom.xml
<plugin>
<artifactId>maven-assembly-plugin</artifactId>
<executions>
<execution>
<id>create-zip</id>
<phase>package</phase>
<goals>
<goal>single</goal>
</goals>
<configuration>
<descriptors>
<descriptor>zip.xml</descriptor>
</descriptors>
<finalName>bootstrap</finalName>
</configuration>
</execution>
</executions>
</plugin>
When I run the assemply, a zip file is created with the name of my maven module, which is as expected. But when I extract this zip file, a folder named 'target' is created which is not very readable. How do i customize the name of this 'target' folder?
How I can build zip file from generated resources?
Trying to generate a zip file for all generated files under target. Not sure where the problem is:
assembly:
<id>resources-bundle</id>
<includeBaseDirectory>false</includeBaseDirectory>
<fileSets>
<fileSet>
<outputDirectory>${project.basedir}/</outputDirectory>
<directory>${project.basedir}/</directory>
<includes>
<include>**/target/dependency/**.properties</include>
</includes>
</fileSet>
</fileSets>
pom entry:
<plugin>
<artifactId>maven-assembly-plugin</artifactId>
<version>2.5.2</version>
<executions>
<execution>
<goals>
<goal>single</goal>
</goals>
<phase>validate</phase>
<id>archive</id>
<configuration>
<appendAssemblyId>true</appendAssemblyId>
<formats>
<format>zip</format>
</formats>
<descriptors>
<descriptor>assembly.xml</descriptor>
</descriptors>
</configuration>
</execution>
</executions>
</plugin>
error I'm facing:
Failed to create assembly: Error creating assembly archive test-libs: You must set at least one file.
Any help much appreciated!
Thanks
Resolved!
assembly.xml::
<fileSet>
<outputDirectory>resources/</outputDirectory>
<directory>${project.basedir}/target/dependency/</directory>
<includes>
<include>**/**.properties</include>
</includes>
</fileSet>
pom.xml:
<execution>
<id>pack-resources</id>
<phase>generate-resources</phase>
<goals>
<goal>single</goal>
</goals>
<configuration>
<appendAssemblyId>true</appendAssemblyId>
<formats>
<format>zip</format>
</formats>
<descriptors>
<descriptor>assembly.xml</descriptor>
</descriptors>
</configuration>
</execution>
Thanks