Maven - Use JDK 7 to Compile for JVM 5

后端 未结 5 1031
迷失自我
迷失自我 2021-01-02 02:19

I\'ve been trying to get this to work for a while now but no luck yet.

I want to run with JAVA_HOME pointing to JDK7 but I want to compile a project for

5条回答
  •  无人及你
    2021-01-02 02:57

    This answer is targeted at the title of the question, not to the specific problems of the question in detail.

    I ended up using this solution in my project, which allows me to use the custom bootstrap classpath selectively, by activating a maven profile. I strongly recommend using a profile for this, because otherwise it makes the build fail for anyone that does not have the environment variable set (very bad, especially for an open source project). I only activate this profile in my IDE for the "Clean & Build" action.

        
            compileWithJava5
            
            
                ${env.JAVA5_HOME}
                ${java.5.home}/jre/lib
                ${java.5.libs}/rt.jar${path.separator}${java.5.libs}/jce.jar
            
            
                
                    
                        org.apache.maven.plugins
                        maven-compiler-plugin
                        
                            1.5
                            1.5
                            
                                ${java.5.bootclasspath}
                            
                        
                    
                
            
        
    

提交回复
热议问题