I´m using maven-assembly-plugin for creating a zip file containing some artifacts and additional stuff. The additional stuff is located at a folder called "Installationattachments". Everything working alright so far. "Installationattachments" also contains a png and an ico file which are also included but these are broken after they´re included.
Here is the plugin declaration of my pom.xml:
<plugin>
<artifactId>maven-assembly-plugin</artifactId>
<version>3.0.0</version>
<configuration>
<appendAssemblyId>false</appendAssemblyId>
<descriptors>
<descriptor>src/assembly/dep.xml</descriptor>
</descriptors>
</configuration>
<executions>
<execution>
<id>create-archive</id>
<phase>package</phase>
<goals>
<goal>single</goal>
</goals>
</execution>
</executions>
<inherited>false</inherited>
</plugin>
And that´s the critical part of the assembly itself:
<!-- installation files -->
<fileSet>
<directory>Installationattachments</directory>
<outputDirectory></outputDirectory>
<lineEnding>unix</lineEnding>
<excludes>
<exclude>*.vbs</exclude>
</excludes>
</fileSet>
<fileSet>
<directory>Installationattachments</directory>
<outputDirectory></outputDirectory>
<lineEnding>dos</lineEnding>
<includes>
<include>*.vbs</include>
</includes>
</fileSet>
The problem is the specification of line endings through the <lineEnding> parameter. The first fileset selects all files that aren't VBS file, so it also selects PNG and ICO files. But since those are binary files, you don't want to set a specific line ending for those.
For lack of a nonFilteredFileExtensions, whose support is asked in MASSEMBLY-849, you can add a third filesets without line ending for images:
<fileSet>
<directory>Installationattachments</directory>
<outputDirectory></outputDirectory>
<lineEnding>unix</lineEnding>
<excludes>
<exclude>*.vbs</exclude>
<exclude>*.ico</exclude>
<exclude>*.png</exclude>
</excludes>
</fileSet>
<fileSet>
<directory>Installationattachments</directory>
<outputDirectory></outputDirectory>
<includes>
<include>*.ico</include>
<include>*.png</include>
</includes>
</fileSet>
<fileSet>
<directory>Installationattachments</directory>
<outputDirectory></outputDirectory>
<lineEnding>dos</lineEnding>
<includes>
<include>*.vbs</include>
</includes>
</fileSet>
Related
I tried using the maven war plugin but is very opinionated on the folder structure and I need specific files into specific folders, so I've looked into using maven assembly plugin with the war format set.
Here's a snippet of the pom.xml.
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-assembly-plugin</artifactId>
<version>3.3.0</version>
<configuration>
<descriptors>
<descriptor>src/main/assembly/war-assembly.xml</descriptor>
</descriptors>
<finalName>${project.artifactId}-assembly</finalName>
<appendAssemblyId>false</appendAssemblyId>
</configuration>
<executions>
<execution>
<phase>package</phase>
<goals>
<goal>single</goal>
</goals>
</execution>
</executions>
</plugin>
and the war-assembly.xml
<assembly xmlns="http://maven.apache.org/ASSEMBLY/2.1.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/ASSEMBLY/2.1.0 http://maven.apache.org/xsd/assembly-2.1.0.xsd">
<id>war</id>
<formats>
<format>war</format>
</formats>
<includeBaseDirectory>false</includeBaseDirectory>
<dependencySets>
<dependencySet>
<outputDirectory>webapp/WEB-INF/lib</outputDirectory>
<excludes>
<exclude>*:war</exclude>
</excludes>
</dependencySet>
</dependencySets>
<fileSets>
<fileSet>
<directory>${project.build.directory}/${project.artifactId}/WEB-INF</directory>
<outputDirectory>webapp</outputDirectory>
<includes>
<include>/**/*</include>
</includes>
<excludes>
<exclude>webapp/lib</exclude>
</excludes>
</fileSet>
<fileSet>
<directory>${project.build.directory}/${project.artifactId}</directory>
<outputDirectory>webapp</outputDirectory>
<includes>
<include>/**/*</include>
</includes>
<excludes>
<exclude>WEB-INF</exclude>
<exclude>META-INF</exclude>
<exclude>info.xml</exclude>
</excludes>
</fileSet>
<fileSet>
<directory>${project.basedir}</directory>
<outputDirectory></outputDirectory>
<includes>
<include>README*</include>
<include>LICENSE*</include>
<include>NOTICE*</include>
</includes>
</fileSet>
</fileSets>
<files>
<file>
<source>${project.build.directory}/${project.artifactId}/info.xml</source>
<filtered>true</filtered>
<outputDirectory></outputDirectory>
</file>
</files>
</assembly>
this produces the desired outcome in terms of where i need the files to be copied to, except something still packages lib folder, classes folder and the web.xml into the webapp folder, which I do not want.
Outputted directory structure:
Expected Directory Structure (lib, classes and web.xml) are removed because they are in the webapp/WEB-INF sub folder:
am I using the maven plugin incorrectly? or a setting that I am overseeing? Or a way to set the output directories for the classes, lib, and the web.xml?
xml and pom.xml which creates jar file and then zip file with some artifacts including jar file. But when i run maven install zip file is getting created as GenerateMissingUsersReport-bin.zip instead I want it to create as GenerateMissingUsersReport.zip. I have set as false. But no difference.
Any pointers?
Here is dep.xml
<id>bin</id>
<baseDirectory>../</baseDirectory>
<formats>
<format>zip</format>
</formats>
<fileSets>
<fileSet>
<directory>${project.basedir}</directory>
<outputDirectory>/</outputDirectory>
<includes>
<include>README*</include>
<include>LICENSE*</include>
<include>NOTICE*</include>
</includes>
</fileSet>
<fileSet>
<directory>${project.build.directory}</directory>
<outputDirectory>/lib</outputDirectory>
<includes>
<include>*.jar</include>
</includes>
</fileSet>
<fileSet>
<directory>${project.build.directory}/classes</directory>
<includes>
<include>plugin.xml</include>
</includes>
<outputDirectory>/</outputDirectory>
</fileSet>
</fileSets>
Here is pom.xml
<finalName>GenerateMissingUsersReport</finalName>
<plugins>
<plugin>
<artifactId>maven-assembly-plugin</artifactId>
<version>2.4</version>
<configuration>
<finalName>GenerateMissingUsersReport</finalName>
<appendAssemblyID>false</appendAssemblyID>
<descriptor>src/assembly/dep.xml</descriptor>
</configuration>
<executions>
<execution>
<id>make-zip</id>
<phase>package</phase>
<goals>
<goal>single</goal>
</goals>
</execution>
</executions>
</plugin>
<plugin>
<artifactId>maven-jar-plugin</artifactId>
<version>2.4</version>
<executions>
<execution>
<id>default-jar</id>
<phase>package</phase>
<goals>
<goal>jar</goal>
</goals>
</execution>
</executions>
<configuration>
<excludes>
<exclude>plugin.xml</exclude>
</excludes></configuration>
</plugin>
Add the following line under configurations element of the pom
<appendAssemblyId>false</appendAssemblyId>
Also make sure you use the latest version of the assembly plugin
<artifactId>maven-assembly-plugin</artifactId>
<version>2.5.5</version>
I have two files in my directory like this:
a.b.so
a.so
I want to delete only a.b.so.
So here is my Maven clean plugin entry in my pom.xml file:
<plugin>
<artifactId>maven-clean-plugin</artifactId>
<executions>
<execution>
<id>auto-clean</id>
<phase>prepare-package</phase>
<goals>
<goal>clean</goal>
</goals>
<configuration>
<excludeDefaultDirectories>true</excludeDefaultDirectories>
<filesets>
<fileset>
<directory>${project.build.directory}/libs/x86</directory>
<includes>
<include>*.so</include>
</includes>
<excludes>
<exclude>a.so</exclude>
<excludes>
<followSymlinks>false</followSymlinks>
</fileset>
</filesets>
<verbose>true</verbose>
</configuration>
</execution>
</executions>
Just for some backgorund of this, file a.b.so gets downloaded as a dependency then it gets renamed into a.so just before i execute the above entry. I copy file using maven depedency plugin. I don't know whether this affects the not deletion of a.b.so
In turn it always delete a.so. Even I tried including **/*, but it deletes a.so every time.
It never deletes a.b.so.
For this particular example, you can try to replace this part:
<includes>
<include>*.so</include>
</includes>
<excludes>
<exclude>a.so</exclude>
<excludes>
with
<includes>
<include>a.b.so</include>
</includes>
I have a Maven project that is an aggregation of a number of sub-projects. This project uses the maven javadoc plugin to aggregate all sub-project javadocs into a single directory in the target/ folder. I have an additional file in the target/ folder that I would like to remain in with the javadoc pages. However, every time I run a clean, this file would be deleted. I was wondering if there was a way to delete the whole target directory and leave only a single file. My plugin is currently configured like so:
<plugin>
<artifactId>maven-clean-plugin</artifactId>
<execution>
<executions>
<id>default-clean</id>
<configuration>
<excludeDefaultDirectories>true</excludeDefaultDirectories>
<filesets>
<fileset>
<directory>target</directory>
<excludes>
<exclude>path/to/myFile.xml</exclude>
</excludes>
<followSymlinks>false</followSymlinks>
<fileset>
</filesets>
</configuration>
<phase>initialize</phase>
<goals>
<goal>clean</goal>
</goals>
</execution>
</executions>
</plugin>
I saw a similar question here, but the solution doesn't seem to work for me.
I had the same need and after playing a while with the plugin I found a working solution for avoiding to delete specific files inside the target folder.
Let's suppose that you don't want to delete the file do_not_delete in the target folder, this configuration works for me:
<plugin>
<artifactId>maven-clean-plugin</artifactId>
<version>3.0.0</version>
<configuration>
<excludeDefaultDirectories>true</excludeDefaultDirectories>
<filesets>
<fileset>
<directory>target</directory>
<followSymlinks>false</followSymlinks>
<useDefaultExcludes>false</useDefaultExcludes>
<excludes>
<exclude>do_not_delete</exclude>
</excludes>
</fileset>
</filesets>
</configuration>
</plugin>
Put that static file in a resources folder and let the maven-resources-plugin copy it to the specific target folder.
As you stated, it is possible to explicitly exclude or include files form your project. Are you positive about the exclude path you provided?
<filesets>
<fileset>
<directory>src/main/generated</directory>
<followSymlinks>false</followSymlinks>
<useDefaultExcludes>true</useDefaultExcludes>
<includes>
<include>*.java</include>
</includes>
<excludes>
<exclude>MyPathRelativeToDirectoryTag/myFile.xml</exclude>
</excludes>
</fileset>
</filesets>
I am using Eclipse/maven plugin.
I want to delete external file with aboslute path, i have following example but it claims to delete only relative files which resides inside the project
<plugin>
<artifactId>maven-clean-plugin</artifactId>
<version>2.4.1</version>
<configuration>
<filesets>
<fileset>
<directory>some/relative/path</directory>
<includes>
<include>**/*.tmp</include>
<include>**/*.log</include>
</includes>
<excludes>
<exclude>**/important.log</exclude>
<exclude>**/another-important.log</exclude>
</excludes>
<followSymlinks>false</followSymlinks>
</fileset>
</filesets>
</configuration>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-clean-plugin</artifactId>
<version>2.4.1</version>
<configuration>
<followSymLinks>false</followSymLinks>
<filesets>
<fileset>
<directory>D:\apache-tomcat-6.0.24\webapps\cat360-web-1.0.0</directory>
</fileset>
</filesets>
</configuration>
</plugin>