Skip to content

Commit

Permalink
Package and publish wire-compiler and proto-pruner as fat jars
Browse files Browse the repository at this point in the history
- Introduces shadow plugin [https://github.com/johnrengelman/shadow]
- Bump gradle-maven-publish-plugin to 0.6.0
- Downgrades Gradle plugin to 4.10.2
  gradle-plugins-maven-plugin-builder is incompatible with Gradle 5.0
  due to a breaking api change removing SourceSetOutput#getClassesDir().
  As a result, uploadArchives is broken.
- Stops publishing tar and zip artifacts; introduced by the
  distribution plugin during the Maven to Gradle conversion.
  • Loading branch information
John Rodriguez committed Jan 10, 2019
1 parent fe7515d commit 6b39545
Show file tree
Hide file tree
Showing 8 changed files with 58 additions and 7 deletions.
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -12,3 +12,6 @@ out/
# Gradle
.gradle
build

# Maven
plugin*.xml
22 changes: 18 additions & 4 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -19,10 +19,14 @@ buildscript {
'maven': '3.5.0',
'mavenAnnotations': '3.5',
'mavenPluginBuilder': '1.2.1',
'mavenPublish': '0.4.0',
'mavenPublish': '0.6.0',
]

ext.deps = [
plugins: [
kotlin: "org.jetbrains.kotlin:kotlin-gradle-plugin:${versions.kotlin}",
shadow: 'com.github.jengelman.gradle.plugins:shadow:4.0.3'
],
'android': "com.google.android:android:${versions.android}",
'guava': "com.google.guava:guava:${versions.guava}",
'okio': "com.squareup.okio:okio:${versions.okio}",
Expand All @@ -35,7 +39,6 @@ buildscript {
'annotations': "com.google.auto.value:auto-value-annotations:${versions.autovalue}"
],
'kotlin': [
'gradle': "org.jetbrains.kotlin:kotlin-gradle-plugin:${versions.kotlin}",
'stdlib': [
'jdk6': "org.jetbrains.kotlin:kotlin-stdlib",
'jdk8': "org.jetbrains.kotlin:kotlin-stdlib-jdk8",
Expand Down Expand Up @@ -64,7 +67,8 @@ buildscript {
]

dependencies {
classpath deps.kotlin.gradle
classpath deps.plugins.kotlin
classpath deps.plugins.shadow
classpath deps.animalSniffer.gradle
classpath deps.maven.plugin.builder
classpath deps.maven.plugin.publish
Expand All @@ -85,7 +89,17 @@ allprojects {
}
}

subprojects {
subprojects { project ->
// The `application` plugin internally applies the `distribution` plugin and
// automatically adds tasks to create/publish tar and zip artifacts.
// https://docs.gradle.org/current/userguide/application_plugin.html
// https://docs.gradle.org/current/userguide/distribution_plugin.html#sec:publishing_distributions_upload
plugins.withType(DistributionPlugin) {
distTar.enabled = false
distZip.enabled = false
configurations.archives.artifacts.removeAll { it.file =~ 'tar' || it.file =~ 'zip' }
}

apply plugin: 'com.vanniktech.maven.publish'
apply plugin: 'checkstyle'

Expand Down
Binary file modified gradle/wrapper/gradle-wrapper.jar
Binary file not shown.
2 changes: 1 addition & 1 deletion gradle/wrapper/gradle-wrapper.properties
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-5.0-all.zip
distributionUrl=https\://services.gradle.org/distributions/gradle-4.10.2-all.zip
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
2 changes: 1 addition & 1 deletion gradlew
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ APP_NAME="Gradle"
APP_BASE_NAME=`basename "$0"`

# Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
DEFAULT_JVM_OPTS='"-Xmx64m"'
DEFAULT_JVM_OPTS=""

# Use the maximum available, or set MAX_FD != -1 to use that value.
MAX_FD="maximum"
Expand Down
2 changes: 1 addition & 1 deletion gradlew.bat
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ set APP_BASE_NAME=%~n0
set APP_HOME=%DIRNAME%

@rem Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
set DEFAULT_JVM_OPTS="-Xmx64m"
set DEFAULT_JVM_OPTS=

@rem Find java.exe
if defined JAVA_HOME goto findJavaFromJavaHome
Expand Down
17 changes: 17 additions & 0 deletions proto-pruner/build.gradle
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
apply plugin: 'application'
apply plugin: 'org.jetbrains.kotlin.jvm'
apply plugin: 'com.github.johnrengelman.shadow'

sourceCompatibility = JavaVersion.VERSION_1_8
targetCompatibility = JavaVersion.VERSION_1_8
Expand All @@ -16,3 +17,19 @@ dependencies {
implementation project(':wire-schema')
implementation deps.kotlin.stdlib.jdk8
}

shadowJar {
classifier = 'jar-with-dependencies'
}

artifacts {
archives shadowJar
}

// The `shadow` plugin internally applies the `distribution` plugin and
// automatically adds tasks to create respective tar and zip artifacts.
// https://github.com/johnrengelman/shadow/issues/347#issuecomment-424726972
// https://github.com/johnrengelman/shadow/commit/a824e4f6e4618785deb7f084c4a80ce1b78fc4fd
shadowDistTar.enabled = false
shadowDistZip.enabled = false
configurations.archives.artifacts.removeAll { it.file =~ 'tar' || it.file =~ 'zip' }
17 changes: 17 additions & 0 deletions wire-compiler/build.gradle
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
apply plugin: 'application'
apply plugin: 'org.jetbrains.kotlin.jvm'
apply plugin: 'com.github.johnrengelman.shadow'

sourceCompatibility = JavaVersion.VERSION_1_8
targetCompatibility = JavaVersion.VERSION_1_8
Expand Down Expand Up @@ -27,3 +28,19 @@ dependencies {
testImplementation deps.jimfs
testImplementation deps.kotlin.test.junit
}

shadowJar {
classifier = 'jar-with-dependencies'
}

artifacts {
archives shadowJar
}

// The `shadow` plugin internally applies the `distribution` plugin and
// automatically adds tasks to create respective tar and zip artifacts.
// https://github.com/johnrengelman/shadow/issues/347#issuecomment-424726972
// https://github.com/johnrengelman/shadow/commit/a824e4f6e4618785deb7f084c4a80ce1b78fc4fd
shadowDistTar.enabled = false
shadowDistZip.enabled = false
configurations.archives.artifacts.removeAll { it.file =~ 'tar' || it.file =~ 'zip' }

0 comments on commit 6b39545

Please sign in to comment.