├── jaxb2-plugin ├── gradle.properties ├── src │ ├── main │ │ ├── resources │ │ │ └── META-INF │ │ │ │ └── gradle-plugins │ │ │ │ └── com.ewerk.gradle.plugins.jaxb2.properties │ │ └── groovy │ │ │ └── com │ │ │ └── ewerk │ │ │ └── gradle │ │ │ └── plugins │ │ │ ├── Jaxb2PluginExtension.groovy │ │ │ ├── tasks │ │ │ ├── XjcTaskConfig.groovy │ │ │ ├── CleanJaxb2SourcesDir.groovy │ │ │ ├── InitJaxb2SourcesDir.groovy │ │ │ └── GenerateJaxb2Classes.groovy │ │ │ └── Jaxb2Plugin.groovy │ └── test │ │ └── groovy │ │ └── com │ │ └── ewerk │ │ └── gradle │ │ └── plugins │ │ ├── Jaxb2PluginExtensionTest.groovy │ │ └── Jaxb2PluginTest.groovy ├── out │ └── production │ │ └── resources │ │ └── META-INF │ │ └── gradle-plugins │ │ └── com.ewerk.gradle.plugins.jaxb2.properties ├── build.gradle ├── change_log.md └── readme.md ├── auto-value-plugin ├── gradle.properties ├── src │ ├── main │ │ ├── resources │ │ │ └── META-INF │ │ │ │ └── gradle-plugins │ │ │ │ └── com.ewerk.gradle.plugins.auto-value.properties │ │ └── groovy │ │ │ └── com │ │ │ └── ewerk │ │ │ └── gradle │ │ │ └── plugins │ │ │ ├── AutoValuePluginExtension.groovy │ │ │ ├── tasks │ │ │ ├── CleanAutoValueSourcesDir.groovy │ │ │ └── InitAutoValueSourcesDir.groovy │ │ │ └── AutoValuePlugin.groovy │ └── test │ │ └── groovy │ │ └── com │ │ └── ewerk │ │ └── gradle │ │ └── plugins │ │ ├── AutoValuePluginExtensionTest.groovy │ │ ├── tasks │ │ └── InitAutoValueSourcesDirTest.groovy │ │ └── AutoValuePluginTest.groovy ├── out │ └── production │ │ └── resources │ │ └── META-INF │ │ └── gradle-plugins │ │ └── com.ewerk.gradle.plugins.auto-value.properties ├── build.gradle ├── change_log.md └── readme.md ├── dagger-plugin ├── gradle.properties ├── src │ ├── main │ │ ├── resources │ │ │ └── META-INF │ │ │ │ └── gradle-plugins │ │ │ │ └── com.ewerk.gradle.plugins.dagger.properties │ │ └── groovy │ │ │ └── com │ │ │ └── ewerk │ │ │ └── gradle │ │ │ └── plugins │ │ │ ├── DaggerPluginExtension.groovy │ │ │ ├── tasks │ │ │ ├── InitDaggerSourcesDir.groovy │ │ │ ├── CleanDaggerSourcesDir.groovy │ │ │ └── DaggerCompile.groovy │ │ │ └── DaggerPlugin.groovy │ └── test │ │ └── groovy │ │ └── com │ │ └── ewerk │ │ └── gradle │ │ └── plugins │ │ ├── tasks │ │ └── DaggerTaskTest.groovy │ │ ├── DaggerAndroidPluginTest.groovy │ │ └── DaggerJavaPluginTest.groovy ├── out │ └── production │ │ └── resources │ │ └── META-INF │ │ └── gradle-plugins │ │ └── com.ewerk.gradle.plugins.dagger.properties ├── change_log.md ├── build.gradle └── readme.md ├── querydsl-plugin ├── gradle.properties ├── src │ ├── main │ │ ├── resources │ │ │ └── META-INF │ │ │ │ └── gradle-plugins │ │ │ │ └── com.ewerk.gradle.plugins.querydsl.properties │ │ └── groovy │ │ │ └── com │ │ │ └── ewerk │ │ │ └── gradle │ │ │ └── plugins │ │ │ ├── tasks │ │ │ ├── InitQuerydslSourcesDir.groovy │ │ │ ├── QuerydslCompile.groovy │ │ │ └── CleanQuerydslSourcesDir.groovy │ │ │ ├── QuerydslPluginExtension.groovy │ │ │ └── QuerydslPlugin.groovy │ └── test │ │ └── groovy │ │ └── com │ │ └── ewerk │ │ └── gradle │ │ └── plugins │ │ ├── tasks │ │ ├── InitQuerydslSourcesDirTest.groovy │ │ └── QuerydslCompileTest.groovy │ │ ├── QuerydslPluginExtensionTest.groovy │ │ └── QuerydslPluginTest.groovy ├── out │ └── production │ │ └── resources │ │ └── META-INF │ │ └── gradle-plugins │ │ └── com.ewerk.gradle.plugins.querydsl.properties ├── build.gradle ├── change_log.md └── readme.md ├── integration-test-plugin ├── gradle.properties ├── src │ ├── test │ │ ├── META-INF │ │ │ └── gradle-plugins │ │ │ │ └── com.ewerk.gradle.plugins.integration-test.properties │ │ └── groovy │ │ │ └── com │ │ │ └── ewerk │ │ │ └── gradle │ │ │ └── plugins │ │ │ └── IntegrationTestPluginTest.groovy │ └── main │ │ ├── resources │ │ └── META-INF │ │ │ └── gradle-plugins │ │ │ └── com.ewerk.gradle.plugins.integration-test.properties │ │ └── groovy │ │ └── com │ │ └── ewerk │ │ └── gradle │ │ └── plugins │ │ └── IntegrationTestPlugin.groovy ├── out │ └── production │ │ └── resources │ │ └── META-INF │ │ └── gradle-plugins │ │ └── com.ewerk.gradle.plugins.integration-test.properties ├── change_log.md ├── build.gradle └── readme.md ├── annotation-processor-plugin ├── gradle.properties ├── src │ ├── main │ │ ├── resources │ │ │ └── META-INF │ │ │ │ └── gradle-plugins │ │ │ │ └── com.ewerk.gradle.plugins.annotation-processor.properties │ │ └── groovy │ │ │ └── com │ │ │ └── ewerk │ │ │ └── gradle │ │ │ └── plugins │ │ │ ├── AnnotationProcessorPluginExtension.groovy │ │ │ ├── tasks │ │ │ ├── InitAnnotationProcessorGeneratedDir.groovy │ │ │ ├── CleanAnnotationProcessorGeneratedDir.groovy │ │ │ └── AnnotationProcessorCompile.groovy │ │ │ └── AnnotationProcessorPlugin.groovy │ └── test │ │ └── groovy │ │ └── com │ │ └── ewerk │ │ └── gradle │ │ └── plugins │ │ ├── tasks │ │ └── AnnotationProcessorTaskTest.groovy │ │ └── AnnotationProcessorPluginTest.groovy ├── out │ └── production │ │ └── resources │ │ └── META-INF │ │ └── gradle-plugins │ │ └── com.ewerk.gradle.plugins.annotation-processor.properties ├── change_log.md ├── build.gradle └── readme.md ├── gradle └── wrapper │ ├── gradle-wrapper.jar │ └── gradle-wrapper.properties ├── artifactory-deb-publish-plugin ├── gradle.properties ├── src │ ├── main │ │ ├── resources │ │ │ └── META-INF │ │ │ │ └── gradle-plugins │ │ │ │ └── com.ewerk.gradle.plugins.artifactory-deb-publish.properties │ │ └── groovy │ │ │ └── com │ │ │ └── ewerk │ │ │ └── gradle │ │ │ └── plugins │ │ │ ├── util │ │ │ ├── Checksums.groovy │ │ │ ├── Urls.groovy │ │ │ └── ArtifactoryHttpClient.groovy │ │ │ ├── PublishException.java │ │ │ ├── ArtifactoryDebPublishPlugin.groovy │ │ │ ├── tasks │ │ │ └── PushDebToArtifactory.groovy │ │ │ └── ArtifactoryDebPublishPluginExtension.groovy │ └── test │ │ └── groovy │ │ └── com │ │ └── ewerk │ │ └── gradle │ │ └── plugins │ │ ├── util │ │ └── ChecksumsTest.java │ │ ├── ArtifactoryDebPushDebToArtifactoryPluginTest.groovy │ │ └── ArtifactoryDebPublishPluginExtensionTest.groovy ├── out │ └── production │ │ └── resources │ │ └── META-INF │ │ └── gradle-plugins │ │ └── com.ewerk.gradle.plugins.artifactory-deb-publish.properties ├── change_log.md ├── build.gradle └── readme.md ├── .gitignore ├── gradle.properties ├── settings.gradle ├── .travis.yml ├── gradlew.bat ├── CONTRIBUTING.md ├── README.md ├── gradlew └── LICENSE /jaxb2-plugin/gradle.properties: -------------------------------------------------------------------------------- 1 | version=1.0.11-SNAPSHOT 2 | -------------------------------------------------------------------------------- /auto-value-plugin/gradle.properties: -------------------------------------------------------------------------------- 1 | #Tue, 21 Apr 2015 13:08:33 +0200 2 | version=1.0.9-SNAPSHOT -------------------------------------------------------------------------------- /dagger-plugin/gradle.properties: -------------------------------------------------------------------------------- 1 | #Mon, 24 Aug 2015 13:08:24 +0200 2 | version=1.0.5-SNAPSHOT 3 | -------------------------------------------------------------------------------- /querydsl-plugin/gradle.properties: -------------------------------------------------------------------------------- 1 | #Wed, 22 Apr 2015 16:42:06 +0200 2 | version=1.0.11-SNAPSHOT 3 | -------------------------------------------------------------------------------- /integration-test-plugin/gradle.properties: -------------------------------------------------------------------------------- 1 | #Wed, 22 Apr 2015 11:59:04 +0200 2 | version=1.0.10-SNAPSHOT -------------------------------------------------------------------------------- /annotation-processor-plugin/gradle.properties: -------------------------------------------------------------------------------- 1 | #Tue, 09 Jun 2015 14:28:03 +0200 2 | version=1.0.5-SNAPSHOT 3 | -------------------------------------------------------------------------------- /gradle/wrapper/gradle-wrapper.jar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ewerk/gradle-plugins/HEAD/gradle/wrapper/gradle-wrapper.jar -------------------------------------------------------------------------------- /dagger-plugin/src/main/resources/META-INF/gradle-plugins/com.ewerk.gradle.plugins.dagger.properties: -------------------------------------------------------------------------------- 1 | implementation-class=com.ewerk.gradle.plugins.DaggerPlugin -------------------------------------------------------------------------------- /jaxb2-plugin/src/main/resources/META-INF/gradle-plugins/com.ewerk.gradle.plugins.jaxb2.properties: -------------------------------------------------------------------------------- 1 | implementation-class=com.ewerk.gradle.plugins.Jaxb2Plugin -------------------------------------------------------------------------------- /artifactory-deb-publish-plugin/gradle.properties: -------------------------------------------------------------------------------- 1 | #Tue, 09 Jun 2015 10:47:18 +0200 2 | version=1.0.3-SNAPSHOT 3 | 4 | # dependencies 5 | okHttpVersion=2.4.0 6 | -------------------------------------------------------------------------------- /dagger-plugin/out/production/resources/META-INF/gradle-plugins/com.ewerk.gradle.plugins.dagger.properties: -------------------------------------------------------------------------------- 1 | implementation-class=com.ewerk.gradle.plugins.DaggerPlugin -------------------------------------------------------------------------------- /jaxb2-plugin/out/production/resources/META-INF/gradle-plugins/com.ewerk.gradle.plugins.jaxb2.properties: -------------------------------------------------------------------------------- 1 | implementation-class=com.ewerk.gradle.plugins.Jaxb2Plugin -------------------------------------------------------------------------------- /querydsl-plugin/src/main/resources/META-INF/gradle-plugins/com.ewerk.gradle.plugins.querydsl.properties: -------------------------------------------------------------------------------- 1 | implementation-class=com.ewerk.gradle.plugins.QuerydslPlugin -------------------------------------------------------------------------------- /auto-value-plugin/src/main/resources/META-INF/gradle-plugins/com.ewerk.gradle.plugins.auto-value.properties: -------------------------------------------------------------------------------- 1 | implementation-class=com.ewerk.gradle.plugins.AutoValuePlugin -------------------------------------------------------------------------------- /querydsl-plugin/out/production/resources/META-INF/gradle-plugins/com.ewerk.gradle.plugins.querydsl.properties: -------------------------------------------------------------------------------- 1 | implementation-class=com.ewerk.gradle.plugins.QuerydslPlugin -------------------------------------------------------------------------------- /auto-value-plugin/out/production/resources/META-INF/gradle-plugins/com.ewerk.gradle.plugins.auto-value.properties: -------------------------------------------------------------------------------- 1 | implementation-class=com.ewerk.gradle.plugins.AutoValuePlugin -------------------------------------------------------------------------------- /integration-test-plugin/src/test/META-INF/gradle-plugins/com.ewerk.gradle.plugins.integration-test.properties: -------------------------------------------------------------------------------- 1 | implementation-class=com.ewerk.gradle.plugins.IntegrationTestPlugin -------------------------------------------------------------------------------- /integration-test-plugin/src/main/resources/META-INF/gradle-plugins/com.ewerk.gradle.plugins.integration-test.properties: -------------------------------------------------------------------------------- 1 | implementation-class=com.ewerk.gradle.plugins.IntegrationTestPlugin -------------------------------------------------------------------------------- /integration-test-plugin/out/production/resources/META-INF/gradle-plugins/com.ewerk.gradle.plugins.integration-test.properties: -------------------------------------------------------------------------------- 1 | implementation-class=com.ewerk.gradle.plugins.IntegrationTestPlugin -------------------------------------------------------------------------------- /annotation-processor-plugin/src/main/resources/META-INF/gradle-plugins/com.ewerk.gradle.plugins.annotation-processor.properties: -------------------------------------------------------------------------------- 1 | implementation-class=com.ewerk.gradle.plugins.AnnotationProcessorPlugin -------------------------------------------------------------------------------- /annotation-processor-plugin/out/production/resources/META-INF/gradle-plugins/com.ewerk.gradle.plugins.annotation-processor.properties: -------------------------------------------------------------------------------- 1 | implementation-class=com.ewerk.gradle.plugins.AnnotationProcessorPlugin -------------------------------------------------------------------------------- /artifactory-deb-publish-plugin/src/main/resources/META-INF/gradle-plugins/com.ewerk.gradle.plugins.artifactory-deb-publish.properties: -------------------------------------------------------------------------------- 1 | implementation-class=com.ewerk.gradle.plugins.ArtifactoryDebPublishPlugin -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | .idea/ 2 | **/build/ 3 | **/*.iml 4 | **/.gradle/ 5 | **/src/auto-value/** 6 | **/src/dagger/** 7 | **/src/querydsl/** 8 | **/src/generated/java/** 9 | hs_err_*.log 10 | classes 11 | *.hprof -------------------------------------------------------------------------------- /artifactory-deb-publish-plugin/out/production/resources/META-INF/gradle-plugins/com.ewerk.gradle.plugins.artifactory-deb-publish.properties: -------------------------------------------------------------------------------- 1 | implementation-class=com.ewerk.gradle.plugins.ArtifactoryDebPublishPlugin -------------------------------------------------------------------------------- /gradle.properties: -------------------------------------------------------------------------------- 1 | # Project config 2 | group=com.ewerk.gradle.plugins 3 | 4 | # JDK config 5 | sourceCompatibility=1.8 6 | targetCompatibility=1.8 7 | 8 | # Dependencies 9 | hamcrestVersion=1.3 10 | junitVersion=4.12 11 | testNgVersion=6.10 12 | -------------------------------------------------------------------------------- /artifactory-deb-publish-plugin/change_log.md: -------------------------------------------------------------------------------- 1 | # Change log 2 | 3 | ## 1.0.0 4 | * Initial release 5 | 6 | ## 1.0.1 7 | * Gradle 2.6 compatibility 8 | 9 | ## 1.0.2 10 | * Gradle 3.3 compatibility 11 | * Set JDK-8 as default 12 | 13 | ## 1.0.3-SNAPSHOT 14 | * Current snapshot 15 | -------------------------------------------------------------------------------- /gradle/wrapper/gradle-wrapper.properties: -------------------------------------------------------------------------------- 1 | #Wed Aug 08 14:45:45 EDT 2018 2 | distributionBase=GRADLE_USER_HOME 3 | distributionPath=wrapper/dists 4 | zipStoreBase=GRADLE_USER_HOME 5 | zipStorePath=wrapper/dists 6 | distributionUrl=https\://services.gradle.org/distributions/gradle-4.3.1-all.zip 7 | -------------------------------------------------------------------------------- /settings.gradle: -------------------------------------------------------------------------------- 1 | rootProject.name = 'gradle-plugins' 2 | 3 | include 'annotation-processor-plugin' 4 | include 'artifactory-deb-publish-plugin' 5 | include 'auto-value-plugin' 6 | include 'dagger-plugin' 7 | include 'integration-test-plugin' 8 | include 'jaxb2-plugin' 9 | include 'querydsl-plugin' 10 | -------------------------------------------------------------------------------- /.travis.yml: -------------------------------------------------------------------------------- 1 | sudo: false 2 | language: android 3 | 4 | android: 5 | components: 6 | - tools 7 | - build-tools-25.0.2 8 | - android-25 9 | - platform-tools 10 | 11 | jdk: 12 | - oraclejdk8 13 | 14 | script: ./gradlew build --stacktrace -i 15 | 16 | cache: 17 | directories: 18 | - "$HOME/.gradle/caches" 19 | 20 | branches: 21 | only: 22 | - master 23 | -------------------------------------------------------------------------------- /annotation-processor-plugin/change_log.md: -------------------------------------------------------------------------------- 1 | # Change log 2 | 3 | ## 1.0.0 4 | * Initial release 5 | 6 | ## 1.0.1 7 | * Gradle 2.6 compatibility 8 | 9 | ## 1.0.2 10 | * Support project dependency module (See issue 23) 11 | 12 | ## 1.0.3 13 | * Add support for optional annotation processor options 14 | 15 | ## 1.0.4 16 | * Gradle 3.3 compatibility 17 | * Set JDK-8 as default 18 | 19 | ## 1.0.5-SNAPSHOT 20 | * Current snapshot 21 | -------------------------------------------------------------------------------- /integration-test-plugin/change_log.md: -------------------------------------------------------------------------------- 1 | # Change log 2 | 3 | ## 1.0.0 4 | * Initial version 5 | 6 | ## 1.0.1 … 1.0.6 7 | * Minor tweaks of the Bintray publication data until everything worked flawlessly. 8 | 9 | ## 1.0.7 10 | * Gradle plugin publication process changed 11 | 12 | ## 1.0.8 13 | * Gradle 2.6 compatibility 14 | 15 | ## 1.0.9 16 | * Gradle 3.3 compatibility 17 | * Set JDK-8 as default 18 | 19 | ## 1.0.10-SNAPSHOT 20 | * Current snapshot 21 | -------------------------------------------------------------------------------- /jaxb2-plugin/src/main/groovy/com/ewerk/gradle/plugins/Jaxb2PluginExtension.groovy: -------------------------------------------------------------------------------- 1 | package com.ewerk.gradle.plugins 2 | 3 | /** 4 | * DSL extension for the Jaxb2 plugin. Provides some convenient configuration options. 5 | * 6 | * @author holgerstolzenberg 7 | * @since 1.0.0 8 | */ 9 | class Jaxb2PluginExtension { 10 | static final String NAME = 'jaxb2' 11 | 12 | String taskName = 'org.jvnet.jaxb2_commons.xjc.XJC2Task' 13 | } 14 | 15 | 16 | 17 | -------------------------------------------------------------------------------- /annotation-processor-plugin/src/main/groovy/com/ewerk/gradle/plugins/AnnotationProcessorPluginExtension.groovy: -------------------------------------------------------------------------------- 1 | package com.ewerk.gradle.plugins 2 | 3 | /** 4 | * @author griffio 5 | */ 6 | class AnnotationProcessorPluginExtension { 7 | 8 | static final String NAME = "annotationProcessor" 9 | static final String DEFAULT_SOURCES_DIR = "src/generated/java" 10 | 11 | String sourcesDir = DEFAULT_SOURCES_DIR 12 | Object library = "" 13 | String processor = "" 14 | Map options 15 | } 16 | -------------------------------------------------------------------------------- /dagger-plugin/change_log.md: -------------------------------------------------------------------------------- 1 | # Change log 2 | 3 | ## 1.0.0 4 | * Initial release 5 | 6 | ## 1.0.1 7 | * Add basic Android project support for Android Studio projects 8 | 9 | ## 1.0.2 10 | * Gradle 2.6 compatibility 11 | 12 | ## 1.0.3 13 | * Make sure clean task does not delete any main source set 14 | 15 | ## 1.0.4 16 | * Updated Dagger2 default library to 2.7 17 | * Check releases for changes - https://github.com/google/dagger/releases 18 | * Set JDK-8 as default 19 | 20 | ## 1.0.5-SNAPSHOT 21 | * Current snapshot 22 | -------------------------------------------------------------------------------- /artifactory-deb-publish-plugin/src/main/groovy/com/ewerk/gradle/plugins/util/Checksums.groovy: -------------------------------------------------------------------------------- 1 | package com.ewerk.gradle.plugins.util 2 | 3 | import java.security.MessageDigest 4 | 5 | /** 6 | * Utility class for creating file checksums. 7 | * 8 | * @author holgerstolzenberg 9 | * @since 1.0.0 10 | */ 11 | final class Checksums { 12 | static String sha1(byte[] payload) { 13 | return MessageDigest.getInstance("sha1"). 14 | digest(payload). 15 | collect { String.format("%02x", it) }.join("") 16 | } 17 | } 18 | -------------------------------------------------------------------------------- /querydsl-plugin/build.gradle: -------------------------------------------------------------------------------- 1 | plugins { 2 | id 'net.researchgate.release' version '2.5.0' 3 | id 'com.gradle.plugin-publish' version '0.9.7' 4 | } 5 | 6 | pluginBundle { 7 | website = 'https://github.com/ewerk/gradle-plugins' 8 | vcsUrl = 'https://github.com/ewerk/gradle-plugins' 9 | description = 'Plugin for generating QueryDSL model files.' 10 | tags = ['querydsl'] 11 | 12 | plugins { 13 | querydslPlugin { 14 | id = 'com.ewerk.gradle.plugins.querydsl' 15 | displayName = 'Gradle Querydsl plugin' 16 | } 17 | } 18 | } 19 | 20 | release { 21 | tagTemplate = '$name-$version' 22 | } 23 | 24 | createReleaseTag.dependsOn('check') -------------------------------------------------------------------------------- /jaxb2-plugin/build.gradle: -------------------------------------------------------------------------------- 1 | plugins { 2 | id 'net.researchgate.release' version '2.6.0' 3 | id 'com.gradle.plugin-publish' version '0.9.7' 4 | } 5 | 6 | pluginBundle { 7 | website = 'https://github.com/ewerk/gradle-plugins' 8 | vcsUrl = 'https://github.com/ewerk/gradle-plugins' 9 | description = 'Plugin for generating Java sources from XML schemas files.' 10 | tags = ['jaxb2', 'jaxb'] 11 | 12 | plugins { 13 | jaxb2Plugin { 14 | id = 'com.ewerk.gradle.plugins.jaxb2' 15 | displayName = 'Gradle JAXB2 plugin' 16 | } 17 | } 18 | } 19 | 20 | release { 21 | tagTemplate = '$name-$version' 22 | } 23 | 24 | createReleaseTag.dependsOn('check') -------------------------------------------------------------------------------- /auto-value-plugin/build.gradle: -------------------------------------------------------------------------------- 1 | plugins { 2 | id 'net.researchgate.release' version '2.6.0' 3 | id 'com.gradle.plugin-publish' version '0.9.7' 4 | } 5 | 6 | pluginBundle { 7 | website = 'https://github.com/ewerk/gradle-plugins' 8 | vcsUrl = 'https://github.com/ewerk/gradle-plugins' 9 | description = 'Plugin for generating Google AutoValue source files.' 10 | tags = ['auto-value'] 11 | 12 | plugins { 13 | autoValuePlugin { 14 | id = 'com.ewerk.gradle.plugins.auto-value' 15 | displayName = 'Gradle Auto-Value plugin' 16 | } 17 | } 18 | } 19 | 20 | release { 21 | tagTemplate = '$name-$version' 22 | } 23 | 24 | createReleaseTag.dependsOn('check') -------------------------------------------------------------------------------- /auto-value-plugin/src/main/groovy/com/ewerk/gradle/plugins/AutoValuePluginExtension.groovy: -------------------------------------------------------------------------------- 1 | package com.ewerk.gradle.plugins 2 | 3 | /** 4 | * DLS extension for the auto-value plugin. Provides some convenient configuration options. 5 | * 6 | * @author holgerstolzenberg 7 | * @since 1.0.0 8 | */ 9 | class AutoValuePluginExtension { 10 | 11 | static final String NAME = "autoValue" 12 | 13 | static final String DEFAULT_AUTO_VALUE_SOURCES_DIR = "src/auto-value/java" 14 | static final String DEFAULT_LIBRARY = "com.google.auto.value:auto-value:1.3" 15 | 16 | String autoValueSourcesDir = DEFAULT_AUTO_VALUE_SOURCES_DIR 17 | String library = DEFAULT_LIBRARY 18 | } 19 | -------------------------------------------------------------------------------- /artifactory-deb-publish-plugin/src/main/groovy/com/ewerk/gradle/plugins/util/Urls.groovy: -------------------------------------------------------------------------------- 1 | package com.ewerk.gradle.plugins.util 2 | 3 | /** 4 | * Utility class that helps constructing the Artifactory publication URLs. 5 | * 6 | * @author holgerstolzenberg 7 | * @since 1.0.0 8 | */ 9 | class Urls { 10 | static GString construct(String url, String repoKey, String name, String component, 11 | String prefix, String distribution, String arch) { 12 | "$url/$repoKey/pool/$component/$prefix/$name;deb.distribution=$distribution;deb.component=$component;deb.architecture=$arch" 13 | } 14 | 15 | static String prefix(String name) { 16 | name.substring(0, 1) 17 | } 18 | } 19 | -------------------------------------------------------------------------------- /integration-test-plugin/build.gradle: -------------------------------------------------------------------------------- 1 | plugins { 2 | id 'net.researchgate.release' version '2.6.0' 3 | id 'com.gradle.plugin-publish' version '0.9.7' 4 | } 5 | 6 | pluginBundle { 7 | website = 'https://github.com/ewerk/gradle-plugins' 8 | vcsUrl = 'https://github.com/ewerk/gradle-plugins' 9 | description = 'Plugin for running integration tests from a own sourceset.' 10 | tags = ['integration-test'] 11 | 12 | plugins { 13 | integrationTestPlugin { 14 | id = 'com.ewerk.gradle.plugins.integration-test' 15 | displayName = 'Gradle Integration-Test plugin' 16 | } 17 | } 18 | } 19 | 20 | release { 21 | tagTemplate = '$name-$version' 22 | } 23 | 24 | createReleaseTag.dependsOn('check') -------------------------------------------------------------------------------- /annotation-processor-plugin/build.gradle: -------------------------------------------------------------------------------- 1 | plugins { 2 | id 'net.researchgate.release' version '2.6.0' 3 | id 'com.gradle.plugin-publish' version '0.9.7' 4 | } 5 | 6 | pluginBundle { 7 | website = 'https://github.com/ewerk/gradle-plugins' 8 | vcsUrl = 'https://github.com/ewerk/gradle-plugins' 9 | description = 'Plugin for generating Java source from annotation processor' 10 | tags = ['annotation-processor'] 11 | 12 | plugins { 13 | annotationProcessorPlugin { 14 | id = 'com.ewerk.gradle.plugins.annotation-processor' 15 | displayName = 'Annotation Processor plugin' 16 | } 17 | } 18 | } 19 | 20 | release { 21 | tagTemplate = '$name-$version' 22 | } 23 | 24 | createReleaseTag.dependsOn('check') -------------------------------------------------------------------------------- /dagger-plugin/build.gradle: -------------------------------------------------------------------------------- 1 | plugins { 2 | id 'net.researchgate.release' version '2.6.0' 3 | id 'com.gradle.plugin-publish' version '0.9.7' 4 | } 5 | 6 | pluginBundle { 7 | website = 'https://github.com/ewerk/gradle-plugins' 8 | vcsUrl = 'https://github.com/ewerk/gradle-plugins' 9 | description = 'Plugin for generating Dagger2 Java source' 10 | tags = ['dagger2'] 11 | 12 | plugins { 13 | daggerPlugin { 14 | id = 'com.ewerk.gradle.plugins.dagger' 15 | displayName = 'Gradle Daggger2 plugin' 16 | } 17 | } 18 | } 19 | 20 | dependencies { 21 | testCompile 'com.android.tools.build:gradle:2.3.3' 22 | } 23 | 24 | release { 25 | tagTemplate = '$name-$version' 26 | } 27 | 28 | createReleaseTag.dependsOn('check') 29 | -------------------------------------------------------------------------------- /dagger-plugin/src/main/groovy/com/ewerk/gradle/plugins/DaggerPluginExtension.groovy: -------------------------------------------------------------------------------- 1 | package com.ewerk.gradle.plugins 2 | 3 | /** 4 | * @author griffio 5 | * 6 | * Defines the default configuration parameters in the Plugin 7 | */ 8 | class DaggerPluginExtension { 9 | 10 | static final String NAME = "dagger" 11 | static final String DEFAULT_DAGGER_SOURCES_DIR = "src/dagger/java" 12 | static final String DEFAULT_PROCESSOR_LIBRARY = "com.google.dagger:dagger-compiler:2.7" 13 | static final String DEFAULT_LIBRARY = "com.google.dagger:dagger:2.7" 14 | static final String PROCESSOR = "dagger.internal.codegen.ComponentProcessor" 15 | 16 | String daggerSourcesDir = DEFAULT_DAGGER_SOURCES_DIR 17 | String library = DEFAULT_LIBRARY 18 | String processorLibrary = DEFAULT_PROCESSOR_LIBRARY 19 | } -------------------------------------------------------------------------------- /artifactory-deb-publish-plugin/build.gradle: -------------------------------------------------------------------------------- 1 | plugins { 2 | id 'net.researchgate.release' version '2.6.0' 3 | id 'com.gradle.plugin-publish' version '0.9.7' 4 | } 5 | 6 | pluginBundle { 7 | website = 'https://github.com/ewerk/gradle-plugins' 8 | vcsUrl = 'https://github.com/ewerk/gradle-plugins' 9 | description = 'Plugin for publishing .deb archives to artifactory.' 10 | tags = ['artifactory', 'debian', 'deb', 'publish', 'publication'] 11 | 12 | plugins { 13 | artifactoryDebPublishPlugin { 14 | id = 'com.ewerk.gradle.plugins.artifactory-deb-publish' 15 | displayName = 'Artifactory .deb publish plugin' 16 | } 17 | } 18 | } 19 | 20 | dependencies { 21 | compile "com.squareup.okhttp:okhttp:$okHttpVersion" 22 | } 23 | 24 | release { 25 | tagTemplate = '$name-$version' 26 | } 27 | 28 | createReleaseTag.dependsOn('check') -------------------------------------------------------------------------------- /jaxb2-plugin/src/main/groovy/com/ewerk/gradle/plugins/tasks/XjcTaskConfig.groovy: -------------------------------------------------------------------------------- 1 | package com.ewerk.gradle.plugins.tasks 2 | 3 | /** 4 | * Simple extension bean. Is used within the plugins extension a wrapper for the 'xjc' container. 5 | * This extension is declared in the plugins main extension itself, it is created on-the-fly 6 | * on plugin apply. See the plugin class for that. 7 | * 8 | * @author holgerstolzenberg 9 | * @since 1.0.0 10 | */ 11 | class XjcTaskConfig { 12 | String name 13 | String generatedSourcesDir = 'src/generated/java' 14 | String basePackage 15 | String schema 16 | String catalog 17 | String bindingsDir 18 | String includedBindingFiles 19 | String encoding = 'UTF-8' 20 | String additionalArgs = '' 21 | boolean createSourceSet = true 22 | boolean extension = false 23 | 24 | XjcTaskConfig(String name) { 25 | this.name = name 26 | } 27 | } 28 | -------------------------------------------------------------------------------- /querydsl-plugin/src/main/groovy/com/ewerk/gradle/plugins/tasks/InitQuerydslSourcesDir.groovy: -------------------------------------------------------------------------------- 1 | package com.ewerk.gradle.plugins.tasks 2 | 3 | import com.ewerk.gradle.plugins.QuerydslPlugin 4 | import org.gradle.api.DefaultTask 5 | import org.gradle.api.tasks.TaskAction 6 | 7 | /** 8 | * This task is responsible for removing and recreating the configured querydsl source roots. 9 | * 10 | * @author holgerstolzenberg 11 | * @since 1.0.0 12 | */ 13 | class InitQuerydslSourcesDir extends DefaultTask { 14 | 15 | static final String DESCRIPTION = "Creates the Querydsl sources dir." 16 | 17 | InitQuerydslSourcesDir() { 18 | this.group = QuerydslPlugin.TASK_GROUP 19 | this.description = DESCRIPTION 20 | } 21 | 22 | @SuppressWarnings("GroovyUnusedDeclaration") 23 | @TaskAction 24 | createSourceFolders() { 25 | project.file(project.querydsl.querydslSourcesDir).mkdirs() 26 | } 27 | } -------------------------------------------------------------------------------- /dagger-plugin/src/main/groovy/com/ewerk/gradle/plugins/tasks/InitDaggerSourcesDir.groovy: -------------------------------------------------------------------------------- 1 | package com.ewerk.gradle.plugins.tasks 2 | 3 | import com.ewerk.gradle.plugins.DaggerPlugin 4 | import org.gradle.api.DefaultTask 5 | import org.gradle.api.logging.Logger 6 | import org.gradle.api.logging.Logging 7 | import org.gradle.api.tasks.TaskAction 8 | 9 | /** 10 | * @author griffio 11 | */ 12 | class InitDaggerSourcesDir extends DefaultTask { 13 | 14 | private static final Logger LOG = Logging.getLogger(InitDaggerSourcesDir.class) 15 | 16 | InitDaggerSourcesDir() { 17 | this.group = DaggerPlugin.TASK_GROUP 18 | this.description = "Creates the Dagger sources dir" 19 | } 20 | 21 | @SuppressWarnings("GroovyUnusedDeclaration") 22 | @TaskAction 23 | createSourceFolders() { 24 | LOG.info("create source") 25 | def daggerSourcesDir = DaggerPlugin.verifyNotWithinMainBuildSrc(project) 26 | daggerSourcesDir.mkdirs() 27 | } 28 | } 29 | -------------------------------------------------------------------------------- /annotation-processor-plugin/src/main/groovy/com/ewerk/gradle/plugins/tasks/InitAnnotationProcessorGeneratedDir.groovy: -------------------------------------------------------------------------------- 1 | package com.ewerk.gradle.plugins.tasks 2 | 3 | import com.ewerk.gradle.plugins.AnnotationProcessorPlugin 4 | import org.gradle.api.DefaultTask 5 | import org.gradle.api.logging.Logger 6 | import org.gradle.api.logging.Logging 7 | import org.gradle.api.tasks.TaskAction 8 | 9 | /** 10 | * @author griffio 11 | */ 12 | class InitAnnotationProcessorGeneratedDir extends DefaultTask { 13 | 14 | private static final Logger LOG = Logging.getLogger(InitAnnotationProcessorGeneratedDir.class) 15 | 16 | InitAnnotationProcessorGeneratedDir() { 17 | this.group = AnnotationProcessorPlugin.TASK_GROUP 18 | this.description = "Creates the generated sources dir" 19 | } 20 | 21 | @SuppressWarnings("GroovyUnusedDeclaration") 22 | @TaskAction 23 | createSourceFolders() { 24 | LOG.info("create source") 25 | project.file(project.annotationProcessor.sourcesDir).mkdirs() 26 | } 27 | } 28 | -------------------------------------------------------------------------------- /dagger-plugin/src/main/groovy/com/ewerk/gradle/plugins/tasks/CleanDaggerSourcesDir.groovy: -------------------------------------------------------------------------------- 1 | package com.ewerk.gradle.plugins.tasks 2 | 3 | import com.ewerk.gradle.plugins.DaggerPlugin 4 | import org.gradle.api.DefaultTask 5 | import org.gradle.api.logging.Logger 6 | import org.gradle.api.logging.Logging 7 | import org.gradle.api.tasks.TaskAction 8 | 9 | /** 10 | * @author griffio 11 | */ 12 | class CleanDaggerSourcesDir extends DefaultTask { 13 | 14 | private static final Logger LOG = Logging.getLogger(CleanDaggerSourcesDir.class) 15 | 16 | CleanDaggerSourcesDir() { 17 | this.group = DaggerPlugin.TASK_GROUP 18 | this.description = "Cleans the Dagger sources dir." 19 | } 20 | 21 | @SuppressWarnings("GroovyUnusedDeclaration") 22 | @TaskAction 23 | cleanSourceFolders() { 24 | LOG.info("clean Source") 25 | def daggerSourcesDir = DaggerPlugin.verifyNotWithinMainBuildSrc(project) 26 | if (daggerSourcesDir.exists()) { 27 | daggerSourcesDir.deleteDir() 28 | } 29 | } 30 | } 31 | -------------------------------------------------------------------------------- /dagger-plugin/src/main/groovy/com/ewerk/gradle/plugins/tasks/DaggerCompile.groovy: -------------------------------------------------------------------------------- 1 | package com.ewerk.gradle.plugins.tasks 2 | 3 | import org.gradle.api.plugins.WarPlugin 4 | import org.gradle.api.tasks.compile.JavaCompile 5 | 6 | /** 7 | * @author griffio 8 | */ 9 | class DaggerCompile extends JavaCompile { 10 | 11 | DaggerCompile() { 12 | 13 | setSource(project.sourceSets.main.java) 14 | 15 | if (project.plugins.hasPlugin(WarPlugin.class)) { 16 | project.configurations { 17 | dagger.extendsFrom compile, providedRuntime, providedCompile 18 | } 19 | } else { 20 | project.configurations { 21 | dagger.extendsFrom compile 22 | } 23 | } 24 | 25 | File file = project.file(project.dagger.daggerSourcesDir) 26 | 27 | options.compilerArgs = [ 28 | "-proc:only", 29 | "-s", file.absolutePath, 30 | "-processor", project.dagger.PROCESSOR 31 | ] 32 | 33 | setClasspath(project.configurations.dagger) 34 | 35 | setDestinationDir(file) 36 | } 37 | } 38 | -------------------------------------------------------------------------------- /jaxb2-plugin/change_log.md: -------------------------------------------------------------------------------- 1 | # Change log 2 | 3 | ## 1.0.0 4 | * Initial release 5 | 6 | ## 1.0.1 7 | * Fix a bug that caused compileJava task to miss configured jaxb source folder 8 | * Dropped support for JDK-7 9 | 10 | ## 1.0.2 11 | * Ant xjc task now adds depends/produces filesets for recompilation update checking 12 | 13 | ## 1.0.3 14 | * Gradle 3.3 compatibility 15 | * Set JDK-8 as default 16 | 17 | ## 1.0.4 18 | * Introduce DSL parameter for configuring XJC binding files within the generation process 19 | 20 | ## 1.0.5 21 | * Introduce support for encoding parameter of XJC 22 | 23 | ## 1.0.6 24 | * Added `org.jvnet.jaxb2_commons:jaxb2-basics-tools:0.9.5` as a plugin default dependency 25 | 26 | ## 1.0.7 27 | * Add `strictMode` configuration option 28 | 29 | ## 1.0.8 30 | * Add `additionalArgs` configuration option 31 | 32 | ## 1.0.9 33 | * Bugfix with `additionalArgs` configuration option, now working properly 34 | 35 | ## 1.0.10 36 | * Add optional `catalog` configuration option 37 | 38 | ## 1.0.10-SNAPSHOT 39 | * Current snapshot 40 | -------------------------------------------------------------------------------- /querydsl-plugin/src/main/groovy/com/ewerk/gradle/plugins/tasks/QuerydslCompile.groovy: -------------------------------------------------------------------------------- 1 | package com.ewerk.gradle.plugins.tasks 2 | 3 | import org.gradle.api.plugins.WarPlugin 4 | import org.gradle.api.tasks.compile.JavaCompile 5 | /** 6 | * Compiles the meta model using querydsl annotation processors supplied by the querydsl extension configuration 7 | * @author holgerstolzenberg , griffio 8 | * @since 1.0.3 9 | */ 10 | class QuerydslCompile extends JavaCompile { 11 | 12 | QuerydslCompile() { 13 | setSource(project.sourceSets.main.java) 14 | 15 | if (project.plugins.hasPlugin(WarPlugin.class)) { 16 | project.configurations { 17 | querydsl.extendsFrom compile, providedRuntime, providedCompile 18 | } 19 | } else { 20 | project.configurations { 21 | querydsl.extendsFrom compile 22 | } 23 | } 24 | 25 | project.afterEvaluate { 26 | setClasspath(project.configurations.querydsl) 27 | File file = project.file(project.querydsl.querydslSourcesDir) 28 | setDestinationDir(file) 29 | } 30 | } 31 | } 32 | -------------------------------------------------------------------------------- /annotation-processor-plugin/src/main/groovy/com/ewerk/gradle/plugins/tasks/CleanAnnotationProcessorGeneratedDir.groovy: -------------------------------------------------------------------------------- 1 | package com.ewerk.gradle.plugins.tasks 2 | 3 | import com.ewerk.gradle.plugins.AnnotationProcessorPlugin 4 | import org.gradle.api.DefaultTask 5 | import org.gradle.api.logging.Logger 6 | import org.gradle.api.logging.Logging 7 | import org.gradle.api.tasks.TaskAction 8 | 9 | /** 10 | * @author griffio 11 | */ 12 | class CleanAnnotationProcessorGeneratedDir extends DefaultTask { 13 | 14 | private static final Logger LOG = Logging.getLogger(CleanAnnotationProcessorGeneratedDir.class) 15 | 16 | CleanAnnotationProcessorGeneratedDir() { 17 | this.group = AnnotationProcessorPlugin.TASK_GROUP 18 | this.description = "Cleans the sources dir." 19 | } 20 | 21 | @SuppressWarnings("GroovyUnusedDeclaration") 22 | @TaskAction 23 | cleanSourceFolders() { 24 | LOG.info("clean source") 25 | project.sourceSets.annotationProcessor.java.srcDirs.each { dir -> 26 | if (dir.exists()) { 27 | dir.deleteDir() 28 | } 29 | } 30 | } 31 | } 32 | -------------------------------------------------------------------------------- /querydsl-plugin/src/main/groovy/com/ewerk/gradle/plugins/tasks/CleanQuerydslSourcesDir.groovy: -------------------------------------------------------------------------------- 1 | package com.ewerk.gradle.plugins.tasks 2 | 3 | import com.ewerk.gradle.plugins.QuerydslPlugin 4 | import org.gradle.api.DefaultTask 5 | import org.gradle.api.logging.Logger 6 | import org.gradle.api.logging.Logging 7 | import org.gradle.api.tasks.TaskAction 8 | 9 | /** 10 | * This task is responsible for purging the 'querydsl' sources dir. 11 | * 12 | * @author holgerstolzenberg 13 | * @since 1.0.0 14 | */ 15 | class CleanQuerydslSourcesDir extends DefaultTask { 16 | 17 | private static final Logger LOG = Logging.getLogger(CleanQuerydslSourcesDir.class) 18 | 19 | static final String DESCRIPTION = "Cleans the Querydsl sources dir." 20 | 21 | CleanQuerydslSourcesDir() { 22 | this.group = QuerydslPlugin.TASK_GROUP 23 | this.description = DESCRIPTION 24 | } 25 | 26 | @SuppressWarnings("GroovyUnusedDeclaration") 27 | @TaskAction 28 | cleanSourceFolders() { 29 | LOG.info("Clean Querydsl source dir") 30 | 31 | project.sourceSets.querydsl.java.srcDirs.each { dir -> 32 | if (dir.exists()) { 33 | dir.deleteDir() 34 | } 35 | } 36 | } 37 | } 38 | -------------------------------------------------------------------------------- /auto-value-plugin/src/main/groovy/com/ewerk/gradle/plugins/tasks/CleanAutoValueSourcesDir.groovy: -------------------------------------------------------------------------------- 1 | package com.ewerk.gradle.plugins.tasks 2 | 3 | import com.ewerk.gradle.plugins.AutoValuePlugin 4 | import org.gradle.api.DefaultTask 5 | import org.gradle.api.logging.Logger 6 | import org.gradle.api.logging.Logging 7 | import org.gradle.api.tasks.TaskAction 8 | 9 | /** 10 | * This task is responsible for purging the auto-value sources dir. 11 | * 12 | * @author holgerstolzenberg 13 | * @since 1.0.1 14 | */ 15 | class CleanAutoValueSourcesDir extends DefaultTask { 16 | 17 | private static final Logger LOG = Logging.getLogger(CleanAutoValueSourcesDir.class) 18 | 19 | static final String DESCRIPTION = "Cleans the Auto-value sources dir." 20 | 21 | CleanAutoValueSourcesDir() { 22 | this.group = AutoValuePlugin.TASK_GROUP 23 | this.description = DESCRIPTION 24 | } 25 | 26 | @SuppressWarnings("GroovyUnusedDeclaration") 27 | @TaskAction 28 | cleanSourceFolders() { 29 | LOG.info("Clean Auto-Value source dir") 30 | 31 | project.sourceSets.autoValue.java.srcDirs.each { dir -> 32 | if (dir.exists()) { 33 | dir.deleteDir() 34 | } 35 | } 36 | } 37 | } 38 | -------------------------------------------------------------------------------- /auto-value-plugin/change_log.md: -------------------------------------------------------------------------------- 1 | # Change log 2 | 3 | ## 1.0.0 4 | * Initial version 5 | 6 | ## 1.0.1 7 | * Removed the `delete` DSL parameter 8 | * Added task `CleanAutoValueSourcesDir` 9 | * Make sure `clean` also calls `CleanAutoValueSourcesDir` via `dependsOn` 10 | * Changed default generated sources dir to `src/auto-value/java` for not interfering with other generated code 11 | 12 | ## 1.0.2 13 | * minor tweaks to the plugins cleaning logic 14 | 15 | ## 1.0.3 16 | * updated default auto-value library used to 1.0 17 | * The plugin publication process changed, moved away from bintray, only plugin portal is supported 18 | * current SNAPSHOT 19 | 20 | ## 1.0.4 21 | * Previous version was accidentally compiled and published with JDK-8 which may break some apps, 1.0.4 uses JDK-7 again 22 | 23 | ## 1.0.5 24 | * Gradle 2.6 compatibility 25 | 26 | ## 1.0.6 27 | * Prevent `src/main/java` to be deleted accidentally by mis-configuration 28 | 29 | ## 1.0.7 30 | * Updated the default AutoValue library version to 1.3 31 | * See changes: https://github.com/google/auto/blob/master/value/CHANGES.md 32 | 33 | ## 1.0.8 34 | * Gradle 3.3 compatibility 35 | * Set JDK-8 as default 36 | 37 | ## 1.0.9-SNAPSHOT 38 | * Current snapshot 39 | -------------------------------------------------------------------------------- /artifactory-deb-publish-plugin/src/test/groovy/com/ewerk/gradle/plugins/util/ChecksumsTest.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2012-2014 the original author or authors. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package com.ewerk.gradle.plugins.util; 18 | 19 | import static com.ewerk.gradle.plugins.util.Checksums.sha1; 20 | import static org.testng.Assert.assertEquals; 21 | 22 | import org.testng.annotations.Test; 23 | 24 | /** 25 | * @author holgerstolzenberg 26 | * @since 1.0.2 27 | */ 28 | public class ChecksumsTest { 29 | @Test 30 | public void testSha1() { 31 | assertEquals(sha1("Test".getBytes()), "640ab2bae07bedc4c163f679a746f7ab7fb5d1fa"); 32 | } 33 | } -------------------------------------------------------------------------------- /artifactory-deb-publish-plugin/src/main/groovy/com/ewerk/gradle/plugins/PublishException.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2012-2014 the original author or authors. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package com.ewerk.gradle.plugins; 18 | 19 | import groovy.transform.CompileStatic; 20 | 21 | /** 22 | * Exception raised when publication to artifactory fails. 23 | * 24 | * @author holgerstolzenberg 25 | * @since 1.0.0 26 | */ 27 | public final class PublishException extends RuntimeException { 28 | 29 | private static final long serialVersionUID = -305297725365156800L; 30 | 31 | @CompileStatic 32 | public PublishException(String message) { 33 | super(message); 34 | } 35 | } -------------------------------------------------------------------------------- /querydsl-plugin/change_log.md: -------------------------------------------------------------------------------- 1 | # Change log 2 | 3 | ## 1.0.0 4 | * Initial release 5 | 6 | ## 1.0.1 7 | * The meta model can be created from different annotation processors 8 | 9 | ## 1.0.2 10 | * added support for com.mysema.query.apt.QuerydslAnnotationProcessor 11 | 12 | ## 1.0.3 13 | * Internal refactoring, only one task `QuerydslCompile` is added to the project that configures all annotation processors 14 | 15 | ## 1.0.4 16 | * Plugin portal release process changed 17 | * Support for `providedCompile` and `providedRuntime` dependencies 18 | 19 | ## 1.0.5 20 | * Gradle 2.6 compatibility 21 | 22 | ## 1.0.6 23 | * Querydsl 4 library dependency is now required for this plugin. 24 | * Querydsl 4 is required for SpringData "Hopper" JPA generation. 25 | 26 | ## 1.0.7 27 | * Bugfix (issue #51) for compileQuerydsl task, Java compiler setting of destinationDir, must evaluate user's querydslSourcesDir preference. 28 | 29 | ## 1.0.8 30 | * Querydsl 4 library dependency updated to (4.1.3) matching Spring Data version 31 | * Gradle 3.3 compatibility 32 | 33 | ## 1.0.9 34 | * Set JDK-8 as default 35 | 36 | ## 1.0.10-SNAPSHOT 37 | * Querydsl 4 library dependency updated to (4.1.4) 38 | * Add support for custom `aptOptions` parameter 39 | 40 | ## 1.0.11-SNAPSHOT 41 | * Current plugin snapshot 42 | -------------------------------------------------------------------------------- /jaxb2-plugin/src/main/groovy/com/ewerk/gradle/plugins/tasks/CleanJaxb2SourcesDir.groovy: -------------------------------------------------------------------------------- 1 | package com.ewerk.gradle.plugins.tasks 2 | 3 | import com.ewerk.gradle.plugins.Jaxb2Plugin 4 | import org.gradle.api.DefaultTask 5 | import org.gradle.api.logging.Logger 6 | import org.gradle.api.tasks.TaskAction 7 | 8 | import static org.gradle.api.logging.Logging.getLogger 9 | 10 | /** 11 | * This task is responsible for purging the Jaxb2 sources dir. 12 | * 13 | * @author holgerstolzenberg 14 | * @since 1.0.1 15 | */ 16 | class CleanJaxb2SourcesDir extends DefaultTask { 17 | private static final Logger LOG = getLogger(CleanJaxb2SourcesDir.class) 18 | 19 | static final String DESCRIPTION = "Cleans the Jaxb2 sources dir." 20 | 21 | CleanJaxb2SourcesDir() { 22 | this.group = Jaxb2Plugin.TASK_GROUP 23 | this.description = DESCRIPTION 24 | } 25 | 26 | @SuppressWarnings("GroovyUnusedDeclaration") 27 | @TaskAction 28 | cleanSourceFolders() { 29 | LOG.info("Clean Jaxb2 source dir") 30 | 31 | Set xjcConfigs = project.extensions.jaxb2.xjc 32 | 33 | for (XjcTaskConfig theConfig : xjcConfigs) { 34 | File generatedSourcesDir = project.file(theConfig.generatedSourcesDir) 35 | if (generatedSourcesDir.exists()) { 36 | generatedSourcesDir.deleteDir() 37 | } 38 | } 39 | } 40 | } 41 | -------------------------------------------------------------------------------- /integration-test-plugin/readme.md: -------------------------------------------------------------------------------- 1 | ### Integration test plugin 2 | 3 | #### Description 4 | 5 | The plugin can be used to execute integration tests from a sophisticated sourceSet. Just place 6 | your integration tests and resources under `src/integration/java` and `src/integration/resources` 7 | and run task `integrationTest`. 8 | 9 | The plugin was inspired by the sources taken from [here](http://blog.lick-me.org/2014/07/fun-with-gradle-plugins-integration-tests/). 10 | 11 | The plugin applies the task `integration-test` to the project. This tasks extends from the default 12 | `test` task. Therefore all configuration properties from test task are available for integration 13 | tests also. 14 | 15 | The `integrationTest` task extends from the `test` task and therefore the complete configuration 16 | set of the `test` task is also available to the integration test configuration 17 | 18 | Please see [Gradle test config](http://www.gradle.org/docs/current/dsl/org.gradle.api.tasks.testing.Test.html) 19 | for details. 20 | 21 | The plugins change log can be found [here](change_log.md). 22 | 23 | #### Examples 24 | 25 | __Use via Gradle plugin portal__ 26 | 27 | ```groovy 28 | plugins { 29 | id "com.ewerk.gradle.plugins.integration-test" version "1.0.6" 30 | } 31 | 32 | integrationTest { 33 | useTestNG() 34 | 35 | minHeapSize = "128m" 36 | maxHeapSize = "512m" 37 | } 38 | ``` -------------------------------------------------------------------------------- /jaxb2-plugin/src/test/groovy/com/ewerk/gradle/plugins/Jaxb2PluginExtensionTest.groovy: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2012-2014 the original author or authors. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package com.ewerk.gradle.plugins 18 | 19 | import org.testng.annotations.BeforeMethod 20 | import org.testng.annotations.Test 21 | 22 | import static org.hamcrest.CoreMatchers.notNullValue 23 | import static org.hamcrest.MatcherAssert.assertThat 24 | 25 | /** 26 | * @author holgerstolzenberg 27 | * @since 1.0.0 28 | */ 29 | class Jaxb2PluginExtensionTest { 30 | 31 | private Jaxb2PluginExtension extension 32 | 33 | @BeforeMethod 34 | void setup() { 35 | extension = new Jaxb2PluginExtension() 36 | } 37 | 38 | @Test 39 | void testTaskNameIsSet() { 40 | assertThat(extension.taskName, notNullValue()) 41 | } 42 | } -------------------------------------------------------------------------------- /artifactory-deb-publish-plugin/src/main/groovy/com/ewerk/gradle/plugins/ArtifactoryDebPublishPlugin.groovy: -------------------------------------------------------------------------------- 1 | package com.ewerk.gradle.plugins 2 | 3 | import com.ewerk.gradle.plugins.tasks.PushDebToArtifactory 4 | import org.gradle.api.Plugin 5 | import org.gradle.api.Project 6 | import org.gradle.api.logging.Logger 7 | import org.gradle.api.logging.Logging 8 | 9 | /** 10 | * A plugin for publishing .deb archives with the according meta-data to Artifactory via HTTP(S) 11 | * REST API. 12 | * 13 | * @see ArtifactoryDebPublishPluginExtension 14 | * @author holgerstolzenberg 15 | * @since 1.0.0 16 | */ 17 | class ArtifactoryDebPublishPlugin implements Plugin { 18 | 19 | public static final String TASK_GROUP = 'Artifactory publishing' 20 | 21 | private static final Logger LOG = Logging.getLogger(ArtifactoryDebPublishPlugin.class) 22 | 23 | @Override 24 | void apply(final Project project) { 25 | 26 | // do nothing if plugin is already applied 27 | if (project.plugins.hasPlugin(ArtifactoryDebPublishPlugin.class)) { 28 | return 29 | } 30 | 31 | LOG.info('Applying artifactory-deb-publish plugin') 32 | 33 | // add DSL extension 34 | project.extensions.create(ArtifactoryDebPublishPluginExtension.NAME, 35 | ArtifactoryDebPublishPluginExtension) 36 | 37 | // register task 38 | project.task(type: PushDebToArtifactory, 'pushDebToArtifactory') 39 | } 40 | } 41 | -------------------------------------------------------------------------------- /annotation-processor-plugin/src/main/groovy/com/ewerk/gradle/plugins/tasks/AnnotationProcessorCompile.groovy: -------------------------------------------------------------------------------- 1 | package com.ewerk.gradle.plugins.tasks 2 | 3 | import org.gradle.api.plugins.WarPlugin 4 | import org.gradle.api.tasks.compile.JavaCompile 5 | 6 | /** 7 | * @author griffio 8 | */ 9 | class AnnotationProcessorCompile extends JavaCompile { 10 | 11 | AnnotationProcessorCompile() { 12 | 13 | setSource(project.sourceSets.main.java) 14 | 15 | if (project.plugins.hasPlugin(WarPlugin.class)) { 16 | project.configurations { 17 | annotationProcessor.extendsFrom compile, providedRuntime, providedCompile 18 | } 19 | } else { 20 | project.configurations { 21 | annotationProcessor.extendsFrom compile 22 | } 23 | } 24 | 25 | setClasspath(project.configurations.annotationProcessor) 26 | 27 | project.afterEvaluate { 28 | 29 | File file = project.file(project.annotationProcessor.sourcesDir) 30 | 31 | setDestinationDir(file) 32 | 33 | options.compilerArgs = [ 34 | "-proc:only", 35 | "-s", file.absolutePath, 36 | "-processor", project.annotationProcessor.processor 37 | ] 38 | 39 | def processorOptions = project.annotationProcessor.options 40 | if(processorOptions){ 41 | processorOptions.each { key, value -> 42 | options.compilerArgs << "-A${key}=${value}" 43 | } 44 | } 45 | } 46 | } 47 | } 48 | -------------------------------------------------------------------------------- /auto-value-plugin/readme.md: -------------------------------------------------------------------------------- 1 | ### Auto-Value plugin 2 | 3 | #### Description 4 | 5 | This plugin makes it easy to generate [Google Auto-Value](https://github.com/google/auto/tree/master/value) 6 | classes within a project. 7 | 8 | Because of the early stage of the plugin, the configuration (and plugin DSL) has undergone some 9 | minor changes. This is documented in the [change log](change_log.md). 10 | 11 | Version 1.0.3 of the plugin was accidentally build and published with JDK-8 which breaks 12 | compatibility to JDK-7. This was fixed in version 1.0.4. 13 | 14 | #### Configuration 15 | 16 | ##### autoValueSourcesDir 17 | 18 | The destination directory for the generated java sources. 19 | 20 | Defaults to 'src/auto-value/java' for Java Plugin projects. 21 | 22 | The autoValueSourcesDir is deleted when executing the clean task; for this reason, a BuildException will be thrown if 23 | autoValueSourcesDir is located in your main java sources. 24 | 25 | ##### library 26 | 27 | The dependency artifact for the compile/runtime usage of Autovalue. 28 | This is added to the compile configuration for the project. 29 | 30 | Defaults to 'com.google.auto.value:auto-value:1.0'. 31 | 32 | #### Examples 33 | 34 | __Use via Gradle plugin portal__ 35 | 36 | ```groovy 37 | plugins { 38 | id "com.ewerk.gradle.plugins.auto-value" version "1.0.5" 39 | } 40 | 41 | // the following closure demonstrates the extension defaults and is not necessary 42 | autoValue { 43 | library = "com.google.auto.value:auto-value:1.3" 44 | autoValueSourcesDir = "src/auto-value/java" 45 | } 46 | ``` -------------------------------------------------------------------------------- /auto-value-plugin/src/main/groovy/com/ewerk/gradle/plugins/tasks/InitAutoValueSourcesDir.groovy: -------------------------------------------------------------------------------- 1 | package com.ewerk.gradle.plugins.tasks 2 | 3 | import com.ewerk.gradle.plugins.AutoValuePlugin 4 | import org.gradle.api.DefaultTask 5 | import org.gradle.api.GradleException 6 | import org.gradle.api.logging.Logger 7 | import org.gradle.api.logging.Logging 8 | import org.gradle.api.tasks.TaskAction 9 | 10 | /** 11 | * This task is responsible for removing and recreating the configured auto-value source roots. 12 | * 13 | * @author holgerstolzenberg 14 | * @since 1.0.0 15 | */ 16 | class InitAutoValueSourcesDir extends DefaultTask { 17 | 18 | private static final Logger LOG = Logging.getLogger(InitAutoValueSourcesDir.class) 19 | 20 | static final String DESCRIPTION = "Creates the Auto-value sources dir." 21 | 22 | InitAutoValueSourcesDir() { 23 | this.group = AutoValuePlugin.TASK_GROUP 24 | this.description = DESCRIPTION 25 | } 26 | 27 | @SuppressWarnings("GroovyUnusedDeclaration") 28 | @TaskAction 29 | createSourceFolders() { 30 | 31 | def autoValueSourcesDir = project.file(project.autoValue.autoValueSourcesDir) 32 | 33 | LOG.info("Create source set ${autoValueSourcesDir}.") 34 | 35 | project.sourceSets.main.java.srcDirs.each { d -> 36 | if (d.absolutePath == autoValueSourcesDir.absolutePath) { 37 | throw new GradleException("The configured autoValueSourcesDir must specify a separate location to existing source code.") 38 | } 39 | } 40 | 41 | project.file(project.autoValue.autoValueSourcesDir).mkdirs() 42 | } 43 | } -------------------------------------------------------------------------------- /querydsl-plugin/src/test/groovy/com/ewerk/gradle/plugins/tasks/InitQuerydslSourcesDirTest.groovy: -------------------------------------------------------------------------------- 1 | package com.ewerk.gradle.plugins.tasks 2 | 3 | import com.ewerk.gradle.plugins.QuerydslPlugin 4 | import org.gradle.api.Project 5 | import org.gradle.testfixtures.ProjectBuilder 6 | import org.testng.annotations.BeforeMethod 7 | import org.testng.annotations.Test 8 | 9 | import static org.hamcrest.CoreMatchers.equalTo 10 | import static org.hamcrest.CoreMatchers.notNullValue 11 | import static org.hamcrest.MatcherAssert.assertThat 12 | 13 | /** 14 | * @author holgerstolzenberg 15 | * @since 1.0.0 16 | */ 17 | class InitQuerydslSourcesDirTest { 18 | 19 | private Project project 20 | private InitQuerydslSourcesDir createTask 21 | 22 | @BeforeMethod 23 | void setup() { 24 | project = ProjectBuilder.builder().build() 25 | project.plugins.apply(QuerydslPlugin.class) 26 | project.evaluate() 27 | 28 | createTask = project.tasks.initQuerydslSourcesDir as InitQuerydslSourcesDir 29 | } 30 | 31 | @Test 32 | void testCreateSourceFolders() { 33 | createTask.createSourceFolders() 34 | assertThat(project.sourceSets.querydsl, notNullValue()) 35 | 36 | File javaDir = project.sourceSets.querydsl.java.srcDirs.first() as File 37 | assertThat(javaDir.name, equalTo("java")) 38 | } 39 | 40 | @Test 41 | void testGroup() { 42 | assertThat(createTask.group, equalTo(QuerydslPlugin.TASK_GROUP)) 43 | } 44 | 45 | @Test 46 | void testDescription() { 47 | assertThat(createTask.description, equalTo(InitQuerydslSourcesDir.DESCRIPTION)) 48 | } 49 | } 50 | -------------------------------------------------------------------------------- /querydsl-plugin/src/test/groovy/com/ewerk/gradle/plugins/QuerydslPluginExtensionTest.groovy: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2012-2014 the original author or authors. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package com.ewerk.gradle.plugins 18 | 19 | import org.testng.annotations.BeforeMethod 20 | import org.testng.annotations.Test 21 | 22 | import static org.hamcrest.CoreMatchers.equalTo 23 | import static org.hamcrest.MatcherAssert.assertThat 24 | 25 | /** 26 | * @author holgerstolzenberg 27 | * @since 1.0.0 28 | */ 29 | class QuerydslPluginExtensionTest { 30 | 31 | private QuerydslPluginExtension extension 32 | 33 | @BeforeMethod 34 | void setup() { 35 | extension = new QuerydslPluginExtension() 36 | } 37 | 38 | @Test 39 | void testDefaultGeneratedSourcesDirIsSet() { 40 | String defaultDir = QuerydslPluginExtension.DEFAULT_QUERYDSL_SOURCES_DIR 41 | assertThat(extension.querydslSourcesDir as File, equalTo(new File(defaultDir))) 42 | } 43 | 44 | @Test 45 | void testDefaultLibraryIsSet() { 46 | def defaultLibrary = QuerydslPluginExtension.DEFAULT_LIBRARY 47 | assertThat(extension.library, 48 | equalTo(defaultLibrary)) 49 | } 50 | } -------------------------------------------------------------------------------- /querydsl-plugin/src/test/groovy/com/ewerk/gradle/plugins/tasks/QuerydslCompileTest.groovy: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2015 the original author or authors. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | package com.ewerk.gradle.plugins.tasks 17 | 18 | import com.ewerk.gradle.plugins.QuerydslPlugin 19 | import org.gradle.api.Project 20 | import org.gradle.api.tasks.SourceTask 21 | import org.gradle.testfixtures.ProjectBuilder 22 | import org.junit.Test 23 | 24 | import static org.hamcrest.CoreMatchers.hasItem 25 | import static org.hamcrest.CoreMatchers.is 26 | import static org.junit.Assert.assertThat 27 | 28 | /** 29 | * @author Illya Boyko 30 | */ 31 | class QuerydslCompileTest { 32 | 33 | private Project project 34 | private SourceTask compileTask 35 | 36 | QuerydslCompileTest() { 37 | project = ProjectBuilder.builder().build() 38 | project.plugins.apply(QuerydslPlugin.class) 39 | compileTask = project.tasks.compileQuerydsl as SourceTask 40 | compileTask.includes += ['**/entities/*.java'] 41 | project.evaluate() 42 | 43 | } 44 | 45 | @Test 46 | void testIncludes() { 47 | assertThat(compileTask.getIncludes(), hasItem(is('**/entities/*.java'))) 48 | } 49 | } -------------------------------------------------------------------------------- /auto-value-plugin/src/test/groovy/com/ewerk/gradle/plugins/AutoValuePluginExtensionTest.groovy: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2012-2014 the original author or authors. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package com.ewerk.gradle.plugins 18 | 19 | import org.testng.annotations.BeforeMethod 20 | import org.testng.annotations.Test 21 | 22 | import static org.hamcrest.CoreMatchers.equalTo 23 | import static org.hamcrest.MatcherAssert.assertThat 24 | 25 | /** 26 | * @author holgerstolzenberg 27 | * @since 1.0.0 28 | */ 29 | class AutoValuePluginExtensionTest { 30 | 31 | private AutoValuePluginExtension extension 32 | 33 | @BeforeMethod 34 | void setup() { 35 | extension = new AutoValuePluginExtension() 36 | } 37 | 38 | @Test 39 | void testDefaultGeneratedSourcesDirIsSet() { 40 | String defaultDir = AutoValuePluginExtension.DEFAULT_AUTO_VALUE_SOURCES_DIR 41 | assertThat(extension.autoValueSourcesDir as File, equalTo(new File(defaultDir))) 42 | } 43 | 44 | @Test 45 | void testDefaultLibraryIsSet() { 46 | def defaultLibrary = AutoValuePluginExtension.DEFAULT_LIBRARY 47 | assertThat(extension.library, 48 | equalTo(defaultLibrary)) 49 | } 50 | } -------------------------------------------------------------------------------- /artifactory-deb-publish-plugin/src/main/groovy/com/ewerk/gradle/plugins/tasks/PushDebToArtifactory.groovy: -------------------------------------------------------------------------------- 1 | package com.ewerk.gradle.plugins.tasks 2 | 3 | import com.ewerk.gradle.plugins.ArtifactoryDebPublishPlugin 4 | import com.ewerk.gradle.plugins.ArtifactoryDebPublishPluginExtension 5 | import com.ewerk.gradle.plugins.util.ArtifactoryHttpClient 6 | import org.gradle.api.DefaultTask 7 | import org.gradle.api.logging.Logger 8 | import org.gradle.api.logging.Logging 9 | import org.gradle.api.tasks.TaskAction 10 | 11 | /** 12 | * Gradle task the publishes the desired .deb archive to the configured Artifactory repo. 13 | * It relies on OK HTTP for transport, the Artifactory HTTP API is used for publication. 14 | * 15 | * @author holgerstolzenberg 16 | * @since 1.0.0 17 | */ 18 | class PushDebToArtifactory extends DefaultTask { 19 | static final String DESCRIPTION = "Publishes the .deb archive to Artifactory." 20 | 21 | private static final Logger LOG = Logging.getLogger(PushDebToArtifactory.class) 22 | 23 | PushDebToArtifactory() { 24 | this.group = ArtifactoryDebPublishPlugin.TASK_GROUP 25 | this.description = DESCRIPTION 26 | } 27 | 28 | @SuppressWarnings("GroovyUnusedDeclaration") 29 | @TaskAction 30 | publishToArtifactory() { 31 | LOG.info("Pushing .deb to Artifactory") 32 | 33 | ArtifactoryHttpClient client = new ArtifactoryHttpClient(extension().baseUrl(), 34 | extension().user(), 35 | extension().password(), 36 | extension().repoKey(), 37 | extension().archiveFile().name, 38 | extension().component(), 39 | extension().distribution(), 40 | extension().arch()) 41 | 42 | client.publish(extension().archiveFile()) 43 | } 44 | 45 | private ArtifactoryDebPublishPluginExtension extension() { 46 | project.extensions.artifactoryDebPublish 47 | } 48 | } -------------------------------------------------------------------------------- /artifactory-deb-publish-plugin/src/test/groovy/com/ewerk/gradle/plugins/ArtifactoryDebPushDebToArtifactoryPluginTest.groovy: -------------------------------------------------------------------------------- 1 | package com.ewerk.gradle.plugins 2 | 3 | import org.gradle.api.Project 4 | import org.gradle.testfixtures.ProjectBuilder 5 | import org.testng.annotations.BeforeMethod 6 | import org.testng.annotations.Test 7 | 8 | import static org.hamcrest.CoreMatchers.is 9 | import static org.hamcrest.CoreMatchers.notNullValue 10 | import static org.hamcrest.MatcherAssert.assertThat 11 | 12 | /** 13 | * @author holgerstolzenberg 14 | * @since 1.0.0 15 | */ 16 | class ArtifactoryDebPushDebToArtifactoryPluginTest { 17 | private Project project 18 | 19 | @BeforeMethod 20 | void setup() { 21 | project = ProjectBuilder.builder().build() 22 | project.plugins.apply(ArtifactoryDebPublishPlugin.class) 23 | 24 | project.extensions.artifactoryDebPublish.baseUrl = "http://debian.any.host.com" 25 | project.extensions.artifactoryDebPublish.repoKey = "debian_repo" 26 | project.extensions.artifactoryDebPublish.distribution = "jessie" 27 | project.extensions.artifactoryDebPublish.component = "non-free" 28 | project.extensions.artifactoryDebPublish.arch = "amd64" 29 | } 30 | 31 | @Test 32 | void testPluginAppliesItself() { 33 | assertThat(project.plugins.hasPlugin(ArtifactoryDebPublishPlugin.class), is(true)) 34 | } 35 | 36 | @Test 37 | void testReApplyDoesNotFail() { 38 | project.plugins.apply(ArtifactoryDebPublishPlugin.class) 39 | } 40 | 41 | @Test 42 | void testPluginRegistersExtensions() { 43 | assertThat(project.extensions.artifactoryDebPublish, notNullValue()) 44 | } 45 | 46 | @Test 47 | void testPluginTasksAreAvailable() { 48 | assertThat(project.tasks.pushDebToArtifactory, notNullValue()) 49 | } 50 | 51 | @Test 52 | void testAfterEvaluate() { 53 | project.evaluate() 54 | } 55 | } 56 | -------------------------------------------------------------------------------- /annotation-processor-plugin/src/test/groovy/com/ewerk/gradle/plugins/tasks/AnnotationProcessorTaskTest.groovy: -------------------------------------------------------------------------------- 1 | package com.ewerk.gradle.plugins.tasks 2 | 3 | import com.ewerk.gradle.plugins.AnnotationProcessorPlugin 4 | import org.gradle.api.Project 5 | import org.gradle.testfixtures.ProjectBuilder 6 | import org.testng.annotations.BeforeMethod 7 | import org.testng.annotations.Test 8 | 9 | import static org.hamcrest.CoreMatchers.equalTo 10 | import static org.hamcrest.CoreMatchers.notNullValue 11 | import static org.hamcrest.MatcherAssert.assertThat 12 | 13 | class AnnotationProcessorTaskTest { 14 | 15 | private Project project 16 | 17 | private InitAnnotationProcessorGeneratedDir initTask 18 | private CleanAnnotationProcessorGeneratedDir cleanTask 19 | 20 | @BeforeMethod 21 | void setup() { 22 | project = ProjectBuilder.builder().build() 23 | project.plugins.apply(AnnotationProcessorPlugin.class) 24 | project.extensions.annotationProcessor.library = "com.querydsl:querydsl-apt:4.0.0" 25 | project.extensions.annotationProcessor.processor = "com.querydsl.apt.morphia.MorphiaAnnotationProcessor" 26 | project.evaluate() 27 | initTask = project.tasks.initAnnotationProcessorSourcesDir as InitAnnotationProcessorGeneratedDir 28 | cleanTask = project.tasks.cleanAnnotationProcessorSourcesDir as CleanAnnotationProcessorGeneratedDir 29 | } 30 | 31 | @Test 32 | void initSourceFolders() { 33 | initTask.createSourceFolders() 34 | assertThat(project.sourceSets.annotationProcessor, notNullValue()) 35 | File javaDir = project.sourceSets.annotationProcessor.java.srcDirs.first() as File 36 | assertThat(javaDir.name, equalTo("java")) 37 | } 38 | 39 | @Test 40 | void taskGroup() { 41 | assertThat(cleanTask.group, equalTo(AnnotationProcessorPlugin.TASK_GROUP)) 42 | assertThat(initTask.group, equalTo(AnnotationProcessorPlugin.TASK_GROUP)) 43 | } 44 | } -------------------------------------------------------------------------------- /auto-value-plugin/src/test/groovy/com/ewerk/gradle/plugins/tasks/InitAutoValueSourcesDirTest.groovy: -------------------------------------------------------------------------------- 1 | package com.ewerk.gradle.plugins.tasks 2 | 3 | import com.ewerk.gradle.plugins.AutoValuePlugin 4 | import org.gradle.api.GradleException 5 | import org.gradle.api.Project 6 | import org.gradle.testfixtures.ProjectBuilder 7 | import org.testng.annotations.BeforeMethod 8 | import org.testng.annotations.Test 9 | 10 | import static org.hamcrest.CoreMatchers.equalTo 11 | import static org.hamcrest.CoreMatchers.notNullValue 12 | import static org.hamcrest.MatcherAssert.assertThat 13 | 14 | /** 15 | * @author holgerstolzenberg 16 | * @since 1.0.0 17 | */ 18 | class InitAutoValueSourcesDirTest { 19 | 20 | private Project project 21 | 22 | private InitAutoValueSourcesDir createTask 23 | 24 | @BeforeMethod 25 | void setup() { 26 | project = ProjectBuilder.builder().build() 27 | project.plugins.apply(AutoValuePlugin.class) 28 | project.evaluate() 29 | 30 | createTask = project.tasks.initAutoValueSourcesDir as InitAutoValueSourcesDir 31 | } 32 | 33 | @Test(expectedExceptions = GradleException.class, expectedExceptionsMessageRegExp = "The configured autoValueSourcesDir.*") 34 | void testCreateSourceFolders() { 35 | project.autoValue.autoValueSourcesDir = "src/main/java" 36 | createTask.createSourceFolders() 37 | } 38 | 39 | @Test 40 | void testCreateSourceFoldersBuildFail() { 41 | 42 | createTask.createSourceFolders() 43 | assertThat(project.sourceSets.autoValue, notNullValue()) 44 | 45 | File javaDir = project.sourceSets.autoValue.java.srcDirs.first() as File 46 | assertThat(javaDir.name, equalTo("java")) 47 | } 48 | 49 | @Test 50 | void testGroup() { 51 | assertThat(createTask.group, equalTo(AutoValuePlugin.TASK_GROUP)) 52 | } 53 | 54 | @Test 55 | void testDescription() { 56 | assertThat(createTask.description, equalTo(InitAutoValueSourcesDir.DESCRIPTION)) 57 | } 58 | } 59 | -------------------------------------------------------------------------------- /artifactory-deb-publish-plugin/readme.md: -------------------------------------------------------------------------------- 1 | ### Artifactory .deb publish plugin 2 | 3 | #### Description 4 | 5 | Currently publishing .deb archives to Artifactory via Gradle is not very straight forward. The 6 | publish plugin provided by JFrog only documents examples for publishing Maven artifacts. 7 | 8 | Deploying .deb archives to artifactory is possible through its HTTP API. This plugin will allow 9 | for publishing .deb archives with the relevant meta data to Artifactory, using the aforementioned 10 | HTTP API. 11 | 12 | The plugin relies on the [OkHttp](change_log.md) library for pushing the .deb archive to Artifactory 13 | via HTTP PUT. 14 | 15 | Please have a look at the plugins [change log](http://square.github.io/okhttp/). 16 | 17 | #### Configuration 18 | 19 | ##### baseUrl 20 | The Artifactory servers base url 21 | 22 | ##### user (optional) 23 | The user for authenticating at Artifactory if anonymous access is disabled 24 | 25 | ##### password (optional) 26 | The password for authenticating at Artifactory if anonymous access is disabled 27 | 28 | ##### repoKey 29 | The Artifactory repository ID to publish to 30 | 31 | ##### distribution 32 | The Debian distribution to publish for (wheezy, jessie, ...) 33 | 34 | ##### distribution 35 | The Debian component to publish for (main, contrib, non-free, ...) 36 | 37 | ##### arch 38 | The Debian architecture to publish for (i386, amd64, ...) 39 | 40 | #### Examples 41 | 42 | __Use via Gradle plugin portal__ 43 | 44 | ```groovy 45 | plugins { 46 | id "com.ewerk.gradle.plugins.artifactory-deb-publish" version "1.0.0" 47 | } 48 | 49 | // the following closure demonstrates some of the configuration defaults and is not necessary 50 | artifactoryDebPublish { 51 | baseUrl = 'https://artifactory.company.com' 52 | user = 'my.user' 53 | password = '***' 54 | repoKey = 'debian_snapshots' 55 | distribution = 'jessie' 56 | component = 'non-free' 57 | arch = 'amd64' 58 | archive = file('src/main/resources/helloworld_1.0_amd64.deb') 59 | } 60 | ``` -------------------------------------------------------------------------------- /jaxb2-plugin/src/main/groovy/com/ewerk/gradle/plugins/tasks/InitJaxb2SourcesDir.groovy: -------------------------------------------------------------------------------- 1 | package com.ewerk.gradle.plugins.tasks 2 | 3 | import com.ewerk.gradle.plugins.Jaxb2Plugin 4 | import org.gradle.api.DefaultTask 5 | import org.gradle.api.GradleException 6 | import org.gradle.api.logging.Logger 7 | import org.gradle.api.tasks.TaskAction 8 | 9 | import static org.gradle.api.logging.Logging.getLogger 10 | 11 | /** 12 | * This task is responsible for removing and recreating the configured Jaxb2 source roots. 13 | * 14 | * @author holgerstolzenberg 15 | * @since 1.0.0 16 | */ 17 | class InitJaxb2SourcesDir extends DefaultTask { 18 | private static final Logger LOG = getLogger(InitJaxb2SourcesDir.class) 19 | 20 | static final String DESCRIPTION = "Creates the Jaxb2 sources dir." 21 | 22 | InitJaxb2SourcesDir() { 23 | this.group = Jaxb2Plugin.TASK_GROUP 24 | this.description = DESCRIPTION 25 | } 26 | 27 | @SuppressWarnings("GroovyUnusedDeclaration") 28 | @TaskAction 29 | createSourceFolders() { 30 | Set xjcConfigs = project.extensions.jaxb2.xjc 31 | 32 | for (XjcTaskConfig theConfig : xjcConfigs) { 33 | File generatedSourcesDir = project.file(theConfig.generatedSourcesDir) 34 | if (theConfig.createSourceSet) { 35 | verifyNotWithinMainBuildSrc(generatedSourcesDir) 36 | } 37 | createSourcesDirectory(generatedSourcesDir) 38 | } 39 | } 40 | 41 | private static boolean createSourcesDirectory(generatedSourcesDir) { 42 | def created = generatedSourcesDir.exists() 43 | if (!created) { 44 | LOG.info("Create source set ${generatedSourcesDir}.") 45 | created = generatedSourcesDir.mkdirs() 46 | } 47 | return created 48 | } 49 | 50 | private void verifyNotWithinMainBuildSrc(generatedSourcesDir) { 51 | project.sourceSets.main.java.srcDirs.each { d -> 52 | if (d.absolutePath == generatedSourcesDir.absolutePath) { 53 | throw new GradleException("The configured generatedSourcesDir must specify a separate location to existing source code.") 54 | } 55 | } 56 | } 57 | } 58 | -------------------------------------------------------------------------------- /dagger-plugin/src/test/groovy/com/ewerk/gradle/plugins/tasks/DaggerTaskTest.groovy: -------------------------------------------------------------------------------- 1 | package com.ewerk.gradle.plugins.tasks 2 | 3 | import com.ewerk.gradle.plugins.DaggerPlugin 4 | import org.gradle.api.GradleException 5 | import org.gradle.api.Project 6 | import org.gradle.testfixtures.ProjectBuilder 7 | import org.testng.annotations.BeforeMethod 8 | import org.testng.annotations.Test 9 | 10 | import static org.hamcrest.CoreMatchers.equalTo 11 | import static org.hamcrest.CoreMatchers.notNullValue 12 | import static org.hamcrest.MatcherAssert.assertThat 13 | 14 | /** 15 | * @griffio 16 | */ 17 | class DaggerTaskTest { 18 | 19 | private Project project 20 | 21 | private InitDaggerSourcesDir initTask 22 | private CleanDaggerSourcesDir cleanTask 23 | 24 | @BeforeMethod 25 | void setup() { 26 | project = ProjectBuilder.builder().build() 27 | project.plugins.apply(DaggerPlugin.class) 28 | project.evaluate() 29 | initTask = project.tasks.initDaggerSourcesDir as InitDaggerSourcesDir 30 | cleanTask = project.tasks.cleanDaggerSourcesDir as CleanDaggerSourcesDir 31 | } 32 | 33 | @Test(expectedExceptions = GradleException.class, expectedExceptionsMessageRegExp = "The configured daggerSourcesDir.*") 34 | void testCreateSourceFoldersException() { 35 | project.dagger.daggerSourcesDir = "src/main/java" 36 | initTask.createSourceFolders() 37 | } 38 | 39 | @Test(expectedExceptions = GradleException.class, expectedExceptionsMessageRegExp = "The configured daggerSourcesDir.*") 40 | void testCleanSourceFoldersException() { 41 | project.dagger.daggerSourcesDir = "src/main/java" 42 | cleanTask.cleanSourceFolders() 43 | } 44 | 45 | @Test 46 | void initSourceFolders() { 47 | initTask.createSourceFolders() 48 | assertThat(project.sourceSets.dagger, notNullValue()) 49 | File javaDir = project.sourceSets.dagger.java.srcDirs.first() as File 50 | assertThat(javaDir.name, equalTo("java")) 51 | } 52 | 53 | @Test 54 | void taskGroup() { 55 | assertThat(cleanTask.group, equalTo(DaggerPlugin.TASK_GROUP)) 56 | assertThat(initTask.group, equalTo(DaggerPlugin.TASK_GROUP)) 57 | } 58 | } -------------------------------------------------------------------------------- /artifactory-deb-publish-plugin/src/test/groovy/com/ewerk/gradle/plugins/ArtifactoryDebPublishPluginExtensionTest.groovy: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2012-2014 the original author or authors. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package com.ewerk.gradle.plugins 18 | 19 | import org.testng.annotations.BeforeMethod 20 | import org.testng.annotations.Test 21 | 22 | import static org.hamcrest.CoreMatchers.notNullValue 23 | import static org.hamcrest.MatcherAssert.assertThat 24 | 25 | /** 26 | * @author holgerstolzenberg 27 | * @since 1.0.0 28 | */ 29 | class ArtifactoryDebPublishPluginExtensionTest { 30 | 31 | private ArtifactoryDebPublishPluginExtension extension 32 | 33 | @BeforeMethod 34 | void setup() { 35 | extension = new ArtifactoryDebPublishPluginExtension() 36 | extension.baseUrl = 'https://artifactory.com' 37 | extension.repoKey = "debian_repo" 38 | extension.distribution = "jessie" 39 | extension.component = "non-free" 40 | extension.arch = "amd64" 41 | } 42 | 43 | @Test 44 | void testBaseUrlMustNotBeNull() { 45 | assertThat(extension.baseUrl, notNullValue()) 46 | } 47 | 48 | @Test 49 | void testRepoKeyMustNotBeNull() { 50 | assertThat(extension.repoKey, notNullValue()) 51 | } 52 | 53 | @Test 54 | void testDistributionMustNotBeNull() { 55 | assertThat(extension.distribution, notNullValue()) 56 | } 57 | 58 | @Test 59 | void testComponentMustNotBeNull() { 60 | assertThat(extension.component, notNullValue()) 61 | } 62 | 63 | @Test 64 | void testArchMustNotBeNull() { 65 | assertThat(extension.arch, notNullValue()) 66 | } 67 | } -------------------------------------------------------------------------------- /auto-value-plugin/src/test/groovy/com/ewerk/gradle/plugins/AutoValuePluginTest.groovy: -------------------------------------------------------------------------------- 1 | package com.ewerk.gradle.plugins 2 | 3 | import com.ewerk.gradle.plugins.tasks.InitAutoValueSourcesDir 4 | import org.gradle.api.Project 5 | import org.gradle.api.Task 6 | import org.gradle.api.internal.artifacts.dependencies.DefaultExternalModuleDependency 7 | import org.gradle.api.plugins.JavaPlugin 8 | import org.gradle.testfixtures.ProjectBuilder 9 | import org.testng.annotations.BeforeMethod 10 | import org.testng.annotations.Test 11 | 12 | import static org.hamcrest.CoreMatchers.* 13 | import static org.hamcrest.MatcherAssert.assertThat 14 | 15 | /** 16 | * @author holgerstolzenberg 17 | * @since 1.0.0 18 | */ 19 | class AutoValuePluginTest { 20 | private Project project 21 | 22 | @BeforeMethod 23 | void setup() { 24 | project = ProjectBuilder.builder().build() 25 | project.plugins.apply(AutoValuePlugin.class) 26 | } 27 | 28 | @Test 29 | void testPluginAppliesItself() { 30 | assertThat(project.plugins.hasPlugin(AutoValuePlugin.class), is(true)) 31 | } 32 | 33 | @Test 34 | void testReApplyDoesNotFail() { 35 | project.plugins.apply(AutoValuePlugin.class) 36 | } 37 | 38 | @Test 39 | void testPluginAppliesJavaPlugin() { 40 | assertThat(project.plugins.hasPlugin(JavaPlugin.class), is(true)) 41 | } 42 | 43 | @Test 44 | void testPluginRegistersAutoValueExtensions() { 45 | assertThat(project.extensions.autoValue, notNullValue()) 46 | } 47 | 48 | @Test 49 | void testPluginTasksAreAvailable() { 50 | assertThat(project.tasks.initAutoValueSourcesDir, notNullValue()) 51 | } 52 | 53 | @Test 54 | void testTaskTypes() { 55 | final Task initTask = project.tasks.initAutoValueSourcesDir 56 | assertThat(initTask, instanceOf(InitAutoValueSourcesDir.class)) 57 | } 58 | 59 | @Test 60 | void testAfterEvaluate() { 61 | project.evaluate() 62 | 63 | DefaultExternalModuleDependency lib = project.configurations.compile.dependencies[0] as DefaultExternalModuleDependency 64 | 65 | String id = lib.group + ":" + 66 | lib.name + 67 | ":" + 68 | lib.version 69 | 70 | assertThat(id, equalTo(AutoValuePluginExtension.DEFAULT_LIBRARY)) 71 | } 72 | } 73 | -------------------------------------------------------------------------------- /dagger-plugin/src/test/groovy/com/ewerk/gradle/plugins/DaggerAndroidPluginTest.groovy: -------------------------------------------------------------------------------- 1 | package com.ewerk.gradle.plugins 2 | 3 | import com.android.build.gradle.AppPlugin 4 | import com.android.build.gradle.LibraryPlugin 5 | import org.gradle.api.Project 6 | import org.gradle.testfixtures.ProjectBuilder 7 | import org.testng.annotations.BeforeMethod 8 | import org.testng.annotations.Test 9 | 10 | import static org.hamcrest.CoreMatchers.* 11 | import static org.hamcrest.MatcherAssert.assertThat 12 | 13 | /** 14 | * @author griffio 15 | * 16 | * */ 17 | class DaggerAndroidPluginTest { 18 | 19 | private Project project 20 | private File generatedDir 21 | 22 | @BeforeMethod 23 | void androidProject() { 24 | Project root = ProjectBuilder.builder().build() 25 | 26 | project = ProjectBuilder.builder().withParent(root).build() 27 | project.plugins.apply('android') 28 | project.plugins.apply(DaggerPlugin.class) 29 | project.android { 30 | compileSdkVersion "android-25" 31 | buildToolsVersion "25.0.2" 32 | defaultConfig { 33 | testApplicationId "com.ewerk.gradle.plugins" 34 | minSdkVersion 15 35 | targetSdkVersion 25 36 | versionCode 1 37 | versionName "1.0" 38 | } 39 | } 40 | 41 | project.repositories { 42 | mavenCentral() 43 | } 44 | 45 | generatedDir = new File(project.projectDir, "/build/generated/source/dagger") 46 | } 47 | 48 | @Test 49 | void testPlugins() { 50 | assertThat(project.plugins.hasPlugin(AppPlugin) || project.plugins.hasPlugin(LibraryPlugin), is(true)) 51 | } 52 | 53 | @Test 54 | void testPluginDependencies() { 55 | def lib = project.configurations.compile.dependencies.collect { 56 | "$it.group:$it.name:$it.version" as String 57 | }.toSet() 58 | assertThat(lib, hasItem(project.extensions.dagger.library)) 59 | } 60 | 61 | @Test 62 | void testVariant() { 63 | project.evaluate() 64 | project.android.applicationVariants.all { variant -> 65 | def args = variant.javaCompile.options.compilerArgs as List 66 | assertThat(args, hasItems('-s', '-processor', DaggerPluginExtension.PROCESSOR, 67 | new File(generatedDir, variant.dirName as String).path)) 68 | } 69 | 70 | } 71 | } 72 | -------------------------------------------------------------------------------- /querydsl-plugin/src/main/groovy/com/ewerk/gradle/plugins/QuerydslPluginExtension.groovy: -------------------------------------------------------------------------------- 1 | package com.ewerk.gradle.plugins 2 | 3 | /** 4 | * DLS extension for the Querydsl plugin. Provides some convenient configuration options. 5 | * 6 | * The processor configuration and processor classes are defined in this location. 7 | * 8 | * @author holgerstolzenberg , griffio 9 | * @since 1.0.0 10 | */ 11 | class QuerydslPluginExtension { 12 | 13 | static String HIBERNATE_PROC = "com.querydsl.apt.hibernate.HibernateAnnotationProcessor" 14 | static String JDO_PROC = "com.querydsl.apt.jdo.JDOAnnotationProcessor" 15 | static String JPA_PROC = "com.querydsl.apt.jpa.JPAAnnotationProcessor" 16 | static String MORPHIA_PROC = "com.querydsl.apt.morphia.MorphiaAnnotationProcessor" 17 | static String QUERYDSL_PROC = "com.querydsl.apt.QuerydslAnnotationProcessor" 18 | static String ROO_PROC = "com.querydsl.apt.roo.RooAnnotationProcessor" 19 | static String SPRING_DATA_MONGO_PROC = "org.springframework.data.mongodb.repository.support.MongoAnnotationProcessor" 20 | 21 | static final String NAME = "querydsl" 22 | static final String DEFAULT_QUERYDSL_SOURCES_DIR = "src/querydsl/java" 23 | static final String DEFAULT_LIBRARY = "com.querydsl:querydsl-apt:4.1.4" 24 | 25 | String querydslSourcesDir = DEFAULT_QUERYDSL_SOURCES_DIR 26 | String library = DEFAULT_LIBRARY 27 | 28 | boolean jpa = false 29 | boolean jdo = false 30 | boolean hibernate = false 31 | boolean morphia = false 32 | boolean roo = false 33 | boolean springDataMongo = false 34 | boolean querydslDefault = false 35 | 36 | List aptOptions = [] 37 | 38 | String processors() { 39 | 40 | List processors = [] 41 | 42 | if (hibernate) { 43 | processors << HIBERNATE_PROC 44 | } 45 | 46 | if (jdo) { 47 | processors << JDO_PROC 48 | } 49 | 50 | if (jpa) { 51 | processors << JPA_PROC 52 | } 53 | 54 | if (morphia) { 55 | processors << MORPHIA_PROC 56 | } 57 | 58 | if (roo) { 59 | processors << ROO_PROC 60 | } 61 | 62 | if (querydslDefault) { 63 | processors << QUERYDSL_PROC 64 | } 65 | 66 | if (springDataMongo) { 67 | processors << SPRING_DATA_MONGO_PROC 68 | } 69 | 70 | return processors.join(",") 71 | } 72 | } 73 | -------------------------------------------------------------------------------- /jaxb2-plugin/src/test/groovy/com/ewerk/gradle/plugins/Jaxb2PluginTest.groovy: -------------------------------------------------------------------------------- 1 | package com.ewerk.gradle.plugins 2 | 3 | import com.ewerk.gradle.plugins.tasks.CleanJaxb2SourcesDir 4 | import com.ewerk.gradle.plugins.tasks.GenerateJaxb2Classes 5 | import com.ewerk.gradle.plugins.tasks.InitJaxb2SourcesDir 6 | import org.gradle.api.Project 7 | import org.gradle.api.plugins.JavaPlugin 8 | import org.gradle.testfixtures.ProjectBuilder 9 | import org.testng.annotations.BeforeMethod 10 | import org.testng.annotations.Test 11 | 12 | import static org.hamcrest.CoreMatchers.* 13 | import static org.hamcrest.MatcherAssert.assertThat 14 | 15 | /** 16 | * @author holgerstolzenberg 17 | * @since 1.0.0 18 | */ 19 | class Jaxb2PluginTest { 20 | private Project project 21 | 22 | @BeforeMethod 23 | void setup() { 24 | project = ProjectBuilder.builder().build() 25 | project.plugins.apply(Jaxb2Plugin.class) 26 | } 27 | 28 | @Test 29 | void testPluginAppliesItself() { 30 | assertThat(project.plugins.hasPlugin(Jaxb2Plugin.class), is(true)) 31 | } 32 | 33 | @Test 34 | void testReApplyDoesNotFail() { 35 | project.plugins.apply(Jaxb2Plugin.class) 36 | } 37 | 38 | @Test 39 | void testPluginAppliesJavaPlugin() { 40 | assertThat(project.plugins.hasPlugin(JavaPlugin.class), is(true)) 41 | } 42 | 43 | @Test 44 | void testPluginRegistersJaxb2Extensions() { 45 | assertThat(project.extensions.jaxb2, notNullValue()) 46 | } 47 | 48 | @Test 49 | void testInitTaskIsAvailable() { 50 | assertThat(project.tasks.initJaxb2SourcesDir, notNullValue()) 51 | } 52 | 53 | @Test 54 | void testCleanTaskIsAvailable() { 55 | assertThat(project.tasks.cleanJaxb2SourcesDir, notNullValue()) 56 | } 57 | 58 | @Test 59 | void testGenerateTaskIsAvailable() { 60 | assertThat(project.tasks.generateJaxb2Classes, notNullValue()) 61 | } 62 | 63 | @Test 64 | void testInitTaskType() { 65 | assertThat(project.tasks.initJaxb2SourcesDir, instanceOf(InitJaxb2SourcesDir.class)) 66 | } 67 | 68 | @Test 69 | void testCleanTaskType() { 70 | assertThat(project.tasks.cleanJaxb2SourcesDir, instanceOf(CleanJaxb2SourcesDir.class)) 71 | } 72 | 73 | @Test 74 | void testGenerateTaskType() { 75 | assertThat(project.tasks.generateJaxb2Classes, instanceOf(GenerateJaxb2Classes.class)) 76 | } 77 | } 78 | -------------------------------------------------------------------------------- /dagger-plugin/readme.md: -------------------------------------------------------------------------------- 1 | ### Dagger plugin 2 | 3 | #### Description 4 | 5 | "Dagger2 dependency injection - The guiding principle is to generate code that mimics the code that a user might have hand-written." 6 | 7 | This plugin uses the [Dagger2](http://google.github.io/dagger/) compiler to process annotations that are compatible with `JSR-330`. 8 | 9 | Gradle Java/Android plugin support (imported into Intellij/Android Studio). 10 | 11 | [This plugins change log](change_log.md). 12 | 13 | #### Building the plugin 14 | Some of the plugin's unit tests need an installed Android SDK in order to test plugin compatibility within 15 | an Android project. 16 | 17 | ##### Installing the SDK 18 | The SDK can be downloaded here: https://developer.android.com/studio/index.html#downloads 19 | 20 | You just need to download the tools distribution. After set point `$ANDROID_HOME` to the install location 21 | and use `android` or `sdkmanger` command to install the Android distribution needed. 22 | 23 | ##### Package managers 24 | Alternatively the Android SDK can be installed using different package managers. 25 | On Mac you can use [Homebrew](http://brew.sh/index_de.html) (Mac). 26 | 27 | `brew install android-sdk` 28 | 29 | #### Configuration 30 | 31 | ##### daggerSourcesDir 32 | The destination directory for the generated Dagger java source. 33 | Defaults to `src/dagger/java` for Java Plugin projects. 34 | 35 | The `daggerSourcesDir` is deleted when executing the clean task; for this reason, a BuildException will be thrown if 36 | `daggerSourcesDir` is located as your main java sources. 37 | 38 | Android projects always use `${buildDir}/generated/source/dagger/` to maintain Android convention. 39 | 40 | ##### library 41 | The dependency artifact for the compile/runtime usage of Dagger. 42 | This is added to the compile configuration for the project. 43 | 44 | Defaults to `com.google.dagger:dagger:2.6.1`. 45 | 46 | ##### processorLibrary 47 | The dependency artifact for the compile/runtime usage of Dagger. 48 | 49 | Defaults to `com.google.dagger:dagger-compiler:2.6.1`. 50 | 51 | #### Examples 52 | __Use via Gradle plugin portal__ 53 | 54 | ```groovy 55 | plugins { 56 | id "com.ewerk.gradle.plugins.dagger" version "1.0.4" 57 | } 58 | 59 | // the following closure demonstrates some of the configuration defaults and is not necessary 60 | dagger { 61 | library = "com.google.dagger:dagger:2.6.1" 62 | processorLibrary = "com.google.dagger:dagger-compiler:2.6.1" 63 | daggerSourcesDir = "src/dagger/java" 64 | } 65 | ``` -------------------------------------------------------------------------------- /annotation-processor-plugin/readme.md: -------------------------------------------------------------------------------- 1 | ### Annotation Processor plugin 2 | 3 | #### Description 4 | 5 | This plugin provides a simple integration point for an Annotation Processor capable of generating Java source. 6 | 7 | A separate compile task that only runs the annotation processor is executed during build phase. 8 | 9 | If the configured processor library is a required compile dependency then add '-proc:none' to your 10 | 'compileJava.options.compilerArgs', this will stop javac executing the processor using classpath discovery. 11 | 12 | [This plugins change log](change_log.md). 13 | 14 | #### Configuration 15 | 16 | ##### sourcesDir 17 | 18 | This specifies the annotation processor destination directory; It will be created automatically. 19 | 20 | Defaults to 'src/generated/java'. 21 | 22 | ##### library 23 | 24 | This specifies dependency artifact co-ordinates or a project dependency module containing the annotation processor. 25 | It will only be added to the classpath of the annotation process compile task 26 | 27 | Required value. 28 | 29 | ##### processor 30 | 31 | This specifies a fully qualified annotation processor class found in the library dependency. 32 | 33 | Required value. 34 | 35 | #### options 36 | 37 | Used to pass options to the processors. Only those options registered with the SupportedOptions annotation are passed to a processor. 38 | 39 | #### Examples 40 | 41 | __Use via Gradle plugin portal__ 42 | 43 | ```groovy 44 | plugins { 45 | id "com.ewerk.gradle.plugins.annotation-processor" version "1.0.2" 46 | } 47 | 48 | // the following closure demonstrates a configuration with artifact co-ordinates 49 | annotationProcessor { 50 | library "com.querydsl:querydsl-apt:4.0.0" 51 | processor "com.querydsl.apt.morphia.MorphiaAnnotationProcessor" 52 | sourcesDir "src/morphia/java" 53 | } 54 | 55 | // the following closure demonstrates a configuration with project module dependency 56 | annotationProcessor { 57 | library project(":myproc") 58 | processor "com.querydsl.apt.morphia.MorphiaAnnotationProcessor" 59 | sourcesDir "src/morphia/java" 60 | options = ['key':'value'] 61 | } 62 | 63 | // the following processor is also required on the compile classpath 64 | annotationProcessor { 65 | library "com.beust:version-processor:0.2" 66 | processor "com.beust.version.VersionProcessor" 67 | } 68 | 69 | // processor dependency for compile 70 | compile("com.beust:version-processor:0.2") 71 | 72 | // must disable classpath processor 73 | compileJava.options.compilerArgs << '-proc:none' 74 | 75 | ``` 76 | -------------------------------------------------------------------------------- /gradlew.bat: -------------------------------------------------------------------------------- 1 | @if "%DEBUG%" == "" @echo off 2 | @rem ########################################################################## 3 | @rem 4 | @rem Gradle startup script for Windows 5 | @rem 6 | @rem ########################################################################## 7 | 8 | @rem Set local scope for the variables with windows NT shell 9 | if "%OS%"=="Windows_NT" setlocal 10 | 11 | set DIRNAME=%~dp0 12 | if "%DIRNAME%" == "" set DIRNAME=. 13 | set APP_BASE_NAME=%~n0 14 | set APP_HOME=%DIRNAME% 15 | 16 | @rem Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script. 17 | set DEFAULT_JVM_OPTS= 18 | 19 | @rem Find java.exe 20 | if defined JAVA_HOME goto findJavaFromJavaHome 21 | 22 | set JAVA_EXE=java.exe 23 | %JAVA_EXE% -version >NUL 2>&1 24 | if "%ERRORLEVEL%" == "0" goto init 25 | 26 | echo. 27 | echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. 28 | echo. 29 | echo Please set the JAVA_HOME variable in your environment to match the 30 | echo location of your Java installation. 31 | 32 | goto fail 33 | 34 | :findJavaFromJavaHome 35 | set JAVA_HOME=%JAVA_HOME:"=% 36 | set JAVA_EXE=%JAVA_HOME%/bin/java.exe 37 | 38 | if exist "%JAVA_EXE%" goto init 39 | 40 | echo. 41 | echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME% 42 | echo. 43 | echo Please set the JAVA_HOME variable in your environment to match the 44 | echo location of your Java installation. 45 | 46 | goto fail 47 | 48 | :init 49 | @rem Get command-line arguments, handling Windows variants 50 | 51 | if not "%OS%" == "Windows_NT" goto win9xME_args 52 | 53 | :win9xME_args 54 | @rem Slurp the command line arguments. 55 | set CMD_LINE_ARGS= 56 | set _SKIP=2 57 | 58 | :win9xME_args_slurp 59 | if "x%~1" == "x" goto execute 60 | 61 | set CMD_LINE_ARGS=%* 62 | 63 | :execute 64 | @rem Setup the command line 65 | 66 | set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar 67 | 68 | @rem Execute Gradle 69 | "%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %CMD_LINE_ARGS% 70 | 71 | :end 72 | @rem End local scope for the variables with windows NT shell 73 | if "%ERRORLEVEL%"=="0" goto mainEnd 74 | 75 | :fail 76 | rem Set variable GRADLE_EXIT_CONSOLE if you need the _script_ return code instead of 77 | rem the _cmd.exe /c_ return code! 78 | if not "" == "%GRADLE_EXIT_CONSOLE%" exit 1 79 | exit /b 1 80 | 81 | :mainEnd 82 | if "%OS%"=="Windows_NT" endlocal 83 | 84 | :omega 85 | -------------------------------------------------------------------------------- /CONTRIBUTING.md: -------------------------------------------------------------------------------- 1 | # How Do I Contribute? 2 | 3 | You can participate to this project and sub projects with any [issues](https://github.com/ewerk/gradle-plugins/issues) and where [pull requests](https://github.com/ewerk/gradle-plugins/pulls) are also welcome, we have some helpful guidelines to follow. 4 | 5 | ### Plugin Development 6 | 7 | When contributing to plugin development, you should fork from the main project and create a new feature branch for your own commits. When you are done create a [pull request](https://help.github.com/articles/using-pull-requests/) to [upstream master](https://github.com/ewerk/gradle-plugins/tree/master). 8 | If you are creating a PR from an issue, see [closing issues via commit messages](https://help.github.com/articles/closing-issues-via-commit-messages/). 9 | 10 | **Some guidelines** 11 | * Plugins are developed for Java 1.8 compatibility 12 | * Please review all existing plugins for naming conventions and source code layout 13 | * Java source code in this project is currently indented with 2 spaces 14 | * Update any plugin README.md or CHANGE_LOG.md to reflect the latest values that may now be relevant after your changes 15 | * Create a minimal JUnit test and possibly add an example to [gradle-plugins-samples](https://github.com/ewerk/gradle-plugins-samples) 16 | 17 | **Development Setup** 18 | 19 | From your plugin development branch, your latest changes can be installed to your local maven (.m2) repository with a version labeled at the SNAPSHOT build located in the gradle.properties. 20 | 21 | To do this, use the **install** task 22 | ``` 23 | ../gradlew build install 24 | ``` 25 | 26 | It is recommended to test any changes against the [gradle-plugins-samples](https://github.com/ewerk/gradle-plugins-samples) 27 | 28 | ### How do I setup a local plugin? 29 | 30 | In your own project or, for example, in the samples build.gradle, remove [1] the line where the released version is applied from the Gradle plugin portal, add a buildscript [2] section using mavenLocal() as the repository and the plugin identifier to apply plugin. 31 | 32 | Each plugin's gradle.properties maintains the current snapshot version. 33 | 34 | **Example** 35 | 36 | [1] Remove the current plugin portal version 37 | ``` 38 | plugins { 39 | // id 'com.ewerk.gradle.plugins.annotation-processor' version '1.0.2' 40 | } 41 | ``` 42 | [2] Replace with a build script for your local snapshot version 43 | ``` 44 | buildscript { 45 | repositories { 46 | mavenLocal() 47 | } 48 | 49 | dependencies { 50 | classpath 'com.ewerk.gradle.plugins:annotation-processor-plugin:1.0.3-SNAPSHOT' 51 | } 52 | } 53 | 54 | apply plugin: 'com.ewerk.gradle.plugins.annotation-processor' 55 | ``` 56 | -------------------------------------------------------------------------------- /dagger-plugin/src/test/groovy/com/ewerk/gradle/plugins/DaggerJavaPluginTest.groovy: -------------------------------------------------------------------------------- 1 | package com.ewerk.gradle.plugins 2 | 3 | import org.gradle.api.Project 4 | import org.gradle.api.plugins.BasePlugin 5 | import org.gradle.api.plugins.JavaPlugin 6 | import org.gradle.api.plugins.WarPlugin 7 | import org.gradle.testfixtures.ProjectBuilder 8 | import org.testng.annotations.BeforeMethod 9 | import org.testng.annotations.Test 10 | 11 | import static org.hamcrest.CoreMatchers.* 12 | import static org.hamcrest.MatcherAssert.assertThat 13 | 14 | /** 15 | * @author griffio 16 | */ 17 | class DaggerJavaPluginTest { 18 | 19 | private Project project 20 | 21 | @BeforeMethod 22 | void setup() { 23 | project = ProjectBuilder.builder().build() 24 | project.plugins.apply(DaggerPlugin.class) 25 | project.plugins.apply(WarPlugin.class) 26 | } 27 | 28 | @Test 29 | void testBasePlugin() { 30 | assertThat(project.plugins.hasPlugin(BasePlugin.class), is(true)) 31 | } 32 | 33 | @Test 34 | void testPluginAppliesItself() { 35 | assertThat(project.plugins.hasPlugin(DaggerPlugin.class), is(true)) 36 | } 37 | 38 | @Test 39 | void testReApplyDoesNotFail() { 40 | project.plugins.apply(DaggerPlugin.class) 41 | } 42 | 43 | @Test 44 | void testPluginAppliesJavaPlugin() { 45 | assertThat(project.plugins.hasPlugin(JavaPlugin.class), is(true)) 46 | } 47 | 48 | @Test 49 | void testPluginEvaluatesDependencies() { 50 | project.evaluate() 51 | def lib = project.configurations.compile.dependencies.collect { 52 | "$it.group:$it.name:$it.version" as String 53 | }.toSet() 54 | assertThat(lib, hasItem(project.extensions.dagger.library)) 55 | } 56 | 57 | @Test 58 | void testPluginEvaluatesCompileOptions() { 59 | project.evaluate() 60 | def args = project.tasks.compileDagger.options.compilerArgs as List 61 | assertThat(args, hasItems('-proc:only', '-s', '-processor', DaggerPluginExtension.PROCESSOR, 62 | new File(project.projectDir, DaggerPluginExtension.DEFAULT_DAGGER_SOURCES_DIR).path)) 63 | } 64 | 65 | @Test 66 | void testDefaultGeneratedSourcesDirIsSet() { 67 | assertThat(project.extensions.dagger.daggerSourcesDir as String, 68 | equalTo(DaggerPluginExtension.DEFAULT_DAGGER_SOURCES_DIR)) 69 | } 70 | 71 | @Test 72 | void testDefaultLibraryIsSet() { 73 | assertThat(project.extensions.dagger.library as String, 74 | equalTo(DaggerPluginExtension.DEFAULT_LIBRARY)) 75 | } 76 | 77 | @Test 78 | void testDefaultProcessorIsSet() { 79 | assertThat(project.extensions.dagger.processorLibrary as String, 80 | equalTo(DaggerPluginExtension.DEFAULT_PROCESSOR_LIBRARY)) 81 | } 82 | } -------------------------------------------------------------------------------- /annotation-processor-plugin/src/test/groovy/com/ewerk/gradle/plugins/AnnotationProcessorPluginTest.groovy: -------------------------------------------------------------------------------- 1 | package com.ewerk.gradle.plugins 2 | 3 | import org.gradle.api.Project 4 | import org.gradle.api.plugins.BasePlugin 5 | import org.gradle.api.plugins.WarPlugin 6 | import org.gradle.testfixtures.ProjectBuilder 7 | import org.testng.annotations.BeforeMethod 8 | import org.testng.annotations.Test 9 | 10 | import static org.hamcrest.CoreMatchers.* 11 | import static org.hamcrest.MatcherAssert.assertThat 12 | 13 | class AnnotationProcessorPluginTest { 14 | 15 | private Project project 16 | 17 | @BeforeMethod 18 | void setup() { 19 | project = ProjectBuilder.builder().build() 20 | project.plugins.apply(AnnotationProcessorPlugin.class) 21 | project.plugins.apply(WarPlugin.class) 22 | project.extensions.annotationProcessor.library = "com.querydsl:querydsl-apt:4.0.0" 23 | project.extensions.annotationProcessor.processor = "com.querydsl.apt.morphia.MorphiaAnnotationProcessor" 24 | } 25 | 26 | @Test 27 | void testBasePlugin() { 28 | assertThat(project.plugins.hasPlugin(BasePlugin.class), is(true)) 29 | } 30 | 31 | @Test 32 | void testPluginAppliesItself() { 33 | assertThat(project.plugins.hasPlugin(AnnotationProcessorPlugin.class), is(true)) 34 | } 35 | 36 | @Test 37 | void testReApplyDoesNotFail() { 38 | project.plugins.apply(AnnotationProcessorPlugin.class) 39 | } 40 | 41 | @Test 42 | void testPluginAppliesJavaPlugin() { 43 | assertThat(project.plugins.hasPlugin(AnnotationProcessorPlugin.class), is(true)) 44 | } 45 | 46 | @Test 47 | void testPluginEvaluatesDependencies() { 48 | project.evaluate() 49 | def lib = project.configurations.annotationProcessor.dependencies.collect { 50 | "$it.group:$it.name:$it.version" as String 51 | }.toSet() 52 | assertThat(lib, hasItem(project.extensions.annotationProcessor.library)) 53 | } 54 | 55 | @Test 56 | void testPluginEvaluatesCompileOptions() { 57 | project.evaluate() 58 | def args = project.tasks.compileAnnotationProcessor.options.compilerArgs as List 59 | assertThat(args, hasItems('-proc:only', '-s', '-processor', project.extensions.annotationProcessor.processor, 60 | new File(project.projectDir, AnnotationProcessorPluginExtension.DEFAULT_SOURCES_DIR).path)) 61 | } 62 | 63 | @Test 64 | void testDefaultGeneratedSourcesDirIsSet() { 65 | assertThat(project.extensions.annotationProcessor.sourcesDir as String, 66 | equalTo(AnnotationProcessorPluginExtension.DEFAULT_SOURCES_DIR)) 67 | } 68 | 69 | @Test 70 | void testDefaultLibraryIsSet() { 71 | assertThat(project.extensions.annotationProcessor.library as String, 72 | equalTo("com.querydsl:querydsl-apt:4.0.0")) 73 | } 74 | } 75 | -------------------------------------------------------------------------------- /artifactory-deb-publish-plugin/src/main/groovy/com/ewerk/gradle/plugins/ArtifactoryDebPublishPluginExtension.groovy: -------------------------------------------------------------------------------- 1 | package com.ewerk.gradle.plugins 2 | 3 | import org.gradle.api.logging.Logger 4 | import org.gradle.api.logging.Logging 5 | 6 | /** 7 | * DLS extension for the auto-value plugin. Provides some convenient configuration options. 8 | * 9 | * @author holgerstolzenberg 10 | * @since 1.0.0 11 | */ 12 | class ArtifactoryDebPublishPluginExtension { 13 | 14 | private static final Logger LOG = Logging.getLogger(ArtifactoryDebPublishPluginExtension.class) 15 | 16 | static final String NAME = "artifactoryDebPublish" 17 | 18 | // Artifactory repository url 19 | String baseUrl 20 | 21 | // Artifactory account credentials 22 | String user 23 | String password 24 | 25 | // the repository key to push to 26 | String repoKey 27 | 28 | // debian package meta information 29 | String distribution 30 | String component 31 | String arch 32 | 33 | // the deb archive to publish 34 | File archive 35 | 36 | String baseUrl() { 37 | if (baseUrl == null || baseUrl.isEmpty()) { 38 | throw new RuntimeException("The 'baseUrl' property was not configured.") 39 | } 40 | LOG.info("Base URL: {}", baseUrl) 41 | baseUrl 42 | } 43 | 44 | File archiveFile() { 45 | if (archive == null) { 46 | throw new RuntimeException("Archive file to publish was not configured.") 47 | } 48 | if (!archive.exists()) { 49 | throw new RuntimeException("The file '$archive' does not exist.") 50 | } 51 | 52 | archive 53 | } 54 | 55 | String password() { 56 | LOG.info("Password: {}", password != null && !password.isEmpty() ? "***" : "") 57 | password 58 | } 59 | 60 | String user() { 61 | LOG.info("User: {}", user) 62 | user 63 | } 64 | 65 | String repoKey() { 66 | if (repoKey == null || repoKey.isEmpty()) { 67 | throw new RuntimeException("The 'repoKey' property was not configured.") 68 | } 69 | LOG.info("RepoKey: {}", repoKey) 70 | repoKey 71 | } 72 | 73 | String component() { 74 | if (component == null || component.isEmpty()) { 75 | throw new RuntimeException("The 'component' property was not configured.") 76 | } 77 | LOG.info("Component: {}", component) 78 | component 79 | } 80 | 81 | String arch() { 82 | if (arch == null || arch.isEmpty()) { 83 | throw new RuntimeException("The 'arch' property was not configured.") 84 | } 85 | LOG.info("Architecture: {}", arch) 86 | arch 87 | } 88 | 89 | String distribution() { 90 | if (distribution == null || distribution.isEmpty()) { 91 | throw new RuntimeException("The 'distribution' property was not configured.") 92 | } 93 | LOG.info("Distribution: {}", distribution) 94 | distribution 95 | } 96 | } 97 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | [![License](http://img.shields.io/badge/license-Apache%202.0-brightgreen.svg?style=flat)](http://www.apache.org/licenses/LICENSE-2.0) [![Build Status](http://img.shields.io/travis/ewerk/gradle-plugins.svg?style=flat)](https://travis-ci.org/ewerk/gradle-plugins) 2 | 3 | # EWERK Gradle Plugins 4 | 5 | > **_NOTE:_** The plugins are currently *not compatible to Gradle 5+* and have not been tested with a JDK higher 6 | than 1.8. Currently a lot of issues arise related to using the plugins with Gradle 5+. There are 7 | plans to adopt the plugins to the newest Gradle API but time is lacking. Help is pretty much 8 | appreciated. Please see https://github.com/ewerk/gradle-plugins/milestone/1. 9 | 10 | 11 | ## Introduction 12 | This repository was introduced in order to use the Github/Gradle Plugin Portal 13 | capabilities for publishing open source Gradle plugins and using them with the new plugin 14 | declaration syntax introduced in Gradle 2.1. 15 | 16 | The plugins are released using the [plugin-publish](https://plugins.gradle.org/plugin/com.gradle.plugin-publish) plugin. 17 | Prior to the actual publication process, the plugins were hosted at Bintray organizational 18 | account 'ewerk'. This account and all associated repositories have been deleted, as the plugins 19 | are now directly hosted at the plugin portal itself. 20 | 21 | The plugins are designed around Java language support. At the time being a lot of issues are raised 22 | regarding Groovy language support, which is not intended. The plugins may become compatible in the future, 23 | therefore help is very appreciated. 24 | 25 | ## Gradle compatibility 26 | |Plugin|≥ 2.1|≥ 3.3|≥ 5.0| 27 | |---|---|---|---| 28 | |annotation-processor-plugin|≤1.0.3|≥1.0.4|ø| 29 | |artifactory-deb-publish-plugin|≤1.0.1|≥1.0.2|ø| 30 | |auto-value-plugin|≤1.0.7|≥1.0.8|ø| 31 | |dagger-plugin|≤1.0.7|≥1.0.8|ø| 32 | |integration-test-plugin|≤1.0.8|≥1.0.9|ø| 33 | |jaxb2-plugin|≤1.0.2|≥1.0.3|ø| 34 | |querydsl-plugin|≤1.0.7|≥1.0.8|`INCUBATING` 35 | 36 | 37 | ## Plugins 38 | * [annotation-processor-plugin](https://github.com/ewerk/gradle-plugins/tree/master/annotation-processor-plugin) 39 | * [artifactory-deb-publish-plugin](https://github.com/ewerk/gradle-plugins/tree/master/artifactory-deb-publish-plugin) 40 | * [auto-value-plugin](https://github.com/ewerk/gradle-plugins/tree/master/auto-value-plugin) 41 | * [dagger-plugin](https://github.com/ewerk/gradle-plugins/tree/master/dagger-plugin) 42 | * [integration-test-plugin](https://github.com/ewerk/gradle-plugins/tree/master/integration-test-plugin) 43 | * [jaxb2-plugin](https://github.com/ewerk/gradle-plugins/tree/master/jaxb2-plugin) 44 | * [querydsl-plugin](https://github.com/ewerk/gradle-plugins/tree/master/querydsl-plugin) 45 | 46 | Please have a look at the [Samples](https://github.com/ewerk/gradle-plugins-samples) providing code examples on how to use the plugins. 47 | -------------------------------------------------------------------------------- /integration-test-plugin/src/test/groovy/com/ewerk/gradle/plugins/IntegrationTestPluginTest.groovy: -------------------------------------------------------------------------------- 1 | package com.ewerk.gradle.plugins 2 | 3 | import org.gradle.api.Project 4 | import org.gradle.api.Task 5 | import org.gradle.api.file.FileCollection 6 | import org.gradle.api.file.SourceDirectorySet 7 | import org.gradle.api.plugins.JavaPlugin 8 | import org.gradle.api.tasks.SourceSet 9 | import org.gradle.testfixtures.ProjectBuilder 10 | import org.testng.annotations.BeforeMethod 11 | import org.testng.annotations.Test 12 | 13 | import static org.hamcrest.CoreMatchers.* 14 | import static org.hamcrest.MatcherAssert.assertThat 15 | 16 | /** 17 | * @author holgerstolzenberg 18 | * @since 1.0.6 19 | */ 20 | class IntegrationTestPluginTest { 21 | private Project project 22 | 23 | @BeforeMethod 24 | void setup() { 25 | project = ProjectBuilder.builder().build() 26 | project.plugins.apply(IntegrationTestPlugin.class) 27 | } 28 | 29 | @Test 30 | void testPluginAppliesJavaPlugin() { 31 | assertThat(project.plugins.hasPlugin(JavaPlugin.class), is(true)) 32 | } 33 | 34 | @Test 35 | void testPluginAppliesItself() { 36 | assertThat(project.plugins.hasPlugin(IntegrationTestPlugin.class), is(true)) 37 | } 38 | 39 | @Test 40 | void testIntegrationTestTaskAvailable() { 41 | assertThat(project.tasks.integrationTest, notNullValue()) 42 | } 43 | 44 | @Test 45 | void testIntegrationTestTaskType() { 46 | final Task integrationTest = project.tasks.integrationTest 47 | assertThat(integrationTest, instanceOf(org.gradle.api.tasks.testing.Test.class)) 48 | } 49 | 50 | @Test 51 | void testAllTestsTaskAvailable() { 52 | assertThat(project.tasks.allTests, notNullValue()) 53 | } 54 | 55 | @Test 56 | void testAllTestsTaskGroup() { 57 | assertThat(project.tasks.allTests.group, equalTo("Integration test")) 58 | } 59 | 60 | @Test 61 | void testAllTestsTaskType() { 62 | final Task integrationTest = project.tasks.allTests 63 | assertThat(integrationTest, instanceOf(Task.class)) 64 | } 65 | 66 | @Test 67 | void testIntegrationSourceSetPresent() { 68 | SourceSet integration = project.sourceSets.integration 69 | assertThat(integration, notNullValue()) 70 | } 71 | 72 | @Test 73 | void testIntegrationJavaDirPresent() { 74 | SourceSet integration = project.sourceSets.integration 75 | SourceDirectorySet java = integration.java 76 | assertThat(java, notNullValue()) 77 | } 78 | 79 | @Test 80 | void testIntegrationResourceDirPresent() { 81 | SourceSet integration = project.sourceSets.integration 82 | SourceDirectorySet resources = integration.resources 83 | assertThat(resources, notNullValue()) 84 | } 85 | 86 | @Test 87 | void testIntegrationTestClassesDirDeprecated() { 88 | org.gradle.api.tasks.testing.Test integrationTest = project.tasks.integrationTest as org.gradle.api.tasks.testing.Test 89 | FileCollection tree = integrationTest.getTestClassesDirs() 90 | assertThat(tree.getFiles().first(), equalTo(integrationTest.getTestClassesDir())) 91 | } 92 | } 93 | -------------------------------------------------------------------------------- /artifactory-deb-publish-plugin/src/main/groovy/com/ewerk/gradle/plugins/util/ArtifactoryHttpClient.groovy: -------------------------------------------------------------------------------- 1 | package com.ewerk.gradle.plugins.util 2 | 3 | import com.ewerk.gradle.plugins.PublishException 4 | import com.ewerk.gradle.plugins.tasks.PushDebToArtifactory 5 | import com.squareup.okhttp.* 6 | import org.gradle.api.logging.Logger 7 | import org.gradle.api.logging.Logging 8 | 9 | /** 10 | * Service class that provides HTTP(S) connectivity to a configured Artifactory REST API endpoint. 11 | * 12 | * @author holgerstolzenberg 13 | * @since 1.0.0 14 | */ 15 | class ArtifactoryHttpClient { 16 | static final MediaType BINARY = MediaType.parse("application/octet-stream; charset=utf-8") 17 | 18 | static final String APPLICATION_VND_JFROG_ITEM_CREATED = 19 | 'application/vnd.org.jfrog.artifactory.storage.ItemCreated+json' 20 | 21 | private static final Logger LOG = Logging.getLogger(PushDebToArtifactory.class) 22 | 23 | private final OkHttpClient client 24 | 25 | final String baseUrl, user, password, repoKey, name, component, distribution, arch 26 | 27 | ArtifactoryHttpClient(String baseUrl, String user, String password, String repoKey, 28 | String name, String component, String distribution, String arch) { 29 | this.baseUrl = baseUrl 30 | this.user = user 31 | this.password = password 32 | this.repoKey = repoKey 33 | this.name = name 34 | this.component = component 35 | this.distribution = distribution 36 | this.arch = arch 37 | 38 | client = new OkHttpClient() 39 | } 40 | 41 | void publish(File theFile) { 42 | 43 | byte[] fileData = theFile.readBytes() 44 | String prefix = Urls.prefix(name) 45 | 46 | Request.Builder requestBuilder = new Request.Builder() 47 | .url(Urls.construct(baseUrl, repoKey, name, component, prefix, distribution, arch)) 48 | .header('Accept', APPLICATION_VND_JFROG_ITEM_CREATED) 49 | .header('X-Checksum-Sha1', Checksums.sha1(fileData)) 50 | .put(RequestBody.create(BINARY, fileData)) 51 | 52 | if (user != null && !user.isEmpty()) { 53 | requestBuilder.header("Authorization", Credentials.basic(user, password)) 54 | } 55 | 56 | Response response = client.newCall(requestBuilder.build()).execute() 57 | dumpResponse(response) 58 | 59 | int code = response.code() 60 | 61 | if (code == HttpCode.UNAUTHORIZED) { 62 | throw new PublishException("Authentication required.") 63 | } 64 | 65 | if (code != HttpCode.CREATED) { 66 | throw new PublishException("Publication failed.") 67 | } 68 | } 69 | 70 | private static void dumpResponse(Response response) { 71 | LOG.info("--------------------------------------------------------------------------------") 72 | LOG.info("Artifactory response") 73 | LOG.info("Artifactory: {}", response.code()) 74 | LOG.info("Artifactory: {}", response.headers()) 75 | LOG.info("Artifactory: {}", response.body().string()) 76 | LOG.info("--------------------------------------------------------------------------------") 77 | } 78 | 79 | private static final class HttpCode { 80 | static final int CREATED = 201 81 | static final int UNAUTHORIZED = 401 82 | } 83 | } 84 | -------------------------------------------------------------------------------- /integration-test-plugin/src/main/groovy/com/ewerk/gradle/plugins/IntegrationTestPlugin.groovy: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright 2012-2014 the original author or authors. 3 | * 4 | * Licensed under the Apache License, Version 2.0 (the "License"); 5 | * you may not use this file except in compliance with the License. 6 | * You may obtain a copy of the License at 7 | * 8 | * http://www.apache.org/licenses/LICENSE-2.0 9 | * 10 | * Unless required by applicable law or agreed to in writing, software 11 | * distributed under the License is distributed on an "AS IS" BASIS, 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | * See the License for the specific language governing permissions and 14 | * limitations under the License. 15 | */ 16 | 17 | package com.ewerk.gradle.plugins 18 | 19 | import org.gradle.api.Plugin 20 | import org.gradle.api.Project 21 | import org.gradle.api.logging.Logging 22 | import org.gradle.api.plugins.JavaPlugin 23 | import org.gradle.api.tasks.testing.Test 24 | import org.slf4j.Logger 25 | 26 | /** 27 | * The integration test plugin can be used to execute integration tests from a own sourceSet named 28 | * "integration". Just place your integration tests and resources under 29 | * "src/integration/[java|resources]" and then run the "integrationTest" task. This allows 30 | * for running unit and integration test in separate without the need to make a specific 31 | * configuration to each involved build script. 32 | * 33 | * The plugin will force the core 'java' plugin to be applied if not present. This is necessary 34 | * for having sourceSets available. 35 | * 36 | * @see JavaPlugin 37 | * @since 1.0.0 38 | * @author holgerstolzenberg 39 | */ 40 | class IntegrationTestPlugin implements Plugin { 41 | 42 | private static final Logger LOG = Logging.getLogger(IntegrationTestPlugin.class) 43 | 44 | static final String GROUP = "Integration test" 45 | 46 | @Override 47 | void apply(final Project project) { 48 | 49 | if (project.plugins.hasPlugin(IntegrationTestPlugin.class)) { 50 | return 51 | } 52 | 53 | LOG.info("Applying integration-test plugin") 54 | 55 | if (!project.plugins.hasPlugin(JavaPlugin.class)) { 56 | project.plugins.apply(JavaPlugin.class) 57 | } 58 | 59 | project.sourceSets { 60 | integration { 61 | java.srcDir project.file("src/integration/java") 62 | resources.srcDir project.file("src/integration/resources") 63 | } 64 | } 65 | 66 | project.dependencies { 67 | integrationCompile project.configurations.testCompile 68 | integrationRuntime project.configurations.testRuntime 69 | 70 | integrationCompile project.sourceSets.main.output 71 | integrationCompile project.sourceSets.test.output 72 | } 73 | 74 | project.task("integrationTest", type: Test, description: "Runs the integration tests.", 75 | group: GROUP) { 76 | testClassesDirs = project.sourceSets.integration.output 77 | classpath = project.sourceSets.integration.runtimeClasspath 78 | } 79 | 80 | project.task("allTests", dependsOn: [project.test, project.integrationTest], 81 | description: "Runs all tests.", group: GROUP) { 82 | } 83 | } 84 | } 85 | -------------------------------------------------------------------------------- /querydsl-plugin/src/test/groovy/com/ewerk/gradle/plugins/QuerydslPluginTest.groovy: -------------------------------------------------------------------------------- 1 | package com.ewerk.gradle.plugins 2 | 3 | import com.ewerk.gradle.plugins.tasks.InitQuerydslSourcesDir 4 | import org.gradle.api.Project 5 | import org.gradle.api.Task 6 | import org.gradle.api.internal.artifacts.dependencies.DefaultExternalModuleDependency 7 | import org.gradle.api.plugins.JavaPlugin 8 | import org.gradle.api.plugins.WarPlugin 9 | import org.gradle.testfixtures.ProjectBuilder 10 | import org.testng.annotations.BeforeMethod 11 | import org.testng.annotations.Test 12 | 13 | import static org.hamcrest.CoreMatchers.* 14 | import static org.hamcrest.MatcherAssert.assertThat 15 | 16 | /** 17 | * @author holgerstolzenberg 18 | * @since 1.0.0 19 | */ 20 | class QuerydslPluginTest { 21 | private Project project 22 | 23 | @BeforeMethod 24 | void setup() { 25 | project = ProjectBuilder.builder().build() 26 | project.plugins.apply(QuerydslPlugin.class) 27 | project.plugins.apply(WarPlugin.class) 28 | 29 | project.extensions.querydsl.jpa = true 30 | project.extensions.querydsl.jdo = true 31 | project.extensions.querydsl.roo = true 32 | project.extensions.querydsl.hibernate = true 33 | project.extensions.querydsl.morphia = true 34 | project.extensions.querydsl.springDataMongo = true 35 | project.extensions.querydsl.querydslDefault = true 36 | 37 | project.extensions.querydsl.aptOptions = ['querydsl.entityAccessors=true','querydsl.useFields=false'] 38 | } 39 | 40 | @Test 41 | void testPluginAppliesItself() { 42 | assertThat(project.plugins.hasPlugin(QuerydslPlugin.class), is(true)) 43 | } 44 | 45 | @Test 46 | void testReApplyDoesNotFail() { 47 | project.plugins.apply(QuerydslPlugin.class) 48 | } 49 | 50 | @Test 51 | void testPluginAppliesJavaPlugin() { 52 | assertThat(project.plugins.hasPlugin(JavaPlugin.class), is(true)) 53 | } 54 | 55 | @Test 56 | void testPluginRegistersQuerydslExtensions() { 57 | assertThat(project.extensions.querydsl, notNullValue()) 58 | } 59 | 60 | @Test 61 | void testPluginProcessorsFromQuerydslExtensions() { 62 | assertThat(project.extensions.querydsl.processors(), notNullValue()) 63 | } 64 | 65 | @Test 66 | void testPluginTasksAreAvailable() { 67 | assertThat(project.tasks.initQuerydslSourcesDir, notNullValue()) 68 | assertThat(project.tasks.cleanQuerydslSourcesDir, notNullValue()) 69 | } 70 | 71 | @Test 72 | void testTaskTypes() { 73 | final Task initTask = project.tasks.initQuerydslSourcesDir 74 | assertThat(initTask, instanceOf(InitQuerydslSourcesDir.class)) 75 | } 76 | 77 | @Test 78 | void testAfterEvaluate() { 79 | project.evaluate() 80 | 81 | DefaultExternalModuleDependency lib = project.configurations.compile.dependencies[0] as DefaultExternalModuleDependency 82 | 83 | String id = lib.group + ":" + lib.name + ":" + lib.version 84 | 85 | assertThat(id, equalTo(QuerydslPluginExtension.DEFAULT_LIBRARY)) 86 | assertThat(project.tasks.compileQuerydsl, notNullValue()) 87 | } 88 | 89 | @Test 90 | void testSourcesDirAfterEvaluate() { 91 | project.extensions.querydsl.querydslSourcesDir = "/java/other/src" 92 | project.evaluate() 93 | File sourcesDir = project.file(project.querydsl.querydslSourcesDir) as File 94 | assertThat(sourcesDir, equalTo(project.tasks.compileQuerydsl.destinationDir as File)) 95 | } 96 | } 97 | -------------------------------------------------------------------------------- /annotation-processor-plugin/src/main/groovy/com/ewerk/gradle/plugins/AnnotationProcessorPlugin.groovy: -------------------------------------------------------------------------------- 1 | package com.ewerk.gradle.plugins 2 | 3 | import com.ewerk.gradle.plugins.tasks.AnnotationProcessorCompile 4 | import com.ewerk.gradle.plugins.tasks.CleanAnnotationProcessorGeneratedDir 5 | import com.ewerk.gradle.plugins.tasks.InitAnnotationProcessorGeneratedDir 6 | import org.gradle.api.GradleException 7 | import org.gradle.api.Plugin 8 | import org.gradle.api.Project 9 | import org.gradle.api.logging.Logger 10 | import org.gradle.api.logging.Logging 11 | import org.gradle.api.plugins.JavaPlugin 12 | import org.gradle.api.plugins.WarPlugin 13 | 14 | /** 15 | * This plugin provides a simple integration point for an Annotation Processor capable of generating Java source. 16 | * A separate task [compileAnnotationProcessor] runs the annotation processor during build phase. 17 | * 18 | * A value for processor and library must be supplied to the extenstion task from the buildscript configuration. 19 | * 20 | * @author griffio 21 | */ 22 | class AnnotationProcessorPlugin implements Plugin { 23 | 24 | public static final String TASK_GROUP = "Annotation-Processor" 25 | 26 | private static final Logger LOG = Logging.getLogger(AnnotationProcessorPlugin.class) 27 | 28 | @Override 29 | void apply(Project project) { 30 | 31 | if (project.plugins.hasPlugin(AnnotationProcessorPlugin.class)) { 32 | return 33 | } 34 | 35 | LOG.info("Applying Annotation Processor plugin") 36 | 37 | if (!project.plugins.hasPlugin(JavaPlugin.class)) { 38 | project.plugins.apply(JavaPlugin.class) 39 | } 40 | 41 | if (project.plugins.hasPlugin(WarPlugin.class)) { 42 | project.configurations { 43 | annotationProcessor.extendsFrom compile, providedRuntime, providedCompile 44 | } 45 | } else { 46 | project.configurations { 47 | annotationProcessor.extendsFrom compile 48 | } 49 | } 50 | 51 | project.extensions.create(AnnotationProcessorPluginExtension.NAME, 52 | AnnotationProcessorPluginExtension) 53 | 54 | project.task(type: CleanAnnotationProcessorGeneratedDir, "cleanAnnotationProcessorSourcesDir") 55 | project.task(type: InitAnnotationProcessorGeneratedDir, "initAnnotationProcessorSourcesDir") 56 | project.task(type: AnnotationProcessorCompile, "compileAnnotationProcessor") 57 | 58 | project.tasks.clean.dependsOn project.tasks.cleanAnnotationProcessorSourcesDir 59 | project.tasks.compileAnnotationProcessor.dependsOn project.tasks.initAnnotationProcessorSourcesDir 60 | project.tasks.compileJava.dependsOn project.tasks.compileAnnotationProcessor 61 | 62 | project.afterEvaluate { 63 | 64 | if (project.extensions.annotationProcessor.processor == "") { 65 | throw new GradleException("processor - provide a fully qualified proc class.") 66 | } 67 | 68 | if (project.extensions.annotationProcessor.library == "") { 69 | throw new GradleException( 70 | "library - provide the dependency reference containing a processor.") 71 | } 72 | 73 | project.dependencies { 74 | annotationProcessor project.extensions.annotationProcessor.library 75 | } 76 | 77 | project.sourceSets { 78 | annotationProcessor { 79 | java.srcDirs = [project.extensions.annotationProcessor.sourcesDir] 80 | } 81 | } 82 | 83 | project.compileJava { 84 | source project.extensions.annotationProcessor.sourcesDir 85 | } 86 | } 87 | } 88 | } -------------------------------------------------------------------------------- /jaxb2-plugin/src/main/groovy/com/ewerk/gradle/plugins/tasks/GenerateJaxb2Classes.groovy: -------------------------------------------------------------------------------- 1 | package com.ewerk.gradle.plugins.tasks 2 | 3 | import com.ewerk.gradle.plugins.Jaxb2Plugin 4 | import org.gradle.api.DefaultTask 5 | import org.gradle.api.logging.Logger 6 | import org.gradle.api.tasks.TaskAction 7 | 8 | import static org.gradle.api.logging.Logging.getLogger 9 | 10 | /** 11 | * Task that does the actual generation stuff. Declares the Ant task and then runs it for all 12 | * configured {@link XjcTaskConfig} objects. 13 | * 14 | * xjc https://jaxb.java.net/2.2.4/docs/xjcTask.html 15 | * depends/produces is used for incremental compilation 16 | * 17 | * @author holgerstolzenberg 18 | * @since 1.0.0 19 | */ 20 | class GenerateJaxb2Classes extends DefaultTask { 21 | private static final Logger LOG = getLogger(GenerateJaxb2Classes.class) 22 | 23 | GenerateJaxb2Classes() { 24 | this.group = Jaxb2Plugin.TASK_GROUP 25 | } 26 | 27 | @SuppressWarnings("GroovyUnusedDeclaration") 28 | @TaskAction 29 | antXjc() { 30 | ant.taskdef( 31 | name: 'xjc', 32 | classname: project.extensions.jaxb2.taskName, 33 | classpath: project.configurations.jaxb2.asPath) 34 | 35 | Set xjcConfigs = project.extensions.jaxb2.xjc 36 | 37 | for (XjcTaskConfig theConfig : xjcConfigs) { 38 | def generatedSourcesDirParent = project.file(theConfig.generatedSourcesDir) 39 | def basePackage = theConfig.basePackage 40 | def encoding = theConfig.encoding 41 | 42 | // Transform package to directory location to specify depends/produces when multiple schema output to same generatedSourcesDir 43 | // Changing one schema will only cause recompilation/generation of that schema 44 | def generatedSourcesDirPackage = new File(generatedSourcesDirParent, 45 | basePackage.replace(".", "/")) 46 | 47 | def schemaFile = project.file(theConfig.schema) 48 | def catalogFile = (theConfig.catalog != null) ? project.file(theConfig.catalog) : null 49 | def bindingsDir = theConfig.bindingsDir 50 | def includedBindingFiles = bindingFileIncludes(theConfig) 51 | def extension = theConfig.extension 52 | def additionalArgs = theConfig.additionalArgs 53 | 54 | def arguments = [ 55 | destdir : generatedSourcesDirParent, 56 | package : basePackage, 57 | schema : schemaFile, 58 | encoding : encoding, 59 | extension: extension, 60 | ] 61 | 62 | if (catalogFile) { 63 | arguments.catalog = catalogFile 64 | } 65 | 66 | // the depends and produces is compared using the time-stamp of the schema file and the destination package folder 67 | ant.xjc(arguments) { 68 | depends(file: schemaFile) 69 | produces(dir: generatedSourcesDirPackage, includes: "**/*.java") 70 | arg(line: additionalArgs) 71 | 72 | if (catalogFile) { 73 | depends(file: catalogFile) 74 | } 75 | 76 | if (bindingsDir?.trim()) { 77 | binding(dir: project.file(bindingsDir), includes: includedBindingFiles) 78 | } 79 | } 80 | } 81 | } 82 | 83 | private static String bindingFileIncludes(XjcTaskConfig config) { 84 | def files = config.includedBindingFiles 85 | 86 | if (!files?.trim()) { 87 | LOG.info("No binding file includes defined, falling back to '**/*.xjb' pattern.") 88 | files = '**/*.xjb' 89 | } 90 | 91 | LOG.info("Binding files: {}", files) 92 | return files 93 | } 94 | } 95 | -------------------------------------------------------------------------------- /auto-value-plugin/src/main/groovy/com/ewerk/gradle/plugins/AutoValuePlugin.groovy: -------------------------------------------------------------------------------- 1 | package com.ewerk.gradle.plugins 2 | 3 | import com.ewerk.gradle.plugins.tasks.CleanAutoValueSourcesDir 4 | import com.ewerk.gradle.plugins.tasks.InitAutoValueSourcesDir 5 | import org.gradle.api.Plugin 6 | import org.gradle.api.Project 7 | import org.gradle.api.logging.Logger 8 | import org.gradle.api.logging.Logging 9 | import org.gradle.api.plugins.JavaPlugin 10 | 11 | /** 12 | * This plugin can be used to easily create Google Auto-Value classes and attach them to the project 13 | * classpath.

14 | * 15 | * The plugin registers the extension 'autoValue' so that plugin specific configuration can 16 | * be overwritten within the build sScript. Please see the readme doc on Github for details on that. 17 | *

18 | * 19 | * The plugin will generate an additional source directory into where the auto-value 20 | * classes will be compiled, so that they can be ignored from SCM commits. Per default, this will 21 | * be {@link AutoValuePluginExtension#DEFAULT_AUTO_VALUE_SOURCES_DIR}. 22 | *

23 | * 24 | * @see AutoValuePluginExtension 25 | * @author holgerstolzenberg 26 | * @since 1.0.0 27 | */ 28 | class AutoValuePlugin implements Plugin { 29 | 30 | public static final String TASK_GROUP = "Auto-Value" 31 | 32 | private static final Logger LOG = Logging.getLogger(AutoValuePlugin.class) 33 | 34 | @Override 35 | void apply(final Project project) { 36 | 37 | // do nothing if plugin is already applied 38 | if (project.plugins.hasPlugin(AutoValuePlugin.class)) { 39 | return 40 | } 41 | 42 | LOG.info("Applying auto-value plugin") 43 | 44 | // apply core 'java' plugin if not present to make 'sourceSets' available 45 | if (!project.plugins.hasPlugin(JavaPlugin.class)) { 46 | project.plugins.apply(JavaPlugin.class) 47 | } 48 | 49 | // add 'autoValue' DSL extension 50 | project.extensions.create(AutoValuePluginExtension.NAME, AutoValuePluginExtension) 51 | 52 | // add new tasks for creating/cleaning the auto-value sources dir 53 | project.task(type: CleanAutoValueSourcesDir, "cleanAutoValueSourcesDir") 54 | project.task(type: InitAutoValueSourcesDir, "initAutoValueSourcesDir") 55 | 56 | // make 'compileJava' require the new task, so that all sources are available 57 | project.tasks.compileJava.dependsOn project.tasks.initAutoValueSourcesDir 58 | project.tasks.clean.dependsOn project.tasks.cleanAutoValueSourcesDir 59 | 60 | // make sure project configuration has finished 61 | project.afterEvaluate { 62 | File autoValueSourcesDir = autoValueSourcesDir(project) 63 | 64 | addLibrary(project) 65 | addSourceSet(project, autoValueSourcesDir) 66 | addCompilerOption(project, autoValueSourcesDir) 67 | } 68 | } 69 | 70 | private void addCompilerOption(Project project, sourcesDir) { 71 | project.tasks.compileJava { 72 | options.compilerArgs = options.compilerArgs + ["-s", sourcesDir.absolutePath] 73 | } 74 | } 75 | 76 | private void addLibrary(Project project) { 77 | def library = project.extensions.autoValue.library 78 | LOG.info("Auto-Value library: {}", library) 79 | project.dependencies { 80 | compile library 81 | } 82 | } 83 | 84 | private void addSourceSet(Project project, File sourcesDir) { 85 | LOG.info("Create source set 'auto-value'.") 86 | 87 | project.sourceSets { 88 | autoValue { 89 | java.srcDirs = [sourcesDir] 90 | } 91 | } 92 | } 93 | 94 | private static File autoValueSourcesDir(Project project) { 95 | String path = project.extensions.autoValue.autoValueSourcesDir 96 | File autoValueSourcesDir = project.file(path) 97 | LOG.info("Auto-value sources dir: {}", autoValueSourcesDir.absolutePath) 98 | return autoValueSourcesDir 99 | } 100 | } 101 | -------------------------------------------------------------------------------- /jaxb2-plugin/readme.md: -------------------------------------------------------------------------------- 1 | ### JAXB2 plugin 2 | 3 | #### Description 4 | 5 | This plugin makes it easy to generate Java source code from XML schema files (.xsd). Internally 6 | the plugin relies on the JAXB2 ant task for generating the code. The examples below show how 7 | the plugin can be used. 8 | 9 | At the moment the plugin is simplistic and just supports creating Java code from XSD. JAXB2 10 | specific special stuff like binding files or additional task parameters are currently not 11 | supported but can surely make it into the plugin in future. 12 | 13 | Please have a look at the plugins [change log](change_log.md). 14 | 15 | #### Dependency management 16 | The plugin creates a own 'jaxb2' configuration and adds it to the project. Then it adds all needed 17 | dependencies to execute the JAXB ant task. You may need to extend are change these dependencies. 18 | As we have the `jaxb2` configuration, you can do this by using the default `dependencies {}` 19 | closure of your project. This is shown in the examples below. 20 | 21 | #### Configuration 22 | 23 | ##### taskName 24 | The full qualified name of the JAXB2 ant task the does the real work. 25 | Defaults to `org.jvnet.jaxb2_commons.xjc.XJC2Task`. 26 | Normally there will be need to change this. 27 | 28 | ##### xjc 29 | This is the container for configuring the distinct generation steps. It can be repeated as needed 30 | within the `jaxb2` extension. The container structure is as follows: 31 | 32 | ```groovy 33 | xjc { 34 | 'generation-step-name' { 35 | // optional, defaults to src/generated/java 36 | generatedSourcesDir = 'any/relative/path' 37 | 38 | // full qualified base package for the classes to be generated 39 | basePackage = 'com.any.app' 40 | 41 | // relative path the XSD file to generate the code from 42 | schema = 'src/main/xsd/any-file.xsd' 43 | 44 | // relative path to directory including binding files 45 | // all files of pattern **/*.xjb will be included 46 | // default to null (no binding files used) 47 | // Optional, can be left away 48 | bindingsDir = 'src/main/xsb' 49 | 50 | // comma separated list of binding file includes 51 | // falls back to '**/*.xjb' if not specified 52 | includedBindingFiles = 'any.xjb, subdir/test.xjb' 53 | 54 | additionalArgs = '-nv -dtd' 55 | 56 | // output encoding of the generated files 57 | encoding = 'UTF-8' 58 | } 59 | } 60 | ``` 61 | 62 | #### Examples 63 | 64 | __Use via Gradle plugin portal__ 65 | 66 | ```groovy 67 | plugins { 68 | id "com.ewerk.gradle.plugins.jaxb2" version "1.0.10" 69 | } 70 | ``` 71 | 72 | __Full configuration example__ 73 | 74 | ```groovy 75 | plugins { 76 | id 'com.ewerk.gradle.plugins.jaxb2' version '1.0.10' 77 | } 78 | 79 | repositories { 80 | mavenCentral() 81 | } 82 | 83 | // the whole dependency container could be left out 84 | dependencies { 85 | // default JAXB2 libs added by the plugin 86 | jaxb2 'org.jvnet.jaxb2_commons:jaxb2-basics-runtime:0.9.5' 87 | jaxb2 'org.jvnet.jaxb2_commons:jaxb2-basics-ant:0.9.5' 88 | jaxb2 'org.jvnet.jaxb2_commons:jaxb2-basics:0.9.5' 89 | 90 | // default JAXB libs added by the plugin 91 | jaxb2 'com.sun.xml.bind:jaxb-core:2.2.11' 92 | jaxb2 'com.sun.xml.bind:jaxb-xjc:2.2.11' 93 | jaxb2 'com.sun.xml.bind:jaxb-impl:2.2.11' 94 | 95 | // any custom libraries here 96 | jaxb2 'com. …' 97 | } 98 | 99 | jaxb2 { 100 | xjc { 101 | 'request-classes' { 102 | basePackage = 'com.any.app.model.request' 103 | schema = 'src/main/xsd/request.xsd' 104 | encoding = 'UTF-8' 105 | extension = true 106 | } 107 | } 108 | 109 | xjc { 110 | 'response-classes' { 111 | basePackage = 'com.any.app.model.response' 112 | schema = 'src/main/xsd/response.xsd' 113 | bindings = 'src/main/xsb' 114 | } 115 | } 116 | } 117 | 118 | ``` 119 | 120 | __Minimal configuration example__ 121 | ```groovy 122 | plugins { 123 | id 'com.ewerk.gradle.plugins.jaxb2' version '1.0.10' 124 | } 125 | 126 | repositories { 127 | mavenCentral() 128 | } 129 | 130 | jaxb2 { 131 | xjc { 132 | 'request-classes' { 133 | basePackage = 'com.any.app.model.request' 134 | schema = 'src/main/xsd/request.xsd' 135 | } 136 | } 137 | } 138 | ``` 139 | -------------------------------------------------------------------------------- /querydsl-plugin/readme.md: -------------------------------------------------------------------------------- 1 | ### Querydsl plugin 2 | 3 | #### Description 4 | 5 | This plugin makes it easy to generate [Querydsl](http://www.querydsl.com/) 6 | classes within a project. Different annotation processors can be activated via the plugins 7 | configuration. The plugin will not manage 3rd party libraries. It is still up to the end user 8 | to add the required dependencies like Hibernate, Spring Data Mongo and the needed Querydsl libs. 9 | 10 | Note: from release 1.0.6 this plugin requires Querydsl 4.x dependencies. 11 | 12 | Please have a look at the plugins [change log](change_log.md). 13 | 14 | #### Configuration 15 | 16 | ##### library 17 | The artifact coordinates of the Querydsl annotation processor library. 18 | 19 | Defaults to `com.querydsl:querydsl-apt:4.1.4`. 20 | 21 | Note: this can only be a version supported by the current [Spring Data](http://projects.spring.io/spring-data/) project. 22 | 23 | ##### querydslSourcesDir 24 | The project relative path to where the querydsl meta model sources are created in. It does not 25 | matter which annotation processors are used, all meta model classes will be created within this 26 | directory. 27 | 28 | Defaults to `src/querydsl/java`. 29 | 30 | ##### jpa 31 | Boolean flag to indicate if creation of meta model from JPA annotated sources 32 | should be enabled. 33 | If so, a java compile task that enables the `com.querydsl.apt.jpa.JPAAnnotationProcessor` will 34 | be added and used within the project. 35 | 36 | Defaults to `false`. 37 | 38 | ##### jdo 39 | Boolean flag to indicate if creation of meta model from JDO annotated sources 40 | should be enabled. 41 | If so, a java compile task that enables the `com.querydsl.apt.jdo.JDOAnnotationProcessor` will 42 | be added and used within the project. 43 | 44 | Defaults to `false`. 45 | 46 | ##### hibernate 47 | Boolean flag to indicate if creation of meta model from Hibernate annotated sources 48 | should be enabled. 49 | If so, a java compile task that enables the `com.querydsl.apt.hibernate.HibernateAnnotationProcessor` will 50 | be added and used within the project. 51 | 52 | Defaults to `false`. 53 | 54 | ##### morphia 55 | Boolean flag to indicate if creation of meta model from Morphia annotated sources 56 | should be enabled. 57 | If so, a java compile task that enables the `com.querydsl.apt.morphia.MorphiaAnnotationProcessor` 58 | will be added and used within the project. 59 | 60 | Defaults to `false`. 61 | 62 | ##### roo 63 | Boolean flag to indicate if creation of meta model from Spring Roo annotated sources 64 | should be enabled. 65 | If so, a java compile task that enables the `com.querydsl.apt.roo.RooAnnotationProcessor` will 66 | be added and used within the project. 67 | 68 | Defaults to `false`. 69 | 70 | ##### springDataMongo 71 | Boolean flag to indicate if creation of meta model from Spring Data Mongo annotated sources 72 | should be enabled. 73 | If so, a java compile task that enables the `org.springframework.data.mongodb.repository.support.MongoAnnotationProcessor` will be added and used within the project. 74 | 75 | Defaults to `false`. 76 | 77 | ##### querydslDefault 78 | Boolean flag to indicate if creation of meta model from Querydsl annotated sources 79 | should be enabled. 80 | If so, a java compile task that enables the `com.querydsl.apt.QuerydslAnnotationProcessor` will 81 | be added and used within the project. 82 | 83 | Defaults to `false`. 84 | 85 | ##### aptOptions 86 | List of APT options to customize QueryDSL generation 87 | 88 | ___Example___ 89 | ```groovy 90 | querydsl { 91 | aptOptions = ['querydsl.entityAccessors=true','querydsl.useFields=false'] 92 | } 93 | ``` 94 | 95 | Default to empty 96 | 97 | [Check all available options from the QueryDSL documentation](http://www.querydsl.com/static/querydsl/4.1.4/reference/html/ch03s03.html) 98 | 99 | 100 | #### Examples 101 | 102 | __Mongo example__ 103 | 104 | ```groovy 105 | plugins { 106 | id "com.ewerk.gradle.plugins.querydsl" version "1.0.10" 107 | } 108 | 109 | repositories { 110 | mavenCentral() 111 | } 112 | 113 | dependencies { 114 | […] 115 | // make MongoDB annotation processor available at classpath 116 | compile "org.springframework.data:spring-data-mongodb:1.9.1.RELEASE" 117 | 118 | // use Querydsl against MongoDB 119 | compile "com.querydsl.apt:querydsl-mongodb:4.1.4" 120 | […] 121 | } 122 | 123 | querydsl { 124 | springDataMongo = true 125 | } 126 | ``` 127 | -------------------------------------------------------------------------------- /querydsl-plugin/src/main/groovy/com/ewerk/gradle/plugins/QuerydslPlugin.groovy: -------------------------------------------------------------------------------- 1 | package com.ewerk.gradle.plugins 2 | 3 | import com.ewerk.gradle.plugins.tasks.CleanQuerydslSourcesDir 4 | import com.ewerk.gradle.plugins.tasks.InitQuerydslSourcesDir 5 | import com.ewerk.gradle.plugins.tasks.QuerydslCompile 6 | import org.gradle.api.Plugin 7 | import org.gradle.api.Project 8 | import org.gradle.api.logging.Logger 9 | import org.gradle.api.logging.Logging 10 | import org.gradle.api.plugins.JavaPlugin 11 | 12 | /** 13 | * This plugin can be used to easily create Mysema querydsl classes and attach them to the project 14 | * classpath.

15 | * 16 | * The plugin registers the extension 'querydsl' so that plugin specific configuration can 17 | * be overwritten within the build sScript. Please see the readme doc on Github for details on that. 18 | *

19 | * 20 | * The plugin will generate an additional source directory into where the querydsl 21 | * classes will be compiled, so that they can be ignored from SCM commits. Per default, this will 22 | * be {@link QuerydslPluginExtension#DEFAULT_QUERYDSL_SOURCES_DIR}. 23 | *

24 | * 25 | * @author holgerstolzenberg , iboyko 26 | * @since 1.0.0 27 | */ 28 | class QuerydslPlugin implements Plugin { 29 | 30 | public static final String TASK_GROUP = "Querydsl" 31 | 32 | private static final Logger LOG = Logging.getLogger(QuerydslPlugin.class) 33 | 34 | @Override 35 | void apply(final Project project) { 36 | LOG.info("Applying Querydsl plugin") 37 | 38 | // do nothing if plugin is already applied 39 | if (project.plugins.hasPlugin(QuerydslPlugin.class)) { 40 | return 41 | } 42 | 43 | LOG.info("Applying querydsl plugin") 44 | 45 | // apply core 'java' plugin if not present to make 'sourceSets' available 46 | if (!project.plugins.hasPlugin(JavaPlugin.class)) { 47 | project.plugins.apply(JavaPlugin.class) 48 | } 49 | 50 | // add 'Querydsl' DSL extension 51 | project.extensions.create(QuerydslPluginExtension.NAME, QuerydslPluginExtension) 52 | 53 | // add new tasks for creating/cleaning the auto-value sources dir 54 | project.task(type: CleanQuerydslSourcesDir, "cleanQuerydslSourcesDir") 55 | project.task(type: InitQuerydslSourcesDir, "initQuerydslSourcesDir") 56 | 57 | // make 'clean' depend clean ing querydsl sources 58 | project.tasks.clean.dependsOn project.tasks.cleanQuerydslSourcesDir 59 | 60 | project.task(type: QuerydslCompile, "compileQuerydsl") 61 | project.tasks.compileQuerydsl.dependsOn project.tasks.initQuerydslSourcesDir 62 | project.tasks.compileJava.dependsOn project.tasks.compileQuerydsl 63 | 64 | project.afterEvaluate { 65 | File querydslSourcesDir = querydslSourcesDir(project) 66 | 67 | addLibrary(project) 68 | addSourceSet(project, querydslSourcesDir) 69 | registerSourceAtCompileJava(project, querydslSourcesDir) 70 | applyCompilerOptions(project) 71 | } 72 | } 73 | 74 | private static void applyCompilerOptions(Project project) { 75 | project.tasks.compileQuerydsl.options.compilerArgs += [ 76 | "-proc:only", 77 | "-processor", project.querydsl.processors() 78 | ] 79 | 80 | if(project.querydsl.aptOptions.size() > 0){ 81 | for(aptOption in project.querydsl.aptOptions) { 82 | project.tasks.compileQuerydsl.options.compilerArgs << "-A" + aptOption 83 | } 84 | } 85 | } 86 | 87 | private void registerSourceAtCompileJava(Project project, File querydslSourcesDir) { 88 | project.compileJava { 89 | source querydslSourcesDir 90 | } 91 | } 92 | 93 | private void addLibrary(Project project) { 94 | def library = project.extensions.querydsl.library 95 | LOG.info("Querydsl library: {}", library) 96 | project.dependencies { 97 | compile library 98 | } 99 | } 100 | 101 | private void addSourceSet(Project project, File sourcesDir) { 102 | LOG.info("Create source set 'querydsl'.") 103 | 104 | project.sourceSets { 105 | querydsl { 106 | java.srcDirs = [sourcesDir] 107 | } 108 | } 109 | } 110 | 111 | private static File querydslSourcesDir(Project project) { 112 | String path = project.extensions.querydsl.querydslSourcesDir 113 | File querydslSourcesDir = project.file(path) 114 | LOG.info("Querydsl sources dir: {}", querydslSourcesDir.absolutePath) 115 | return querydslSourcesDir 116 | } 117 | } 118 | -------------------------------------------------------------------------------- /jaxb2-plugin/src/main/groovy/com/ewerk/gradle/plugins/Jaxb2Plugin.groovy: -------------------------------------------------------------------------------- 1 | package com.ewerk.gradle.plugins 2 | 3 | import com.ewerk.gradle.plugins.tasks.CleanJaxb2SourcesDir 4 | import com.ewerk.gradle.plugins.tasks.GenerateJaxb2Classes 5 | import com.ewerk.gradle.plugins.tasks.InitJaxb2SourcesDir 6 | import com.ewerk.gradle.plugins.tasks.XjcTaskConfig 7 | import org.gradle.api.Plugin 8 | import org.gradle.api.Project 9 | import org.gradle.api.artifacts.Configuration 10 | import org.gradle.api.plugins.JavaPlugin 11 | import org.gradle.internal.reflect.Instantiator 12 | import org.slf4j.Logger 13 | import org.slf4j.LoggerFactory 14 | 15 | /** 16 | * A plugin for generating Java source code from XSD files backed by JAXB2 ant task. 17 | * 18 | * @author holgerstolzenberg 19 | * @since 1.0.0 20 | */ 21 | class Jaxb2Plugin implements Plugin { 22 | public static final String TASK_GROUP = "Jaxb2" 23 | 24 | private static final Logger LOG = LoggerFactory.getLogger(Jaxb2Plugin.class) 25 | 26 | private static final String SLF4J_VERSION = '1.7.13' 27 | private static final String JAXB2_VERSION = '0.9.5' 28 | private static final String JAXB_VERSION = '2.2.11' 29 | private static final String COMMONS_LOGGING_VERSION = '1.2' 30 | 31 | @Override 32 | void apply(final Project project) { 33 | // do nothing if plugin is already applied 34 | if (project.plugins.hasPlugin(Jaxb2Plugin.class)) { 35 | return 36 | } 37 | 38 | LOG.info("Applying JAXB2 plugin") 39 | 40 | applyJavaPlugin(project) 41 | addJaxb2Extension(project) 42 | addJaxb2Configuration(project) 43 | addTasks(project) 44 | addJaxbDependencies(project) 45 | 46 | // make sure project configuration has finished 47 | project.afterEvaluate { 48 | addSourceSet(project) 49 | } 50 | } 51 | 52 | private static Configuration addJaxb2Configuration(Project project) { 53 | project.configurations.maybeCreate('jaxb2') 54 | } 55 | 56 | private static void addJaxb2Extension(Project project) { 57 | project.extensions.create(Jaxb2PluginExtension.NAME, Jaxb2PluginExtension) 58 | project.extensions.jaxb2.extensions.xjc = project.container(XjcTaskConfig) { String name -> 59 | return project.gradle.services.get(Instantiator).newInstance(XjcTaskConfig, name) 60 | } 61 | } 62 | 63 | private static void applyJavaPlugin(Project project) { 64 | // apply core 'java' plugin if not present to make 'sourceSets' available 65 | if (!project.plugins.hasPlugin(JavaPlugin.class)) { 66 | project.plugins.apply(JavaPlugin.class) 67 | } 68 | } 69 | 70 | private static void addTasks(Project project) { 71 | // add new tasks for creating/cleaning the auto-value sources dir 72 | project.task(type: CleanJaxb2SourcesDir, "cleanJaxb2SourcesDir") 73 | project.task(type: InitJaxb2SourcesDir, "initJaxb2SourcesDir") 74 | project.task(type: GenerateJaxb2Classes, "generateJaxb2Classes") 75 | 76 | // make 'compileJava' require the new task, so that all sources are available 77 | project.tasks.clean.dependsOn project.tasks.cleanJaxb2SourcesDir 78 | project.tasks.generateJaxb2Classes.dependsOn project.tasks.initJaxb2SourcesDir 79 | project.tasks.compileJava.dependsOn project.tasks.generateJaxb2Classes 80 | } 81 | 82 | private addJaxbDependencies(Project project) { 83 | project.dependencies { 84 | jaxb2 'org.slf4j:slf4j-simple:' + SLF4J_VERSION 85 | 86 | jaxb2 'org.jvnet.jaxb2_commons:jaxb2-basics-runtime:' + JAXB2_VERSION 87 | jaxb2 'org.jvnet.jaxb2_commons:jaxb2-basics-ant:' + JAXB2_VERSION 88 | jaxb2 'org.jvnet.jaxb2_commons:jaxb2-basics:' + JAXB2_VERSION 89 | jaxb2 'org.jvnet.jaxb2_commons:jaxb2-basics-tools:' + JAXB2_VERSION 90 | jaxb2 'commons-logging:commons-logging:' + COMMONS_LOGGING_VERSION 91 | 92 | jaxb2 'com.sun.xml.bind:jaxb-core:' + JAXB_VERSION 93 | jaxb2 'com.sun.xml.bind:jaxb-xjc:' + JAXB_VERSION 94 | jaxb2 'com.sun.xml.bind:jaxb-impl:' + JAXB_VERSION 95 | } 96 | } 97 | 98 | private void addSourceSet(Project project) { 99 | Set xjcConfigs = project.extensions.jaxb2.xjc 100 | 101 | for (XjcTaskConfig theConfig : xjcConfigs) { 102 | if (theConfig.createSourceSet) { 103 | File sourcesDir = project.file(theConfig.generatedSourcesDir) 104 | LOG.info("Create source set 'jaxb2': {}", sourcesDir.absolutePath) 105 | 106 | project.sourceSets { 107 | jaxb2 { 108 | java.srcDirs += [sourcesDir] 109 | } 110 | } 111 | 112 | project.compileJava { 113 | source += project.files(sourcesDir) 114 | } 115 | } 116 | } 117 | } 118 | } 119 | -------------------------------------------------------------------------------- /dagger-plugin/src/main/groovy/com/ewerk/gradle/plugins/DaggerPlugin.groovy: -------------------------------------------------------------------------------- 1 | package com.ewerk.gradle.plugins 2 | 3 | import com.ewerk.gradle.plugins.tasks.CleanDaggerSourcesDir 4 | import com.ewerk.gradle.plugins.tasks.DaggerCompile 5 | import com.ewerk.gradle.plugins.tasks.InitDaggerSourcesDir 6 | import org.gradle.api.GradleException 7 | import org.gradle.api.Plugin 8 | import org.gradle.api.Project 9 | import org.gradle.api.logging.Logger 10 | import org.gradle.api.logging.Logging 11 | import org.gradle.api.plugins.JavaPlugin 12 | import org.gradle.api.plugins.WarPlugin 13 | import org.gradle.api.tasks.Delete 14 | 15 | /** 16 | * @author griffio 17 | * 18 | * Dagger2 (http://google.github.io/dagger/) is a library with a processor dependency (com.google.dagger:dagger-compiler) 19 | * and compile transitive dependency (com.google.dagger:dagger) that is required for the generated code. 20 | * 21 | * Apply configuration to JavaPlugin project. 22 | * A separate DaggerCompile task is executed with the annotation processor 23 | * 24 | * Apply configuration to Android project. 25 | * The source is ${project.buildDir}/generated/source/dagger/ 26 | * The variant.javaCompile compile task is executed with the annotation processor 27 | */ 28 | class DaggerPlugin implements Plugin { 29 | 30 | public static final String TASK_GROUP = "Dagger" 31 | 32 | private static final Logger LOG = Logging.getLogger(DaggerPlugin.class) 33 | 34 | @Override 35 | void apply(Project project) { 36 | 37 | if (project.plugins.hasPlugin(DaggerPlugin.class)) { 38 | return 39 | } 40 | 41 | project.extensions.create(DaggerPluginExtension.NAME, DaggerPluginExtension) 42 | 43 | if (hasAndroidProject(project)) { 44 | androidApply(project) 45 | } else { 46 | javaApply(project) 47 | } 48 | } 49 | 50 | def javaApply(project) { 51 | 52 | LOG.info("Apply Java Dagger plugin") 53 | 54 | if (!project.plugins.hasPlugin(JavaPlugin.class)) { 55 | project.plugins.apply(JavaPlugin.class) 56 | } 57 | 58 | if (project.plugins.hasPlugin(WarPlugin.class)) { 59 | project.configurations { 60 | dagger.extendsFrom compile, providedRuntime, providedCompile 61 | } 62 | } else { 63 | project.configurations { 64 | dagger.extendsFrom compile 65 | } 66 | } 67 | 68 | project.task(type: CleanDaggerSourcesDir, "cleanDaggerSourcesDir") 69 | project.task(type: InitDaggerSourcesDir, "initDaggerSourcesDir") 70 | project.task(type: DaggerCompile, "compileDagger") 71 | 72 | project.tasks.clean.dependsOn project.tasks.cleanDaggerSourcesDir 73 | project.tasks.compileDagger.dependsOn project.tasks.initDaggerSourcesDir 74 | project.tasks.compileJava.dependsOn project.tasks.compileDagger 75 | 76 | project.afterEvaluate { 77 | 78 | project.dependencies { 79 | dagger project.extensions.dagger.processorLibrary 80 | compile project.extensions.dagger.library 81 | } 82 | 83 | project.sourceSets { 84 | dagger { 85 | java.srcDirs = [project.extensions.dagger.daggerSourcesDir] 86 | } 87 | } 88 | 89 | project.compileJava { 90 | source project.extensions.dagger.daggerSourcesDir 91 | } 92 | } 93 | } 94 | 95 | def androidApply(Project project) { 96 | 97 | LOG.info("Apply Android Dagger plugin") 98 | 99 | project.configurations { 100 | dagger.extendsFrom compile 101 | } 102 | 103 | // needed for Android Studio to show dependencies 104 | project.dependencies { 105 | compile project.dagger.library 106 | dagger project.dagger.processorLibrary 107 | } 108 | 109 | project.afterEvaluate { 110 | 111 | def generatedOutputDir = new File(project.buildDir as File, "generated/source/dagger") 112 | 113 | project.tasks.create(name: 'cleanDaggerSourcesDir', type: Delete) { 114 | delete generatedOutputDir 115 | } 116 | 117 | project.tasks.clean.dependsOn project.tasks.cleanDaggerSourcesDir 118 | 119 | def android = project.extensions.android 120 | 121 | def variants = projectAndroidVariants(project) 122 | 123 | android.sourceSets.main.java.srcDirs += [generatedOutputDir] 124 | 125 | variants.all { variant -> 126 | 127 | def variantOutputDir = new File(generatedOutputDir as File, variant.dirName as String) 128 | 129 | variant.javaCompile.classpath += project.configurations.dagger 130 | 131 | variant.javaCompile.doFirst() { 132 | variantOutputDir.mkdirs() 133 | } 134 | 135 | variant.javaCompile.options.compilerArgs += [ 136 | "-s", variantOutputDir.absolutePath, 137 | "-processor", project.dagger.PROCESSOR 138 | ] 139 | 140 | //Makes the generated/source folder visible in Android Studio 141 | variant.addJavaSourceFoldersToModel(variantOutputDir) 142 | } 143 | } 144 | } 145 | 146 | static hasAndroidProject(Project project) { 147 | return project.plugins.hasPlugin('com.android.application') || project.plugins.hasPlugin('com.android.library') 148 | } 149 | 150 | static projectAndroidVariants(Project project) { 151 | if (project.android.hasProperty('applicationVariants')) { 152 | return project.android.applicationVariants 153 | } else if (project.android.hasProperty('libraryVariants')) { 154 | return project.android.libraryVariants 155 | } else { 156 | throw new GradleException('Android project must contain application variants or library variants') 157 | } 158 | } 159 | 160 | static verifyNotWithinMainBuildSrc(Project project) { 161 | def daggerSourcesDir = project.file(project.dagger.daggerSourcesDir) as File 162 | project.sourceSets.main.java.srcDirs.each { d -> 163 | if (d.absolutePath == daggerSourcesDir.absolutePath) { 164 | throw new GradleException("The configured daggerSourcesDir must specify a separate location to existing source code.") 165 | } 166 | } 167 | return daggerSourcesDir 168 | } 169 | } -------------------------------------------------------------------------------- /gradlew: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env sh 2 | 3 | ############################################################################## 4 | ## 5 | ## Gradle start up script for UN*X 6 | ## 7 | ############################################################################## 8 | 9 | # Attempt to set APP_HOME 10 | # Resolve links: $0 may be a link 11 | PRG="$0" 12 | # Need this for relative symlinks. 13 | while [ -h "$PRG" ] ; do 14 | ls=`ls -ld "$PRG"` 15 | link=`expr "$ls" : '.*-> \(.*\)$'` 16 | if expr "$link" : '/.*' > /dev/null; then 17 | PRG="$link" 18 | else 19 | PRG=`dirname "$PRG"`"/$link" 20 | fi 21 | done 22 | SAVED="`pwd`" 23 | cd "`dirname \"$PRG\"`/" >/dev/null 24 | APP_HOME="`pwd -P`" 25 | cd "$SAVED" >/dev/null 26 | 27 | APP_NAME="Gradle" 28 | APP_BASE_NAME=`basename "$0"` 29 | 30 | # Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script. 31 | DEFAULT_JVM_OPTS="" 32 | 33 | # Use the maximum available, or set MAX_FD != -1 to use that value. 34 | MAX_FD="maximum" 35 | 36 | warn ( ) { 37 | echo "$*" 38 | } 39 | 40 | die ( ) { 41 | echo 42 | echo "$*" 43 | echo 44 | exit 1 45 | } 46 | 47 | # OS specific support (must be 'true' or 'false'). 48 | cygwin=false 49 | msys=false 50 | darwin=false 51 | nonstop=false 52 | case "`uname`" in 53 | CYGWIN* ) 54 | cygwin=true 55 | ;; 56 | Darwin* ) 57 | darwin=true 58 | ;; 59 | MINGW* ) 60 | msys=true 61 | ;; 62 | NONSTOP* ) 63 | nonstop=true 64 | ;; 65 | esac 66 | 67 | CLASSPATH=$APP_HOME/gradle/wrapper/gradle-wrapper.jar 68 | 69 | # Determine the Java command to use to start the JVM. 70 | if [ -n "$JAVA_HOME" ] ; then 71 | if [ -x "$JAVA_HOME/jre/sh/java" ] ; then 72 | # IBM's JDK on AIX uses strange locations for the executables 73 | JAVACMD="$JAVA_HOME/jre/sh/java" 74 | else 75 | JAVACMD="$JAVA_HOME/bin/java" 76 | fi 77 | if [ ! -x "$JAVACMD" ] ; then 78 | die "ERROR: JAVA_HOME is set to an invalid directory: $JAVA_HOME 79 | 80 | Please set the JAVA_HOME variable in your environment to match the 81 | location of your Java installation." 82 | fi 83 | else 84 | JAVACMD="java" 85 | which java >/dev/null 2>&1 || die "ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. 86 | 87 | Please set the JAVA_HOME variable in your environment to match the 88 | location of your Java installation." 89 | fi 90 | 91 | # Increase the maximum file descriptors if we can. 92 | if [ "$cygwin" = "false" -a "$darwin" = "false" -a "$nonstop" = "false" ] ; then 93 | MAX_FD_LIMIT=`ulimit -H -n` 94 | if [ $? -eq 0 ] ; then 95 | if [ "$MAX_FD" = "maximum" -o "$MAX_FD" = "max" ] ; then 96 | MAX_FD="$MAX_FD_LIMIT" 97 | fi 98 | ulimit -n $MAX_FD 99 | if [ $? -ne 0 ] ; then 100 | warn "Could not set maximum file descriptor limit: $MAX_FD" 101 | fi 102 | else 103 | warn "Could not query maximum file descriptor limit: $MAX_FD_LIMIT" 104 | fi 105 | fi 106 | 107 | # For Darwin, add options to specify how the application appears in the dock 108 | if $darwin; then 109 | GRADLE_OPTS="$GRADLE_OPTS \"-Xdock:name=$APP_NAME\" \"-Xdock:icon=$APP_HOME/media/gradle.icns\"" 110 | fi 111 | 112 | # For Cygwin, switch paths to Windows format before running java 113 | if $cygwin ; then 114 | APP_HOME=`cygpath --path --mixed "$APP_HOME"` 115 | CLASSPATH=`cygpath --path --mixed "$CLASSPATH"` 116 | JAVACMD=`cygpath --unix "$JAVACMD"` 117 | 118 | # We build the pattern for arguments to be converted via cygpath 119 | ROOTDIRSRAW=`find -L / -maxdepth 1 -mindepth 1 -type d 2>/dev/null` 120 | SEP="" 121 | for dir in $ROOTDIRSRAW ; do 122 | ROOTDIRS="$ROOTDIRS$SEP$dir" 123 | SEP="|" 124 | done 125 | OURCYGPATTERN="(^($ROOTDIRS))" 126 | # Add a user-defined pattern to the cygpath arguments 127 | if [ "$GRADLE_CYGPATTERN" != "" ] ; then 128 | OURCYGPATTERN="$OURCYGPATTERN|($GRADLE_CYGPATTERN)" 129 | fi 130 | # Now convert the arguments - kludge to limit ourselves to /bin/sh 131 | i=0 132 | for arg in "$@" ; do 133 | CHECK=`echo "$arg"|egrep -c "$OURCYGPATTERN" -` 134 | CHECK2=`echo "$arg"|egrep -c "^-"` ### Determine if an option 135 | 136 | if [ $CHECK -ne 0 ] && [ $CHECK2 -eq 0 ] ; then ### Added a condition 137 | eval `echo args$i`=`cygpath --path --ignore --mixed "$arg"` 138 | else 139 | eval `echo args$i`="\"$arg\"" 140 | fi 141 | i=$((i+1)) 142 | done 143 | case $i in 144 | (0) set -- ;; 145 | (1) set -- "$args0" ;; 146 | (2) set -- "$args0" "$args1" ;; 147 | (3) set -- "$args0" "$args1" "$args2" ;; 148 | (4) set -- "$args0" "$args1" "$args2" "$args3" ;; 149 | (5) set -- "$args0" "$args1" "$args2" "$args3" "$args4" ;; 150 | (6) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" ;; 151 | (7) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" ;; 152 | (8) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" ;; 153 | (9) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" "$args8" ;; 154 | esac 155 | fi 156 | 157 | # Escape application args 158 | save ( ) { 159 | for i do printf %s\\n "$i" | sed "s/'/'\\\\''/g;1s/^/'/;\$s/\$/' \\\\/" ; done 160 | echo " " 161 | } 162 | APP_ARGS=$(save "$@") 163 | 164 | # Collect all arguments for the java command, following the shell quoting and substitution rules 165 | eval set -- $DEFAULT_JVM_OPTS $JAVA_OPTS $GRADLE_OPTS "\"-Dorg.gradle.appname=$APP_BASE_NAME\"" -classpath "\"$CLASSPATH\"" org.gradle.wrapper.GradleWrapperMain "$APP_ARGS" 166 | 167 | # by default we should be in the correct project dir, but when run from Finder on Mac, the cwd is wrong 168 | if [ "$(uname)" = "Darwin" ] && [ "$HOME" = "$PWD" ]; then 169 | cd "$(dirname "$0")" 170 | fi 171 | 172 | exec "$JAVACMD" "$@" 173 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | 2 | Apache License 3 | Version 2.0, January 2004 4 | http://www.apache.org/licenses/ 5 | 6 | TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION 7 | 8 | 1. Definitions. 9 | 10 | "License" shall mean the terms and conditions for use, reproduction, 11 | and distribution as defined by Sections 1 through 9 of this document. 12 | 13 | "Licensor" shall mean the copyright owner or entity authorized by 14 | the copyright owner that is granting the License. 15 | 16 | "Legal Entity" shall mean the union of the acting entity and all 17 | other entities that control, are controlled by, or are under common 18 | control with that entity. For the purposes of this definition, 19 | "control" means (i) the power, direct or indirect, to cause the 20 | direction or management of such entity, whether by contract or 21 | otherwise, or (ii) ownership of fifty percent (50%) or more of the 22 | outstanding shares, or (iii) beneficial ownership of such entity. 23 | 24 | "You" (or "Your") shall mean an individual or Legal Entity 25 | exercising permissions granted by this License. 26 | 27 | "Source" form shall mean the preferred form for making modifications, 28 | including but not limited to software source code, documentation 29 | source, and configuration files. 30 | 31 | "Object" form shall mean any form resulting from mechanical 32 | transformation or translation of a Source form, including but 33 | not limited to compiled object code, generated documentation, 34 | and conversions to other media types. 35 | 36 | "Work" shall mean the work of authorship, whether in Source or 37 | Object form, made available under the License, as indicated by a 38 | copyright notice that is included in or attached to the work 39 | (an example is provided in the Appendix below). 40 | 41 | "Derivative Works" shall mean any work, whether in Source or Object 42 | form, that is based on (or derived from) the Work and for which the 43 | editorial revisions, annotations, elaborations, or other modifications 44 | represent, as a whole, an original work of authorship. For the purposes 45 | of this License, Derivative Works shall not include works that remain 46 | separable from, or merely link (or bind by name) to the interfaces of, 47 | the Work and Derivative Works thereof. 48 | 49 | "Contribution" shall mean any work of authorship, including 50 | the original version of the Work and any modifications or additions 51 | to that Work or Derivative Works thereof, that is intentionally 52 | submitted to Licensor for inclusion in the Work by the copyright owner 53 | or by an individual or Legal Entity authorized to submit on behalf of 54 | the copyright owner. For the purposes of this definition, "submitted" 55 | means any form of electronic, verbal, or written communication sent 56 | to the Licensor or its representatives, including but not limited to 57 | communication on electronic mailing lists, source code control systems, 58 | and issue tracking systems that are managed by, or on behalf of, the 59 | Licensor for the purpose of discussing and improving the Work, but 60 | excluding communication that is conspicuously marked or otherwise 61 | designated in writing by the copyright owner as "Not a Contribution." 62 | 63 | "Contributor" shall mean Licensor and any individual or Legal Entity 64 | on behalf of whom a Contribution has been received by Licensor and 65 | subsequently incorporated within the Work. 66 | 67 | 2. Grant of Copyright License. Subject to the terms and conditions of 68 | this License, each Contributor hereby grants to You a perpetual, 69 | worldwide, non-exclusive, no-charge, royalty-free, irrevocable 70 | copyright license to reproduce, prepare Derivative Works of, 71 | publicly display, publicly perform, sublicense, and distribute the 72 | Work and such Derivative Works in Source or Object form. 73 | 74 | 3. Grant of Patent License. Subject to the terms and conditions of 75 | this License, each Contributor hereby grants to You a perpetual, 76 | worldwide, non-exclusive, no-charge, royalty-free, irrevocable 77 | (except as stated in this section) patent license to make, have made, 78 | use, offer to sell, sell, import, and otherwise transfer the Work, 79 | where such license applies only to those patent claims licensable 80 | by such Contributor that are necessarily infringed by their 81 | Contribution(s) alone or by combination of their Contribution(s) 82 | with the Work to which such Contribution(s) was submitted. If You 83 | institute patent litigation against any entity (including a 84 | cross-claim or counterclaim in a lawsuit) alleging that the Work 85 | or a Contribution incorporated within the Work constitutes direct 86 | or contributory patent infringement, then any patent licenses 87 | granted to You under this License for that Work shall terminate 88 | as of the date such litigation is filed. 89 | 90 | 4. Redistribution. You may reproduce and distribute copies of the 91 | Work or Derivative Works thereof in any medium, with or without 92 | modifications, and in Source or Object form, provided that You 93 | meet the following conditions: 94 | 95 | (a) You must give any other recipients of the Work or 96 | Derivative Works a copy of this License; and 97 | 98 | (b) You must cause any modified files to carry prominent notices 99 | stating that You changed the files; and 100 | 101 | (c) You must retain, in the Source form of any Derivative Works 102 | that You distribute, all copyright, patent, trademark, and 103 | attribution notices from the Source form of the Work, 104 | excluding those notices that do not pertain to any part of 105 | the Derivative Works; and 106 | 107 | (d) If the Work includes a "NOTICE" text file as part of its 108 | distribution, then any Derivative Works that You distribute must 109 | include a readable copy of the attribution notices contained 110 | within such NOTICE file, excluding those notices that do not 111 | pertain to any part of the Derivative Works, in at least one 112 | of the following places: within a NOTICE text file distributed 113 | as part of the Derivative Works; within the Source form or 114 | documentation, if provided along with the Derivative Works; or, 115 | within a display generated by the Derivative Works, if and 116 | wherever such third-party notices normally appear. The contents 117 | of the NOTICE file are for informational purposes only and 118 | do not modify the License. You may add Your own attribution 119 | notices within Derivative Works that You distribute, alongside 120 | or as an addendum to the NOTICE text from the Work, provided 121 | that such additional attribution notices cannot be construed 122 | as modifying the License. 123 | 124 | You may add Your own copyright statement to Your modifications and 125 | may provide additional or different license terms and conditions 126 | for use, reproduction, or distribution of Your modifications, or 127 | for any such Derivative Works as a whole, provided Your use, 128 | reproduction, and distribution of the Work otherwise complies with 129 | the conditions stated in this License. 130 | 131 | 5. Submission of Contributions. Unless You explicitly state otherwise, 132 | any Contribution intentionally submitted for inclusion in the Work 133 | by You to the Licensor shall be under the terms and conditions of 134 | this License, without any additional terms or conditions. 135 | Notwithstanding the above, nothing herein shall supersede or modify 136 | the terms of any separate license agreement you may have executed 137 | with Licensor regarding such Contributions. 138 | 139 | 6. Trademarks. This License does not grant permission to use the trade 140 | names, trademarks, service marks, or product names of the Licensor, 141 | except as required for reasonable and customary use in describing the 142 | origin of the Work and reproducing the content of the NOTICE file. 143 | 144 | 7. Disclaimer of Warranty. Unless required by applicable law or 145 | agreed to in writing, Licensor provides the Work (and each 146 | Contributor provides its Contributions) on an "AS IS" BASIS, 147 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or 148 | implied, including, without limitation, any warranties or conditions 149 | of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A 150 | PARTICULAR PURPOSE. You are solely responsible for determining the 151 | appropriateness of using or redistributing the Work and assume any 152 | risks associated with Your exercise of permissions under this License. 153 | 154 | 8. Limitation of Liability. In no event and under no legal theory, 155 | whether in tort (including negligence), contract, or otherwise, 156 | unless required by applicable law (such as deliberate and grossly 157 | negligent acts) or agreed to in writing, shall any Contributor be 158 | liable to You for damages, including any direct, indirect, special, 159 | incidental, or consequential damages of any character arising as a 160 | result of this License or out of the use or inability to use the 161 | Work (including but not limited to damages for loss of goodwill, 162 | work stoppage, computer failure or malfunction, or any and all 163 | other commercial damages or losses), even if such Contributor 164 | has been advised of the possibility of such damages. 165 | 166 | 9. Accepting Warranty or Additional Liability. While redistributing 167 | the Work or Derivative Works thereof, You may choose to offer, 168 | and charge a fee for, acceptance of support, warranty, indemnity, 169 | or other liability obligations and/or rights consistent with this 170 | License. However, in accepting such obligations, You may act only 171 | on Your own behalf and on Your sole responsibility, not on behalf 172 | of any other Contributor, and only if You agree to indemnify, 173 | defend, and hold each Contributor harmless for any liability 174 | incurred by, or claims asserted against, such Contributor by reason 175 | of your accepting any such warranty or additional liability. 176 | 177 | END OF TERMS AND CONDITIONS 178 | 179 | APPENDIX: How to apply the Apache License to your work. 180 | 181 | To apply the Apache License to your work, attach the following 182 | boilerplate notice, with the fields enclosed by brackets "[]" 183 | replaced with your own identifying information. (Don't include 184 | the brackets!) The text should be enclosed in the appropriate 185 | comment syntax for the file format. We also recommend that a 186 | file or class name and description of purpose be included on the 187 | same "printed page" as the copyright notice for easier 188 | identification within third-party archives. 189 | 190 | Copyright [yyyy] [name of copyright owner] 191 | 192 | Licensed under the Apache License, Version 2.0 (the "License"); 193 | you may not use this file except in compliance with the License. 194 | You may obtain a copy of the License at 195 | 196 | http://www.apache.org/licenses/LICENSE-2.0 197 | 198 | Unless required by applicable law or agreed to in writing, software 199 | distributed under the License is distributed on an "AS IS" BASIS, 200 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 201 | See the License for the specific language governing permissions and 202 | limitations under the License. --------------------------------------------------------------------------------