Move kotlin-reflect Gradle project to libraries/reflect/
This commit is contained in:
+1
-1
@@ -58,7 +58,7 @@ class RuntimePublicAPITest {
|
||||
}
|
||||
|
||||
@Test fun kotlinReflect() {
|
||||
snapshotAPIAndCompare("../../tools/kotlin-reflect/build/libs", "kotlin-reflect(?!-[-a-z]+)", listOf("../reflect-declarations.json"), nonPublicPackages = listOf("kotlin.reflect.jvm.internal"))
|
||||
snapshotAPIAndCompare("../../reflect/build/libs", "kotlin-reflect(?!-[-a-z]+)", listOf("../reflect-declarations.json"), nonPublicPackages = listOf("kotlin.reflect.jvm.internal"))
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -1,191 +0,0 @@
|
||||
import com.github.jengelman.gradle.plugins.shadow.tasks.ShadowJar
|
||||
|
||||
description = 'Kotlin Full Reflection Library'
|
||||
|
||||
buildscript {
|
||||
repositories {
|
||||
jcenter()
|
||||
}
|
||||
dependencies {
|
||||
classpath 'net.sf.proguard:proguard-gradle:5.2.1'
|
||||
classpath "com.github.jengelman.gradle.plugins:shadow:${property("versions.shadow")}"
|
||||
}
|
||||
}
|
||||
|
||||
apply plugin: 'com.github.johnrengelman.shadow'
|
||||
apply plugin: 'kotlin'
|
||||
|
||||
configureJvm6Project(project)
|
||||
configurePublishing(project)
|
||||
|
||||
|
||||
def core = "${rootDir}/core"
|
||||
def annotationsSrc = "${buildDir}/annotations"
|
||||
def relocatedCoreSrc = "${buildDir}/core-relocated"
|
||||
|
||||
sourceSets {
|
||||
main {
|
||||
java {
|
||||
srcDir annotationsSrc
|
||||
srcDir "${core}/reflection.jvm/src"
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
configurations {
|
||||
proguardDeps
|
||||
shadows { transitive = false }
|
||||
compileOnly.extendsFrom(shadows)
|
||||
mainJar
|
||||
}
|
||||
|
||||
dependencies {
|
||||
proguardDeps project(':kotlin-stdlib')
|
||||
shadows project(':core:descriptors')
|
||||
shadows project(':core:descriptors.jvm')
|
||||
shadows project(':core:deserialization')
|
||||
shadows project(':core:descriptors.runtime')
|
||||
shadows project(':core:util.runtime')
|
||||
shadows 'javax.inject:javax.inject:1'
|
||||
shadows project(path: ':custom-dependencies:protobuf-lite', configuration: 'default')
|
||||
|
||||
compile project(':kotlin-stdlib')
|
||||
compileOnly project(path: ':custom-dependencies:protobuf-lite', configuration: 'default')
|
||||
}
|
||||
|
||||
task copyAnnotations(type: Sync) {
|
||||
// copy just two missing annotations
|
||||
from("${core}/runtime.jvm/src") {
|
||||
include "**/Mutable.java"
|
||||
include "**/ReadOnly.java"
|
||||
}
|
||||
into(annotationsSrc)
|
||||
includeEmptyDirs false
|
||||
}
|
||||
|
||||
|
||||
compileJava {
|
||||
dependsOn copyAnnotations
|
||||
// options.compilerArgs.addAll(["-Xlint:unchecked"])
|
||||
}
|
||||
|
||||
compileKotlin {
|
||||
dependsOn copyAnnotations
|
||||
dependsOn ':custom-dependencies:protobuf-lite:prepare'
|
||||
kotlinOptions {
|
||||
freeCompilerArgs = ["-version",
|
||||
"-Xallow-kotlin-package",
|
||||
"-Xnormalize-constructor-calls=enable",
|
||||
"-module-name", "kotlin-reflection",
|
||||
"-Xdump-declarations-to=${buildDir}/reflect-declarations.json"]
|
||||
}
|
||||
}
|
||||
|
||||
kotlin.experimental.coroutines "enable"
|
||||
|
||||
|
||||
task reflectShadowJar(type: ShadowJar) {
|
||||
classifier = 'shadow'
|
||||
version = null
|
||||
manifestAttributes(manifest, project, 'Main')
|
||||
|
||||
from(sourceSets.main.output)
|
||||
from(project(":core:descriptors.jvm").sourceSets.main.resources) {
|
||||
include 'META-INF/services/**'
|
||||
}
|
||||
from(project(":core:deserialization").sourceSets.main.resources) {
|
||||
include 'META-INF/services/**'
|
||||
}
|
||||
|
||||
configurations = [project.configurations.shadows]
|
||||
relocate 'org.jetbrains.kotlin', 'kotlin.reflect.jvm.internal.impl'
|
||||
relocate 'javax.inject', 'kotlin.reflect.jvm.internal.impl.javax.inject'
|
||||
mergeServiceFiles()
|
||||
}
|
||||
|
||||
task stripMetadata {
|
||||
dependsOn reflectShadowJar
|
||||
def inputJar = reflectShadowJar.archivePath
|
||||
def outputJar = new File("${libsDir}/kotlin-reflect-stripped.jar")
|
||||
inputs.file(inputJar)
|
||||
outputs.file(outputJar)
|
||||
doLast {
|
||||
StripMetadataKt.stripMetadata(logger, "kotlin/reflect/jvm/internal/impl/.*", inputJar, outputJar)
|
||||
}
|
||||
}
|
||||
|
||||
def mainArchiveName = "${archivesBaseName}-${project.version}.jar"
|
||||
def outputJarPath = "${libsDir}/${mainArchiveName}"
|
||||
def rtJar = ['jre/lib/rt.jar', '../Classes/classes.jar'].collect { new File(JDK_16, it) }.find { it.isFile() }
|
||||
|
||||
task proguard(type: proguard.gradle.ProGuardTask) {
|
||||
dependsOn stripMetadata
|
||||
inputs.files(stripMetadata.outputs.files)
|
||||
outputs.file(outputJarPath)
|
||||
|
||||
injars stripMetadata.outputs.files
|
||||
outjars outputJarPath
|
||||
|
||||
libraryjars configurations.proguardDeps
|
||||
libraryjars rtJar
|
||||
|
||||
configuration "${core}/reflection.jvm/reflection.pro"
|
||||
}
|
||||
|
||||
|
||||
task relocateCoreSources(type: Copy) {
|
||||
def commonPackage = "org/jetbrains/kotlin"
|
||||
|
||||
doFirst {
|
||||
delete(relocatedCoreSrc)
|
||||
}
|
||||
|
||||
from "${core}/descriptors/src/${commonPackage}"
|
||||
from "${core}/descriptors.jvm/src/${commonPackage}"
|
||||
from "${core}/descriptors.runtime/src/${commonPackage}"
|
||||
from "${core}/deserialization/src/${commonPackage}"
|
||||
from "${core}/util.runtime/src/${commonPackage}"
|
||||
|
||||
into "${relocatedCoreSrc}/kotlin/reflect/jvm/internal/impl"
|
||||
|
||||
doLast {
|
||||
ant.replaceregexp(
|
||||
match: 'org\\.jetbrains\\.kotlin',
|
||||
replace: 'kotlin.reflect.jvm.internal.impl',
|
||||
flags: 'g'
|
||||
) {
|
||||
fileset(dir: relocatedCoreSrc)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
jar.enabled false
|
||||
|
||||
task relocatedSourcesJar(type: Jar) {
|
||||
dependsOn relocateCoreSources
|
||||
classifier 'sources'
|
||||
from relocatedCoreSrc
|
||||
from "${core}/reflection.jvm/src"
|
||||
}
|
||||
|
||||
def artifactJar = [file: file(outputJarPath), builtBy: proguard, name: archivesBaseName]
|
||||
|
||||
task dexMethodCount(type: DexMethodCount) {
|
||||
dependsOn(artifactJar.builtBy)
|
||||
jarFile = artifactJar.file
|
||||
ownPackages = ['kotlin.reflect']
|
||||
}
|
||||
check.dependsOn(dexMethodCount)
|
||||
|
||||
artifacts {
|
||||
mainJar artifactJar
|
||||
runtime artifactJar
|
||||
archives artifactJar
|
||||
archives relocatedSourcesJar
|
||||
archives javadocJar
|
||||
}
|
||||
|
||||
dist {
|
||||
from(proguard)
|
||||
from(relocatedSourcesJar)
|
||||
}
|
||||
Reference in New Issue
Block a user