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 ':tools:binary-compatibility-validator'
include ':tools:kotlin-stdlib-gen'
include ':tools:protobuf-lite'
include ':kotlin-reflect'
//include ':kotlin-compiler'
+8 -13
View File
@@ -15,7 +15,6 @@ buildscript {
apply plugin: 'com.github.johnrengelman.shadow'
def core = "${rootDir}/../core"
def depDir = "${rootDir}/../dependencies"
def annotationsSrc = "${buildDir}/annotations"
def relocatedCoreSrc = "${buildDir}/core-relocated"
@@ -36,14 +35,14 @@ sourceSets {
configurations {
proguardDeps
shadowes
compileOnly.extendsFrom(shadowes)
shadows
compileOnly.extendsFrom(shadows)
}
dependencies {
proguardDeps project(':kotlin-stdlib')
shadowes 'javax.inject:javax.inject:1'
shadowes files("${depDir}/protobuf-2.6.1-lite.jar")
shadows 'javax.inject:javax.inject:1'
shadows project(path: ':tools:protobuf-lite')
compile project(':kotlin-stdlib')
}
@@ -85,7 +84,7 @@ task reflectShadowJar(type: ShadowJar) {
include 'META-INF/services/**'
}
configurations = [project.configurations.shadowes]
configurations = [project.configurations.shadows]
relocate 'org.jetbrains.kotlin', 'kotlin.reflect.jvm.internal.impl'
relocate 'javax.inject', 'kotlin.reflect.jvm.internal.impl.javax.inject'
}
@@ -161,14 +160,10 @@ task relocatedSourcesJar(type: Jar) {
}
artifacts {
it.default(file(outputJarPath)) {
builtBy proguard
}
def artifactJar = [file: file(outputJarPath), builtBy: proguard, name: archivesBaseName]
archives(file(outputJarPath)) {
name archivesBaseName
builtBy proguard
}
runtime artifactJar
archives artifactJar
archives relocatedSourcesJar
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
}