From 97e09903561b1abc443dcdb86e4fe704b66419a2 Mon Sep 17 00:00:00 2001 From: zml Date: Sun, 15 Aug 2021 14:44:08 -0700 Subject: [PATCH] build: Publish Javadoc properly --- .github/workflows/ci.yaml | 123 +++++++++++++++++--------------- build.gradle | 21 ++++++ src/main/java9/module-info.java | 6 ++ 3 files changed, 92 insertions(+), 58 deletions(-) diff --git a/.github/workflows/ci.yaml b/.github/workflows/ci.yaml index 2182472..90c40a3 100644 --- a/.github/workflows/ci.yaml +++ b/.github/workflows/ci.yaml @@ -10,6 +10,9 @@ on: release: types: [released] +env: + PROJECT_NAME: math + jobs: build: # Only run on PRs if the source branch is on someone else's repo @@ -20,63 +23,67 @@ jobs: matrix: os: [ubuntu-latest, windows-latest] steps: - # Setup - - name: Check out - uses: actions/checkout@v2 - - name: Setup JDK 11 - uses: actions/setup-java@v2 - with: - distribution: adopt - java-version: 11 - - name: Validate Gradle wrapper - uses: gradle/wrapper-validation-action@v1 + # Setup + - name: Check out + uses: actions/checkout@v2 + with: + ssh-key: ${{ secrets.SPONGE_JD_DEPLOY_KEY }} + - name: Setup JDK 11 + uses: actions/setup-java@v2 + with: + distribution: adopt + java-version: 11 + - name: Validate Gradle wrapper + uses: gradle/wrapper-validation-action@v1 - # Actually build - - name: Build with Gradle - run: ./gradlew build - - name: Archive test results - if: "${{ always() }}" - uses: actions/upload-artifact@v2 - with: - name: "test-results-${{ matrix.os }}" - path: | - build/reports/ - */build/reports/ + # Actually build + - name: Build with Gradle + run: ./gradlew build + - name: Archive test results + if: "${{ always() }}" + uses: actions/upload-artifact@v2 + with: + name: test-results + path: | + build/reports/ + */build/reports/ - # Then publish if we are all set up to do so - - name: Determine status - if: "${{ runner.os == 'Linux' }}" - run: | - if [ "$(./gradlew properties | awk '/^version:/ { print $2; }' | grep '\-SNAPSHOT')" ]; then - echo "STATUS=snapshot" >> $GITHUB_ENV - else - echo "STATUS=release" >> $GITHUB_ENV - fi - - name: Publish with Gradle (snapshot) - if: "${{ runner.os == 'Linux' && env.STATUS != 'release' && github.event_name == 'push' && github.ref == 'refs/heads/master' }}" - run: ./gradlew -PforceSign=true publish - env: - ORG_GRADLE_PROJECT_githubPackagesUsername: "${{ github.actor }}" - ORG_GRADLE_PROJECT_githubPackagesPassword: "${{ secrets.GITHUB_TOKEN }}" - ORG_GRADLE_PROJECT_spongeSnapshotRepo: "${{ secrets.SPONGE_MAVEN_SNAPSHOT_REPO_URL }}" - ORG_GRADLE_PROJECT_spongeReleaseRepo: "${{ secrets.SPONGE_MAVEN_RELEASE_REPO_URL }}" - ORG_GRADLE_PROJECT_spongeUsername: "${{ secrets.SPONGE_MAVEN_REPO_USER }}" - ORG_GRADLE_PROJECT_spongePassword: "${{ secrets.SPONGE_MAVEN_REPO_PASSWORD }}" - ORG_GRADLE_PROJECT_sonatypeUsername: "${{ secrets.SPONGE_MAVEN_OSSRH_USER }}" - ORG_GRADLE_PROJECT_sonatypePassword: "${{ secrets.SPONGE_MAVEN_OSSRH_PASSWORD }}" - ORG_GRADLE_PROJECT_spongeSigningKey: "${{ secrets.SPONGE_SIGNING_KEY }}" - ORG_GRADLE_PROJECT_spongeSigningPassword: "${{ secrets.SPONGE_SIGNING_PASSWORD }}" - - name: Publish with Gradle (release) - if: "${{ runner.os == 'Linux' && env.STATUS == 'release' && github.event_name == 'release' }}" - run: ./gradlew publish closeSonatypeStagingRepository - env: - ORG_GRADLE_PROJECT_githubPackagesUsername: "${{ github.actor }}" - ORG_GRADLE_PROJECT_githubPackagesPassword: "${{ secrets.GITHUB_TOKEN }}" - ORG_GRADLE_PROJECT_spongeSnapshotRepo: "${{ secrets.SPONGE_MAVEN_SNAPSHOT_REPO_URL }}" - ORG_GRADLE_PROJECT_spongeReleaseRepo: "${{ secrets.SPONGE_MAVEN_RELEASE_REPO_URL }}" - ORG_GRADLE_PROJECT_spongeUsername: "${{ secrets.SPONGE_MAVEN_REPO_USER }}" - ORG_GRADLE_PROJECT_spongePassword: "${{ secrets.SPONGE_MAVEN_REPO_PASSWORD }}" - ORG_GRADLE_PROJECT_sonatypeUsername: "${{ secrets.SPONGE_MAVEN_OSSRH_USER }}" - ORG_GRADLE_PROJECT_sonatypePassword: "${{ secrets.SPONGE_MAVEN_OSSRH_PASSWORD }}" - ORG_GRADLE_PROJECT_spongeSigningKey: "${{ secrets.SPONGE_SIGNING_KEY }}" - ORG_GRADLE_PROJECT_spongeSigningPassword: "${{ secrets.SPONGE_SIGNING_PASSWORD }}" + # Then publish if we are all set up to do so + - name: Determine status + if: "${{ runner.os == 'Linux' }}" + run: | + VERSION=$(./gradlew :properties | awk '/^version:/ { print $2; }') + if [ "$(echo $VERSION | grep '\-SNAPSHOT')" ]; then + echo "STATUS=snapshot" >> $GITHUB_ENV + else + echo "STATUS=release" >> $GITHUB_ENV + fi + echo "PROJECT_VERSION=$VERSION" >> $GITHUB_ENV + - name: Publish with Gradle + if: "${{ runner.os == 'Linux' && ((env.STATUS != 'release' && github.event_name == 'push' && github.ref == 'refs/heads/master') || (env.STATUS == 'release' && github.event_name == 'release')) }}" + run: ./gradlew -PforceSign=true publish + env: + ORG_GRADLE_PROJECT_githubPackagesUsername: "${{ github.actor }}" + ORG_GRADLE_PROJECT_githubPackagesPassword: "${{ secrets.GITHUB_TOKEN }}" + ORG_GRADLE_PROJECT_spongeSnapshotRepo: "${{ secrets.SPONGE_MAVEN_SNAPSHOT_REPO_URL }}" + ORG_GRADLE_PROJECT_spongeReleaseRepo: "${{ secrets.SPONGE_MAVEN_RELEASE_REPO_URL }}" + ORG_GRADLE_PROJECT_spongeUsername: "${{ secrets.SPONGE_MAVEN_REPO_USER }}" + ORG_GRADLE_PROJECT_spongePassword: "${{ secrets.SPONGE_MAVEN_REPO_PASSWORD }}" + ORG_GRADLE_PROJECT_sonatypeUsername: "${{ secrets.SPONGE_MAVEN_OSSRH_USER }}" + ORG_GRADLE_PROJECT_sonatypePassword: "${{ secrets.SPONGE_MAVEN_OSSRH_PASSWORD }}" + ORG_GRADLE_PROJECT_spongeSigningKey: "${{ secrets.SPONGE_SIGNING_KEY }}" + ORG_GRADLE_PROJECT_spongeSigningPassword: "${{ secrets.SPONGE_SIGNING_PASSWORD }}" + - name: Publish Javadoc + if: "${{ runner.os == 'Linux' && ((env.STATUS != 'release' && github.event_name == 'push' && github.ref == 'refs/heads/master') || (env.STATUS == 'release' && github.event_name == 'release')) }}" + run: | + git clone git@github.com:SpongePowered/APIJavadocs.git publish-jd -b data -c core.sshCommand="$(git config --local --get core.sshCommand)" -c user.name=Spongie -c user.email="staff@spongepowered.org" + cd publish-jd + DESTDIR="$PROJECT_NAME/$PROJECT_VERSION" + rm -rf $DESTDIR + mkdir -p $DESTDIR + cp -R ../build/docs/javadoc/* $DESTDIR + git add . + git commit -m "Publishing javadoc for $PROJECT_NAME $PROJECT_VERSION" + git push origin + cd .. + rm -rf publish-jd diff --git a/build.gradle b/build.gradle index 0234d49..58d1852 100644 --- a/build.gradle +++ b/build.gradle @@ -1,3 +1,5 @@ +import org.gradle.external.javadoc.StandardJavadocDocletOptions + import java.io.StringWriter import java.util.stream.Collectors @@ -119,6 +121,25 @@ tasks.withType(JavaCompile.class) { options.compilerArgs << "-Xlint:-cast" // skip cast warnings, the generated source is most likely just overly safe. } +// Handle JD publishing with modules +javadoc { + source("src/main/java9") + options { + addStringOption("-patch-module", "org.spongepowered.math=${sourceSets.main.allJava.srcDirs.collect { it.absolutePath }.join(File.pathSeparator)}") + } +} + +afterEvaluate { + javadoc { + classpath += sourceSets.java9.output + + options { + addStringOption("-release", "9") + addBooleanOption("-no-module-directories", false) + } + } +} + // -- Publishing -- // indra { javaVersions { diff --git a/src/main/java9/module-info.java b/src/main/java9/module-info.java index bc38fd9..1380f88 100644 --- a/src/main/java9/module-info.java +++ b/src/main/java9/module-info.java @@ -23,9 +23,15 @@ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN * THE SOFTWARE. */ +/** + * Immutable math library for Java with a focus on games and computer graphics. + */ module org.spongepowered.math { exports org.spongepowered.math; exports org.spongepowered.math.imaginary; exports org.spongepowered.math.matrix; exports org.spongepowered.math.vector; + + requires static transitive com.google.errorprone.annotations; + requires java.desktop; // java.awt.Color } \ No newline at end of file