Filtering through maven package -Pexplode does not work. "$ {ds.xml}" is not replaced by "openmind-ds.xml". The value "openmind-ds.xml" and the key "ds.xml" are in the filter.properties file. Also $ {as.deploy}.
Error message
[ERROR] Failed to execute goal org.apache.maven.plugins:maven-antrun-plugin:1.3:run (package) on project openmind-ear: An Ant BuildException has occured: Warning: Could not find file /home/localhost/workspaceOM/openmind/openmind-ear/target/${ds.xml} to copy. -> [Help 1]
Debug mode
[INFO] Executing tasks [DEBUG] getProperty(ns=null, name=ant.reuse.loader, user=false) [antlib:org.apache.tools.ant] Could not load definitions from resource org/apache/tools/ant/antlib.xml. It could not be found. [DEBUG] getProperty(ns=null, name=as.deploy, user=false) Property "as.deploy" has not been set Setting project property: deploy-path -> ${as.deploy}/openmind-ear.ear [DEBUG] getProperty(ns=null, name=deploy-path, user=false) [echo] Exploding to ${as.deploy}/openmind-ear.ear [DEBUG] getProperty(ns=null, name=deploy-path, user=false) [delete] Directory /home/localhost/workspaceOM/openmind/openmind-ear/${as.deploy}/openmind-ear.ear cannot be removed using the file attribute. Use dir instead. [DEBUG] getProperty(ns=null, name=deploy-path, user=false) [mkdir] Skipping /home/localhost/workspaceOM/openmind/openmind-ear/${as.deploy}/openmind-ear.ear because it already exists. [DEBUG] getProperty(ns=null, name=deploy-path, user=false) [sync] PASS
pom.xml in an ear project
<?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> <parent> <groupId>de.openmind</groupId> <artifactId>openmind</artifactId> <version>1.0-SNAPSHOT</version> <relativePath>../pom.xml</relativePath> </parent> <artifactId>openmind-ear</artifactId> <packaging>ear</packaging> <name>${project.artifactId} : ${project.version} EAR</name> <profiles> <profile> <id>env-dev</id> <properties> <env>dev</env> </properties> </profile> <profile> <id>env-prod</id> <properties> <env>prod</env> </properties> </profile> <profile> <id>explode</id> <build> <plugins> <plugin> <artifactId>maven-antrun-plugin</artifactId> <executions> <execution> <id>package</id> <phase>package</phase> <configuration> <tasks> <property name="deploy-path" value="${as.deploy}/${app.context}-ear.ear" /> <echo>Exploding to ${deploy-path}</echo> <delete file="${deploy-path}" quiet="true" /> <mkdir dir="${deploy-path}" /> <sync todir="${deploy-path}" verbose="true"> <fileset dir="${project.build.directory}/${project.build.finalName}" /> </sync> <copy todir="${as.deploy}" file="${project.build.directory}/${ds.xml}" verbose="true" /> </tasks> </configuration> <goals> <goal>run</goal> </goals> </execution> </executions> </plugin> </plugins> </build> </profile> <profile> <id>unexplode</id> <build> <plugins> <plugin> <artifactId>maven-antrun-plugin</artifactId> <executions> <execution> <id>clean</id> <phase>clean</phase> <configuration> <tasks> <property name="deploy-path" value="${as.deploy}/${app.context}-ear.ear" /> <echo>Unexploding: ${deploy-path}</echo> <delete file="${deploy-path}" quiet="true" /> <delete dir="${deploy-path}" quiet="true" /> <delete file="${as.deploy}/${ds.xml}" quiet="true" /> </tasks> </configuration> <goals> <goal>run</goal> </goals> </execution> </executions> </plugin> </plugins> </build> </profile> </profiles> <dependencies> ..... </dependencies> <build> <finalName>${app.context}-ear</finalName> <filters> <filter>../src/main/filters/filter-${env}.properties</filter> </filters> <plugins> <plugin> <artifactId>maven-ear-plugin</artifactId> <configuration> <defaultJavaBundleDir>lib/</defaultJavaBundleDir> <version>6</version> <archive> <manifestEntries> <Build-Date>${timestamp}</Build-Date> <Build-Revision>${buildNumber}</Build-Revision> <Mode>${env}</Mode> </manifestEntries> </archive> <modules> <jarModule> <groupId>org.jboss.el</groupId> <artifactId>jboss-el</artifactId> <includeInApplicationXml>false</includeInApplicationXml> <bundleDir>lib</bundleDir> </jarModule> <jarModule> <groupId>${project.groupId}</groupId> <artifactId>${app.context}-datamodel</artifactId> <includeInApplicationXml>false</includeInApplicationXml> <bundleDir>lib</bundleDir> </jarModule> <webModule> <groupId>${project.groupId}</groupId> <artifactId>${app.context}-war</artifactId> <contextRoot>/${app.web.context}</contextRoot> <unpack>${app.unpack.modules}</unpack> <bundleFileName>${app.context}-war.war</bundleFileName> </webModule> <ejbModule> <groupId>${project.groupId}</groupId> <artifactId>${app.context}-bootstrap</artifactId> <excluded>${exclude.bootstrap}</excluded> <bundleFileName>${app.context}-bootstrap.jar</bundleFileName> <unpack>${app.unpack.modules}</unpack> </ejbModule> <ejbModule> <groupId>${project.groupId}</groupId> <artifactId>${app.context}-ejb</artifactId> <bundleFileName>${app.context}-ejb.jar</bundleFileName> <unpack>${app.unpack.modules}</unpack> </ejbModule> <ejbModule> <groupId>org.jboss.seam</groupId> <artifactId>jboss-seam</artifactId> </ejbModule> </modules> </configuration> </plugin> <plugin> <groupId>org.codehaus.mojo</groupId> <artifactId>properties-maven-plugin</artifactId> <executions> <execution> <configuration> <files> <file>${basedir}/../src/main/filters/filter-${env}.properties</file> </files> </configuration> </execution> <execution> <id>pre-clean</id> <phase>pre-clean</phase> <goals> <goal>read-project-properties</goal> </goals> <configuration> <files> <file>${basedir}/../src/main/filters/filter-${env}.properties</file> </files> </configuration> </execution> </executions> </plugin> <plugin> <groupId>org.apache.maven.plugins</groupId> <artifactId>maven-resources-plugin</artifactId> <version>2.6</version> <configuration> <outputDirectory>${project.build.directory}</outputDirectory> <resources> <resource> <directory>src/main/resources</directory> <filtering>true</filtering> <includes> <include>${ds.xml}</include> </includes> </resource> </resources> </configuration> <executions> <execution> <id>copy-app-ds-xml</id> <goals> <goal>copy-resources</goal> </goals> </execution> </executions> </plugin> </plugins> <resources> <resource> <directory>src/main/resources</directory> <filtering>true</filtering> </resource> </resources> </build> </project>
source share