98 lines
2.1 KiB
Groovy
98 lines
2.1 KiB
Groovy
import com.github.jengelman.gradle.plugins.shadow.tasks.ShadowJar
|
|
|
|
buildscript {
|
|
repositories {
|
|
jcenter()
|
|
}
|
|
|
|
dependencies {
|
|
classpath "com.github.jengelman.gradle.plugins:shadow:${property("versions.shadow")}"
|
|
}
|
|
}
|
|
|
|
apply plugin: 'base'
|
|
apply plugin: 'com.github.johnrengelman.shadow'
|
|
|
|
def protobufVersion = "2.6.1"
|
|
version = protobufVersion
|
|
|
|
def outputJarPath = "${libsDir}/${archivesBaseName}-${protobufVersion}.jar"
|
|
|
|
|
|
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
|
|
} |