2013-03-24 12 views
12

私はgithub Java/PHP projecttravis-ci環境に統合しようとしています。バージョン1.3でサポートされていないJavaジェネリックとアノテーション(トラビス統合)

Using worker: bluebox-linux-1.worker.travis-ci.org:travis-linux-9 
$ git clone --depth=50 --branch=master git://github.com/tkoomzaaskz/wealthy-laughing-duck.git tkoomzaaskz/wealthy-laughing-duck 
Cloning into 'tkoomzaaskz/wealthy-laughing-duck'... 
remote: Counting objects: 458, done. 
remote: Compressing objects: 100% (263/263), done. 
remote: Total 458 (delta 156), reused 390 (delta 96) 
Receiving objects: 100% (458/458), 458.40 KiB, done. 
Resolving deltas: 100% (156/156), done. 
$ cd tkoomzaaskz/wealthy-laughing-duck 
$ git checkout -qf 47d1ef528f19ad6d01288ac9a3d4c550a79b14f4 
$ jdk_switcher use openjdk7 
Switching to OpenJDK7 (java-1.7.0-openjdk-amd64), JAVA_HOME will be set to /usr/lib/jvm/java-7-openjdk-amd64 
update-alternatives: error: no alternatives for apt. 
update-alternatives: error: no alternatives for mozilla-javaplugin.so. 
update-java-alternatives: plugin alternative does not exist: /usr/lib/jvm/java-7-openjdk-amd64/jre/lib/amd64/IcedTeaPlugin.so 
$ java -version 
java version "1.7.0_15" 
OpenJDK Runtime Environment (IcedTea7 2.3.7) (7u15-2.3.7-0ubuntu1~12.04.1) 
OpenJDK 64-Bit Server VM (build 23.7-b01, mixed mode) 
$ javac -version 
javac 1.7.0_15 
$ mvn install --quiet -DskipTests=true 
[ERROR] Failed to execute goal org.apache.maven.plugins:maven-compiler-plugin:2.0.2:compile (default-compile) on project wealthy-laughing-duck: Compilation failure: Compilation failure: 
[ERROR] /home/travis/build/tkoomzaaskz/wealthy-laughing-duck/src/main/java/com/blogspot/symfonyworld/wealthylaughingduck/dao/OutcomeDao.java:[19,8] error: generics are not supported in -source 1.3 
[ERROR] 
[ERROR] (use -source 5 or higher to enable generics) 
[ERROR] /home/travis/build/tkoomzaaskz/wealthy-laughing-duck/src/main/java/com/blogspot/symfonyworld/wealthylaughingduck/model/Income.java:[12,1] error: annotations are not supported in -source 1.3 
[ERROR] 
[ERROR] (use -source 5 or higher to enable annotations) 
[ERROR] /home/travis/build/tkoomzaaskz/wealthy-laughing-duck/src/main/java/com/blogspot/symfonyworld/wealthylaughingduck/model/User.java:[10,1] error: annotations are not supported in -source 1.3 

出力は、私が注釈やジェネリックを使用するには、Javaの、あまりにも古いバージョンを使用していると述べている:以下

language: java 
jdk: 
    - openjdk7 
    - oraclejdk7 
script: mvn test 

がプリントをトラヴィス出力されます:これは私のトラヴィス構成です。しかし、これらは新しいものではなく、何とかサポートされなければなりません(私は推測します)。私はtravis/javaドキュメントを見てきましたが、javaバージョンに関するオプションは見つかりませんでした(したがって私は別のJDKを使用しようとしました)。誰かが私がtravis設定ファイルに入れなければならないものを私に指摘できますか?


編集:@hertzsprung以下

、私はmvn help:effective-pomを実行し、それが出力される(実際には、sourcetarget属性でもないが、maven-compiler-pluginために定義されたノートです - 私はそれについて何ができるのでしょうか?)以下返さ:

<!-- ====================================================================== --> 
<!--                  --> 
<!-- Generated by Maven Help Plugin on 2013-03-24T08:15:13     --> 
<!-- See: http://maven.apache.org/plugins/maven-help-plugin/    --> 
<!--                  --> 
<!-- ====================================================================== --> 

<!-- ====================================================================== --> 
<!--                  --> 
<!-- Effective POM for project            --> 
<!-- 'com.blogspot.symfony-world:wealthy-laughing-duck:jar:1.0-SNAPSHOT' --> 
<!--                  --> 
<!-- ====================================================================== --> 

<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/xsd/maven-4.0.0.xsd"> 
    <modelVersion>4.0.0</modelVersion> 
    <groupId>com.blogspot.symfony-world</groupId> 
    <artifactId>wealthy-laughing-duck</artifactId> 
    <version>1.0-SNAPSHOT</version> 
    <name>wealthy-laughing-duck</name> 
    <url>http://maven.apache.org</url> 
    <build> 
    <sourceDirectory>/var/www/github/wealthy-laughing-duck/src/main/java</sourceDirectory> 
    <scriptSourceDirectory>src/main/scripts</scriptSourceDirectory> 
    <testSourceDirectory>/var/www/github/wealthy-laughing-duck/src/test/java</testSourceDirectory> 
    <outputDirectory>/var/www/github/wealthy-laughing-duck/target/classes</outputDirectory> 
    <testOutputDirectory>/var/www/github/wealthy-laughing-duck/target/test-classes</testOutputDirectory> 
    <resources> 
     <resource> 
     <mergeId>resource-0</mergeId> 
     <directory>/var/www/github/wealthy-laughing-duck/src/main/resources</directory> 
     </resource> 
    </resources> 
    <testResources> 
     <testResource> 
     <mergeId>resource-1</mergeId> 
     <directory>/var/www/github/wealthy-laughing-duck/src/test/resources</directory> 
     </testResource> 
    </testResources> 
    <directory>/var/www/github/wealthy-laughing-duck/target</directory> 
    <finalName>wealthy-laughing-duck-1.0-SNAPSHOT</finalName> 
    <pluginManagement> 
     <plugins> 
     <plugin> 
      <artifactId>maven-antrun-plugin</artifactId> 
      <version>1.6</version> 
     </plugin> 
     <plugin> 
      <artifactId>maven-assembly-plugin</artifactId> 
      <version>2.2-beta-4</version> 
     </plugin> 
     <plugin> 
      <artifactId>maven-clean-plugin</artifactId> 
      <version>2.3</version> 
     </plugin> 
     <plugin> 
      <artifactId>maven-compiler-plugin</artifactId> 
      <version>2.0.2</version> 
     </plugin> 
     <plugin> 
      <artifactId>maven-dependency-plugin</artifactId> 
      <version>2.1</version> 
     </plugin> 
     <plugin> 
      <artifactId>maven-deploy-plugin</artifactId> 
      <version>2.4</version> 
     </plugin> 
     <plugin> 
      <artifactId>maven-ear-plugin</artifactId> 
      <version>2.3.2</version> 
     </plugin> 
     <plugin> 
      <artifactId>maven-ejb-plugin</artifactId> 
      <version>2.2</version> 
     </plugin> 
     <plugin> 
      <artifactId>maven-install-plugin</artifactId> 
      <version>2.3</version> 
     </plugin> 
     <plugin> 
      <artifactId>maven-jar-plugin</artifactId> 
      <version>2.2</version> 
     </plugin> 
     <plugin> 
      <artifactId>maven-javadoc-plugin</artifactId> 
      <version>2.6.1</version> 
     </plugin> 
     <plugin> 
      <artifactId>maven-plugin-plugin</artifactId> 
      <version>2.8</version> 
     </plugin> 
     <plugin> 
      <artifactId>maven-rar-plugin</artifactId> 
      <version>2.2</version> 
     </plugin> 
     <plugin> 
      <artifactId>maven-release-plugin</artifactId> 
      <version>2.0-beta-8</version> 
     </plugin> 
     <plugin> 
      <artifactId>maven-resources-plugin</artifactId> 
      <version>2.3</version> 
     </plugin> 
     <plugin> 
      <artifactId>maven-site-plugin</artifactId> 
      <version>2.1</version> 
     </plugin> 
     <plugin> 
      <artifactId>maven-source-plugin</artifactId> 
      <version>2.0.4</version> 
     </plugin> 
     <plugin> 
      <artifactId>maven-surefire-plugin</artifactId> 
      <version>2.4.3</version> 
     </plugin> 
     <plugin> 
      <artifactId>maven-war-plugin</artifactId> 
      <version>2.1-beta-1</version> 
     </plugin> 
     </plugins> 
    </pluginManagement> 
    <plugins> 
     <plugin> 
     <artifactId>maven-help-plugin</artifactId> 
     <version>2.2</version> 
     </plugin> 
    </plugins> 
    </build> 
    <repositories> 
    <repository> 
     <snapshots> 
     <enabled>false</enabled> 
     </snapshots> 
     <id>central</id> 
     <name>Maven Repository Switchboard</name> 
     <url>http://repo1.maven.org/maven2</url> 
    </repository> 
    </repositories> 
    <pluginRepositories> 
    <pluginRepository> 
     <releases> 
     <updatePolicy>never</updatePolicy> 
     </releases> 
     <snapshots> 
     <enabled>false</enabled> 
     </snapshots> 
     <id>central</id> 
     <name>Maven Plugin Repository</name> 
     <url>http://repo1.maven.org/maven2</url> 
    </pluginRepository> 
    </pluginRepositories> 
    <dependencies> 
    <dependency> 
     <groupId>junit</groupId> 
     <artifactId>junit</artifactId> 
     <version>3.8.1</version> 
     <scope>test</scope> 
    </dependency> 
    <dependency> 
     <groupId>org.apache.thrift</groupId> 
     <artifactId>libthrift</artifactId> 
     <version>0.9.0</version> 
    </dependency> 
    <dependency> 
     <groupId>org.slf4j</groupId> 
     <artifactId>slf4j-api</artifactId> 
     <version>1.7.3</version> 
    </dependency> 
    <dependency> 
     <groupId>org.hibernate</groupId> 
     <artifactId>hibernate-core</artifactId> 
     <version>4.1.10.Final</version> 
    </dependency> 
    <dependency> 
     <groupId>mysql</groupId> 
     <artifactId>mysql-connector-java</artifactId> 
     <version>5.1.24</version> 
    </dependency> 
    </dependencies> 
    <reporting> 
    <outputDirectory>/var/www/github/wealthy-laughing-duck/target/site</outputDirectory> 
    </reporting> 
    <properties> 
    <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding> 
    </properties> 
</project> 

[INFO] ------------------------------------------------------------------------ 
[INFO] BUILD SUCCESSFUL 
[INFO] ------------------------------------------------------------------------ 
[INFO] Total time: 16 seconds 
[INFO] Finished at: Sun Mar 24 20:15:13 CET 2013 
[INFO] Final Memory: 11M/60M 
[INFO] ------------------------------------------------------------------------ 

これは私の元pom.xmlコンテンツです:

<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/xsd/maven-4.0.0.xsd"> 
    <modelVersion>4.0.0</modelVersion> 

    <groupId>com.blogspot.symfony-world</groupId> 
    <artifactId>wealthy-laughing-duck</artifactId> 
    <version>1.0-SNAPSHOT</version> 
    <packaging>jar</packaging> 

    <name>wealthy-laughing-duck</name> 
    <url>http://maven.apache.org</url> 

    <properties> 
     <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding> 
    </properties> 

    <dependencies> 
     <dependency> 
      <groupId>junit</groupId> 
      <artifactId>junit</artifactId> 
      <version>3.8.1</version> 
      <scope>test</scope> 
     </dependency> 
     <dependency> 
      <groupId>org.apache.thrift</groupId> 
      <artifactId>libthrift</artifactId> 
      <version>0.9.0</version> 
     </dependency> 
     <dependency> 
      <artifactId>slf4j-api</artifactId> 
      <groupId>org.slf4j</groupId> 
      <type>jar</type> 
      <version>1.7.3</version> 
     </dependency> 
     <dependency> 
      <artifactId>hibernate-core</artifactId> 
      <groupId>org.hibernate</groupId> 
      <type>jar</type> 
      <version>4.1.10.Final</version> 
     </dependency> 
     <dependency> 
      <groupId>mysql</groupId> 
      <artifactId>mysql-connector-java</artifactId> 
      <version>5.1.24</version> 
     </dependency> 
    </dependencies> 
</project> 
+2

これはtravis-ciではなくpomの問題です。 'mvn help:effective-pom'を見て、裕福な笑い声のダックのために、または要素がmaven-compiler-pluginに設定されているかどうかを確認してください。 – hertzsprung

+0

あなたのコメントに記載された出力を提供しました。あなたはそれを見て解決策を提案できますか? – ducin

+3

[ソースとターゲットを明示的に指定](http://maven.apache.org/plugins/maven-compiler-plugin/examples/set-compiler-source-and-target.html)を試して、1.7を使用してifそれは助ける? – hertzsprung

答えて

36

Mavenビルド設定のpom.xmlに次のコードを追加してください。私は自分と同じ問題を抱えていたし、これは私のためにトリックを行うように見えた:

<build> 
    <pluginManagement> 
     <plugins> 
      <plugin> 
       <artifactId>maven-compiler-plugin</artifactId> 
       <version>2.3.2</version> 
       <configuration> 
        <source>1.6</source> 
        <target>1.6</target> 
        <compilerArgument></compilerArgument> 
       </configuration> 
      </plugin> 
     </plugins> 
    </pluginManagement> 
</build> 
+1

それは私のためにも機能しますが、問題がなぜ解決されるのか教えてください。ありがとう。 –

+0

@ Shubham.Shukla - それはずっと前に完全に忘れてしまった。アノテーションには1.5以上が必要だからだと思います。 – blackpanther

+0

私はそれを責めません! :)ありがとう。 –

7

はトラヴィスは、ソースレベルと1.3をJDKへ設定された目標のJVMを使用しているいくつかの奇妙な理由のためのように見えます。私は、このエラーが私を驚かせてくれたため、それを修正するには時間がかかりました。なぜなら、外部ツールに応じてプロジェクトの設定や動作を変更したくないからです。

language: java 
jdk: 
    - oraclejdk7 
    - openjdk7 
install: mvn install -Dmaven.compiler.target=1.5 -Dmaven.compiler.source=1.5 -DskipTests=true -B 
script: mvn test -Dmaven.compiler.target=1.5 -Dmaven.compiler.source=1.5 -B 

この:

あなたは(あなたの継続的インテグレーションツールから依存すべきではない)あなたのpom.xmlを修正することを避けるために、あなたはapproriateソースレベルとターゲットJVMを使用してコンパイルするトラヴィスを設定することができますしたい場合は

1.5のソースレベルを使用してコンパイルし、1.5のVMMをターゲットとするバイトコードを生成します。 1.7をターゲットにする場合は、1.5の代わりに1.7を指定できます。

関連する問題