3

だから私は次のようなものを持っています:

<plugin>
            <groupId>org.codehaus.mojo</groupId>
            <artifactId>properties-maven-plugin</artifactId>
            <version>1.0-alpha-1</version>
            <executions>
                <execution>
                    <phase>initialize</phase>
                    <goals>
                        <goal>read-properties</goal>
                    </goals>
                    <configuration>
                        <files>
                            <file>${user.home}/build.properties</file>
                        </files>
                    </configuration>
                </execution>
            </executions>
        </plugin>

そして私はdistributionManagement好きです:

<distributionManagement>
    <repository>
        <id>local-repo</id>
        <url>file:///${deploy.dir}/${project.artifactId}</url>
    </repository>
</distributionManagement>

私はリモートリポジトリを持っていないので、それを使用してそれを行っていますfile:///

${deploy.dir}build.propertiesファイルのプロパティであり、そのプロパティの値は取得されません。なんで?

4

2 に答える 2

5

ビルドプロファイルを使用して複数の配布ターゲットを管理することをお勧めします。例えば:

<profiles>
   <profile>
      <id>repo1</id>
      <distributionManagement>
         <repository>
            <id>repo1-release</id>
            <url>http://.......</url>
         </repository>
      </distributionManagement>
   </profile>

   <profile>
      <id>repo2</id>
      <distributionManagement>
         <repository>
            <id>repo2-release</id>
            <url>http://.......</url>
         </repository>
      </distributionManagement>
   </profile>
   ..
</profiles>

デプロイ目標を呼び出すときは、プロファイルをアクティブ化して宛先を選択できます。

mvn -Prepo1 clean deploy
于 2012-05-18T18:17:40.533 に答える
2

マークの答えはおそらく進むべき道であり、リモートリポジトリの本番インスタンスとテストインスタンスを切り替えるために私が行っていることです。議論によると、後のプラグイン構成で使用するためにプロパティをロードできるように思えますが、のようなコアMavenモデル要素<distributionManagement>には、POMの初期ロードでのみ解釈されるプロパティがあります。

(OPリクエストごとにコメントを移動して回答します。)

于 2012-05-21T13:43:47.720 に答える