From f08ad751f6fe54f7949093a91b560061dae3e70c Mon Sep 17 00:00:00 2001 From: Justin Brooks Date: Mon, 15 Feb 2021 20:58:21 -0600 Subject: [PATCH] Add a gradle plugin Resolves #20 --- .github/readme.md | 31 +++ .github/workflows/{gradle.yml => build.yml} | 5 - .github/workflows/publish.yml | 37 ++++ .idea/gradle.xml | 1 + .idea/jarRepositories.xml | 10 + .../Gradle__com_jzbrooks_vgo_1_4_0.xml | 9 + .../Gradle__com_jzbrooks_vgo_core_1_4_0.xml | 9 + ...Gradle__org_jetbrains_annotations_13_0.xml | 4 +- ...jetbrains_kotlin_kotlin_reflect_1_4_20.xml | 11 + ..._jetbrains_kotlin_kotlin_stdlib_1_4_21.xml | 4 +- ...ins_kotlin_kotlin_stdlib_common_1_4_21.xml | 4 +- ...rains_kotlin_kotlin_stdlib_jdk7_1_4_21.xml | 4 +- ...rains_kotlin_kotlin_stdlib_jdk8_1_4_21.xml | 4 +- .idea/modules.xml | 5 +- .idea/modules/vgo-core/vgo.vgo-core.main.iml | 1 + .idea/modules/vgo-core/vgo.vgo-core.test.iml | 3 + .idea/modules/vgo-plugin.iml | 10 + .idea/modules/vgo-plugin/vgo.vgo-plugin.iml | 13 ++ .../vgo-plugin/vgo.vgo-plugin.main.iml | 161 ++++++++++++++ .../vgo-plugin/vgo.vgo-plugin.test.iml | 197 ++++++++++++++++++ .idea/modules/vgo/vgo.vgo.integrationTest.iml | 5 + .idea/modules/vgo/vgo.vgo.main.iml | 1 + .idea/modules/vgo/vgo.vgo.test.iml | 1 + .idea/runConfigurations/test.xml | 3 + build.gradle.kts | 33 ++- build.properties | 1 + changelog.md | 8 + settings.gradle.kts | 2 +- vgo-core/build.gradle.kts | 71 ++++++- .../vgo/core}/svg/ScalableVectorGraphic.kt | 2 +- .../ScalableVectorGraphicCommandPrinter.kt | 2 +- .../core}/svg/ScalableVectorGraphicReader.kt | 8 +- .../core}/svg/ScalableVectorGraphicWriter.kt | 4 +- .../vgo/core}/svg/SvgOptimizationRegistry.kt | 4 +- .../vgo/core}/svg/VectorDrawableConverter.kt | 8 +- .../vgo/core}/svg/graphic/ClipPath.kt | 2 +- .../svg/optimization/BakeTransformations.kt | 2 +- .../vgo/core}/util/xml/XmlExtensions.kt | 2 +- .../com/jzbrooks/vgo/core}/vd/SvgConverter.kt | 6 +- .../jzbrooks/vgo/core}/vd/VectorDrawable.kt | 2 +- .../core}/vd/VectorDrawableCommandPrinter.kt | 2 +- .../vd/VectorDrawableOptimizationRegistry.kt | 4 +- .../vgo/core}/vd/VectorDrawableReader.kt | 8 +- .../vgo/core}/vd/VectorDrawableWriter.kt | 4 +- .../jzbrooks/vgo/core}/vd/graphic/ClipPath.kt | 2 +- .../vd/optimization/BakeTransformations.kt | 2 +- .../optimization/RemoveRedundantAttributes.kt | 4 +- .../vgo/{ => core}/assertk/extensions/Map.kt | 2 +- .../vgo/core}/assertk/extensions/Node.kt | 2 +- .../svg/ScalableVectorGraphicReaderTests.kt | 8 +- .../svg/ScalableVectorGraphicWriterTests.kt | 10 +- .../core}/svg/VectorDrawableConverterTests.kt | 6 +- .../vgo/core}/vd/SvgConverterTests.kt | 4 +- .../vd/VectorDrawableCommandPrinterTests.kt | 2 +- .../vgo/core}/vd/VectorDrawableReaderTests.kt | 8 +- .../vgo/core}/vd/VectorDrawableWriterTests.kt | 12 +- .../optimization/BakeTransformationsTests.kt | 6 +- .../optimization/ConvertCurvesToArcsTest.kt | 5 +- .../RemoveRedundantAttributesTests.kt | 4 +- .../src/test}/resources/avocado_example.xml | 0 .../src/test}/resources/simple_heart.svg | 0 .../test/resources/vd_visibilitystrike.xml | 0 vgo-plugin/.gitignore | 1 + vgo-plugin/build.gradle.kts | 92 ++++++++ .../com/jzbrooks/vgo/plugin/VgoPlugin.kt | 46 ++++ .../jzbrooks/vgo/plugin/VgoPluginExtension.kt | 17 ++ .../com/jzbrooks/vgo/plugin/VgoPluginTest.kt | 37 ++++ .../caches/journal-1/file-access.properties | 2 + vgo/build.gradle.kts | 176 +++++++++------- vgo/build.properties | 1 - .../kotlin/com/jzbrooks/vgo/Application.kt | 21 +- .../kotlin/com/jzbrooks/vgo/BaselineTests.kt | 4 +- .../jzbrooks/vgo/CommandLineInterfaceTests.kt | 10 +- .../jzbrooks/vgo/InPlaceModificationTest.kt | 20 +- .../jzbrooks/vgo/assertk/extensions/Map.kt | 26 --- .../baseline/avocado_example_optimized.xml | 0 .../baseline/charging_battery_optimized.xml | 0 .../baseline/dribbble_ball_mark_optimized.svg | 0 .../baseline/dribbble_ball_mark_optimized.xml | 0 .../eleven_below_single_optimized.svg | 0 .../eleven_below_single_optimized.xml | 0 .../baseline/guacamole_optimized.svg | 0 .../resources/baseline/nasa_optimized.svg | 0 .../resources/baseline/nasa_optimized.xml | 0 .../baseline/regression-31_optimized.xml | 0 .../baseline/regression_31_optimized.xml | 0 .../baseline/simple_heart_optimized.svg | 0 .../baseline/simple_heart_optimized.xml | 0 .../resources/baseline/tiger_optimized.svg | 0 .../resources/baseline/tiger_optimized.xml | 0 .../baseline/visibility_strike_optimized.xml | 0 .../resources/charging_battery.xml | 0 .../resources/dribbble_ball_mark.svg | 0 .../resources/dribbble_ball_mark.xml | 0 .../resources/eleven_below_single.svg | 0 .../resources/eleven_below_single.xml | 0 .../resources/guacamole.svg | 0 .../in-place-modify/avocado_example.xml | 0 .../avocado_example_optimized.xml | 0 .../resources/in-place-modify/non_vector.xml | 0 .../resources/nasa.svg | 0 .../resources/nasa.xml | 0 .../resources/regression_31.xml | 0 .../resources/simple_heart.xml | 0 .../resources/tiger.svg | 0 .../resources/tiger.xml | 0 .../resources/visibility_strike.xml | 0 107 files changed, 1024 insertions(+), 214 deletions(-) rename .github/workflows/{gradle.yml => build.yml} (83%) create mode 100644 .github/workflows/publish.yml create mode 100644 .idea/libraries/Gradle__com_jzbrooks_vgo_1_4_0.xml create mode 100644 .idea/libraries/Gradle__com_jzbrooks_vgo_core_1_4_0.xml create mode 100644 .idea/libraries/Gradle__org_jetbrains_kotlin_kotlin_reflect_1_4_20.xml create mode 100644 .idea/modules/vgo-plugin.iml create mode 100644 .idea/modules/vgo-plugin/vgo.vgo-plugin.iml create mode 100644 .idea/modules/vgo-plugin/vgo.vgo-plugin.main.iml create mode 100644 .idea/modules/vgo-plugin/vgo.vgo-plugin.test.iml create mode 100644 .idea/modules/vgo/vgo.vgo.integrationTest.iml create mode 100644 build.properties rename {vgo/src/main/kotlin/com/jzbrooks/vgo => vgo-core/src/main/kotlin/com/jzbrooks/vgo/core}/svg/ScalableVectorGraphic.kt (87%) rename {vgo/src/main/kotlin/com/jzbrooks/vgo => vgo-core/src/main/kotlin/com/jzbrooks/vgo/core}/svg/ScalableVectorGraphicCommandPrinter.kt (99%) rename {vgo/src/main/kotlin/com/jzbrooks/vgo => vgo-core/src/main/kotlin/com/jzbrooks/vgo/core}/svg/ScalableVectorGraphicReader.kt (91%) rename {vgo/src/main/kotlin/com/jzbrooks/vgo => vgo-core/src/main/kotlin/com/jzbrooks/vgo/core}/svg/ScalableVectorGraphicWriter.kt (97%) rename {vgo/src/main/kotlin/com/jzbrooks/vgo => vgo-core/src/main/kotlin/com/jzbrooks/vgo/core}/svg/SvgOptimizationRegistry.kt (90%) rename {vgo/src/main/kotlin/com/jzbrooks/vgo => vgo-core/src/main/kotlin/com/jzbrooks/vgo/core}/svg/VectorDrawableConverter.kt (98%) rename {vgo/src/main/kotlin/com/jzbrooks/vgo => vgo-core/src/main/kotlin/com/jzbrooks/vgo/core}/svg/graphic/ClipPath.kt (86%) rename {vgo/src/main/kotlin/com/jzbrooks/vgo => vgo-core/src/main/kotlin/com/jzbrooks/vgo/core}/svg/optimization/BakeTransformations.kt (99%) rename {vgo/src/main/kotlin/com/jzbrooks/vgo => vgo-core/src/main/kotlin/com/jzbrooks/vgo/core}/util/xml/XmlExtensions.kt (94%) rename {vgo/src/main/kotlin/com/jzbrooks/vgo => vgo-core/src/main/kotlin/com/jzbrooks/vgo/core}/vd/SvgConverter.kt (98%) rename {vgo/src/main/kotlin/com/jzbrooks/vgo => vgo-core/src/main/kotlin/com/jzbrooks/vgo/core}/vd/VectorDrawable.kt (87%) rename {vgo/src/main/kotlin/com/jzbrooks/vgo => vgo-core/src/main/kotlin/com/jzbrooks/vgo/core}/vd/VectorDrawableCommandPrinter.kt (99%) rename {vgo/src/main/kotlin/com/jzbrooks/vgo => vgo-core/src/main/kotlin/com/jzbrooks/vgo/core}/vd/VectorDrawableOptimizationRegistry.kt (90%) rename {vgo/src/main/kotlin/com/jzbrooks/vgo => vgo-core/src/main/kotlin/com/jzbrooks/vgo/core}/vd/VectorDrawableReader.kt (92%) rename {vgo/src/main/kotlin/com/jzbrooks/vgo => vgo-core/src/main/kotlin/com/jzbrooks/vgo/core}/vd/VectorDrawableWriter.kt (97%) rename {vgo/src/main/kotlin/com/jzbrooks/vgo => vgo-core/src/main/kotlin/com/jzbrooks/vgo/core}/vd/graphic/ClipPath.kt (86%) rename {vgo/src/main/kotlin/com/jzbrooks/vgo => vgo-core/src/main/kotlin/com/jzbrooks/vgo/core}/vd/optimization/BakeTransformations.kt (99%) rename {vgo/src/main/kotlin/com/jzbrooks/vgo => vgo-core/src/main/kotlin/com/jzbrooks/vgo/core}/vd/optimization/RemoveRedundantAttributes.kt (93%) rename vgo-core/src/test/kotlin/com/jzbrooks/vgo/{ => core}/assertk/extensions/Map.kt (93%) rename {vgo/src/test/kotlin/com/jzbrooks/vgo => vgo-core/src/test/kotlin/com/jzbrooks/vgo/core}/assertk/extensions/Node.kt (93%) rename {vgo/src/test/kotlin/com/jzbrooks/vgo => vgo-core/src/test/kotlin/com/jzbrooks/vgo/core}/svg/ScalableVectorGraphicReaderTests.kt (96%) rename {vgo/src/test/kotlin/com/jzbrooks/vgo => vgo-core/src/test/kotlin/com/jzbrooks/vgo/core}/svg/ScalableVectorGraphicWriterTests.kt (95%) rename {vgo/src/test/kotlin/com/jzbrooks/vgo => vgo-core/src/test/kotlin/com/jzbrooks/vgo/core}/svg/VectorDrawableConverterTests.kt (98%) rename {vgo/src/test/kotlin/com/jzbrooks/vgo => vgo-core/src/test/kotlin/com/jzbrooks/vgo/core}/vd/SvgConverterTests.kt (99%) rename {vgo/src/test/kotlin/com/jzbrooks/vgo => vgo-core/src/test/kotlin/com/jzbrooks/vgo/core}/vd/VectorDrawableCommandPrinterTests.kt (99%) rename {vgo/src/test/kotlin/com/jzbrooks/vgo => vgo-core/src/test/kotlin/com/jzbrooks/vgo/core}/vd/VectorDrawableReaderTests.kt (96%) rename {vgo/src/test/kotlin/com/jzbrooks/vgo => vgo-core/src/test/kotlin/com/jzbrooks/vgo/core}/vd/VectorDrawableWriterTests.kt (95%) rename {vgo/src/test/kotlin/com/jzbrooks/vgo => vgo-core/src/test/kotlin/com/jzbrooks/vgo/core}/vd/optimization/BakeTransformationsTests.kt (98%) rename {vgo/src/test/kotlin/com/jzbrooks/vgo => vgo-core/src/test/kotlin/com/jzbrooks/vgo/core}/vd/optimization/ConvertCurvesToArcsTest.kt (97%) rename {vgo/src/test/kotlin/com/jzbrooks/vgo => vgo-core/src/test/kotlin/com/jzbrooks/vgo/core}/vd/optimization/RemoveRedundantAttributesTests.kt (95%) rename {vgo/src/integration-test => vgo-core/src/test}/resources/avocado_example.xml (100%) rename {vgo/src/integration-test => vgo-core/src/test}/resources/simple_heart.svg (100%) rename {vgo => vgo-core}/src/test/resources/vd_visibilitystrike.xml (100%) create mode 100644 vgo-plugin/.gitignore create mode 100644 vgo-plugin/build.gradle.kts create mode 100644 vgo-plugin/src/main/kotlin/com/jzbrooks/vgo/plugin/VgoPlugin.kt create mode 100644 vgo-plugin/src/main/kotlin/com/jzbrooks/vgo/plugin/VgoPluginExtension.kt create mode 100644 vgo-plugin/src/test/kotlin/com/jzbrooks/vgo/plugin/VgoPluginTest.kt create mode 100644 vgo-plugin/src/test/userHome/caches/journal-1/file-access.properties delete mode 100644 vgo/build.properties rename vgo/src/{integration-test => test}/kotlin/com/jzbrooks/vgo/BaselineTests.kt (96%) rename vgo/src/{integration-test => test}/kotlin/com/jzbrooks/vgo/CommandLineInterfaceTests.kt (92%) rename vgo/src/{integration-test => test}/kotlin/com/jzbrooks/vgo/InPlaceModificationTest.kt (68%) delete mode 100644 vgo/src/test/kotlin/com/jzbrooks/vgo/assertk/extensions/Map.kt rename vgo/src/{integration-test => test}/resources/baseline/avocado_example_optimized.xml (100%) rename vgo/src/{integration-test => test}/resources/baseline/charging_battery_optimized.xml (100%) rename vgo/src/{integration-test => test}/resources/baseline/dribbble_ball_mark_optimized.svg (100%) rename vgo/src/{integration-test => test}/resources/baseline/dribbble_ball_mark_optimized.xml (100%) rename vgo/src/{integration-test => test}/resources/baseline/eleven_below_single_optimized.svg (100%) rename vgo/src/{integration-test => test}/resources/baseline/eleven_below_single_optimized.xml (100%) rename vgo/src/{integration-test => test}/resources/baseline/guacamole_optimized.svg (100%) rename vgo/src/{integration-test => test}/resources/baseline/nasa_optimized.svg (100%) rename vgo/src/{integration-test => test}/resources/baseline/nasa_optimized.xml (100%) rename vgo/src/{integration-test => test}/resources/baseline/regression-31_optimized.xml (100%) rename vgo/src/{integration-test => test}/resources/baseline/regression_31_optimized.xml (100%) rename vgo/src/{integration-test => test}/resources/baseline/simple_heart_optimized.svg (100%) rename vgo/src/{integration-test => test}/resources/baseline/simple_heart_optimized.xml (100%) rename vgo/src/{integration-test => test}/resources/baseline/tiger_optimized.svg (100%) rename vgo/src/{integration-test => test}/resources/baseline/tiger_optimized.xml (100%) rename vgo/src/{integration-test => test}/resources/baseline/visibility_strike_optimized.xml (100%) rename vgo/src/{integration-test => test}/resources/charging_battery.xml (100%) rename vgo/src/{integration-test => test}/resources/dribbble_ball_mark.svg (100%) rename vgo/src/{integration-test => test}/resources/dribbble_ball_mark.xml (100%) rename vgo/src/{integration-test => test}/resources/eleven_below_single.svg (100%) rename vgo/src/{integration-test => test}/resources/eleven_below_single.xml (100%) rename vgo/src/{integration-test => test}/resources/guacamole.svg (100%) rename vgo/src/{integration-test => test}/resources/in-place-modify/avocado_example.xml (100%) rename vgo/src/{integration-test => test}/resources/in-place-modify/avocado_example_optimized.xml (100%) rename vgo/src/{integration-test => test}/resources/in-place-modify/non_vector.xml (100%) rename vgo/src/{integration-test => test}/resources/nasa.svg (100%) rename vgo/src/{integration-test => test}/resources/nasa.xml (100%) rename vgo/src/{integration-test => test}/resources/regression_31.xml (100%) rename vgo/src/{integration-test => test}/resources/simple_heart.xml (100%) rename vgo/src/{integration-test => test}/resources/tiger.svg (100%) rename vgo/src/{integration-test => test}/resources/tiger.xml (100%) rename vgo/src/{integration-test => test}/resources/visibility_strike.xml (100%) diff --git a/.github/readme.md b/.github/readme.md index d77ee1d3..d63e5075 100644 --- a/.github/readme.md +++ b/.github/readme.md @@ -8,6 +8,37 @@ vgo is a tool for optimizing vector artwork files that helps ensure your vector Download the distribution from the releases page and ensure it has execute permission. On macOS & Linux run `chmod +x vgo`. +## Gradle Plugin +Add the plugin to your buildscript classpath. +``` +buildscript { + repositories { + mavenCentral() + } + + dependencies { + classpath "com.jzbrooks:vgo-plugin:1.4.0" + } +} +``` + +Then, in the relevant project, add the plugin. +``` +plugins { + id 'com.jzbrooks.vgo' +} + +vgo { + inputs = fileTree(projectDir) { + include '**/res/drawable*/*.xml' + } + outputs = inputs + showStatistics = true + format = OutputFormat.UNCHANGED + indent = 0 +} +``` + ## Command Line Interface ``` diff --git a/.github/workflows/gradle.yml b/.github/workflows/build.yml similarity index 83% rename from .github/workflows/gradle.yml rename to .github/workflows/build.yml index 0f325dc2..07cb764e 100644 --- a/.github/workflows/gradle.yml +++ b/.github/workflows/build.yml @@ -32,11 +32,6 @@ jobs: with: name: vgo_core_test_results path: vgo-core/build/reports/tests/test/ - - name: archive integration test results - uses: actions/upload-artifact@v1 - with: - name: integration_test_results - path: vgo/build/reports/tests/integrationTest - name: release binary run: ./gradlew binary - name: archive vgo diff --git a/.github/workflows/publish.yml b/.github/workflows/publish.yml new file mode 100644 index 00000000..b1193446 --- /dev/null +++ b/.github/workflows/publish.yml @@ -0,0 +1,37 @@ +name: publish + +on: + release: + types: [released] + +jobs: + publish: + name: Release build and publish + runs-on: ubuntu-latest + steps: + - name: Check out code + uses: actions/checkout@v2 + + - name: set up JDK + id: setup-jdk + uses: actions/setup-java@v1 + with: + java-version: 11 + + - name: Create binary keyring + env: + GPG_KEY_CONTENTS: ${{ secrets.SIGNING_KEY_SECRET }} + SIGNING_KEY_RING_FILE: ${{ secrets.SIGNING_KEY_FILE_PATH }} + run: | + git fetch --unshallow + sudo bash -c "echo '$GPG_KEY_CONTENTS' | base64 -d > '$SIGNING_KEY_RING_FILE'" + + - name: Publish to MavenCentral + run: ./gradlew --max-workers 1 --no-daemon publishReleasePublicationToSonatypeRepository closeAndReleaseRepository + env: + SIGNING_KEY_ID: ${{ secrets.SIGNING_KEY_ID }} + SIGNING_PASSWORD: ${{ secrets.SIGNING_KEY_PASSWORD }} + SIGNING_KEY_FILE_PATH: ${{ secrets.SIGNING_KEY_FILE_PATH }} + OSSRH_USERNAME: ${{ secrets.OSSRH_USERNAME }} + OSSRH_PASSWORD: ${{ secrets.OSSRH_PASSWORD }} + SONATYPE_PROFILE_ID: ${{ secrets.SONATYPE_PROFILE_ID }} \ No newline at end of file diff --git a/.idea/gradle.xml b/.idea/gradle.xml index 55a34cee..72a8a920 100644 --- a/.idea/gradle.xml +++ b/.idea/gradle.xml @@ -14,6 +14,7 @@