1
プロジェクトをビルドしてテストを実行するときに、the correct version of alpn-bootにプルするMaven POMを作成しようとしています。JVMバージョンに依存するMaven依存バージョン
ビルド実行しているとき、私は「外」からプロパティを注入していた場合、全部の作品(例えば、を。mvn -Dalpn-boot.version=8.1.8.v20160420 test
を介して、または環境変数として)ではなく${java.version}
を使用してPOMの内側にそれを補間しようとしています。
pom.xml
ファイル(スニペット)で、以下の設定でこれを達成するために
properties-maven-pluginを使用してみました
:プロパティファイルのいずれかの
<project>
<build>
<plugins>
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>properties-maven-plugin</artifactId>
<version>1.0.0</version>
<executions>
<execution>
<phase>initialize</phase>
<goals>
<goal>read-project-properties</goal>
</goals>
<configuration>
<files>
<file>${project.basedir}/alpn-boot/jdk-${java.version}.properties</file>
</files>
</configuration>
</execution>
</executions>
</plugin>
</plugins>
</build>
<dependencies>
<dependency>
<groupId>org.mortbay.jetty.alpn</groupId>
<artifactId>alpn-boot</artifactId>
<version>${alpn-boot.version}</version>
<scope>test</scope>
</dependency>
</dependencies>
</project>
内容:
$ cat alpn-boot/jdk-1.8.0_92.properties
alpn-boot.version=8.1.8.v20160420
基本的には同じgmaven-plugin
の問題:
<plugin>
<groupId>org.codehaus.groovy.maven</groupId>
<artifactId>gmaven-plugin</artifactId>
<version>1.0</version>
<executions>
<execution>
<phase>initialize</phase>
<goals>
<goal>execute</goal>
</goals>
<configuration>
<source>
alpnVersions = [ '1.8.0_92': '8.1.8.v20160420' ]
project.properties['alpn-boot.version'] = alpnVersions[System.getProperty('java.version')]
</source>
</configuration>
</execution>
</executions>
</plugin>
[INFO] Scanning for projects...
[ERROR] [ERROR] Some problems were encountered while processing the POMs:
[ERROR] 'dependencies.dependency.version' for org.mortbay.jetty.alpn:alpn-boot:jar must be a valid version but is '${alpn-boot.version}'. @ org.example:my-project:[unknown-version], /path/to/pom.xml, line 132, column 22
@
[ERROR] The build could not read 1 project -> [Help 1]
[ERROR]
[ERROR] The project org.example:my-project:1.0.0-rc3-SNAPSHOT (/path/to/pom.xml) has 1 error
[ERROR] 'dependencies.dependency.version' for org.mortbay.jetty.alpn:alpn-boot:jar must be a valid version but is '${alpn-boot.version}'. @ org.example:my-project:[unknown-version], /path/to/pom.xml, line 132, column 22
[ERROR]
[ERROR] To see the full stack trace of the errors, re-run Maven with the -e switch.
[ERROR] Re-run Maven using the -X switch to enable full debug logging.
[ERROR]
[ERROR] For more information about the errors and possible solutions, please read the following articles:
[ERROR] [Help 1] http://cwiki.apache.org/confluence/display/MAVEN/ProjectBuildingException
大きな問題である私は、次のエラーメッセージが表示されます近づくと両方で文字通りpomにバージョンを書き込むには? – khmarbaise
@khmarbaise問題は、JVMの「間違った」バージョンが使用されているとビルド/テストがハングアップして失敗することです。残念ながら私は開発マシン上で別のバージョンのJVMをTravis CIよりも実行しているので、内部で "alpn-boot"のバージョンをハードコーディングした場合、私のビルドが失敗したり、Travis CIのビルドが失敗するという選択肢がありますPOM – joschi
これは、Mavenのツールチェーンの仕事のように思えます。 (7/8?)あなたのコードをチェックしてください。さらに、jvmの何かが環境経由で利用可能です。 JVM/JDKに基づいた異なる依存関係を使用する必要があります[JDKバージョンによってアクティブ化されるプロファイル](https://maven.apache.org/guides/introduction/introduction-to-profiles.html).. – khmarbaise