4

过滤孔maven package -Pexplode不起作用。“${ds.xml}”没有被“openmind-ds.xml”替换。值“openmind-ds.xml”和键“ds.xml”在 filter.properties 中。还有 ${as.deploy}。

错误信息

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

1 回答 1

0

您的过滤器属性依赖于${env}参数:

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

此参数在您的“explode”配置文件中没有任何价值。所以Maven一定在寻找:

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

我怀疑你希望它会是filter.properties而不是filter-.properties

于 2012-10-27T14:55:07.640 回答