Share filter file amoung modules
I have the same question as this poster
How to share a filter file among Maven2 modules?
share filter file among all sub projects and sub projects of sub projects
I implemented the solution provided by Rich Seller...this particular one and it works. "Alternatively, you can specify a filter file as an attached artifact on some build"
But at the end of the build, i get an error message
Installing /..../spring/hibernate/search/src/main/resources/shared-filter.properties to /.../spring-hibernate-search-1.0-SNAPSHOT-filter.properties
[ERROR]BUILD ERROR Error installing artifact: File /..../spring/hibernate/search/src/main/resources/shared-filter.properties does not exist
I am guessing Maven is trying to install the artifact proivded in the parent pom
<configuration>
<artifacts>
<artifact>
<file>src/main/resources/shared-filter.properties</file>
<type>properties</type>
<classifier>filter</classifier>
</artifact>
开发者_运维百科 </artifacts>
</configuration>
Is there a way to tell Maven not to install this artifact while building the childrens
PLEASE HELP, STUCK ON THIS FOR A WHILE
***********new addition***************
my parent pom has the following
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>build-helper-maven-plugin</artifactId>
<version>1.3</version>
<executions>
<execution>
<id>attach-artifacts</id>
<phase>package</phase>
<goals>
<goal>attach-artifact</goal>
</goals>
<configuration>
<artifacts>
<artifact>
<file>src/main/resources/filters/mradha.filter.properties</file>
<type>properties</type>
<classifier>filter</classifier>
</artifact>
</artifacts>
</configuration>
</execution>
</executions>
</plugin>
<pluginManagement>
<plugins>
<plugin>
<artifactId>maven-dependency-plugin</artifactId>
<executions>
<execution>
<id>copy</id>
<phase>generate-sources</phase>
<goals>
<goal>copy</goal>
</goals>
<configuration>
<artifactItems>
<artifactItem>
<groupId>com.merc</groupId>
<artifactId>MavenMasterProject</artifactId>
<version>1.0-SNAPSHOT</version>
<classifier>filter</classifier>
<type>properties</type>
<overWrite>false</overWrite>
<destFileName>mradha.filter.properties</destFileName>
</artifactItem>
</artifactItems>
<outputDirectory>
${project.build.directory}/filters
</outputDirectory>
</configuration>
</execution>
</executions>
</plugin>
</plugins>
</pluginManagement>
My sub project or modules have the following
<build>
<filters>
<filter>${project.build.directory}/filters/mradha.filter.properties</filter>
</filters>
<resources>
<resource>
<directory>src/main/resources</directory>
<filtering>true</filtering>
</resource>
</resources>
<plugins>
<plugin>
<artifactId>maven-dependency-plugin</artifactId>
</plugin>
</plugins>
</build>
When i click on the sub project or module and do install, it tries to install the attached artifact and I get the build failure
I just fixed exactly the same problem. We have even more nested structure of projects and I defined 'filters.path' property first
<properties>
<filters.path>../../filters</filters.path>
</properties>
The structure of projects (filtering rules) matched following pattern:
<filters>
<filter>${filters.path}/filter-${env}.properties</filter>
<filter>${filters.path}/filter-shared.properties</filter>
</filters>
I have only 2 projects where custom filtering was required and i just changed the 'filters.path' property
<properties>
<env>dev</env>
<filters.path>../filters</filters.path>
<jbehave-revision>3.4.5</jbehave-revision>
<xmlunit-revision>1.3</xmlunit-revision>
<scale4j-revision>0.2</scale4j-revision>
</properties>
Hope this can help!
Is the xml snippet posted above present in each children? If so, that explains the problem.
If you carefully go through the steps suggested by @Rich Seller in the linked SO post, the parent project should attach
the filter artifact using build-helper-maven-plugin
. The children which require filtering should use maven-dependency-plugin
to have this filter available during the generate-sources
phase. They should then use the filter using the <filter>
and <resource>
tags.
精彩评论