Clean unused dependencies, minor refactorings

This commit is contained in:
Ilya Chernikov
2017-08-22 16:23:42 +02:00
parent 27968c8e13
commit 3e46c59187
29 changed files with 90 additions and 397 deletions
Generated
+1 -1
View File
@@ -1 +1 @@
kotlin
kotlin gradle
+2 -15
View File
@@ -2,7 +2,6 @@ import org.gradle.api.Project
import java.util.*
import java.io.File
import org.gradle.api.tasks.bundling.Jar
import org.gradle.kotlin.dsl.java
import org.jetbrains.kotlin.gradle.tasks.KotlinCompile
import org.jetbrains.kotlin.gradle.tasks.Kotlin2JsCompile
@@ -31,8 +30,6 @@ buildscript {
}
plugins {
// java // so we can benefit from the `java()` accessor below
// kotlin("jvm")
`build-scan`
}
@@ -85,11 +82,6 @@ extra["JDK_16"] = jdkPath("1.6")
extra["JDK_17"] = jdkPath("1.7")
extra["JDK_18"] = jdkPath("1.8")
extra["compilerBaseName"] = "kotlin-compiler"
extra["embeddableCompilerBaseName"] = "kotlin-compiler-embeddable"
extra["buildLocalRepoPath"] = File(commonBuildDir, "repo")
extra["versions.protobuf-java"] = "2.6.1"
extra["versions.javax.inject"] = "1"
extra["versions.jsr305"] = "1.3.9"
@@ -158,10 +150,6 @@ tasks.matching { task ->
// dependsOn(tasks.getByName(importedAntTasksPrefix + "update"))
//}
//val prepareBootstrapTask = task("prepareBootstrap") {
// dependsOn(bootstrapCfg, scriptCompileCfg, scriptRuntimeCfg)
//}
fun Project.allprojectsRecursive(body: Project.() -> Unit) {
this.body()
this.subprojects { allprojectsRecursive(body) }
@@ -187,12 +175,11 @@ allprojects {
configureJvmProject(javaHome!!, jvmTarget!!)
tasks.withType<KotlinCompile> {
kotlinOptions.freeCompilerArgs = listOf("-Xallow-kotlin-package", "-module-name", project.name)
// kotlinOptions.jvmTarget = "1.8"
kotlinOptions.freeCompilerArgs = listOf("-Xallow-kotlin-package")
}
tasks.withType<Kotlin2JsCompile> {
kotlinOptions.freeCompilerArgs = listOf("-Xallow-kotlin-package", "-module-name", project.name)
kotlinOptions.freeCompilerArgs = listOf("-Xallow-kotlin-package")
}
tasks.withType<Javadoc> {
-2
View File
@@ -37,8 +37,6 @@ dependencies {
testRuntime(ideaSdkCoreDeps("*.jar"))
testRuntime(ideaSdkDeps("*.jar"))
// testRuntime(project(":kotlin-compiler", configuration = "default"))
buildVersion()
}
sourceSets {
-2
View File
@@ -6,9 +6,7 @@ apply { plugin("kotlin") }
jvmTarget = "1.6"
dependencies {
val compile by configurations
compile(project(":kotlin-stdlib"))
buildVersion()
}
sourceSets {
-2
View File
@@ -6,9 +6,7 @@ apply { plugin("kotlin") }
jvmTarget = "1.6"
dependencies {
val compile by configurations
compile(ideaSdkDeps("asm-all"))
buildVersion()
}
sourceSets {
-1
View File
@@ -7,7 +7,6 @@ apply { plugin("kotlin") }
jvmTarget = "1.6"
dependencies {
val compile by configurations
compile(project(":core:builtins"))
compile(project("util.runtime"))
compile(protobufLite())
-1
View File
@@ -17,7 +17,6 @@ val builtinsSerialized = File(rootProject.extra["distDir"].toString(), "builtins
val builtins by configurations.creating
dependencies {
val compile by configurations
compile(protobufLite())
compile(files(builtinsSerialized))
}
-1
View File
@@ -22,7 +22,6 @@ apply {
jvmTarget = "1.6"
dependencies {
val compile by configurations
compile(project(":core:builtins"))
compile(project(":core"))
compile(protobufLite())
-24
View File
@@ -1,24 +0,0 @@
import org.gradle.jvm.tasks.Jar
apply { plugin("kotlin") }
jvmTarget = "1.6"
dependencies {
val compile by configurations
compile(project(":core:builtins"))
compile(project(":kotlin-stdlib"))
buildVersion()
}
sourceSets {
"main" { projectDefault() }
"test" {}
}
tasks.withType<Jar> {
setupRuntimeJar("Kotlin Script Runtime")
archiveName = "kotlin-script-runtime.jar"
}
+1 -1
View File
@@ -1,3 +1,4 @@
apply { plugin("kotlin") }
dependencies {
@@ -8,7 +9,6 @@ dependencies {
// compile(files(PathUtil.getJdkClassesRootsFromCurrentJre())) // TODO: make this one work instead of the nex one, since it contains more universal logic
compile(files("${System.getProperty("java.home")}/../lib/tools.jar"))
testCompile(project(":kotlin-test:kotlin-test-junit"))
buildVersion()
}
sourceSets {
+36 -73
View File
@@ -50,6 +50,23 @@
"reporting": "org.gradle.api.reporting.ReportingExtension"
}
},
":android-lint": {
"conventions": {
"base": "org.gradle.api.plugins.BasePluginConvention",
"java": "org.gradle.api.plugins.JavaPluginConvention"
},
"configurations": [
"archives",
"buildVersion",
"default",
"runtimeJar"
],
"extensions": {
"ext": "org.gradle.api.plugins.ExtraPropertiesExtension",
"defaultArtifacts": "org.gradle.api.internal.plugins.DefaultArtifactPublicationSet",
"reporting": "org.gradle.api.reporting.ReportingExtension"
}
},
":compiler": {
"conventions": {
"base": "org.gradle.api.plugins.BasePluginConvention",
@@ -58,7 +75,6 @@
"configurations": [
"apiElements",
"archives",
"build-version",
"compile",
"compileClasspath",
"compileOnly",
@@ -176,7 +192,6 @@
"configurations": [
"apiElements",
"archives",
"build-version",
"compile",
"compileClasspath",
"compileOnly",
@@ -932,7 +947,6 @@
"configurations": [
"apiElements",
"archives",
"build-version",
"buildVersion",
"compile",
"compileClasspath",
@@ -1013,7 +1027,6 @@
"configurations": [
"apiElements",
"archives",
"build-version",
"buildVersion",
"compile",
"compileClasspath",
@@ -2339,42 +2352,6 @@
"shadow": "com.github.jengelman.gradle.plugins.shadow.ShadowExtension"
}
},
":core:script.runtime": {
"conventions": {
"base": "org.gradle.api.plugins.BasePluginConvention",
"java": "org.gradle.api.plugins.JavaPluginConvention"
},
"configurations": [
"apiElements",
"archives",
"build-version",
"compile",
"compileClasspath",
"compileOnly",
"default",
"implementation",
"kapt",
"kaptTest",
"runtime",
"runtimeClasspath",
"runtimeElements",
"runtimeOnly",
"testCompile",
"testCompileClasspath",
"testCompileOnly",
"testImplementation",
"testRuntime",
"testRuntimeClasspath",
"testRuntimeOnly"
],
"extensions": {
"ext": "org.gradle.api.plugins.ExtraPropertiesExtension",
"kotlin": "org.jetbrains.kotlin.gradle.dsl.KotlinProjectExtension",
"kapt": "org.jetbrains.kotlin.gradle.plugin.KaptExtension",
"defaultArtifacts": "org.gradle.api.internal.plugins.DefaultArtifactPublicationSet",
"reporting": "org.gradle.api.reporting.ReportingExtension"
}
},
":core:util.runtime": {
"conventions": {
"base": "org.gradle.api.plugins.BasePluginConvention",
@@ -2783,7 +2760,7 @@
"configurations": [
"apiElements",
"archives",
"build-version",
"buildVersion",
"compile",
"compileClasspath",
"compileOnly",
@@ -2794,6 +2771,7 @@
"runtime",
"runtimeClasspath",
"runtimeElements",
"runtimeJar",
"runtimeOnly",
"testCompile",
"testCompileClasspath",
@@ -3248,6 +3226,7 @@
"configurations": [
"apiElements",
"archives",
"buildVersion",
"compile",
"compileClasspath",
"compileOnly",
@@ -3258,6 +3237,7 @@
"runtime",
"runtimeClasspath",
"runtimeElements",
"runtimeJar",
"runtimeOnly",
"testCompile",
"testCompileClasspath",
@@ -3283,6 +3263,7 @@
"configurations": [
"apiElements",
"archives",
"buildVersion",
"compile",
"compileClasspath",
"compileOnly",
@@ -3293,6 +3274,7 @@
"runtime",
"runtimeClasspath",
"runtimeElements",
"runtimeJar",
"runtimeOnly",
"testCompile",
"testCompileClasspath",
@@ -3460,6 +3442,7 @@
"configurations": [
"apiElements",
"archives",
"buildVersion",
"compile",
"compileClasspath",
"compileOnly",
@@ -3470,6 +3453,7 @@
"runtime",
"runtimeClasspath",
"runtimeElements",
"runtimeJar",
"runtimeOnly",
"testCompile",
"testCompileClasspath",
@@ -3531,6 +3515,7 @@
"configurations": [
"apiElements",
"archives",
"buildVersion",
"compile",
"compileClasspath",
"compileOnly",
@@ -3541,6 +3526,7 @@
"runtime",
"runtimeClasspath",
"runtimeElements",
"runtimeJar",
"runtimeOnly",
"testCompile",
"testCompileClasspath",
@@ -3602,7 +3588,6 @@
"configurations": [
"apiElements",
"archives",
"build-version",
"compile",
"compileClasspath",
"compileOnly",
@@ -3630,37 +3615,6 @@
"reporting": "org.gradle.api.reporting.ReportingExtension"
}
},
":prepare:android-lint": {
"conventions": {
"base": "org.gradle.api.plugins.BasePluginConvention",
"java": "org.gradle.api.plugins.JavaPluginConvention"
},
"configurations": [
"apiElements",
"archives",
"compile",
"compileClasspath",
"compileOnly",
"default",
"implementation",
"runtime",
"runtimeClasspath",
"runtimeElements",
"runtimeOnly",
"testCompile",
"testCompileClasspath",
"testCompileOnly",
"testImplementation",
"testRuntime",
"testRuntimeClasspath",
"testRuntimeOnly"
],
"extensions": {
"ext": "org.gradle.api.plugins.ExtraPropertiesExtension",
"defaultArtifacts": "org.gradle.api.internal.plugins.DefaultArtifactPublicationSet",
"reporting": "org.gradle.api.reporting.ReportingExtension"
}
},
":prepare:build.version": {
"conventions": {
@@ -3680,6 +3634,7 @@
"configurations": [
"apiElements",
"archives",
"buildVersion",
"compile",
"compileClasspath",
"compileOnly",
@@ -3688,6 +3643,7 @@
"runtime",
"runtimeClasspath",
"runtimeElements",
"runtimeJar",
"runtimeOnly",
"testCompile",
"testCompileClasspath",
@@ -3711,6 +3667,7 @@
"configurations": [
"apiElements",
"archives",
"buildVersion",
"compile",
"compileClasspath",
"compileOnly",
@@ -3719,6 +3676,7 @@
"runtime",
"runtimeClasspath",
"runtimeElements",
"runtimeJar",
"runtimeOnly",
"testCompile",
"testCompileClasspath",
@@ -3739,7 +3697,10 @@
},
"configurations": [
"archives",
"buildVersion",
"packedJars",
"runtimeJar",
"sideJars"
],
"extensions": {
@@ -3754,6 +3715,7 @@
"configurations": [
"apiElements",
"archives",
"buildVersion",
"compile",
"compileClasspath",
"compileOnly",
@@ -3764,6 +3726,7 @@
"runtime",
"runtimeClasspath",
"runtimeElements",
"runtimeJar",
"runtimeOnly",
"testCompile",
"testCompileClasspath",
+3 -7
View File
@@ -1,10 +1,9 @@
import org.gradle.jvm.tasks.Jar
description = "Kotlin Gradle Tooling support"
apply { plugin("kotlin") }
dependencies {
val compile by configurations
compile(project(":kotlin-stdlib"))
compile(project(":compiler:cli-common"))
compile(ideaSdkDeps("gradle-tooling-api",
@@ -13,7 +12,6 @@ dependencies {
"gradle-core",
"gradle-base-services-groovy",
subdir = "plugins/gradle/lib"))
buildVersion()
}
sourceSets {
@@ -21,8 +19,6 @@ sourceSets {
"test" {}
}
val jar: Jar by tasks
runtimeJar()
ideaPlugin {
from(jar)
}
ideaPlugin()
@@ -4,8 +4,6 @@ description = "Kotlin AllOpen Compiler Plugin"
apply { plugin("kotlin") }
dependencies {
val compileOnly by configurations
val runtime by configurations
compileOnly(ideaSdkCoreDeps("intellij-core"))
compileOnly(project(":compiler:plugin-api"))
compileOnly(project(":compiler:frontend"))
+4 -7
View File
@@ -1,9 +1,9 @@
import org.gradle.jvm.tasks.Jar
description = "Kotlin AllOpen IDEA Plugin"
apply { plugin("kotlin") }
dependencies {
val compile by configurations
compile(project(":kotlin-allopen-compiler-plugin"))
compile(project(":compiler:util"))
compile(project(":compiler:frontend"))
@@ -22,10 +22,7 @@ sourceSets {
"test" {}
}
runtimeJar()
val jar: Jar by tasks
ideaPlugin {
from(jar)
}
ideaPlugin()
@@ -1,15 +1,9 @@
import org.gradle.jvm.tasks.Jar
description = "Kotlin Android Extensions IDEA"
apply { plugin("kotlin") }
dependencies {
val compile by configurations
val compileOnly by configurations
val testCompile by configurations
val testCompileOnly by configurations
val testRuntime by configurations
compile(project(":compiler:util"))
compile(project(":compiler:light-classes"))
compile(project(":idea:idea-core"))
@@ -54,8 +48,6 @@ projectTest {
workingDir = rootDir
}
val jar: Jar by tasks
runtimeJar()
ideaPlugin {
from(jar)
}
ideaPlugin()
+3 -7
View File
@@ -1,10 +1,9 @@
import org.gradle.jvm.tasks.Jar
description = "Kotlin NoArg IDEA Plugin"
apply { plugin("kotlin") }
dependencies {
val compile by configurations
compile(project(":kotlin-noarg-compiler-plugin"))
compile(project(":compiler:util"))
compile(project(":compiler:frontend"))
@@ -25,9 +24,6 @@ sourceSets {
"test" {}
}
val jar: Jar by tasks
ideaPlugin {
from(jar)
}
runtimeJar()
ideaPlugin()
@@ -4,8 +4,6 @@ description = "Kotlin SamWithReceiver Compiler Plugin"
apply { plugin("kotlin") }
dependencies {
val compileOnly by configurations
val runtime by configurations
compileOnly(project(":compiler:frontend"))
compileOnly(project(":compiler:frontend.java"))
compileOnly(project(":compiler:plugin-api"))
@@ -1,9 +1,9 @@
import org.gradle.jvm.tasks.Jar
description = "Kotlin SamWithReceiver IDEA Plugin"
apply { plugin("kotlin") }
dependencies {
val compile by configurations
compile(project(":kotlin-sam-with-receiver-compiler-plugin"))
compile(project(":plugins:annotation-based-compiler-plugins-ide-support"))
compile(project(":compiler:util"))
@@ -19,10 +19,7 @@ sourceSets {
"test" {}
}
runtimeJar()
val jar: Jar by tasks
ideaPlugin {
from(jar)
}
ideaPlugin()
@@ -8,7 +8,6 @@ dependencies {
compile(project(":compiler:frontend.java"))
compile(project(":idea:ide-common"))
compile(project(":plugins:uast-kotlin"))
buildVersion()
}
sourceSets {
+9 -15
View File
@@ -1,16 +1,19 @@
import org.gradle.jvm.tasks.Jar
description = "Kotlin Android Lint"
apply { plugin("java") }
apply { plugin("java-base") }
val projectsToShadow = listOf(
":plugins:lint",
":plugins:uast-kotlin",
":plugins:uast-kotlin-idea")
tasks.withType<Jar> {
setupRuntimeJar("Kotlin Android Lint")
archiveName = "android-lint.jar"
sourceSets {
"main" {}
"test" {}
}
runtimeJar {
projectsToShadow.forEach {
dependsOn("$it:classes")
project(it).let { p ->
@@ -21,13 +24,4 @@ tasks.withType<Jar> {
}
}
sourceSets {
"main" {}
"test" {}
}
val jar: Jar by tasks
ideaPlugin {
from(jar)
}
ideaPlugin()
@@ -30,7 +30,6 @@ val projectsToInclude = listOf(
":kotlin-daemon-client")
dependencies {
val testCompile by configurations
projectsToInclude.forEach {
jarContents(project(it)) { isTransitive = false }
testCompile(project(it))
+4 -9
View File
@@ -33,11 +33,11 @@ val fatJar by configurations.creating
val compilerJar by configurations.creating
val archives by configurations
val compilerBaseName: String by rootProject.extra
val compilerBaseName = name
val outputJar = File(buildDir, "libs", "$compilerBaseName.jar")
val javaHome = System.getProperty("java.home")
val jreHome = System.getProperty("java.home")
val compilerModules: Array<String> by rootProject.extra
@@ -57,8 +57,8 @@ val ideaCoreSdkJars: Array<String> by rootProject.extra
val coreSdkJarsSimple = ideaCoreSdkJars.filterNot { it == "jdom" || it == "log4j" }.toTypedArray()
fun firstFromJavaHomeThatExists(vararg paths: String): File =
paths.mapNotNull { File(javaHome, it).takeIf { it.exists() } }.firstOrNull()
?: throw GradleException("Cannot find under '$javaHome' neither of: ${paths.joinToString()}")
paths.mapNotNull { File(jreHome, it).takeIf { it.exists() } }.firstOrNull()
?: throw GradleException("Cannot find under '$jreHome' neither of: ${paths.joinToString()}")
compilerModules.forEach { evaluationDependsOn(it) }
@@ -73,7 +73,6 @@ dependencies {
compiledModulesSources.forEach {
fatSourcesJarContents(it)
}
// buildVersion()
fatJarContents(project(":core:builtins", configuration = "builtins"))
fatJarContents(ideaSdkCoreDeps(*coreSdkJarsSimple))
@@ -93,10 +92,6 @@ dependencies {
proguardLibraryJars(project(":kotlin-script-runtime", configuration = "mainJar"))
proguardLibraryJars(project(":kotlin-reflect", configuration = "mainJar"))
proguardLibraryJars(preloadedDeps("kotlinx-coroutines-core"))
// proguardLibraryJars(project(":prepare:runtime", configuration = "default").apply { isTransitive = false })
// proguardLibraryJars(project(":prepare:reflect", configuration = "default").apply { isTransitive = false })
// proguardLibraryJars(project(":core:script.runtime").apply { isTransitive = false })
}
val packCompiler by task<ShadowJar> {
+2 -3
View File
@@ -1,10 +1,9 @@
import org.gradle.jvm.tasks.Jar
description = "Kotlin Formatter"
apply { plugin("java") }
tasks.withType<Jar> {
setupRuntimeJar("Kotlin Formatter")
runtimeJar {
archiveName = "kotlin-formatter.jar"
dependsOn(":idea:formatter:classes")
project(":idea:formatter").let { p ->
+2 -3
View File
@@ -1,10 +1,9 @@
import org.gradle.jvm.tasks.Jar
description = "Kotlin IDE Lazy Resolver"
apply { plugin("java") }
tasks.withType<Jar> {
setupRuntimeJar("Kotlin IDE Lazy Resolver")
runtimeJar {
archiveName = "kotlin-ide-common.jar"
dependsOn(":idea:ide-common:classes")
project(":idea:ide-common").let { p ->
+4 -8
View File
@@ -1,6 +1,8 @@
import com.github.jengelman.gradle.plugins.shadow.tasks.ShadowJar
description = "Kotlin IDEA plugin"
buildscript {
repositories {
jcenter()
@@ -60,11 +62,7 @@ dependencies {
sideJars(preloadedDeps("markdown", "kotlinx-coroutines-core", "kotlinx-coroutines-jdk8"))
}
val targetJar = File(buildDir, "libs", "kotlin-plugin.jar")
val shadowTask = task<ShadowJar>("shadowJar") {
setupRuntimeJar("Kotlin IDEA plugin")
archiveName = targetJar.canonicalPath
val jar = runtimeJar(task<ShadowJar>("shadowJar")) {
projectsToShadow.forEach {
dependsOn("$it:classes")
project(it).let { p ->
@@ -78,9 +76,7 @@ val shadowTask = task<ShadowJar>("shadowJar") {
}
ideaPlugin {
dependsOn(shadowTask)
from(targetJar)
dependsOn(":kotlin-script-runtime:jar")
from(jar)
from(sideJars)
}
+10 -19
View File
@@ -1,21 +1,13 @@
import org.gradle.jvm.tasks.Jar
import org.gradle.api.internal.HasConvention
import org.jetbrains.kotlin.gradle.plugin.KotlinSourceSet
import org.jetbrains.kotlin.gradle.tasks.KotlinCompile
description = "Kotlin Mock Runtime for Tests"
apply { plugin("kotlin") }
dependencies {
val compile by configurations
compile(project(":kotlin-stdlib"))
}
jvmTarget = "1.6"
javaHome = rootProject.extra["JDK_16"] as String
val jar: Jar by tasks
jar.apply {
setupRuntimeJar("Kotlin Mock Runtime for Tests")
from(fileTree("${rootProject.extra["distDir"]}/builtins")) { include("kotlin/**") }
archiveName = "kotlin-mock-runtime-for-test.jar"
dependencies {
compile(project(":kotlin-stdlib"))
}
sourceSets {
@@ -38,17 +30,16 @@ sourceSets {
tasks.withType<JavaCompile> {
sourceCompatibility = "1.6"
targetCompatibility = "1.6"
// options.fork = true
options.forkOptions.javaHome = file(rootProject.extra["JDK_16"] as String)
}
tasks.withType<KotlinCompile> {
kotlinOptions.jvmTarget = "1.6"
kotlinOptions.jdkHome = rootProject.extra["JDK_16"] as String
val jar = runtimeJar {
from(fileTree("${rootProject.extra["distDir"]}/builtins")) { include("kotlin/**") }
archiveName = "kotlin-mock-runtime-for-test.jar"
}
task<Copy>("dist") {
into(rootProject.extra["distDir"].toString())
from(jar)
into(rootProject.extra["distDir"].toString())
rename("-${Regex.escape(rootProject.extra["build.number"].toString())}", "")
}
-131
View File
@@ -1,131 +0,0 @@
import com.github.jengelman.gradle.plugins.shadow.tasks.ShadowJar
import org.gradle.api.Project
import org.jetbrains.org.objectweb.asm.*
import org.gradle.jvm.tasks.Jar
import java.io.BufferedOutputStream
import java.io.File
import java.io.FileOutputStream
import java.util.jar.JarFile
import java.util.zip.ZipOutputStream
buildscript {
repositories {
jcenter()
}
dependencies {
classpath("com.github.jengelman.gradle.plugins:shadow:1.2.3")
classpath(ideaSdkDeps("asm-all"))
}
}
apply { plugin("com.github.johnrengelman.shadow") }
// Set to false to prevent relocation and metadata stripping on kotlin-reflect.jar and reflection sources. Use to debug reflection
val obfuscateReflect = true
val classesFromProjectsCfg = configurations.create("classes-from-projects")
val otherDepsCfg = configurations.create("other-deps")
val mainCfg = configurations.create("default")
val outputReflectJarFileBase = "$buildDir/libs/kotlin-reflect"
val coreProjectName = ":core"
val reflectionProjectName = ":core:reflection.jvm"
artifacts.add(mainCfg.name, File(outputReflectJarFileBase + ".jar"))
dependencies {
classesFromProjectsCfg.name(projectDepIntransitive(coreProjectName))
classesFromProjectsCfg.name(projectDepIntransitive(":core:util.runtime"))
classesFromProjectsCfg.name(projectDepIntransitive(reflectionProjectName))
otherDepsCfg.name(protobufLite())
otherDepsCfg.name(commonDep("javax.inject"))
buildVersion()
}
val prePackReflectTask = task<ShadowJar>("pre-pack-reflect") {
classifier = if (obfuscateReflect) outputReflectJarFileBase + "_beforeStrip" else outputReflectJarFileBase
configurations = listOf(mainCfg)
setupRuntimeJar("Kotlin Reflect")
dependsOn("$coreProjectName:assemble", "$reflectionProjectName:assemble", protobufLiteTask)
from(project(reflectionProjectName).getCompiledClasses())
from(project(coreProjectName).getCompiledClasses())
from(project(":core:util.runtime").getCompiledClasses())
from(project(coreProjectName).file("descriptor.loader.java/src")) {
include("META-INF/services/**")
}
from(otherDepsCfg.files)
manifest.attributes.put("Class-Path", "kotlin-runtime.jar")
if (obfuscateReflect) {
relocate("org.jetbrains.kotlin", "kotlin.reflect.jvm.internal.impl")
relocate("javax.inject", "kotlin.reflect.jvm.internal.impl.javax.inject")
}
}
val mainTask = task("prepare") {
dependsOn(prePackReflectTask)
val inFile = File(outputReflectJarFileBase + "_beforeStrip.jar")
val outFile = File(outputReflectJarFileBase + ".jar")
inputs.file(inFile)
outputs.file(outFile)
val annotationRegex = "kotlin/Metadata".toRegex()
val classRegex = "kotlin/reflect/jvm/internal/impl/.*".toRegex()
doLast {
println("Stripping annotations from all classes in $inFile")
println("Input file size: ${inFile.length()} bytes")
fun transform(entryName: String, bytes: ByteArray): ByteArray {
if (!entryName.endsWith(".class")) return bytes
if (!classRegex.matches(entryName.removeSuffix(".class"))) return bytes
var changed = false
val classWriter = ClassWriter(0)
val classVisitor = object : ClassVisitor(Opcodes.ASM5, classWriter) {
override fun visitAnnotation(desc: String, visible: Boolean): AnnotationVisitor? {
if (annotationRegex.matches(Type.getType(desc).internalName)) {
changed = true
return null
}
return super.visitAnnotation(desc, visible)
}
}
ClassReader(bytes).accept(classVisitor, 0)
if (!changed) return bytes
return classWriter.toByteArray()
}
ZipOutputStream(BufferedOutputStream(FileOutputStream(outFile))).use { outJar ->
val inJar = JarFile(inFile)
try {
for (entry in inJar.entries()) {
if (entry.isDirectory) continue
val inBytes = inJar.getInputStream(entry).readBytes()
val outBytes = transform(entry.name, inBytes)
if (inBytes.size < outBytes.size) {
error("Size increased for ${entry.name}: was ${inBytes.size} bytes, became ${outBytes.size} bytes")
}
entry.compressedSize = -1L
outJar.putNextEntry(entry)
outJar.write(outBytes)
outJar.closeEntry()
}
}
finally {
// Yes, JarFile does not extend Closeable on JDK 6 so we can't use "use" here
inJar.close()
}
}
println("Output written to $outFile")
println("Output file size: ${outFile.length()} bytes")
}
}
defaultTasks(mainTask.name)
-39
View File
@@ -1,39 +0,0 @@
import com.github.jengelman.gradle.plugins.shadow.tasks.ShadowJar
import java.io.File
buildscript {
repositories {
jcenter()
}
dependencies {
classpath("com.github.jengelman.gradle.plugins:shadow:1.2.3")
classpath(ideaSdkDeps("asm-all"))
}
}
apply { plugin("com.github.johnrengelman.shadow") }
val mainCfg = configurations.create("default")
val outputRuntimeJarFileBase = "$buildDir/libs/kotlin-runtime"
artifacts.add(mainCfg.name, File(outputRuntimeJarFileBase + ".jar"))
dependencies {
mainCfg.name(projectDepIntransitive(":core:builtins"))
mainCfg.name(projectDepIntransitive(":kotlin-stdlib"))
buildVersion()
}
val mainTask = task<ShadowJar>("prepare") {
classifier = outputRuntimeJarFileBase
configurations = listOf(mainCfg)
dependsOn(":core:builtins:assemble", ":kotlin-stdlib:assemble")
setupRuntimeJar("Kotlin Runtime")
from(mainCfg.files)
}
defaultTasks(mainTask.name)
+2 -2
View File
@@ -50,7 +50,6 @@ include ":kotlin-build-common",
":core",
":core:builtins",
":core:reflection.jvm",
":core:script.runtime",
":core:util.runtime",
":custom-dependencies:protobuf-lite",
":idea:idea-jps-common",
@@ -97,7 +96,7 @@ include ":kotlin-build-common",
":prepare:formatter",
":prepare:ide-lazy-resolver",
":prepare:kotlin-plugin",
":prepare:android-lint",
":android-lint",
":prepare:mock-runtime-for-test",
":kotlin-compiler",
":kotlin-compiler-embeddable",
@@ -157,6 +156,7 @@ project(':idea:idea-android-output-parser').projectDir = "$rootDir/idea/idea-and
project(':android-extensions-compiler').projectDir = "$rootDir/plugins/android-extensions/android-extensions-compiler" as File
project(':plugins:android-extensions-idea').projectDir = "$rootDir/plugins/android-extensions/android-extensions-idea" as File
project(':plugins:android-extensions-jps').projectDir = "$rootDir/plugins/android-extensions/android-extensions-jps" as File
project(':android-lint').projectDir = "$rootDir/prepare/android-lint" as File
project(':kotlin-allopen-compiler-plugin').projectDir = "$rootDir/plugins/allopen/allopen-cli" as File
project(':plugins:allopen-ide').projectDir = "$rootDir/plugins/allopen/allopen-ide" as File
project(':kotlin-noarg-compiler-plugin').projectDir = "$rootDir/plugins/noarg/noarg-cli" as File