From 6cc7c254cb817662f21e1db66d7b433cc83774f3 Mon Sep 17 00:00:00 2001 From: Ned Twigg Date: Sat, 28 Jan 2023 00:56:56 -0800 Subject: [PATCH 1/7] Bump blowdryer-diffplug 6.0.1 -> 7.0.0 --- build.gradle | 2 +- gradle.properties | 3 ++- settings.gradle | 47 ++++++++++++++++++++++++++--------------------- 3 files changed, 29 insertions(+), 23 deletions(-) diff --git a/build.gradle b/build.gradle index 30de6ab..ffddf83 100644 --- a/build.gradle +++ b/build.gradle @@ -13,7 +13,7 @@ apply from: 干.file('base/sonatype.gradle') String VER_JUNIT_JUPITER = '5.9.1' subprojects { - apply from: 干.file('base/java8.gradle') + apply from: 干.file('base/java.gradle') apply from: 干.file('base/kotlin.gradle') apply from: 干.file('spotless/java.gradle') apply plugin: 'java-library' diff --git a/gradle.properties b/gradle.properties index 47b57e6..e6e84b0 100644 --- a/gradle.properties +++ b/gradle.properties @@ -6,6 +6,7 @@ plugin_atplug_id=com.diffplug.atplug plugin_atplug_impl=com.diffplug.atplug.tooling.gradle.PlugPlugin plugin_atplug_name=AtPlug Gradle Plugin plugin_atplug_desc=Generates plugin metadata for AtPlug +ver_java=8 maven_group=com.diffplug.atplug -javadoc_links= \ No newline at end of file +javadoc_links= diff --git a/settings.gradle b/settings.gradle index 961c025..cbbfb70 100644 --- a/settings.gradle +++ b/settings.gradle @@ -1,32 +1,37 @@ pluginManagement { - plugins { - id 'com.diffplug.blowdryer' version '1.6.0' - id 'com.diffplug.blowdryerSetup' version '1.6.0' - id 'com.diffplug.configuration-cache-for-platform-specific-build' version '3.40.0' - id 'com.diffplug.spotless' version '6.12.0' - id 'com.diffplug.spotless-changelog' version '2.4.1' - id 'org.jetbrains.dokka' version '1.7.20' - id 'org.jetbrains.kotlin.jvm' version '1.8.0' - id 'org.jetbrains.kotlin.plugin.serialization' version '1.8.0' - id 'com.gradle.plugin-publish' version '1.1.0' - id 'io.github.gradle-nexus.publish-plugin' version '1.1.0' + repositories { + mavenCentral() + gradlePluginPortal() } } plugins { - id 'com.diffplug.blowdryerSetup' - id 'com.diffplug.configuration-cache-for-platform-specific-build' apply false - id 'com.diffplug.spotless' apply false - id 'com.diffplug.spotless-changelog' apply false - id 'org.jetbrains.dokka' apply false - id 'org.jetbrains.kotlin.jvm' apply false - id 'org.jetbrains.kotlin.plugin.serialization' apply false - id 'com.gradle.plugin-publish' apply false - id 'io.github.gradle-nexus.publish-plugin' apply false + // https://github.com/diffplug/blowdryer/blob/main/CHANGELOG.md + id 'com.diffplug.blowdryerSetup' version '1.7.0' + // https://github.com/diffplug/spotless/blob/main/plugin-gradle/CHANGES.md + id 'com.diffplug.spotless' version '6.14.0' apply false + // https://github.com/diffplug/spotless-changelog/blob/main/CHANGELOG.md + id 'com.diffplug.spotless-changelog' version '2.4.1' apply false + // https://plugins.gradle.org/plugin/com.gradle.plugin-publish + id 'com.gradle.plugin-publish' version '1.1.0' apply false + // https://github.com/equodev/equo-ide/blob/main/plugin-gradle/CHANGELOG.md + id 'dev.equo.ide' version '0.12.1' apply false + // https://github.com/gradle-nexus/publish-plugin/releases + id 'io.github.gradle-nexus.publish-plugin' version '1.1.0' apply false + // https://plugins.gradle.org/plugin/org.jetbrains.dokka + id 'org.jetbrains.dokka' version '1.7.20' apply false + // https://plugins.gradle.org/plugin/org.jetbrains.kotlin.jvm + id 'org.jetbrains.kotlin.jvm' version '1.8.0' apply false + // https://plugins.gradle.org/plugin/org.jetbrains.kotlin.plugin.serialization + id 'org.jetbrains.kotlin.plugin.serialization' version '1.8.0' apply false } blowdryerSetup { - github 'diffplug/blowdryer-diffplug', 'tag', '6.0.1' + github 'diffplug/blowdryer-diffplug', 'tag', '7.0.0' //devLocal '../blowdryer-diffplug' + setPluginsBlockTo { + it.file 'plugin.versions' + it.file 'plugin-kotlin.versions' + } } include 'atplug-runtime' From e9e9a01ae054ed38a10ca16faa4e09f9e2f14e54 Mon Sep 17 00:00:00 2001 From: Ned Twigg Date: Sat, 28 Jan 2023 01:06:34 -0800 Subject: [PATCH 2/7] Dump CircleCI for GitHub Actions. --- .circleci/config.yml | 89 ------------------- .github/workflows/changelog-print.yml | 22 +++++ .github/workflows/ci.yml | 40 +++++++++ .github/workflows/deploy.yml | 51 +++++++++++ .../workflows/gradle-wrapper-validation.yml | 23 +++++ 5 files changed, 136 insertions(+), 89 deletions(-) delete mode 100644 .circleci/config.yml create mode 100644 .github/workflows/changelog-print.yml create mode 100644 .github/workflows/ci.yml create mode 100644 .github/workflows/deploy.yml create mode 100644 .github/workflows/gradle-wrapper-validation.yml diff --git a/.circleci/config.yml b/.circleci/config.yml deleted file mode 100644 index f41a6e1..0000000 --- a/.circleci/config.yml +++ /dev/null @@ -1,89 +0,0 @@ -version: 2.1 -anchors: - env_gradle: &env_gradle - environment: - # we're only allowed to use 2 vCPUs - GRADLE_OPTS: "-Dorg.gradle.workers.max=2" - docker: - - image: cimg/openjdk:8.0 - - restore_cache_wrapper: &restore_cache_wrapper - restore_cache: - key: gradle-wrapper-{{ checksum "gradle/wrapper/gradle-wrapper.properties" }} - restore_cache_deps: &restore_cache_deps - restore_cache: - keys: - - gradle-deps-{{ checksum "build.gradle" }}-{{ checksum "gradle.properties" }} - - gradle-deps- - set_git_origin_to_https: &set_git_origin_to_https - run: - name: set git origin to https - command: git remote set-url --push origin https://github.com/diffplug/atplug - -jobs: - test_8: - <<: *env_gradle - steps: - - checkout - - run: - name: gradlew test - command: ./gradlew test - - run: - name: gradlew javadoc - command: ./gradlew javadoc - - store_test_results: - path: build/test-results/test - test_11: - docker: - - image: cimg/openjdk:11.0 - steps: - - checkout - - run: - name: gradlew test - command: ./gradlew test - - run: - name: gradlew spotlessCheck - command: ./gradlew spotlessCheck - - store_test_results: - path: build/test-results/test - changelog_print: - << : *env_gradle - steps: - - checkout - - *restore_cache_wrapper - - *restore_cache_deps - - run: - name: gradlew changelogPrint - command: ./gradlew changelogPrint - do_release: - << : *env_gradle - steps: - - checkout - - *restore_cache_wrapper - - *restore_cache_deps - - *set_git_origin_to_https - - run: - name: changelogPush - command: ./gradlew changelogPush -Penable_publishing=true -Pgradle.publish.key=${gradle_key} -Pgradle.publish.secret=${gradle_secret} --stacktrace --warning-mode all - -workflows: - version: 2 - tests: - jobs: - - test_8 - - test_11 - deploy: - jobs: - - changelog_print: - filters: - branches: - only: main - - release: - type: approval - requires: - - changelog_print - - do_release: - requires: - - release - context: - - SonatypeDeploy diff --git a/.github/workflows/changelog-print.yml b/.github/workflows/changelog-print.yml new file mode 100644 index 0000000..a3009e3 --- /dev/null +++ b/.github/workflows/changelog-print.yml @@ -0,0 +1,22 @@ +name: changelogPrint + +on: + push: + branches: [main] + +jobs: + build: + runs-on: ubuntu-latest + name: changelogPrint + steps: + - uses: actions/checkout@v3 + - name: jdk 11 + uses: actions/setup-java@v3 + with: + java-version: 11 + distribution: 'temurin' + - name: gradle caching + uses: gradle/gradle-build-action@v2 + with: + gradle-home-cache-cleanup: true + - run: ./gradlew changelogPrint diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml new file mode 100644 index 0000000..7e13371 --- /dev/null +++ b/.github/workflows/ci.yml @@ -0,0 +1,40 @@ +on: + pull_request: + push: + branches: [main] +concurrency: + group: ${{ github.workflow }}-${{ github.ref }} + cancel-in-progress: true +jobs: + build: + strategy: + fail-fast: false + matrix: + jre: [17] + os: [ubuntu-latest, windows-latest] + include: + - jre: 8 + os: ubuntu-latest + runs-on: ${{ matrix.os }} + steps: + - name: Checkout + uses: actions/checkout@v3 + - name: Install JDK ${{ matrix.jre }} + uses: actions/setup-java@v3 + with: + distribution: "temurin" + java-version: ${{ matrix.jre }} + - name: gradle caching + uses: gradle/gradle-build-action@v2 + with: + gradle-home-cache-cleanup: true + - name: git fetch origin main + run: git fetch origin main + - name: gradlew build + run: ./gradlew build + - name: junit result + uses: mikepenz/action-junit-report@v3 + if: always() # always run even if the previous step fails + with: + check_name: JUnit ${{ matrix.jre }} ${{ matrix.os }} + report_paths: '*/build/test-results/*/TEST-*.xml' diff --git a/.github/workflows/deploy.yml b/.github/workflows/deploy.yml new file mode 100644 index 0000000..3d95da7 --- /dev/null +++ b/.github/workflows/deploy.yml @@ -0,0 +1,51 @@ +# GH_TOKEN +# NEXUS_USER +# NEXUS_PASS64 (base64 NOTE: `base64` and `openssl base64` failed, had to use Java +# byte[] data = "{{password}}".getBytes(StandardCharsets.UTF_8); +# String encoded = new String(Base64.getEncoder().encode(data), StandardCharsets.UTF_8); +# System.out.println(encoded); +# GPG_PASSPHRASE +# GPG_KEY64 (base64) +# gpg --export-secret-keys --armor KEY_ID | openssl base64 | pbcopy +# GRADLE_KEY +# GRADLE_SECRET + +name: deploy +on: + workflow_dispatch: + inputs: + to_publish: + description: 'What to publish' + required: true + default: 'all' + type: choice + options: + - all + +jobs: + build: + runs-on: ubuntu-latest + name: deploy + env: + gh_token: ${{ secrets.GH_TOKEN }} + ORG_GRADLE_PROJECT_nexus_user: ${{ secrets.NEXUS_USER }} + ORG_GRADLE_PROJECT_nexus_pass64: ${{ secrets.NEXUS_PASS64 }} + ORG_GRADLE_PROJECT_gpg_passphrase: ${{ secrets.GPG_PASSPHRASE }} + ORG_GRADLE_PROJECT_gpg_key64: ${{ secrets.GPG_KEY64 }} + steps: + - uses: actions/checkout@v3 + - name: jdk 11 + uses: actions/setup-java@v3 + with: + java-version: 11 + distribution: 'temurin' + - name: gradle caching + uses: gradle/gradle-build-action@v2 + with: + gradle-home-cache-cleanup: true + - name: git fetch origin main + run: git fetch origin main + - name: publish all + if: "${{ github.event.inputs.to_publish == 'all' }}" + run: | + ./gradlew :changelogPush -Prelease=true -Penable_publishing=true -Pgradle.publish.key=${{ secrets.GRADLE_KEY }} -Pgradle.publish.secret=${{ secrets.GRADLE_SECRET }} --stacktrace --warning-mode all diff --git a/.github/workflows/gradle-wrapper-validation.yml b/.github/workflows/gradle-wrapper-validation.yml new file mode 100644 index 0000000..2c02ce0 --- /dev/null +++ b/.github/workflows/gradle-wrapper-validation.yml @@ -0,0 +1,23 @@ +name: "Validate Gradle Wrapper" +on: + push: + paths: + - 'gradlew' + - 'gradlew.bat' + - 'gradle/wrapper/' + pull_request: + paths: + - 'gradlew' + - 'gradlew.bat' + - 'gradle/wrapper/' + +permissions: + contents: read + +jobs: + validation: + name: "Validation" + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v3 + - uses: gradle/wrapper-validation-action@v1 From 2250dabcadf52feb870c072a322cb6164718a0f6 Mon Sep 17 00:00:00 2001 From: Ned Twigg Date: Sat, 28 Jan 2023 01:08:45 -0800 Subject: [PATCH 3/7] The build needs 11. --- .github/workflows/ci.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 7e13371..9ae317d 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -13,7 +13,7 @@ jobs: jre: [17] os: [ubuntu-latest, windows-latest] include: - - jre: 8 + - jre: 11 os: ubuntu-latest runs-on: ${{ matrix.os }} steps: From 4e5c581440e635262743e218752ff9cdbebbf425 Mon Sep 17 00:00:00 2001 From: Ned Twigg Date: Sat, 28 Jan 2023 01:10:02 -0800 Subject: [PATCH 4/7] Migrate java8 compat to the same place. --- build.gradle | 2 -- gradle.properties | 2 ++ 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/build.gradle b/build.gradle index ffddf83..b857a18 100644 --- a/build.gradle +++ b/build.gradle @@ -24,8 +24,6 @@ subprojects { testImplementation "org.junit.jupiter:junit-jupiter-api:${VER_JUNIT_JUPITER}" testRuntimeOnly "org.junit.jupiter:junit-jupiter-engine:${VER_JUNIT_JUPITER}" } - - ext.kotlin_jvmTarget = '1.8' if (it.name == 'atplug-runtime') { ext.maven_name = 'AtPlug runtime' apply plugin: 'kotlinx-serialization' diff --git a/gradle.properties b/gradle.properties index e6e84b0..4914cc3 100644 --- a/gradle.properties +++ b/gradle.properties @@ -6,7 +6,9 @@ plugin_atplug_id=com.diffplug.atplug plugin_atplug_impl=com.diffplug.atplug.tooling.gradle.PlugPlugin plugin_atplug_name=AtPlug Gradle Plugin plugin_atplug_desc=Generates plugin metadata for AtPlug + ver_java=8 +kotlin_jvmTarget=1.8 maven_group=com.diffplug.atplug javadoc_links= From 9f46559c5cdff78d90f05fc2013dc665d381426a Mon Sep 17 00:00:00 2001 From: Ned Twigg Date: Sat, 28 Jan 2023 09:52:05 -0800 Subject: [PATCH 5/7] Fix build on Windows. --- .../atplug/tooling/gradle/PlugPluginTest.kt | 148 +++++++++--------- 1 file changed, 74 insertions(+), 74 deletions(-) diff --git a/atplug-plugin-gradle/src/test/java/com/diffplug/atplug/tooling/gradle/PlugPluginTest.kt b/atplug-plugin-gradle/src/test/java/com/diffplug/atplug/tooling/gradle/PlugPluginTest.kt index 69a9a0b..cadf58f 100644 --- a/atplug-plugin-gradle/src/test/java/com/diffplug/atplug/tooling/gradle/PlugPluginTest.kt +++ b/atplug-plugin-gradle/src/test/java/com/diffplug/atplug/tooling/gradle/PlugPluginTest.kt @@ -1,74 +1,74 @@ -package com.diffplug.atplug.tooling.gradle - -import com.diffplug.atplug.tooling.PlugGeneratorTest -import java.io.File -import java.nio.charset.StandardCharsets -import java.nio.file.Files -import org.junit.jupiter.api.Test - -class PlugPluginTest : GradleIntegrationHarness() { - @Test - fun test() { - val runtimeJar = PlugGeneratorTest.findRuntimeJar().canonicalPath - setFile("build.gradle") - .toContent( - """ - plugins { - id 'org.jetbrains.kotlin.jvm' version '1.8.0' - id 'com.diffplug.atplug' - } - repositories { - mavenCentral() - } - dependencies { - implementation files("$runtimeJar") - implementation "org.jetbrains.kotlinx:kotlinx-serialization-json:1.4.1" - } - """ - .trimIndent()) - - val copy = { str: String -> - val src = File("../atplug-runtime/src/test/java/com/diffplug/atplug/$str") - setFile("src/main/java/com/diffplug/atplug/$str") - .toContent(String(Files.readAllBytes(src.toPath()), StandardCharsets.UTF_8)) - } - copy("Fruit.kt") - copy("Shape.java") - - gradleRunner().withArguments("jar", "--stacktrace").build() - - assertFile("src/main/resources/ATPLUG-INF/com.diffplug.atplug.Apple.json") - .hasContent( - "{\n" + - " \"implementation\": \"com.diffplug.atplug.Apple\",\n" + - " \"provides\": \"com.diffplug.atplug.Fruit\",\n" + - " \"properties\": {\n" + - " \"id\": \"Apple\"\n" + - " }\n" + - "}") - assertFile("src/main/resources/ATPLUG-INF/com.diffplug.atplug.Orange.json") - .hasContent( - "{\n" + - " \"implementation\": \"com.diffplug.atplug.Orange\",\n" + - " \"provides\": \"com.diffplug.atplug.Fruit\",\n" + - " \"properties\": {\n" + - " \"id\": \"Orange\"\n" + - " }\n" + - "}") - assertFile("src/main/resources/ATPLUG-INF/com.diffplug.atplug.Shape\$Circle.json") - .hasContent( - "{\n" + - " \"implementation\": \"com.diffplug.atplug.Shape\$Circle\",\n" + - " \"provides\": \"com.diffplug.atplug.Shape\",\n" + - " \"properties\": {\n" + - " \"id\": \"Circle\"\n" + - " }\n" + - "}") - assertFile("src/main/resources/META-INF/MANIFEST.MF") - .hasContentIgnoreWhitespace( - "Manifest-Version: 1.0\n" + - "AtPlug-Component: ATPLUG-INF/com.diffplug.atplug.Apple.json,ATPLUG-INF/com.d\n" + - " iffplug.atplug.Orange.json,ATPLUG-INF/com.diffplug.atplug.Shape\$Circle.json\n" + - " ,ATPLUG-INF/com.diffplug.atplug.Shape\$Square.json") - } -} +package com.diffplug.atplug.tooling.gradle + +import com.diffplug.atplug.tooling.PlugGeneratorTest +import java.io.File +import java.nio.charset.StandardCharsets +import java.nio.file.Files +import org.junit.jupiter.api.Test + +class PlugPluginTest : GradleIntegrationHarness() { + @Test + fun test() { + val runtimeJar = PlugGeneratorTest.findRuntimeJar().canonicalPath.replace('\\', '/') + setFile("build.gradle") + .toContent( + """ + plugins { + id 'org.jetbrains.kotlin.jvm' version '1.8.0' + id 'com.diffplug.atplug' + } + repositories { + mavenCentral() + } + dependencies { + implementation files("$runtimeJar") + implementation "org.jetbrains.kotlinx:kotlinx-serialization-json:1.4.1" + } + """ + .trimIndent()) + + val copy = { str: String -> + val src = File("../atplug-runtime/src/test/java/com/diffplug/atplug/$str") + setFile("src/main/java/com/diffplug/atplug/$str") + .toContent(String(Files.readAllBytes(src.toPath()), StandardCharsets.UTF_8)) + } + copy("Fruit.kt") + copy("Shape.java") + + gradleRunner().withArguments("jar", "--stacktrace").build() + + assertFile("src/main/resources/ATPLUG-INF/com.diffplug.atplug.Apple.json") + .hasContent( + "{\n" + + " \"implementation\": \"com.diffplug.atplug.Apple\",\n" + + " \"provides\": \"com.diffplug.atplug.Fruit\",\n" + + " \"properties\": {\n" + + " \"id\": \"Apple\"\n" + + " }\n" + + "}") + assertFile("src/main/resources/ATPLUG-INF/com.diffplug.atplug.Orange.json") + .hasContent( + "{\n" + + " \"implementation\": \"com.diffplug.atplug.Orange\",\n" + + " \"provides\": \"com.diffplug.atplug.Fruit\",\n" + + " \"properties\": {\n" + + " \"id\": \"Orange\"\n" + + " }\n" + + "}") + assertFile("src/main/resources/ATPLUG-INF/com.diffplug.atplug.Shape\$Circle.json") + .hasContent( + "{\n" + + " \"implementation\": \"com.diffplug.atplug.Shape\$Circle\",\n" + + " \"provides\": \"com.diffplug.atplug.Shape\",\n" + + " \"properties\": {\n" + + " \"id\": \"Circle\"\n" + + " }\n" + + "}") + assertFile("src/main/resources/META-INF/MANIFEST.MF") + .hasContentIgnoreWhitespace( + "Manifest-Version: 1.0\n" + + "AtPlug-Component: ATPLUG-INF/com.diffplug.atplug.Apple.json,ATPLUG-INF/com.d\n" + + " iffplug.atplug.Orange.json,ATPLUG-INF/com.diffplug.atplug.Shape\$Circle.json\n" + + " ,ATPLUG-INF/com.diffplug.atplug.Shape\$Square.json") + } +} From c4eac70166daf2a9da3646b99164f1167a4ced81 Mon Sep 17 00:00:00 2001 From: Ned Twigg Date: Sat, 28 Jan 2023 13:01:30 -0800 Subject: [PATCH 6/7] spotlessApply --- .../atplug/tooling/gradle/PlugPluginTest.kt | 148 +++++++++--------- 1 file changed, 74 insertions(+), 74 deletions(-) diff --git a/atplug-plugin-gradle/src/test/java/com/diffplug/atplug/tooling/gradle/PlugPluginTest.kt b/atplug-plugin-gradle/src/test/java/com/diffplug/atplug/tooling/gradle/PlugPluginTest.kt index cadf58f..184434c 100644 --- a/atplug-plugin-gradle/src/test/java/com/diffplug/atplug/tooling/gradle/PlugPluginTest.kt +++ b/atplug-plugin-gradle/src/test/java/com/diffplug/atplug/tooling/gradle/PlugPluginTest.kt @@ -1,74 +1,74 @@ -package com.diffplug.atplug.tooling.gradle - -import com.diffplug.atplug.tooling.PlugGeneratorTest -import java.io.File -import java.nio.charset.StandardCharsets -import java.nio.file.Files -import org.junit.jupiter.api.Test - -class PlugPluginTest : GradleIntegrationHarness() { - @Test - fun test() { - val runtimeJar = PlugGeneratorTest.findRuntimeJar().canonicalPath.replace('\\', '/') - setFile("build.gradle") - .toContent( - """ - plugins { - id 'org.jetbrains.kotlin.jvm' version '1.8.0' - id 'com.diffplug.atplug' - } - repositories { - mavenCentral() - } - dependencies { - implementation files("$runtimeJar") - implementation "org.jetbrains.kotlinx:kotlinx-serialization-json:1.4.1" - } - """ - .trimIndent()) - - val copy = { str: String -> - val src = File("../atplug-runtime/src/test/java/com/diffplug/atplug/$str") - setFile("src/main/java/com/diffplug/atplug/$str") - .toContent(String(Files.readAllBytes(src.toPath()), StandardCharsets.UTF_8)) - } - copy("Fruit.kt") - copy("Shape.java") - - gradleRunner().withArguments("jar", "--stacktrace").build() - - assertFile("src/main/resources/ATPLUG-INF/com.diffplug.atplug.Apple.json") - .hasContent( - "{\n" + - " \"implementation\": \"com.diffplug.atplug.Apple\",\n" + - " \"provides\": \"com.diffplug.atplug.Fruit\",\n" + - " \"properties\": {\n" + - " \"id\": \"Apple\"\n" + - " }\n" + - "}") - assertFile("src/main/resources/ATPLUG-INF/com.diffplug.atplug.Orange.json") - .hasContent( - "{\n" + - " \"implementation\": \"com.diffplug.atplug.Orange\",\n" + - " \"provides\": \"com.diffplug.atplug.Fruit\",\n" + - " \"properties\": {\n" + - " \"id\": \"Orange\"\n" + - " }\n" + - "}") - assertFile("src/main/resources/ATPLUG-INF/com.diffplug.atplug.Shape\$Circle.json") - .hasContent( - "{\n" + - " \"implementation\": \"com.diffplug.atplug.Shape\$Circle\",\n" + - " \"provides\": \"com.diffplug.atplug.Shape\",\n" + - " \"properties\": {\n" + - " \"id\": \"Circle\"\n" + - " }\n" + - "}") - assertFile("src/main/resources/META-INF/MANIFEST.MF") - .hasContentIgnoreWhitespace( - "Manifest-Version: 1.0\n" + - "AtPlug-Component: ATPLUG-INF/com.diffplug.atplug.Apple.json,ATPLUG-INF/com.d\n" + - " iffplug.atplug.Orange.json,ATPLUG-INF/com.diffplug.atplug.Shape\$Circle.json\n" + - " ,ATPLUG-INF/com.diffplug.atplug.Shape\$Square.json") - } -} +package com.diffplug.atplug.tooling.gradle + +import com.diffplug.atplug.tooling.PlugGeneratorTest +import java.io.File +import java.nio.charset.StandardCharsets +import java.nio.file.Files +import org.junit.jupiter.api.Test + +class PlugPluginTest : GradleIntegrationHarness() { + @Test + fun test() { + val runtimeJar = PlugGeneratorTest.findRuntimeJar().canonicalPath.replace('\\', '/') + setFile("build.gradle") + .toContent( + """ + plugins { + id 'org.jetbrains.kotlin.jvm' version '1.8.0' + id 'com.diffplug.atplug' + } + repositories { + mavenCentral() + } + dependencies { + implementation files("$runtimeJar") + implementation "org.jetbrains.kotlinx:kotlinx-serialization-json:1.4.1" + } + """ + .trimIndent()) + + val copy = { str: String -> + val src = File("../atplug-runtime/src/test/java/com/diffplug/atplug/$str") + setFile("src/main/java/com/diffplug/atplug/$str") + .toContent(String(Files.readAllBytes(src.toPath()), StandardCharsets.UTF_8)) + } + copy("Fruit.kt") + copy("Shape.java") + + gradleRunner().withArguments("jar", "--stacktrace").build() + + assertFile("src/main/resources/ATPLUG-INF/com.diffplug.atplug.Apple.json") + .hasContent( + "{\n" + + " \"implementation\": \"com.diffplug.atplug.Apple\",\n" + + " \"provides\": \"com.diffplug.atplug.Fruit\",\n" + + " \"properties\": {\n" + + " \"id\": \"Apple\"\n" + + " }\n" + + "}") + assertFile("src/main/resources/ATPLUG-INF/com.diffplug.atplug.Orange.json") + .hasContent( + "{\n" + + " \"implementation\": \"com.diffplug.atplug.Orange\",\n" + + " \"provides\": \"com.diffplug.atplug.Fruit\",\n" + + " \"properties\": {\n" + + " \"id\": \"Orange\"\n" + + " }\n" + + "}") + assertFile("src/main/resources/ATPLUG-INF/com.diffplug.atplug.Shape\$Circle.json") + .hasContent( + "{\n" + + " \"implementation\": \"com.diffplug.atplug.Shape\$Circle\",\n" + + " \"provides\": \"com.diffplug.atplug.Shape\",\n" + + " \"properties\": {\n" + + " \"id\": \"Circle\"\n" + + " }\n" + + "}") + assertFile("src/main/resources/META-INF/MANIFEST.MF") + .hasContentIgnoreWhitespace( + "Manifest-Version: 1.0\n" + + "AtPlug-Component: ATPLUG-INF/com.diffplug.atplug.Apple.json,ATPLUG-INF/com.d\n" + + " iffplug.atplug.Orange.json,ATPLUG-INF/com.diffplug.atplug.Shape\$Circle.json\n" + + " ,ATPLUG-INF/com.diffplug.atplug.Shape\$Square.json") + } +} From 57fe1fba9953310f1b718c990211bf62f26a62e4 Mon Sep 17 00:00:00 2001 From: Ned Twigg Date: Sat, 28 Jan 2023 13:04:17 -0800 Subject: [PATCH 7/7] Add the missing .gitattributes file. --- .gitattributes | 2 ++ 1 file changed, 2 insertions(+) create mode 100644 .gitattributes diff --git a/.gitattributes b/.gitattributes new file mode 100644 index 0000000..2ff7738 --- /dev/null +++ b/.gitattributes @@ -0,0 +1,2 @@ +* text eol=lf +*.jar binary