Build: Fix manifest for kotlin-compiler in jps build

Trigger manifest generation from jar task during jps import
This commit is contained in:
Vyacheslav Gerasimov
2019-06-25 18:09:41 +03:00
parent fc68bb46dc
commit 22bbbeb1ec
4 changed files with 33 additions and 30 deletions
+1 -1
View File
@@ -17,5 +17,5 @@ sourceSets {
}
runtimeJar {
manifest.attributes.put("Class-Path", "$compilerManifestClassPath kotlin-preloader.jar")
manifest.attributes["Class-Path"] = "$compilerManifestClassPath kotlin-preloader.jar"
}
+2 -2
View File
@@ -16,6 +16,6 @@ sourceSets {
}
runtimeJar {
manifest.attributes.put("Main-Class", "org.jetbrains.kotlin.runner.Main")
manifest.attributes.put("Class-Path", "kotlin-stdlib.jar")
manifest.attributes["Main-Class"] = "org.jetbrains.kotlin.runner.Main"
manifest.attributes["Class-Path"] = "kotlin-stdlib.jar"
}
+7 -2
View File
@@ -1,6 +1,7 @@
@file:Suppress("UnstableApiUsage")
import org.jetbrains.gradle.ext.*
import org.gradle.jvm.tasks.Jar
import org.jetbrains.kotlin.ideaExt.*
@@ -341,8 +342,12 @@ fun NamedDomainObjectContainer<TopLevelArtifact>.jarFromProject(project: Project
val jarName = name ?: project.name + ".jar"
create(jarName) {
archive(jarName) {
directory("META-INF") {
file("${project.buildDir}/tmp/jar/MANIFEST.MF")
(project.tasks["jar"] as? Jar)?.let { jar ->
val manifestPath = jar.temporaryDir.resolve("MANIFEST.MF")
jar.manifest.writeTo(manifestPath)
directory("META-INF") {
file(manifestPath)
}
}
if (project.sourceSets.names.contains("main")) {
+23 -25
View File
@@ -32,7 +32,6 @@ if (kotlinBuildProperties.isInJpsBuildIdeaSync) {
}
}
val runtimeJar by configurations.creating
val compile by configurations // maven plugin writes pom compile scope from compile configuration by default
val proguardLibraries by configurations.creating {
extendsFrom(compile)
@@ -220,15 +219,12 @@ dependencies {
publish()
noDefaultJar()
val packCompiler by task<ShadowJar> {
configurations = emptyList()
duplicatesStrategy = DuplicatesStrategy.EXCLUDE
destinationDirectory.set(File(buildDir, "libs"))
archiveClassifier.set("before-proguard")
setupPublicJar(compilerBaseName, "before-proguard")
from(fatJarContents)
dependsOn(fatJarContentsStripServices)
@@ -244,9 +240,6 @@ val packCompiler by task<ShadowJar> {
zipTree(it).matching { exclude("META-INF/jb/**", "META-INF/LICENSE") }
}
}
manifest.attributes["Class-Path"] = compilerManifestClassPath
manifest.attributes["Main-Class"] = "org.jetbrains.kotlin.cli.jvm.K2JVMCompiler"
}
val proguard by task<ProGuardTask> {
@@ -270,9 +263,29 @@ val proguard by task<ProGuardTask> {
}
val pack = if (shrink) proguard else packCompiler
val distDir: String by rootProject.extra
val jar = runtimeJar {
dependsOn(pack)
from {
zipTree(pack.outputs.files.singleFile)
}
manifest.attributes["Class-Path"] = compilerManifestClassPath
manifest.attributes["Main-Class"] = "org.jetbrains.kotlin.cli.jvm.K2JVMCompiler"
}
sourcesJar {
from {
compilerModules.map {
project(it).mainSourceSet.allSource
}
}
}
javadocJar()
val distKotlinc = distTask<Sync>("distKotlinc") {
destinationDir = File("$distDir/kotlinc")
@@ -287,7 +300,7 @@ val distKotlinc = distTask<Sync>("distKotlinc") {
}
into("lib") {
from(pack) { rename { "$compilerBaseName.jar" } }
from(jar) { rename { "$compilerBaseName.jar" } }
from(libraries)
from(sources)
from(compilerPlugins) {
@@ -323,21 +336,6 @@ distTask<Copy>("dist") {
from(distStdlibMinimalForTests)
}
runtimeJarArtifactBy(pack, pack.outputs.files.singleFile) {
name = compilerBaseName
classifier = ""
}
sourcesJar {
from {
compilerModules.map {
project(it).mainSourceSet.allSource
}
}
}
javadocJar()
inline fun <reified T : AbstractCopyTask> Project.distTask(
name: String,
crossinline block: T.() -> Unit