2013-04-23 35 views
1

我已經對javac進行了一些代碼更改,並希望maven使用我更改的javac版本。不幸的是,maven似乎發佈了自己的javac實現。如何讓maven使用全系統javac(在shell中運行javac時執行的那個)編譯源代碼。強制Maven使用System的javac

沒有真正知道這些選項的意思是,我試圖提供forkforceJavacCompilerUse我發現在這裏:http://maven.apache.org/plugins/maven-compiler-plugin/compile-mojo.html 但他們似乎並沒有幫助的。

回答

1

你在正確的場地。看看這裏:

http://maven.apache.org/plugins/maven-compiler-plugin/examples/compile-using-different-jdk.html

爲了避免硬編碼的可執行文件系統路徑,你可以使用 的屬性。例如:

<executable>${JAVA_1_4_HOME}/bin/javac</executable>

每個顯影劑然後定義Settings.XML中此屬性,或設置 環境變量,從而構建保持便攜。

<settings> 
    [...] 
    <profiles> 
    [...] 
    <profile> 
     <id>compiler</id> 
     <properties> 
      <JAVA_1_4_HOME>C:\Program Files\Java\j2sdk1.4.2_09</JAVA_1_4_HOME> 
     </properties> 
    </profile> 
    </profiles> 
    [...] 
    <activeProfiles> 
    <activeProfile>compiler</activeProfile> 
    </activeProfiles> 
</settings> 

如果你建立不同的JDK,您可能需要自定義的jar 文件清單。

我相信關鍵是設置一個明確的<executable>。我懷疑它可能是硬編碼的,不會搞亂環境變量或其他子句。

也請參閱此鏈接,以及樣品在pom.xml看「可執行文件」:

Where is the JDK version to be used by Maven compiler specified?

0

我相信行家查找JVA_HOME尋找了Java。所以當你把它設置爲你的特定的java maven應該可以使用它