Assemble protobuf-lite with gradle, and use it in kotlin-reflect.

This commit is contained in:
Ilya Gorbunov
2017-03-27 07:01:49 +03:00
parent d1d62d557d
commit 026a76e98c
3 changed files with 106 additions and 13 deletions
+1
View File
@@ -13,6 +13,7 @@ include ':kotlin-stdlib-jre7'
include ':kotlin-stdlib-jre8' include ':kotlin-stdlib-jre8'
include ':tools:binary-compatibility-validator' include ':tools:binary-compatibility-validator'
include ':tools:kotlin-stdlib-gen' include ':tools:kotlin-stdlib-gen'
include ':tools:protobuf-lite'
include ':kotlin-reflect' include ':kotlin-reflect'
//include ':kotlin-compiler' //include ':kotlin-compiler'
+8 -13
View File
@@ -15,7 +15,6 @@ buildscript {
apply plugin: 'com.github.johnrengelman.shadow' apply plugin: 'com.github.johnrengelman.shadow'
def core = "${rootDir}/../core" def core = "${rootDir}/../core"
def depDir = "${rootDir}/../dependencies"
def annotationsSrc = "${buildDir}/annotations" def annotationsSrc = "${buildDir}/annotations"
def relocatedCoreSrc = "${buildDir}/core-relocated" def relocatedCoreSrc = "${buildDir}/core-relocated"
@@ -36,14 +35,14 @@ sourceSets {
configurations { configurations {
proguardDeps proguardDeps
shadowes shadows
compileOnly.extendsFrom(shadowes) compileOnly.extendsFrom(shadows)
} }
dependencies { dependencies {
proguardDeps project(':kotlin-stdlib') proguardDeps project(':kotlin-stdlib')
shadowes 'javax.inject:javax.inject:1' shadows 'javax.inject:javax.inject:1'
shadowes files("${depDir}/protobuf-2.6.1-lite.jar") shadows project(path: ':tools:protobuf-lite')
compile project(':kotlin-stdlib') compile project(':kotlin-stdlib')
} }
@@ -85,7 +84,7 @@ task reflectShadowJar(type: ShadowJar) {
include 'META-INF/services/**' include 'META-INF/services/**'
} }
configurations = [project.configurations.shadowes] configurations = [project.configurations.shadows]
relocate 'org.jetbrains.kotlin', 'kotlin.reflect.jvm.internal.impl' relocate 'org.jetbrains.kotlin', 'kotlin.reflect.jvm.internal.impl'
relocate 'javax.inject', 'kotlin.reflect.jvm.internal.impl.javax.inject' relocate 'javax.inject', 'kotlin.reflect.jvm.internal.impl.javax.inject'
} }
@@ -161,14 +160,10 @@ task relocatedSourcesJar(type: Jar) {
} }
artifacts { artifacts {
it.default(file(outputJarPath)) { def artifactJar = [file: file(outputJarPath), builtBy: proguard, name: archivesBaseName]
builtBy proguard
}
archives(file(outputJarPath)) { runtime artifactJar
name archivesBaseName archives artifactJar
builtBy proguard
}
archives relocatedSourcesJar archives relocatedSourcesJar
archives javadocJar archives javadocJar
} }
@@ -0,0 +1,97 @@
import com.github.jengelman.gradle.plugins.shadow.tasks.ShadowJar
buildscript {
repositories {
jcenter()
}
dependencies {
classpath 'com.github.jengelman.gradle.plugins:shadow:1.2.4'
}
}
apply plugin: 'com.github.johnrengelman.shadow'
def protobufVersion = "2.6.1"
def outputJarPath = "$buildDir/libs/${archivesBaseName}-${protobufVersion}.jar"
version = protobufVersion
configurations {
protobuf
protobufSrc
}
dependencies {
protobuf "com.google.protobuf:protobuf-java:$protobufVersion"
protobufSrc "com.google.protobuf:protobuf-java:$protobufVersion:sources"
}
task shadowJar(type: ShadowJar) {
classifier = "shadow"
version = null
configurations = [project.configurations.protobuf]
relocate("com.google.protobuf", "org.jetbrains.kotlin.protobuf" ) {
exclude("META-INF/maven/com.google.protobuf/protobuf-java/pom.properties")
}
}
createScriptTask(project, "buildLiteJar") {
dependsOn shadowJar
def inputJar = shadowJar.archivePath
inputs.file(inputJar)
outputs.file(outputJarPath)
args += [
"${rootDir}/../generators/infrastructure/build-protobuf-lite.kts",
inputJar,
outputJarPath
]
}
def artifactJar = [file: file(outputJarPath), builtBy: buildLiteJar]
task sourcesJar(type: Jar) {
inputs.file configurations.protobufSrc
def tmpSrcDir = "${buildDir}/src"
doFirst {
copy {
from (zipTree(configurations.protobufSrc.singleFile))
into tmpSrcDir
}
ant.replaceregexp(
match: 'com\\.google\\.protobuf',
replace: 'org.jetbrains.kotlin.protobuf',
flags: 'g'
) {
fileset(dir: tmpSrcDir) {
include(name: "**/*.java")
}
}
}
classifier 'sources'
from ("${tmpSrcDir}/com/google/protobuf") {
into 'org/jetbrains/kotlin/protobuf'
}
doLast {
delete(tmpSrcDir)
}
}
artifacts {
it."default"(artifactJar)
archives(artifactJar)
archives(sourcesJar)
}
assemble {
dependsOn configurations.archives
}