2012-10-26 102 views
4

通过maven package -Pexplode进行的筛选不起作用。 “$ {ds.xml}”不被“openmind-ds.xml”替代。值“openmind-ds.xml”和键“ds.xml”位于filter.properties中。还有$ {as.deploy}。使用配置文件时未设置Maven属性

错误消息

[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]

模式调试

[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#1: Copying files to /home/argonist/om-umgebung/workspaceOM/openmind/openmind-ear/${as.deploy}/openmind-ear.ear 

pom.xml的耳朵项目

<?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> 
      <!-- Properties needed by unexplode profile --> 
      <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>${env.JBOSS_HOME}/server/default/deploy</outputDirectory> --> 
      <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> 
     <!-- <execution> <id>copy-mysql-driver</id> <phase>install</phase> <goals> 
      <goal>copy-resources</goal> </goals> <configuration> <outputDirectory>${env.JBOSS_HOME}/server/default/lib</outputDirectory> 
      <resources> <resource> <directory>${settings.localRepository}/mysql/mysql-connector-java/5.1.6</directory> 
      <includes> <include>mysql-connector-java-5.1.6.jar</include> </includes> 
      </resource> </resources> </configuration> </execution> --> 
     </plugin> 
    </plugins> 
    <resources> 
     <resource> 
     <directory>src/main/resources</directory> 
     <filtering>true</filtering> 
     </resource> 
    </resources> 
    </build> 
</project> 

回答

0

你的过滤性能依赖于${env}参数:

<filter>../src/main/filters/filter-${env}.properties</filter> 

这个参数对你的“爆炸”的个人资料没有价值。所以Maven的,必须寻找:

../src/main/filters/filter-.properties 

我怀疑你希望这将是filter.properties,而不是filter-.properties

+0

$ {env}参数在该pom的父级中设置。 dev我尝试了您的建议。它仍然没有工作。但我找到了解决方案。它正在使用命令“mvn clean install -Pexplode”。我必须将“干净”添加到命令中!我不明白,为什么。我想使用正常的命令“mvn install -Pexplode”。解? – argonist

相关问题