2016-11-10 1 views
1

Ich habe ein Projekt, das mit JDK 1.7 und Sonarqube 6.0 gebaut und kompiliert wird, die nur mit JDK 1.8 läuft. Auf Jenkins Armaturenbrett, ich setze Ziel: : org.codehaus.mojo: Sonar-Maven-Plugin: LATEST: Sonar und auf wrapper.conf auf Sonarqube Ordner, ich änderte wrapper.java.command = C: \ Programme \ Java \ jdk1.8.0_91 \ bin \ java, Jenkins JDK ist 1,7 eingestellt .... aber Sonar funktioniert nicht mit JDK 1.8. Bitte helfen Sie mir beraten.Jenkins vs SonarQube: Run mit bestimmten JDK

Antwort

1

Ich hatte ein ähnliches Problem.

Die Lösung bestand darin, JDK8 für die Job-Konfiguration in Jenkins zu verwenden und JDK7 für die Kompilierung der Quellen, der Testquellen und des todsicheren Plugins zu verwenden.

Etwas wie folgt aus:

 <plugin> 
      <groupId>org.apache.maven.plugins</groupId> 
      <artifactId>maven-compiler-plugin</artifactId> 
      <version>2.5.1</version> 
      <configuration> 
       <source>1.5</source> 
       <target>1.5</target> 
       <testSource>1.7</testSource> 
       <testTarget>1.7</testTarget> 
       <verbose>true</verbose> 
       <fork>true</fork> 
       <executable>C:\java\jdk1.7.0_25\bin\javac</executable> 
       <compilerVersion>1.7</compilerVersion> 
      </configuration> 
      <executions> 
       <execution> 
        <id>test-compile</id> 
        <phase>process-test-sources</phase> 
        <goals> 
         <goal>testCompile</goal> 
        </goals> 
        <configuration> 
         <fork>true</fork> 
         <executable>C:\java\jdk1.7.0_25\bin\javac</executable> 
         <source>1.5</source> 
         <target>1.5</target> 
         <compilerVersion>1.7</compilerVersion> 
        </configuration> 
       </execution> 
      </executions> 
     </plugin> 

     <plugin> 
      <groupId>org.apache.maven.plugins</groupId> 
      <artifactId>maven-surefire-plugin</artifactId> 
      <configuration> 
       <jvm>C:\java\jdk1.7.0_25\bin\java</jvm> 
       <forkMode>once</forkMode> 
      </configuration> 
     </plugin> 

Wenn es für Sie arbeitet, können Sie den Pfad zum JDK in settings.xml einstellen und diese Einstellung verwenden, in Sie pom.xml so jede Umgebung/Entwickler können ihre Verwendung eigenes JDK.

<profile> 
    <id>jdk7</id> 
    <properties> 
    <JDK_1_7_HOME>C:\java\jdk1.7.0_25</JDK_1_7_HOME> 
    </properties> 
    <activation> 
    <activeByDefault>true</activeByDefault> 
    </activation> 
</profile> 

Und Ihre pom.xml

... 
    <executable>${JDK_1_7_HOME}/bin/javac</executable> 
...