0

Inside a maven project with some resources configured like this :

<webResources>
    ....
    <resource>
        <directory>${project.build.directory}/${temp.dir}</directory>
    </resource>
</webResources>

the ${temp.dir} is generated conditionally by a plugin and do not exists always. When it is not there maven of course fail with an NPE, how could I fix this ?

4

1 回答 1

1

我不确定我是否理解您的问题(确切地),但在我看来 Maven 配置文件可以帮助您:

http://maven.apache.org/guides/introduction/introduction-to-profiles.html

在您的情况下,您可能需要在属性存在时激活配置文件,如下所示:

<profiles>
  <profile>
    <activation>
      <property>
        <name>temp.dir</name>
      </property>
    </activation>
    ...
  </profile>
</profiles>
于 2012-04-12T08:56:38.983 回答