Maven exclude language files from jasig CAS - maven

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>

Related

Unable to bind maven profile to spring boot profile

I've seen all the questions and post regarding this issue so please don't mark this as duplicate or route me to those issues, I have tried implementing those solutions but nothing worked as of now.
I have profile specific application.properties files i.e application-prod.properties, application-dev.properties, application-int.properties etc
pom.xml
<profiles>
<profile>
<id>prod</id>
<properties>
<activeProfile>prod</activeProfile>
</properties>
</profile>
<profile>
<id>int</id>
<properties>
<activeProfile>int</activeProfile>
</properties>
</profile>
<profile>
<id>dev</id>
<properties>
<activeProfile>dev</activeProfile>
</properties>
</profile>
</profiles>
<build>
<resources>
<resource>
<directory>src/main/resources</directory>
<filtering>true</filtering>
</resource>
</resources>
…
</build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-jar-plugin</artifactId>
<configuration>
<archive>
<index>true</index>
<manifest>
<mainClass>com.demo.Application</mainClass>
</manifest>
</archive>
</configuration>
</plugin>
<plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<configuration>
<source>1.8</source>
<target>1.8</target>
</configuration>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-help-plugin</artifactId>
<executions>
<execution>
<id>show-profiles</id>
<phase>compile</phase>
<goals>
<goal>active-profiles</goal>
</goals>
</execution>
</executions>
</plugin>
</plugins>
application.properties
spring.profiles.active=#activeProfile#
I'm doing mvn clean install -Pprod and then running the application.
I'm sure the maven profile is executing during the build as I get this during the build
The following profiles are active:
- prod (source: my-project-snapshot)
This is what I'm getting when running the application:
: The following profiles are active: #activeProfile#
Can anyone please help me here.
UPDATE
when I close my IDE(STS) and do the maven build, it is working. Any info regarding this info would be really appreciated.
Have you enabled resource filtering in your pom.xml? Since you are using spring-boot this can be easily enabled, in your pom.xml
<build>
<resources>
<resource>
<directory>src/main/resources</directory>
<filtering>true</filtering>
</resource>
</resources>
…
</build>
UPDATE
I have put all your plugins in a sample project's pom.xml also matching your spring-boot version:
<?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 https://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<parent>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-parent</artifactId>
<version>2.2.1.RELEASE</version>
<relativePath/> <!-- lookup parent from repository -->
</parent>
<groupId>in.example</groupId>
<artifactId>demo</artifactId>
<version>0.0.1-SNAPSHOT</version>
<name>demo</name>
<description>Demo project for Spring Boot</description>
<properties>
<java.version>11</java.version>
</properties>
<profiles>
<profile>
<id>prod</id>
<properties>
<activeProfile>prod</activeProfile>
</properties>
</profile>
<profile>
<id>dev</id>
<properties>
<activeProfile>dev</activeProfile>
</properties>
</profile>
</profiles>
<dependencies>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-data-jpa</artifactId>
</dependency>
<dependency>
<groupId>com.h2database</groupId>
<artifactId>h2</artifactId>
<scope>runtime</scope>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-aop</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-test</artifactId>
<scope>test</scope>
</dependency>
</dependencies>
<build>
<resources>
<resource>
<directory>src/main/resources</directory>
<filtering>true</filtering>
</resource>
</resources>
<plugins>
<plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-help-plugin</artifactId>
<executions>
<execution>
<id>show-profiles</id>
<phase>compile</phase>
<goals>
<goal>active-profiles</goal>
</goals>
</execution>
</executions>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<configuration>
<source>1.8</source>
<target>1.8</target>
</configuration>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-jar-plugin</artifactId>
<configuration>
<archive>
<index>true</index>
<manifest>
<mainClass>com.example.demo.DemoApplication</mainClass>
</manifest>
</archive>
</configuration>
</plugin>
</plugins>
</build>
</project>
When I run
mvn clean package spring-boot:run -Pdev -DskipTests
I see in the log files
com.example.demo.DemoApplication : The following profiles are active: dev
And when I check the generated jar in target dir...target\demo-0.0.1-SNAPSHOT.jar\BOOT-INF\classes\ filtering has succeeded since in application.properties I get the line:
spring.profiles.active=dev
which in the source application.properties is
spring.profiles.active=#activeProfile#
So if you have a pom file similar to the above filtering should work.
Thanks a lot #pleft, I tried everything and because of that I realized this may not be a maven issue but an IDE issue. I'm using STS 3 and I found out that disabling "Refresh using native hooks" under Window > preferences > General > Workspace > Refresh using native hooks would solve the issue of STS IDE ignoring -P<profile> during maven build when STS is open.
There seems to be already a bug ticket for this.

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

How to get artificactId of dependencies in 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.

Configuring jetty:run to use the "final" lib folder

I have a Maven project using a war overlay. As outlined in this answer, one problem with WAR overlays is that they seem to effectively sidestep Maven's dependency resolution. This results in build and/or runtime verification errors.
Fortunately, there is a solution - using the overlay/excludes configuration directives. This ensures that the resultant WAR will only have what you want.
However, it seems that the jetty:run uses the war plugin's work directory for library resolution (which does contain the "bad" JAR).
The problem is avoided by using either jetty:run-war or jetty:run-exploded.
However,
as most of our projects run fine using jetty:run,
and jetty-run with scanInterval is very convenient during development,
I'd like to know whether it's possible to add some configuration changes to the POM that would force the run goal to use the target lib folder?
For illustration purposes, here's the specific example:
the project uses the org.apache.solr:solr:3.6.2 overlay,
the overlay includes an old version of Guava, r05, while our code uses a more recent one, 14.0.1,
as stated before, while the target artifact war is fine, jetty:run includes the r05 version into the classpath, which causes verification errors in our code.
Here's the example POM:
<?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/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>com.example</groupId>
<artifactId>solr.archetype.examination</artifactId>
<version>0.0.1-SNAPSHOT</version>
<packaging>war</packaging>
<name>A Solr project</name>
<properties>
<solr.version>3.6.2</solr.version>
<solr.port>8983</solr.port>
</properties>
<dependencies>
<dependency>
<groupId>org.apache.solr</groupId>
<artifactId>solr-core</artifactId>
<version>${solr.version}</version>
</dependency>
<dependency>
<groupId>org.apache.solr</groupId>
<artifactId>solr</artifactId>
<version>${solr.version}</version>
<type>war</type>
</dependency>
<dependency>
<groupId>org.apache.solr</groupId>
<artifactId>solr-solrj</artifactId>
<version>${solr.version}</version>
</dependency>
<dependency>
<groupId>com.google.guava</groupId>
<artifactId>guava</artifactId>
<version>14.0.1</version>
</dependency>
</dependencies>
<build>
<resources>
<resource>
<directory>src/main/resources</directory>
<filtering>true</filtering>
</resource>
</resources>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>2.5.1</version>
<configuration>
<source>1.7</source>
<target>1.7</target>
</configuration>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-war-plugin</artifactId>
<version>2.3</version>
<configuration>
<overlays>
<overlay>
<groupId>org.apache.solr</groupId>
<artifactId>solr</artifactId>
<excludes>
<exclude>**/guava-r05.jar</exclude>
</excludes>
</overlay>
</overlays>
</configuration>
</plugin>
<plugin>
<groupId>org.mortbay.jetty</groupId>
<artifactId>maven-jetty-plugin</artifactId>
<version>6.1.25</version>
<configuration>
<scanIntervalSeconds>10</scanIntervalSeconds>
<stopKey>foo</stopKey>
<stopPort>9999</stopPort>
<contextPath>/solr</contextPath>
<connectors>
<connector implementation="org.mortbay.jetty.nio.SelectChannelConnector">
<port>${solr.port}</port>
<maxIdleTime>60000</maxIdleTime>
</connector>
</connectors>
<systemProperties>
<systemProperty>
<name>solr.data.dir</name>
<value>target/data</value>
</systemProperty>
</systemProperties>
</configuration>
</plugin>
</plugins>
</build>
</project>

Resources