How to get artificactId of dependencies in Maven? - maven

I have multi-module project. Dependencies are as follows:
<dependencies>
<dependency>
<groupId>com.gwr</groupId>
<artifactId>gwr-commons</artifactId>
<version>0.0.1-SNAPSHOT</version>
</dependency>
<dependency>
<groupId>com.gwr</groupId>
<artifactId>gwr-places-module</artifactId>
<version>0.0.1-SNAPSHOT</version>
</dependency>
<dependency>
<groupId>com.gwr</groupId>
<artifactId>gwr-devices-module</artifactId>
<version>0.0.1-SNAPSHOT</version>
</dependency>
<dependency>
<groupId>com.gwr</groupId>
<artifactId>gwr-events-module</artifactId>
<version>0.0.1-SNAPSHOT</version>
</dependency>
<dependency>
<groupId>com.gwr</groupId>
<artifactId>gwr-controls-module</artifactId>
<version>0.0.1-SNAPSHOT</version>
</dependency>
<dependency>
<groupId>com.gwr</groupId>
<artifactId>gwr-logs-module</artifactId>
<version>0.0.1-SNAPSHOT</version>
</dependency>
</dependencies>
And, under src/main/resources of each module/dependency I have one ZIP file named as <module>-persistence.zip (e.g. C:\gwr-logs-module\src\main\resources\logs-persistence.zip). I want to copy this ZIP file of each module under some other directory let us say C:\users\user\project. I have defined maven-resources-plugin as below:
<plugin>
<artifactId>maven-resources-plugin</artifactId>
<executions>
<execution>
<id>copy-presubscriptionfiles</id>
<phase>validate</phase>
<goals>
<goal>copy-resources</goal>
</goals>
<configuration>
<outputDirectory>${user.home}/${dasmo.storage}/</outputDirectory>
<overwrite>true</overwrite>
<resources>
<resource>
<directory>${basedir}/../gwr-logs-module/src/main/resources</directory>
<includes>
<include>*.zip</include>
</includes>
</resource>
<resource>
<directory>${basedir}/../gwr-devices-module/src/main/resources</directory>
<includes>
<include>*.zip</include>
</includes>
</resource>
<resource>
<directory>${basedir}/../gwr-controls-module/src/main/resources</directory>
<includes>
<include>*.zip</include>
</includes>
</resource>
<resource>
<directory>${basedir}/../gwr-events-module/src/main/resources</directory>
<includes>
<include>*.zip</include>
</includes>
</resource>
</resources>
</configuration>
</execution>
</executions>
</plugin>
As you see, under resource section I have to hard code each module name. How can I avoid this? Can't we use artifactId of each dependency? If yes, how to use it? Or is there any other way to do this job?
Thank you so much.
regards,
Yeshwant

You can reduce the <plugin> section in your multi-module POM to the following:
<plugin>
<artifactId>maven-resources-plugin</artifactId>
<executions>
<execution>
<id>copy-presubscriptionfiles</id>
<!-- Note: this phase is more appropriate than 'validate' -->
<phase>process-resources</phase>
<goals>
<goal>copy-resources</goal>
</goals>
<configuration>
<outputDirectory>${user.home}/${dasmo.storage}</outputDirectory>
<overwrite>true</overwrite>
<resources>
<resource>
<directory>${project.basedir}/src/main/resources</directory>
<!-- or likewise
<directory>${project.projectDirectory}/src/main/resources</directory>
-->
<includes>
<include>*.zip</include>
</includes>
</resource>
</resources>
</configuration>
</execution>
</executions>
</plugin>
If you declare your multi-module project as <parent> in any of your sub-module POMs this will be inherited by them (see Introduction to the POM, Project Inheritance) and such performed at each sub-module build.
Note: basedir is deprecated in favor of project.basedir.
See Maven: The Complete Reference, Multi-module vs. Inheritance for further reading.

Related

Renaming jar of the same Maven project before bundling it into its war file

We've a Maven project that has war packaging. It has a couple of other projects as dependencies. The requirement here is that all projects added as dependencies should have a common naming convention such that they can be patched in every release. So we decided to replace the version from all such artifacts by -1.0-SNAPSHOT. The below code does it well for artifacts added as dependencies.
We want the classes of this project itself to be included as a jar file. So we set archiveClasses to true. Now the problem here is that the jar generated out of this has the version appended to it - ns-commonservices-6.5.x and maven-dependency-plugin is unable to rename it to ns-commonservices-1.0-SNAPSHOT (Hence, I've removed that code).
Is there any way by which we can rename the jar/artifact of the same project before bundling it into its own war?
Kindly refer the screenshot below. In this we want ns-commonservices-6.5.x.jar to named as ns-commonservices-1.0-SNAPSHOT.jar.
<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">
<modelVersion>4.0.0</modelVersion>
<groupId>com.ns.commonservices</groupId>
<artifactId>ns-commonservices</artifactId>
<packaging>war</packaging>
<version>6.5.x</version>
<name>NSHub</name>
<properties>
<nsweb.version>6.5.x</nsweb.version>
<maven-compiler-plugin.version>3.2</maven-compiler-plugin.version>
<buildDirectory>${project.basedir}/target</buildDirectory>
</properties>
<prerequisites>
<maven>3.2.5</maven>
</prerequisites>
<dependencies>
<dependency>
<groupId>com.ns</groupId>
<artifactId>ns-core</artifactId>
<version>${nsweb.version}</version>
</dependency>
<dependency>
<groupId>com.ns</groupId>
<artifactId>ns-common</artifactId>
<version>${nsweb.version}</version>
</dependency>
</dependencies>
<build>
<directory>${buildDirectory}</directory>
<outputDirectory>target/classes</outputDirectory>
<testOutputDirectory>target/test-classes</testOutputDirectory>
<sourceDirectory>src/main/java</sourceDirectory>
<testSourceDirectory>src/test/java</testSourceDirectory>
<resources>
<resource>
<directory>src/main/resources</directory>
</resource>
</resources>
<testResources>
<testResource>
<directory>src/test/resources</directory>
</testResource>
</testResources>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>${maven-compiler-plugin.version}</version>
<configuration>
<source>1.8</source>
<target>1.8</target>
<encoding>Cp1252</encoding>
</configuration>
</plugin>
<plugin>
<artifactId>maven-war-plugin</artifactId>
<version>2.6</version>
<configuration>
<archiveClasses>true</archiveClasses>
<attachClasses>true</attachClasses>
<warSourceIncludes>WEB-INF/**</warSourceIncludes>
<packagingExcludes>
WEB-INF/lib/ns-common-${nsweb.version}.jar,
WEB-INF/lib/ns-core-${nsweb.version}.jar,
WEB-INF/classes
</packagingExcludes>
<webResources>
<resource>
<directory>src/main/resources</directory>
<includes>
<include>**/*.xls</include>
<include>**/*.xml</include>
<include>**/*.properties</include>
<include>**/*.version</include>
<include>**/*.json</include>
</includes>
<targetPath>WEB-INF/classes</targetPath>
</resource>
</webResources>
</configuration>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-dependency-plugin</artifactId>
<configuration>
<artifactItems>
<artifactItem>
<groupId>com.ns</groupId>
<artifactId>ns-common</artifactId>
<version>${nsweb.version}</version>
<type>jar</type>
<overWrite>true</overWrite>
<outputDirectory>${buildDirectory}/${project.build.finalName}/WEB-INF/lib</outputDirectory>
<destFileName>ns-common-1.0-SNAPSHOT.jar</destFileName>
</artifactItem>
<artifactItem>
<groupId>com.ns</groupId>
<artifactId>ns-core</artifactId>
<version>${nsweb.version}</version>
<type>jar</type>
<overWrite>true</overWrite>
<outputDirectory>${buildDirectory}/${project.build.finalName}/WEB-INF/lib</outputDirectory>
<destFileName>ns-core-1.0-SNAPSHOT.jar</destFileName>
</artifactItem>
</artifactItems>
</configuration>
</plugin>
</plugins>
<finalName>nshub</finalName>
</build>
</project>
I guess that the
https://maven.apache.org/plugins/maven-war-plugin/war-mojo.html#outputFileNameMapping
outputFileNameMapping parameter allows you to customise that.

Apache CXF failed by generating of Client webservice after adding cxf-rt-transports-http dependency

I am trying to generate a JAVA based Webservice client from an existing WSDL with it's related XSD files using Apache CXF. To do this i use a maven configuration file listed below which basicall works well.
<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">
<modelVersion>4.0.0</modelVersion>
<groupId>com.testcamera</groupId>
<artifactId>TestCamera</artifactId>
<packaging>jar</packaging>
<version>1.0-SNAPSHOT</version>
<name>TestCamera Maven App</name>
<properties>
<java.version>1.8</java.version>
<tomcat.version>9.0.4</tomcat.version>
<cxf.version>3.2.2</cxf.version>
</properties>
<build>
<!-- <finalName>???</finalName> -->
<plugins>
<plugin>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.7.0</version>
<configuration>
<source>${java.version}</source>
<target>${java.version}</target>
<!-- encoding>UTF-8</encoding -->
<showWarnings>true</showWarnings>
<showDeprecation>true</showDeprecation>
</configuration>
</plugin>
<plugin>
<groupId>org.apache.cxf</groupId>
<artifactId>cxf-codegen-plugin</artifactId>
<version>${cxf.version}</version>
<executions>
<execution>
<id>generate-sources</id>
<phase>generate-sources</phase>
<configuration>
<sourceRoot>${project.build.directory}/generated/cxf</sourceRoot>
<wsdlOptions>
<wsdlOption>
<wsdl>${basedir}/src/main/resources/wsdls/ver10/device/wsdl/devicemgmt.wsdl</wsdl>
</wsdlOption>
</wsdlOptions>
</configuration>
<goals>
<goal>wsdl2java</goal>
</goals>
</execution>
</executions>
</plugin>
</plugins>
<resources>
<resource>
<filtering>false</filtering>
<directory>src/main/resources</directory>
</resource>
<resource>
<filtering>false</filtering>
<directory>src/main/java</directory>
<includes>
<include>**</include>
</includes>
<excludes>
<exclude>**/*.java</exclude>
</excludes>
</resource>
</resources>
<testResources>
<testResource>
<filtering>false</filtering>
<directory>src/test/resources</directory>
</testResource>
<testResource>
<filtering>false</filtering>
<directory>src/test/java</directory>
<includes>
<include>**</include>
</includes>
<excludes>
<exclude>**/*.java</exclude>
</excludes>
</testResource>
</testResources>
</build>
<dependencies>
<dependency>
<groupId>org.apache.cxf</groupId>
<artifactId>cxf-rt-frontend-jaxws</artifactId>
<version>${cxf.version}</version>
</dependency>
<!-- <dependency> -->
<!-- <groupId>org.apache.cxf</groupId> -->
<!-- <artifactId>cxf-rt-transports-http</artifactId> -->
<!-- <version>${cxf.version}</version> -->
<!-- </dependency> -->
<!-- Jetty is needed if you're are not using the CXFServlet -->
<!-- <dependency> -->
<!-- <groupId>org.apache.cxf</groupId> -->
<!-- <artifactId>cxf-rt-transports-http-jetty</artifactId> -->
<!-- <version>${cxf.version}</version> -->
<!-- </dependency> -->
</dependencies>
</project>
The problem is that i need to add proxy support to this web service. That is why i need to add following dependencies to my maven dependencies which cause problem and show me an error.
Here the related POM.xml:
<dependency>
<groupId>org.apache.cxf</groupId>
<artifactId>cxf-rt-transports-http</artifactId>
<version>${cxf.version}</version>
</dependency>
And related Error Message after aftivation of cxf-rt-transports-http
Caused by: javax.wsdl.WSDLException: WSDLException (at /wsdl:definitions/wsdl:types/xs:schema/xs:schema): faultCode=PARSER_ERROR: Problem parsing 'http://www.w3.org/2003/05/soap-envelope'.: org.xml.sax.SAXParseException: White spaces are required between publicId and systemId.
at com.ibm.wsdl.xml.WSDLReaderImpl.getDocument (WSDLReaderImpl.java:2198)
at com.ibm.wsdl.xml.WSDLReaderImpl.parseSchema (WSDLReaderImpl.java:830)
at com.ibm.wsdl.xml.WSDLReaderImpl.parseSchema (WSDLReaderImpl.java:864)
at com.ibm.wsdl.xml.WSDLReaderImpl.parseSchema (WSDLReaderImpl.java:654)
at com.ibm.wsdl.xml.WSDLReaderImpl.parseTypes (WSDLReaderImpl.java:610)
at com.ibm.wsdl.xml.WSDLReaderImpl.parseDefinitions (WSDLReaderImpl.java:320)
at com.ibm.wsdl.xml.WSDLReaderImpl.readWSDL (WSDLReaderImpl.java:2352)
at com.ibm.wsdl.xml.WSDLReaderImpl.readWSDL (WSDLReaderImpl.java:2338)
at org.apache.cxf.wsdl11.WSDLManagerImpl.loadDefinition (WSDLManagerImpl.java:255)
at org.apache.cxf.wsdl11.WSDLManagerImpl.getDefinition (WSDLManagerImpl.java:165)
at org.apache.cxf.tools.wsdlto.core.WSDLDefinitionBuilder.parseWSDL (WSDLDefinitionBuilder.java:80)
at org.apache.cxf.tools.wsdlto.core.WSDLDefinitionBuilder.build (WSDLDefinitionBuilder.java:71)
at org.apache.cxf.tools.wsdlto.frontend.jaxws.wsdl11.JAXWSDefinitionBuilder.build (JAXWSDefinitionBuilder.java:83)
at org.apache.cxf.tools.wsdlto.frontend.jaxws.wsdl11.JAXWSDefinitionBuilder.build (JAXWSDefinitionBuilder.java:60)
at org.apache.cxf.tools.wsdlto.WSDLToJavaContainer.processWsdl (WSDLToJavaContainer.java:195)
at org.apache.cxf.tools.wsdlto.WSDLToJavaContainer.execute (WSDLToJavaContainer.java:164)
at org.apache.cxf.tools.wsdlto.WSDLToJavaContainer.execute (WSDLToJavaContainer.java:412)
at org.apache.cxf.tools.common.toolspec.ToolRunner.runTool (ToolRunner.java:105)
at org.apache.cxf.tools.wsdlto.WSDLToJava.run (WSDLToJava.java:113)
It will be great if someone know why that behavior happens!
The related WSDL is available under following url:
https://www.onvif.org/ver10/device/wsdl/devicemgmt.wsdl
Note: To see content of wsdl you need right click on that page and see source code!
Thanks in advance!
kami

Include xml files in maven project

I have a maven pom file to build from a structure like:
package1
--1.java
--2.java
--packageMetaInfo.xml
package2
--21.java
--22.java
--packageMetaInfo.xml
When I do a maven compile, the xml files don't come in the target.
maven-compiler-plugin 3.5.1 - Unless I exclude the xmls through <exclusions>, I get an error that "Fatal error compiling: All compilation units must be of SOURCE kind ->"
maven-compiler-plugin 2.0.1 - compiles but skips the xmls
Is there a way I can have the xmls included in my jar. The structure would be
x.jar
package1
--1.class
--2.class
--packageMetaInfo.xml
package2
--21.class
--22.class
--packageMetaInfo.xml
*I understand it may not be maven standard to have xml with source files but I am working on a specific product and need to maintain this structure in both input and output.
<?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">
<modelVersion>4.0.0</modelVersion>
<groupId>com.incent</groupId>
<artifactId>Release-4.3.0.1.0.0001</artifactId>
<name>AAA Custom code</name>
<version>2.4.0.1</version>
<properties>
<ormb.cmccb.path>./Active_Repository/CMCCB</ormb.cmccb.path>
<ormb.customcode.path>${ormb.cmccb.path}/data</ormb.customcode.path>
<ormb.release.name>AAA-4.3.0.1.0.0001</ormb.release.name>
<ormb.target.path>./target</ormb.target.path>
<ormb.output.path>Release-${ormb.release.name}/Application/${ormb.release.name}/CMCCB</ormb.output.path>
<ormb.serverfile.output.relpath>./target/server</ormb.serverfile.output.relpath>
<build.number>SNAPSHOT</build.number>
</properties>
<dependencies>
<dependency>
<groupId>org.ow2.asm</groupId>
<artifactId>asm</artifactId>
<version>5.0.3</version>
</dependency>
<dependency>
<groupId>antlr</groupId>
<artifactId>antlr</artifactId>
<version>2.7.7</version>
<type>jar</type>
</dependency>
<dependency>
<groupId>icu4j</groupId>
<artifactId>icu4j</artifactId>
<version>49.1</version>
<type>jar</type>
</dependency>
<dependency>
<groupId>dom4j</groupId>
<artifactId>dom4j</artifactId>
<version>1.6.1</version>
<type>jar</type>
</dependency>
<dependency>
<groupId>commons-lang</groupId>
<artifactId>commons-lang</artifactId>
<version>2.2</version>
<type>jar</type>
</dependency>
<dependency>
<groupId>wlfullclient</groupId>
<artifactId>wlfullclient</artifactId>
<version>10.3.4.0</version>
<type>jar</type>
</dependency>
</dependencies>
<build>
<sourceDirectory>${ormb.customcode.path}/java</sourceDirectory>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-resources-plugin</artifactId>
<version>2.6</version>
<configuration>
<encoding>UTF-8</encoding>
</configuration>
<executions>
<execution>
<id>copy-cm</id>
<phase>install</phase>
<goals>
<goal>copy-resources</goal>
</goals>
<configuration>
<outputDirectory>${ormb.customcode.path}/etc/lib</outputDirectory>
<overwrite>true</overwrite>
<resources>
<resource>
<directory>${ormb.target.path}</directory>
<includes>
<include>cm.jar</include>
</includes>
</resource>
</resources>
</configuration>
</execution>
<execution>
<id>copy-mwpackage</id>
<phase>install</phase>
<goals>
<goal>copy-resources</goal>
</goals>
<configuration>
<outputDirectory>${ormb.serverfile.output.relpath}</outputDirectory>
<overwrite>true</overwrite>
<resources>
<resource>
<directory>${ormb.target.path}</directory>
<includes>
<include>Release-${ormb.release.name}.zip</include>
</includes>
</resource>
</resources>
</configuration>
</execution>
</executions>
</plugin>
<plugin>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.5.1</version>
<configuration>
<encoding>ISO-8859-1</encoding>
<source>1.7</source>
<target>1.7</target>
<includes>
<include>**/cm/**</include>
</includes>
<excludes>
<exclude>**/*.xml</exclude>
</excludes>
<resources>
<resource>
<directory>${ormb.customcode.path}/java</directory>
<includes>
<include>**/*.xml</include>
</includes>
</resource>
</resources>
</configuration>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-assembly-plugin</artifactId>
<version>2.6</version>
<executions>
<execution>
<id>create-cm</id>
<phase>package</phase>
<goals>
<goal>single</goal>
</goals>
<configuration>
<appendAssemblyId>false</appendAssemblyId>
<descriptors>
<descriptor>Active_Repository/assembly/executable.xml</descriptor>
</descriptors>
<finalName>cm</finalName>
<manifest>
<addDefaultImplementationEntries>true</addDefaultImplementationEntries>
</manifest>
<archive>
<manifestEntries>
<Specification-Title>${project.name}</Specification-Title>
<Specification-Version>${project.version}</Specification-Version>
<Implementation-Version>${build.number}</Implementation-Version>
</manifestEntries>
</archive>
</configuration>
</execution>
<execution>
<id>create-distro</id>
<phase>package</phase>
<goals>
<goal>single</goal>
</goals>
<configuration>
<descriptors>
<descriptor>Active_Repository/assembly/dist.xml</descriptor>
</descriptors>
<finalName>custom-action-dist</finalName>
<appendAssemblyId>false</appendAssemblyId>
<finalName>Release-${ormb.release.name}</finalName>
</configuration>
</execution>
</executions>
</plugin>
</plugins>
</build>
</project>
I faced the same issue, I wanted to keep fxml & java files in the same folder (I'm using scenebuilder who needs both fxml and java files at the same place).
Here is my solution in pom.xml:
<resources>
<resource>
<directory>src/main/resources</directory>
</resource>
<resource>
<directory>src/main/java</directory>
<includes>
<include>**/*.fxml</include>
</includes>
</resource>
</resources>
If you want the xml files to be included in your JAR file, then store them in the resources folder, instead of java.
Presumably they're in src/main/java. Try moving them to src/main/resources. Anything in src/main/resources will be packaged into the JAR file along with the .class files.

POM How to include properties file inside a jar. The pom also creates a war

I developed a pom that creates a war file and a jar file. How do I insert a properties file into the JAR(not the war)? The file I need to insert into the JAR is located in the directory, properties/its, within the project. You can see in the pom below in the maven-resources-plugin where I have attempted to add the properties file in the package phase with the associated jar goal. Then I tried again in the maven-jar-plugin, using the process-resources phase and jar goal.
<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">
<modelVersion>4.0.0</modelVersion>
<groupId>xxx.xx.Lookup</groupId>
<artifactId>lookup</artifactId>
<packaging>war</packaging>
<version>${env.ENVIRONMENT}</version>
<name>elookup</name>
<url>http://maven.apache.org</url>
<description>Lookup</description>
<dependencies>
<dependency>
<groupId>xxx.xxx.utils</groupId>
<artifactId>Utils</artifactId>
<version>${env.ENVIRONMENT}</version>
</dependency>
</dependencies>
<parent>
<groupId>xxx.xx.parent_project</groupId>
<artifactId>xxxProject</artifactId>
<version>master-version-1.0</version>
<relativePath>../Project/pom.xml</relativePath>
</parent>
<profiles>
<profile>
<id>development</id>
<activation>
<activeByDefault>true</activeByDefault>
</activation>
<properties>
<env>${env.ENVIRONMENT}</env>
</properties>
</profile>
<profile>
<id>test</id>
<properties>
<env>${env.ENVIRONMENT}</env>
</properties>
</profile>
<profile>
<id>production</id>
<properties>
<env>${env.ENVIRONMENT}</env>
</properties>
</profile>
</profiles>
<build>
<finalName>${project.name}-${project.version}</finalName>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-war-plugin</artifactId>
<version>2.1.1</version>
<configuration>
<archive>
<addMavenDescriptor>false</addMavenDescriptor>
</archive>
<webResources>
<resource>
<!-- this is relative to the pom.xml directory -->
<directory>properties/its</directory>
<!-- override the destination directory for this resource -->
<targetPath>properties/its</targetPath>
</resource>
<resource>
<!-- this is relative to the pom.xml directory -->
<directory>src/main/webapp/META-INF</directory>
<!-- override the destination directory for this resource -->
<targetPath>META-INF</targetPath>
<filtering>true</filtering>
</resource>
<resource>
<!-- this is relative to the pom.xml directory -->
<directory>src/main/webapp/WEB-INF</directory>
<!-- override the destination directory for this resource -->
<targetPath>WEB-INF</targetPath>
<filtering>true</filtering>
</resource>
<resource>
<!-- this is relative to the pom.xml directory -->
<directory>images</directory>
<!-- override the destination directory for this resource -->
<targetPath>images</targetPath>
</resource>
<resource>
<!-- this is relative to the pom.xml directory -->
<directory>style</directory>
<!-- override the destination directory for this resource -->
<targetPath>style</targetPath>
</resource>
<resource>
<!-- this is relative to the pom.xml directory -->
<directory>html</directory>
<!-- override the destination directory for this resource -->
<targetPath>.</targetPath>
</resource>
</webResources>
<packagingExcludes>WEB-INF/lib/stax-api-1.0.1.jar</packagingExcludes>
</configuration>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-eclipse-plugin</artifactId>
<version>2.8</version>
<configuration>
<downloadSources>true</downloadSources>
</configuration>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-resources-plugin</artifactId>
<version>2.4</version>
<configuration>
<!-- specify UTF-8, ISO-8859-1 or any other file encoding -->
<encoding>UTF-8</encoding>
<executions>
<execution>
<id>make-a-jar</id>
<phase>package</phase>
<goals>
<goal>jar</goal>
</goals>
<resources>
<resource>
<directory>properties/its</directory>
<includes>
<include>**/*</include>
</includes>
<!-- <targetPath>.</targetPath> -->
</resource>
</resources>
</execution>
</executions>
</configuration>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-jar-plugin</artifactId>
<version>2.4</version>
<executions>
<execution>
<id>make-a-jar</id>
<phase>package</phase>
<goals>
<goal>jar</goal>
</goals>
<configuration>
<archive>
<addMavenDescriptor>false</addMavenDescriptor>
<manifest>
<addClasspath>true</addClasspath>
</manifest>
</archive>
</configuration>
</execution>
<execution>
<id>jar-resources</id>
<phase>process-resources</phase>
<goals>
<goal>jar</goal>
</goals>
<configuration>
<resources>
<resource>
<directory>properties/its</directory>
<targetPath>.</targetPath>
</resource>
</resources>
</configuration>
</execution>
</executions>
</plugin>
<plugin>
<artifactId>maven-assembly-plugin</artifactId>
<version>2.4</version>
<configuration>
<descriptor>src/main/assembly/jar.xml</descriptor>
</configuration>
<executions>
<execution>
<id>make-assembly</id>
<phase>package</phase>
<goals>
<goal>single</goal>
</goals>
</execution>
</executions>
</plugin>
</plugins>
<resources>
<resource>
<directory>src/main/resources</directory>
<filtering>true</filtering>
</resource>
</resources>
<filters>
<filter>../../Project/workspace/src/main/filters/eddb.${env.ENVIRONMENT}.properties</filter>
</filters>
</build>
</project>
How do I insert a properties file into the JAR(not the war)? The file I need to insert into the JAR is located in the directory, properties/its, within the project.
Before package the jar use maven-antrun-plugin to copy your file into the same directory the maven-jar-plugin uses as source directory for jar-ing.

Maven exclude language files from jasig CAS

I searched to disable all languages and set the default language to english. So that only english is available. But i think there is no possibility to do this in jasig CAS.
So i'm trying to remove all language files from the final .war file of my jasig CAS build.
Her is my pom.xml file:
<modelVersion>4.0.0</modelVersion>
<groupId>lu.ion.cas</groupId>
<artifactId>cas-ion</artifactId>
<packaging>war</packaging>
<version>1.0-SNAPSHOT</version>
<name>cas-ion Maven Webapp</name>
<url>http://maven.apache.org</url>
<dependencies>
<dependency>
<groupId>org.jasig.cas</groupId>
<artifactId>cas-server-webapp</artifactId>
<version>${cas.version}</version>
<type>war</type>
<scope>runtime</scope>
</dependency>
<dependency>
<groupId>org.jasig.cas</groupId>
<artifactId>cas-server-support-ldap</artifactId>
<version>${cas.version}</version>
<type>jar</type>
<scope>runtime</scope>
</dependency>
</dependencies>
<properties>
<cas.version>3.5.1</cas.version>
</properties>
<repositories>
<repository>
<id>ja-sig</id>
<url>http://oss.sonatype.org/content/repositories/releases/</url>
</repository>
</repositories>
<build>
<plugins>
<plugin>
<artifactId>maven-war-plugin</artifactId>
<configuration>
<warName>cas-ion</warName>
<excludes>
<exclude>**/messages_*.properties</exclude>
</excludes>
</configuration>
</plugin>
</plugins>
</build>
The part who is supposed to remove those files:
<excludes>
<exclude>**/messages_*.properties</exclude>
</excludes>
But those files are still there.
Use Maven War plugin Overlays described here: http://maven.apache.org/plugins/maven-war-plugin/overlays.html
In this case pom is like this:
<plugin>
<artifactId>maven-war-plugin</artifactId>
<version>2.4</version>
<configuration>
<overlays>
<overlay>
<groupId>org.jasig.cas</groupId>
<artifactId>cas-server-webapp</artifactId>
<excludes>
<exclude>WEB-INF/classes/messages_*.properties</exclude>
</excludes>
</overlay>
</overlays>
</configuration>
If you want include a language, add another overlay like this:
<overlay>
<groupId>org.jasig.cas</groupId>
<artifactId>cas-server-webapp</artifactId>
<includes>
<include>WEB-INF/classes/messages_en.properties</include>
</includes>
Use webResources element. http://maven.apache.org/plugins/maven-war-plugin/faq.html#webresourcesexclude
<plugin>
<artifactId>maven-war-plugin</artifactId>
<version>2.3</version>
<configuration>
<webResources>
<resource>
<directory>path_to_messages</directory>
<excludes>
<exclude>messages_*.properties</exclude>
</excludes>
</resource>
</webResources>
</configuration>
</plugin>

Resources