use jdk annotations from maven repository
This commit is contained in:
@@ -10,4 +10,9 @@
|
||||
<item name='org.gradle.api.Project org.gradle.api.plugins.Convention getConvention()'>
|
||||
<annotation name='org.jetbrains.annotations.NotNull'/>
|
||||
</item>
|
||||
<item name='org.gradle.api.Project org.gradle.api.initialization.dsl.ScriptHandler getBuildscript()'>
|
||||
<annotation name='jet.runtime.typeinfo.KotlinSignature'>
|
||||
<val name="value" val=""fun getBuildscript() : ScriptHandler""/>
|
||||
</annotation>
|
||||
</item>
|
||||
</root>
|
||||
+7
@@ -0,0 +1,7 @@
|
||||
<root>
|
||||
<item name='org.gradle.api.initialization.dsl.ScriptHandler org.gradle.api.artifacts.ConfigurationContainer getConfigurations()'>
|
||||
<annotation name='jet.runtime.typeinfo.KotlinSignature'>
|
||||
<val name="value" val=""fun getConfigurations() : ConfigurationContainer""/>
|
||||
</annotation>
|
||||
</item>
|
||||
</root>
|
||||
+5
@@ -7,4 +7,9 @@
|
||||
<item name='org.gradle.api.internal.AbstractTask org.gradle.api.logging.Logger getLogger()'>
|
||||
<annotation name='org.jetbrains.annotations.NotNull'/>
|
||||
</item>
|
||||
<item name='org.gradle.api.internal.AbstractTask org.gradle.api.Project getProject()'>
|
||||
<annotation name='jet.runtime.typeinfo.KotlinSignature'>
|
||||
<val name="value" val=""fun getProject() : Project""/>
|
||||
</annotation>
|
||||
</item>
|
||||
</root>
|
||||
@@ -52,6 +52,11 @@
|
||||
<artifactId>kotlin-compiler</artifactId>
|
||||
<version>${project.version}</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.jetbrains.kotlin</groupId>
|
||||
<artifactId>kotlin-jdk-annotations</artifactId>
|
||||
<version>${project.version}</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.jetbrains.kotlin</groupId>
|
||||
<artifactId>kdoc</artifactId>
|
||||
|
||||
+15
-17
@@ -31,12 +31,13 @@ import org.gradle.api.logging.Logging
|
||||
import org.apache.commons.io.FileUtils
|
||||
import java.io.IOException
|
||||
import org.apache.commons.lang.StringUtils
|
||||
import org.gradle.api.initialization.dsl.ScriptHandler
|
||||
|
||||
public open class KotlinCompile(): AbstractCompile() {
|
||||
|
||||
val srcDirsRoots = HashSet<File>()
|
||||
val compiler = K2JVMCompiler()
|
||||
val logger = getLogger()
|
||||
val logger = Logging.getLogger(getClass())
|
||||
|
||||
public val kotlinOptions: K2JVMCompilerArguments = K2JVMCompilerArguments()
|
||||
|
||||
@@ -112,17 +113,9 @@ public open class KotlinCompile(): AbstractCompile() {
|
||||
args.outputDir =if (StringUtils.isEmpty(kotlinOptions.outputDir)) { getDestinationDir()?.getPath() } else { kotlinOptions.outputDir }
|
||||
args.annotations = if (StringUtils.isEmpty(kotlinOptions.annotations)) { embeddedAnnotations.getPath() } else { kotlinOptions.annotations }
|
||||
|
||||
val logger = Logging.getLogger(getClass())
|
||||
val messageCollector = GradleMessageCollector(logger)
|
||||
val exitCode = compiler.exec(messageCollector, args)
|
||||
|
||||
val annotationsDir = embeddedAnnotations.getParentFile()
|
||||
try {
|
||||
FileUtils.deleteDirectory(annotationsDir);
|
||||
} catch (e : IOException) {
|
||||
logger.warn("Could not delete temporary annotations directory " + annotationsDir, e)
|
||||
}
|
||||
|
||||
when (exitCode) {
|
||||
ExitCode.COMPILATION_ERROR -> throw GradleException("Compilation error. See log for more details")
|
||||
ExitCode.INTERNAL_ERROR -> throw GradleException("Internal compiler error. See log for more details")
|
||||
@@ -131,20 +124,26 @@ public open class KotlinCompile(): AbstractCompile() {
|
||||
}
|
||||
|
||||
fun getAnnotations(): File {
|
||||
val jdkAnnotations: String = "kotlin-jdk-annotations.jar"
|
||||
val jdkAnnotationsResource = Resources.getResource(jdkAnnotations) ?:
|
||||
throw GradleException(jdkAnnotations + " not found in Kotlin gradle plugin classpath")
|
||||
val configuration = getProject()
|
||||
.getBuildscript()
|
||||
.getConfigurations()
|
||||
.getByName(ScriptHandler.CLASSPATH_CONFIGURATION)!!
|
||||
|
||||
val jdkAnnotationsTempDir = Files.createTempDir()
|
||||
val jdkAnnotationsFile = File(jdkAnnotationsTempDir, jdkAnnotations)
|
||||
val jdkAnnotationsFromClasspath = configuration.find { it.name.startsWith("kotlin-jdk-annotations") }
|
||||
|
||||
Files.copy(Resources.newInputStreamSupplier(jdkAnnotationsResource), jdkAnnotationsFile)
|
||||
return jdkAnnotationsFile
|
||||
if (jdkAnnotationsFromClasspath != null) {
|
||||
logger.info("using jdk annontations from [${jdkAnnotationsFromClasspath.getAbsolutePath()}]")
|
||||
return jdkAnnotationsFromClasspath
|
||||
} else {
|
||||
throw GradleException("kotlin-jdk-annotations not found in Kotlin gradle plugin classpath")
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public open class KDoc(): SourceTask() {
|
||||
|
||||
val logger = Logging.getLogger(getClass())
|
||||
|
||||
/**
|
||||
* Returns the directory to use to output the API docs
|
||||
*/
|
||||
@@ -216,7 +215,6 @@ public open class KDoc(): SourceTask() {
|
||||
|
||||
val compiler = KDocCompiler()
|
||||
|
||||
val logger = Logging.getLogger(getClass())
|
||||
val messageCollector = GradleMessageCollector(logger)
|
||||
val exitCode = compiler.exec(messageCollector, args);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user