From 756497d923a03e0dcdff5824907bab7ddfc6e0b0 Mon Sep 17 00:00:00 2001 From: Sergei Egorov Date: Sat, 12 Sep 2020 11:47:40 +0200 Subject: [PATCH] Publish to Bintray --- .github/workflows/release.yml | 23 +++++++++++++ build.gradle | 16 ++++++++++ gradle/publishing.gradle | 32 +++++++++++++++++++ jabel-javac-plugin/build.gradle | 27 +++++++++++++++- .../bsideup/jabel/CheckSourceLevelAdvice.java | 4 +-- 5 files changed, 99 insertions(+), 3 deletions(-) create mode 100644 .github/workflows/release.yml create mode 100644 gradle/publishing.gradle diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml new file mode 100644 index 0000000..1308358 --- /dev/null +++ b/.github/workflows/release.yml @@ -0,0 +1,23 @@ +name: Release + +on: + release: + types: + - prereleased + - released + +jobs: + build: + runs-on: ubuntu-18.04 + steps: + - uses: actions/checkout@v1 + - name: Set up JDK + uses: actions/setup-java@v1 + with: + java-version: 14 + - name: Deploy with Gradle + env: + GRADLE_PUBLISH_REPO_URL: ${{ secrets.GRADLE_PUBLISH_REPO_URL }} + GRADLE_PUBLISH_MAVEN_USER: ${{ secrets.GRADLE_PUBLISH_MAVEN_USER }} + GRADLE_PUBLISH_MAVEN_PASSWORD: ${{ secrets.GRADLE_PUBLISH_MAVEN_PASSWORD }} + run: ./gradlew --no-daemon -Pversion=$(git tag --points-at HEAD) publish \ No newline at end of file diff --git a/build.gradle b/build.gradle index 3a08b71..1525a77 100644 --- a/build.gradle +++ b/build.gradle @@ -1,6 +1,22 @@ subprojects { + apply from: "$rootDir/gradle/publishing.gradle" + group = 'com.github.bsideup.jabel' repositories { jcenter() } + + plugins.withType(MavenPublishPlugin) { + project.publishing { + repositories { + maven { + url System.getenv('GRADLE_PUBLISH_REPO_URL') + credentials { + username = System.getenv('GRADLE_PUBLISH_MAVEN_USER') + password = System.getenv('GRADLE_PUBLISH_MAVEN_PASSWORD') + } + } + } + } + } } \ No newline at end of file diff --git a/gradle/publishing.gradle b/gradle/publishing.gradle new file mode 100644 index 0000000..ffc3b3b --- /dev/null +++ b/gradle/publishing.gradle @@ -0,0 +1,32 @@ +plugins.withType(MavenPublishPlugin) { + project.publishing { + publications { + mavenJava(MavenPublication) { publication -> + pom { + description = 'Jabel - use modern Java 9-14 syntax when targeting Java 8.' + name = project.description ?: description + url = 'https://github.com/bsideup/jabel' + licenses { + license { + name = 'Apache License, Version 2.0' + url = 'https://www.apache.org/licenses/LICENSE-2.0.txt' + distribution = 'repo' + } + } + scm { + url = 'https://github.com/bsideup/jabel/' + connection = 'scm:git:git://github.com/bsideup/jabel.git' + developerConnection = 'scm:git:ssh://git@github.com/bsideup/jabel.git' + } + developers { + developer { + id = 'bsideup' + name = 'Sergei Egorov' + email = 'bsideup@gmail.com' + } + } + } + } + } + } +} \ No newline at end of file diff --git a/jabel-javac-plugin/build.gradle b/jabel-javac-plugin/build.gradle index 47fa235..c90d33e 100644 --- a/jabel-javac-plugin/build.gradle +++ b/jabel-javac-plugin/build.gradle @@ -1,6 +1,6 @@ plugins { id "java" - id "maven" + id "maven-publish" } sourceCompatibility = targetCompatibility = 8 @@ -8,4 +8,29 @@ sourceCompatibility = targetCompatibility = 8 dependencies { compile 'net.bytebuddy:byte-buddy:1.10.14' compile 'net.bytebuddy:byte-buddy-agent:1.10.14' +} + + +task sourcesJar(type: Jar) { + classifier 'sources' + from sourceSets.main.allJava +} + +javadoc { + options.source = "8" +} + +task javadocJar(type: Jar) { + from javadoc + classifier = 'javadoc' +} + +publishing { + publications { + mavenJava(MavenPublication) { publication -> + from components.java + artifact sourcesJar + artifact javadocJar + } + } } \ No newline at end of file diff --git a/jabel-javac-plugin/src/main/java/com/github/bsideup/jabel/CheckSourceLevelAdvice.java b/jabel-javac-plugin/src/main/java/com/github/bsideup/jabel/CheckSourceLevelAdvice.java index f28f34b..2266777 100644 --- a/jabel-javac-plugin/src/main/java/com/github/bsideup/jabel/CheckSourceLevelAdvice.java +++ b/jabel-javac-plugin/src/main/java/com/github/bsideup/jabel/CheckSourceLevelAdvice.java @@ -4,10 +4,10 @@ import com.sun.tools.javac.code.Source.Feature; import net.bytebuddy.asm.Advice; -public class CheckSourceLevelAdvice { +class CheckSourceLevelAdvice { @Advice.OnMethodEnter - public static void checkSourceLevel( + static void checkSourceLevel( @Advice.Argument(value = 1, readOnly = false) Feature feature ) { if (feature.allowedInSource(Source.JDK8)) {