Suppress warning for mvn+kapt+jdk9
Suppress the warning about lack of tools.jar, as this jar does not present in JDK9+ #KT-47110 Fixed
This commit is contained in:
committed by
teamcity
parent
f2bc25c71d
commit
de5fd767d4
+18
-6
@@ -40,7 +40,9 @@ import java.util.stream.Collectors;
|
|||||||
import static org.jetbrains.kotlin.maven.Util.joinArrays;
|
import static org.jetbrains.kotlin.maven.Util.joinArrays;
|
||||||
import static org.jetbrains.kotlin.maven.kapt.AnnotationProcessingManager.*;
|
import static org.jetbrains.kotlin.maven.kapt.AnnotationProcessingManager.*;
|
||||||
|
|
||||||
/** @noinspection UnusedDeclaration */
|
/**
|
||||||
|
* @noinspection UnusedDeclaration
|
||||||
|
*/
|
||||||
@Mojo(name = "kapt", defaultPhase = LifecyclePhase.PROCESS_SOURCES, requiresDependencyResolution = ResolutionScope.COMPILE)
|
@Mojo(name = "kapt", defaultPhase = LifecyclePhase.PROCESS_SOURCES, requiresDependencyResolution = ResolutionScope.COMPILE)
|
||||||
public class KaptJVMCompilerMojo extends K2JVMCompileMojo {
|
public class KaptJVMCompilerMojo extends K2JVMCompileMojo {
|
||||||
@Parameter
|
@Parameter
|
||||||
@@ -72,7 +74,7 @@ public class KaptJVMCompilerMojo extends K2JVMCompileMojo {
|
|||||||
@Component
|
@Component
|
||||||
private ArtifactHandlerManager artifactHandlerManager;
|
private ArtifactHandlerManager artifactHandlerManager;
|
||||||
|
|
||||||
@Parameter( defaultValue = "${session}", readonly = true, required = true )
|
@Parameter(defaultValue = "${session}", readonly = true, required = true)
|
||||||
private MavenSession session;
|
private MavenSession session;
|
||||||
|
|
||||||
@Component
|
@Component
|
||||||
@@ -194,8 +196,7 @@ public class KaptJVMCompilerMojo extends K2JVMCompileMojo {
|
|||||||
|
|
||||||
try {
|
try {
|
||||||
resolvedArtifacts = getAnnotationProcessingManager().resolveAnnotationProcessors(annotationProcessorPaths);
|
resolvedArtifacts = getAnnotationProcessingManager().resolveAnnotationProcessors(annotationProcessorPaths);
|
||||||
}
|
} catch (Exception e) {
|
||||||
catch (Exception e) {
|
|
||||||
throw new MojoExecutionException("Error while processing kapt options", e);
|
throw new MojoExecutionException("Error while processing kapt options", e);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -220,6 +221,18 @@ public class KaptJVMCompilerMojo extends K2JVMCompileMojo {
|
|||||||
getLog().warn("Can't determine Java home, 'java.home' property does not exist");
|
getLog().warn("Can't determine Java home, 'java.home' property does not exist");
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
String jdkStringVersion = System.getProperty("java.specification.version");
|
||||||
|
if (jdkStringVersion == null) return null;
|
||||||
|
int jdkVersion;
|
||||||
|
try {
|
||||||
|
jdkVersion = Integer.parseInt(jdkStringVersion);
|
||||||
|
} catch (NumberFormatException e) {
|
||||||
|
// we got 1.8 or 1.6
|
||||||
|
jdkVersion = 0;
|
||||||
|
}
|
||||||
|
if (jdkVersion >= 9) return null;
|
||||||
|
|
||||||
File javaHome = new File(javaHomePath);
|
File javaHome = new File(javaHomePath);
|
||||||
File toolsJar = new File(javaHome, "lib/tools.jar");
|
File toolsJar = new File(javaHome, "lib/tools.jar");
|
||||||
if (toolsJar.exists()) {
|
if (toolsJar.exists()) {
|
||||||
@@ -302,8 +315,7 @@ public class KaptJVMCompilerMojo extends K2JVMCompileMojo {
|
|||||||
int equalsIndex = option.indexOf("=");
|
int equalsIndex = option.indexOf("=");
|
||||||
if (equalsIndex < 0) {
|
if (equalsIndex < 0) {
|
||||||
map.put(option, "");
|
map.put(option, "");
|
||||||
}
|
} else {
|
||||||
else {
|
|
||||||
map.put(option.substring(0, equalsIndex).trim(), option.substring(equalsIndex + 1).trim());
|
map.put(option.substring(0, equalsIndex).trim(), option.substring(equalsIndex + 1).trim());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user