更改reactor构建中每个模块的当前工作目录?

时间:2014-02-14 07:01:21

标签: java spring maven

据我所知,Maven 无法为反应堆构建中的每个模块构建(对于正在构建的模块)更改当前工作目录,因为它不是可能在标准Java中更改当前工作目录。首先,这是正确的吗?

如果是,我如何使以下方案有效?

更新:我有一个 some.properties 文件应该在正在构建的模块的类路径上(例如在src / main / resources中)并且它在 Maven插件的Spring上下文文件中引用,如下所示:

<bean id="placeholderConfig" class="org.springframework.beans.factory.config.PropertyPlaceholderConfigurer">
        <property name="ignoreResourceNotFound" value="true"/>
        <property name="locations">
            <array>
                <value>classpath:some.properties</value>
            </array>
        </property>
    </bean>

Maven插件正在“process-test-resources”阶段执行。此外,some.properties文件具有引用外部相对可配置路径的属性:

some.spring.config.dir=target/test-classes

然后,来自此路径的一些配置文件将加载到正在构建的模块中的spring上下文文件中,例如:

<property name="configLocation" value="file:${some.spring.config.dir}/cache.xml" />

当我从pom.xml目录构建项目时,此方案有效,但当我从顶级目录构建反应器构建的一部分时,。当从任何目录运行maven 并且还保留我的属性文件中的路径(例如“target / test-classes”) relative 时,有没有办法让它工作?< / p>

1 个答案:

答案 0 :(得分:0)

需要两个步骤:

  1. 包含配置文件的资源过滤:http://maven.apache.org/plugins/maven-resources-plugin/examples/filter.html

  2. 配置文件中的
  3. add basedir:

      some.spring.config.dir=${basedir}/target/test-classes
    

    在“target”目录中,“some.spring.config.dir”将以完整路径填充。

相关问题