├── plugin ├── src │ ├── test │ │ ├── resources │ │ │ └── test-cases │ │ │ │ ├── build_modules │ │ │ │ ├── build.gradle.kts │ │ │ │ ├── gradle │ │ │ │ │ └── buildStuff │ │ │ │ │ │ ├── src │ │ │ │ │ │ └── main │ │ │ │ │ │ │ └── kotlin │ │ │ │ │ │ │ └── value.kt │ │ │ │ │ │ ├── settings.gradle.kts │ │ │ │ │ │ └── build.gradle.kts │ │ │ │ ├── settings.gradle.kts │ │ │ │ ├── consumer │ │ │ │ │ └── build.gradle.kts │ │ │ │ └── versions.properties │ │ │ │ ├── simple_module │ │ │ │ ├── build.gradle.kts │ │ │ │ ├── library │ │ │ │ │ └── build.gradle.kts │ │ │ │ ├── versions.properties │ │ │ │ ├── settings.gradle.kts │ │ │ │ └── consumer │ │ │ │ │ └── build.gradle.kts │ │ │ │ ├── custom_versions_location │ │ │ │ ├── build.gradle.kts │ │ │ │ ├── library │ │ │ │ │ └── build.gradle.kts │ │ │ │ ├── config │ │ │ │ │ └── versions.properties │ │ │ │ ├── consumer │ │ │ │ │ └── build.gradle.kts │ │ │ │ └── settings.gradle.kts │ │ │ │ ├── remote_versions_location │ │ │ │ ├── build.gradle.kts │ │ │ │ ├── library │ │ │ │ │ └── build.gradle.kts │ │ │ │ ├── consumer │ │ │ │ │ └── build.gradle.kts │ │ │ │ └── settings.gradle.kts │ │ │ │ ├── groovy_support │ │ │ │ ├── library │ │ │ │ │ └── build.gradle.kts │ │ │ │ ├── settings.gradle.kts │ │ │ │ ├── groovyConsumer │ │ │ │ │ └── build.gradle │ │ │ │ └── build.gradle.kts │ │ │ │ ├── nested_modules │ │ │ │ ├── library │ │ │ │ │ └── build.gradle.kts │ │ │ │ ├── group │ │ │ │ │ └── library │ │ │ │ │ │ ├── build.gradle.kts │ │ │ │ │ │ └── nested │ │ │ │ │ │ └── build.gradle.kts │ │ │ │ ├── settings.gradle.kts │ │ │ │ ├── consumer │ │ │ │ │ └── build.gradle.kts │ │ │ │ └── build.gradle.kts │ │ │ │ ├── ignore_modules │ │ │ │ ├── included │ │ │ │ │ └── build.gradle.kts │ │ │ │ ├── settingsKtIgnored │ │ │ │ │ └── build.gradle.kts │ │ │ │ ├── extensionIgnored │ │ │ │ │ └── build.gradle.kts.ignored │ │ │ │ ├── settings.gradle.kts │ │ │ │ └── build.gradle.kts │ │ │ │ ├── multiple_modules │ │ │ │ ├── libraryOne │ │ │ │ │ └── build.gradle.kts │ │ │ │ ├── libraryTwo │ │ │ │ │ └── build.gradle.kts │ │ │ │ ├── settings.gradle.kts │ │ │ │ ├── consumer │ │ │ │ │ └── build.gradle.kts │ │ │ │ └── build.gradle.kts │ │ │ │ └── template_task │ │ │ │ ├── settings.gradle.kts │ │ │ │ └── build.gradle.kts │ │ └── kotlin │ │ │ └── com │ │ │ └── pablisco │ │ │ └── gradle │ │ │ └── automodule │ │ │ ├── gradle │ │ │ ├── GradleFileFixtures.kt │ │ │ └── _GradleRunner.kt │ │ │ ├── AutoModulePluginBenchmarks.kt │ │ │ └── AutoModulePluginTest.kt │ └── main │ │ └── kotlin │ │ ├── com │ │ └── pablisco │ │ │ └── gradle │ │ │ └── automodule │ │ │ ├── utils │ │ │ ├── lang.kt │ │ │ ├── _Settings.kt │ │ │ ├── log.kt │ │ │ ├── _String.kt │ │ │ └── _Path.kt │ │ │ ├── GroovyAutoModules.kt │ │ │ ├── GroovyAutoModuleDependency.kt │ │ │ ├── SettingsScope.kt │ │ │ ├── AutoModule.kt │ │ │ ├── ModuleNode.kt │ │ │ ├── ModulesWriter.kt │ │ │ ├── Versions.kt │ │ │ ├── CreateModuleTask.kt │ │ │ ├── filetree │ │ │ └── FileTreeScope.kt │ │ │ └── AutoModulePlugin.kt │ │ ├── _Versions.kt │ │ ├── _AutoModule.kt │ │ └── AutoModuleDependency.kt └── build.gradle.kts ├── demos └── simple_module │ ├── library │ └── build.gradle.kts │ ├── gradle │ └── wrapper │ │ ├── gradle-wrapper.jar │ │ └── gradle-wrapper.properties │ ├── consumer │ └── build.gradle.kts │ ├── build.gradle.kts │ ├── settings.gradle.kts │ ├── gradlew.bat │ └── gradlew ├── repo └── com │ └── pablisco │ └── gradle │ └── automodule │ ├── core │ ├── 0.12 │ │ ├── core-0.12.jar.md5 │ │ ├── core-0.12.module.md5 │ │ ├── core-0.12.pom.md5 │ │ ├── core-0.12-sources.jar.md5 │ │ ├── core-0.12.jar.sha1 │ │ ├── core-0.12.module.sha1 │ │ ├── core-0.12.pom.sha1 │ │ ├── core-0.12-sources.jar.sha1 │ │ ├── core-0.12.jar.sha256 │ │ ├── core-0.12.module.sha256 │ │ ├── core-0.12.pom.sha256 │ │ ├── core-0.12-sources.jar.sha256 │ │ ├── core-0.12.jar │ │ ├── core-0.12-sources.jar │ │ ├── core-0.12.jar.sha512 │ │ ├── core-0.12.module.sha512 │ │ ├── core-0.12.pom.sha512 │ │ ├── core-0.12-sources.jar.sha512 │ │ ├── core-0.12.pom │ │ └── core-0.12.module │ ├── maven-metadata.xml.md5 │ ├── maven-metadata.xml.sha1 │ ├── maven-metadata.xml.sha256 │ ├── maven-metadata.xml.sha512 │ └── maven-metadata.xml │ ├── plugin │ ├── maven-metadata.xml.md5 │ ├── 0.12 │ │ ├── plugin-0.12.jar.md5 │ │ ├── plugin-0.12.module.md5 │ │ ├── plugin-0.12.pom.md5 │ │ ├── plugin-0.12-sources.jar.md5 │ │ ├── plugin-0.12.jar.sha1 │ │ ├── plugin-0.12.pom.sha1 │ │ ├── plugin-0.12.module.sha1 │ │ ├── plugin-0.12-sources.jar.sha1 │ │ ├── plugin-0.12.jar.sha256 │ │ ├── plugin-0.12.module.sha256 │ │ ├── plugin-0.12.pom.sha256 │ │ ├── plugin-0.12-sources.jar.sha256 │ │ ├── plugin-0.12.jar │ │ ├── plugin-0.12-sources.jar │ │ ├── plugin-0.12.jar.sha512 │ │ ├── plugin-0.12.pom.sha512 │ │ ├── plugin-0.12.module.sha512 │ │ ├── plugin-0.12-sources.jar.sha512 │ │ ├── plugin-0.12.pom │ │ └── plugin-0.12.module │ ├── 0.13 │ │ ├── plugin-0.13.jar.md5 │ │ ├── plugin-0.13.module.md5 │ │ ├── plugin-0.13.pom.md5 │ │ ├── plugin-0.13-sources.jar.md5 │ │ ├── plugin-0.13.jar.sha1 │ │ ├── plugin-0.13.pom.sha1 │ │ ├── plugin-0.13.module.sha1 │ │ ├── plugin-0.13-sources.jar.sha1 │ │ ├── plugin-0.13.jar.sha256 │ │ ├── plugin-0.13.module.sha256 │ │ ├── plugin-0.13.pom.sha256 │ │ ├── plugin-0.13-sources.jar.sha256 │ │ ├── plugin-0.13.jar │ │ ├── plugin-0.13-sources.jar │ │ ├── plugin-0.13.jar.sha512 │ │ ├── plugin-0.13.pom.sha512 │ │ ├── plugin-0.13.module.sha512 │ │ ├── plugin-0.13-sources.jar.sha512 │ │ ├── plugin-0.13.pom │ │ └── plugin-0.13.module │ ├── 0.14 │ │ ├── plugin-0.14.jar.md5 │ │ ├── plugin-0.14.module.md5 │ │ ├── plugin-0.14.pom.md5 │ │ ├── plugin-0.14-sources.jar.md5 │ │ ├── plugin-0.14.jar.sha1 │ │ ├── plugin-0.14.pom.sha1 │ │ ├── plugin-0.14.module.sha1 │ │ ├── plugin-0.14-sources.jar.sha1 │ │ ├── plugin-0.14.jar.sha256 │ │ ├── plugin-0.14.module.sha256 │ │ ├── plugin-0.14.pom.sha256 │ │ ├── plugin-0.14-sources.jar.sha256 │ │ ├── plugin-0.14.jar │ │ ├── plugin-0.14-sources.jar │ │ ├── plugin-0.14.jar.sha512 │ │ ├── plugin-0.14.pom.sha512 │ │ ├── plugin-0.14.module.sha512 │ │ ├── plugin-0.14-sources.jar.sha512 │ │ ├── plugin-0.14.pom │ │ └── plugin-0.14.module │ ├── 0.15 │ │ ├── plugin-0.15.jar.md5 │ │ ├── plugin-0.15.module.md5 │ │ ├── plugin-0.15.pom.md5 │ │ ├── plugin-0.15-sources.jar.md5 │ │ ├── plugin-0.15.jar.sha1 │ │ ├── plugin-0.15.pom.sha1 │ │ ├── plugin-0.15.module.sha1 │ │ ├── plugin-0.15-sources.jar.sha1 │ │ ├── plugin-0.15.jar.sha256 │ │ ├── plugin-0.15.module.sha256 │ │ ├── plugin-0.15.pom.sha256 │ │ ├── plugin-0.15-sources.jar.sha256 │ │ ├── plugin-0.15.jar │ │ ├── plugin-0.15-sources.jar │ │ ├── plugin-0.15.jar.sha512 │ │ ├── plugin-0.15.pom.sha512 │ │ ├── plugin-0.15.module.sha512 │ │ ├── plugin-0.15-sources.jar.sha512 │ │ ├── plugin-0.15.pom │ │ └── plugin-0.15.module │ ├── maven-metadata.xml.sha1 │ ├── maven-metadata.xml.sha256 │ ├── maven-metadata.xml.sha512 │ └── maven-metadata.xml │ └── com.pablisco.gradle.automodule.gradle.plugin │ ├── maven-metadata.xml.md5 │ ├── maven-metadata.xml.sha1 │ ├── maven-metadata.xml.sha256 │ ├── 0.12 │ ├── com.pablisco.gradle.automodule.gradle.plugin-0.12.pom.md5 │ ├── com.pablisco.gradle.automodule.gradle.plugin-0.12.pom.sha1 │ ├── com.pablisco.gradle.automodule.gradle.plugin-0.12.pom.sha256 │ ├── com.pablisco.gradle.automodule.gradle.plugin-0.12.pom.sha512 │ └── com.pablisco.gradle.automodule.gradle.plugin-0.12.pom │ ├── 0.13 │ ├── com.pablisco.gradle.automodule.gradle.plugin-0.13.pom.md5 │ ├── com.pablisco.gradle.automodule.gradle.plugin-0.13.pom.sha1 │ ├── com.pablisco.gradle.automodule.gradle.plugin-0.13.pom.sha256 │ ├── com.pablisco.gradle.automodule.gradle.plugin-0.13.pom.sha512 │ └── com.pablisco.gradle.automodule.gradle.plugin-0.13.pom │ ├── 0.14 │ ├── com.pablisco.gradle.automodule.gradle.plugin-0.14.pom.md5 │ ├── com.pablisco.gradle.automodule.gradle.plugin-0.14.pom.sha1 │ ├── com.pablisco.gradle.automodule.gradle.plugin-0.14.pom.sha256 │ ├── com.pablisco.gradle.automodule.gradle.plugin-0.14.pom.sha512 │ └── com.pablisco.gradle.automodule.gradle.plugin-0.14.pom │ ├── 0.15 │ ├── com.pablisco.gradle.automodule.gradle.plugin-0.15.pom.md5 │ ├── com.pablisco.gradle.automodule.gradle.plugin-0.15.pom.sha1 │ ├── com.pablisco.gradle.automodule.gradle.plugin-0.15.pom.sha256 │ ├── com.pablisco.gradle.automodule.gradle.plugin-0.15.pom.sha512 │ └── com.pablisco.gradle.automodule.gradle.plugin-0.15.pom │ ├── maven-metadata.xml.sha512 │ └── maven-metadata.xml ├── gradle ├── wrapper │ ├── gradle-wrapper.jar │ └── gradle-wrapper.properties ├── dependencies │ ├── build.gradle.kts │ ├── include.settings.gradle.kts │ ├── settings.gradle.kts │ └── src │ │ └── main │ │ └── kotlin │ │ └── dependencies.kt └── maven-version-check │ ├── src │ └── main │ │ └── kotlin │ │ ├── AutoModuleMavenMetadata.kt │ │ └── MavenMetadataApi.kt │ ├── build.gradle.kts │ └── settings.gradle.kts ├── .idea ├── codeStyles │ ├── codeStyleConfig.xml │ └── Project.xml └── uiDesigner.xml ├── .github └── workflows │ ├── test.yml │ └── publish.yml ├── versions.properties ├── settings.gradle.kts ├── .gitignore ├── license.md ├── gradle.properties ├── gradlew.bat ├── gradlew └── readme.md /plugin/src/test/resources/test-cases/build_modules/build.gradle.kts: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /plugin/src/test/resources/test-cases/simple_module/build.gradle.kts: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /plugin/src/test/resources/test-cases/custom_versions_location/build.gradle.kts: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /plugin/src/test/resources/test-cases/remote_versions_location/build.gradle.kts: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /demos/simple_module/library/build.gradle.kts: -------------------------------------------------------------------------------- 1 | plugins { 2 | kotlin("jvm") 3 | } -------------------------------------------------------------------------------- /repo/com/pablisco/gradle/automodule/core/0.12/core-0.12.jar.md5: -------------------------------------------------------------------------------- 1 | 2eb15aa53f9d294583d7bbe8a51a1c85 -------------------------------------------------------------------------------- /repo/com/pablisco/gradle/automodule/core/0.12/core-0.12.module.md5: -------------------------------------------------------------------------------- 1 | 2a845ab46b9f2f02e2fb489cd12b4524 -------------------------------------------------------------------------------- /repo/com/pablisco/gradle/automodule/core/0.12/core-0.12.pom.md5: -------------------------------------------------------------------------------- 1 | 27b5ddcd3a1ec3fab0ec27c43d5cc499 -------------------------------------------------------------------------------- /repo/com/pablisco/gradle/automodule/core/maven-metadata.xml.md5: -------------------------------------------------------------------------------- 1 | f13b1413b22428d1513795f3228d1cf5 -------------------------------------------------------------------------------- /repo/com/pablisco/gradle/automodule/plugin/maven-metadata.xml.md5: -------------------------------------------------------------------------------- 1 | 0c63614395344979210e2e77debb5e91 -------------------------------------------------------------------------------- /plugin/src/test/resources/test-cases/groovy_support/library/build.gradle.kts: -------------------------------------------------------------------------------- 1 | plugins { kotlin("jvm") } -------------------------------------------------------------------------------- /plugin/src/test/resources/test-cases/nested_modules/library/build.gradle.kts: -------------------------------------------------------------------------------- 1 | plugins { kotlin("jvm") } -------------------------------------------------------------------------------- /plugin/src/test/resources/test-cases/simple_module/library/build.gradle.kts: -------------------------------------------------------------------------------- 1 | plugins { kotlin("jvm") } -------------------------------------------------------------------------------- /plugin/src/test/resources/test-cases/simple_module/versions.properties: -------------------------------------------------------------------------------- 1 | org.jetbrains.kotlin=1.4.0 2 | -------------------------------------------------------------------------------- /repo/com/pablisco/gradle/automodule/core/0.12/core-0.12-sources.jar.md5: -------------------------------------------------------------------------------- 1 | 5f91ef5e86f7c5931524605e2d77aeef -------------------------------------------------------------------------------- /repo/com/pablisco/gradle/automodule/plugin/0.12/plugin-0.12.jar.md5: -------------------------------------------------------------------------------- 1 | 01befb0c97d584f07665bb005c7c11f4 -------------------------------------------------------------------------------- /repo/com/pablisco/gradle/automodule/plugin/0.12/plugin-0.12.module.md5: -------------------------------------------------------------------------------- 1 | 216b2a129535d458842d0cb3f1cf993a -------------------------------------------------------------------------------- /repo/com/pablisco/gradle/automodule/plugin/0.12/plugin-0.12.pom.md5: -------------------------------------------------------------------------------- 1 | 37ec272280a143077d11ffff054fba34 -------------------------------------------------------------------------------- /repo/com/pablisco/gradle/automodule/plugin/0.13/plugin-0.13.jar.md5: -------------------------------------------------------------------------------- 1 | 54c5a08871e7b127c118c26c6075fc51 -------------------------------------------------------------------------------- /repo/com/pablisco/gradle/automodule/plugin/0.13/plugin-0.13.module.md5: -------------------------------------------------------------------------------- 1 | f5beac64b632b68539248846d1fed2cd -------------------------------------------------------------------------------- /repo/com/pablisco/gradle/automodule/plugin/0.13/plugin-0.13.pom.md5: -------------------------------------------------------------------------------- 1 | 036bce7e14012a1af367281ea19d3586 -------------------------------------------------------------------------------- /repo/com/pablisco/gradle/automodule/plugin/0.14/plugin-0.14.jar.md5: -------------------------------------------------------------------------------- 1 | 21fe689996a3f117156ffb75eced9027 -------------------------------------------------------------------------------- /repo/com/pablisco/gradle/automodule/plugin/0.14/plugin-0.14.module.md5: -------------------------------------------------------------------------------- 1 | 608c269b091860e5ab9edd697da11e52 -------------------------------------------------------------------------------- /repo/com/pablisco/gradle/automodule/plugin/0.14/plugin-0.14.pom.md5: -------------------------------------------------------------------------------- 1 | f53f533cba1d58e9a097dec2cee27bd1 -------------------------------------------------------------------------------- /repo/com/pablisco/gradle/automodule/plugin/0.15/plugin-0.15.jar.md5: -------------------------------------------------------------------------------- 1 | 850a3c198302ac7747ee1d9ddd3a5280 -------------------------------------------------------------------------------- /repo/com/pablisco/gradle/automodule/plugin/0.15/plugin-0.15.module.md5: -------------------------------------------------------------------------------- 1 | c4af24d8923238453b4cd40c382b4930 -------------------------------------------------------------------------------- /repo/com/pablisco/gradle/automodule/plugin/0.15/plugin-0.15.pom.md5: -------------------------------------------------------------------------------- 1 | 7a790e23a877f51b4550bb09c91181d3 -------------------------------------------------------------------------------- /plugin/src/test/resources/test-cases/ignore_modules/included/build.gradle.kts: -------------------------------------------------------------------------------- 1 | plugins { kotlin("jvm") } 2 | -------------------------------------------------------------------------------- /plugin/src/test/resources/test-cases/multiple_modules/libraryOne/build.gradle.kts: -------------------------------------------------------------------------------- 1 | plugins { kotlin("jvm") } -------------------------------------------------------------------------------- /plugin/src/test/resources/test-cases/multiple_modules/libraryTwo/build.gradle.kts: -------------------------------------------------------------------------------- 1 | plugins { kotlin("jvm") } -------------------------------------------------------------------------------- /plugin/src/test/resources/test-cases/nested_modules/group/library/build.gradle.kts: -------------------------------------------------------------------------------- 1 | plugins { kotlin("jvm") } -------------------------------------------------------------------------------- /repo/com/pablisco/gradle/automodule/core/0.12/core-0.12.jar.sha1: -------------------------------------------------------------------------------- 1 | bdabbc2820b817f6ac20fca4111cddbc4d0c25d2 -------------------------------------------------------------------------------- /repo/com/pablisco/gradle/automodule/core/0.12/core-0.12.module.sha1: -------------------------------------------------------------------------------- 1 | 69d150b618ab2e7cbf60e3e444496c628348db67 -------------------------------------------------------------------------------- /repo/com/pablisco/gradle/automodule/core/0.12/core-0.12.pom.sha1: -------------------------------------------------------------------------------- 1 | 7758ab34a219460106ae94897e5d5daa4709e737 -------------------------------------------------------------------------------- /repo/com/pablisco/gradle/automodule/core/maven-metadata.xml.sha1: -------------------------------------------------------------------------------- 1 | 95ce7521c828fd6e3dd3707be8aee667566d4150 -------------------------------------------------------------------------------- /repo/com/pablisco/gradle/automodule/plugin/0.12/plugin-0.12-sources.jar.md5: -------------------------------------------------------------------------------- 1 | 4851027a6dc2965aeeeb99e2a51f13b5 -------------------------------------------------------------------------------- /repo/com/pablisco/gradle/automodule/plugin/0.12/plugin-0.12.jar.sha1: -------------------------------------------------------------------------------- 1 | 6cd3a5c1a2091b218fdc3e0194f219c956ff66a4 -------------------------------------------------------------------------------- /repo/com/pablisco/gradle/automodule/plugin/0.12/plugin-0.12.pom.sha1: -------------------------------------------------------------------------------- 1 | 89f0cc8032442ac90345be5d5b616f308349c42e -------------------------------------------------------------------------------- /repo/com/pablisco/gradle/automodule/plugin/0.13/plugin-0.13-sources.jar.md5: -------------------------------------------------------------------------------- 1 | 3d461294cd11f50ab253ae817882110d -------------------------------------------------------------------------------- /repo/com/pablisco/gradle/automodule/plugin/0.13/plugin-0.13.jar.sha1: -------------------------------------------------------------------------------- 1 | a1120b781bbde6eb22f0976a8aa45b8c5b8dfd75 -------------------------------------------------------------------------------- /repo/com/pablisco/gradle/automodule/plugin/0.13/plugin-0.13.pom.sha1: -------------------------------------------------------------------------------- 1 | 130d6fefa328e6cf4fc738bc5d41a78a42ea78d5 -------------------------------------------------------------------------------- /repo/com/pablisco/gradle/automodule/plugin/0.14/plugin-0.14-sources.jar.md5: -------------------------------------------------------------------------------- 1 | 792f9bc124a9ec9731382be539e2d0d8 -------------------------------------------------------------------------------- /repo/com/pablisco/gradle/automodule/plugin/0.14/plugin-0.14.jar.sha1: -------------------------------------------------------------------------------- 1 | f0b892383a7315d618ca89dfe806d532bfa8894f -------------------------------------------------------------------------------- /repo/com/pablisco/gradle/automodule/plugin/0.14/plugin-0.14.pom.sha1: -------------------------------------------------------------------------------- 1 | 81ceefab7ebee768e81c9f24697c09ace9eb24e5 -------------------------------------------------------------------------------- /repo/com/pablisco/gradle/automodule/plugin/0.15/plugin-0.15-sources.jar.md5: -------------------------------------------------------------------------------- 1 | e748352d8e741de8158fcc522c1c869b -------------------------------------------------------------------------------- /repo/com/pablisco/gradle/automodule/plugin/0.15/plugin-0.15.jar.sha1: -------------------------------------------------------------------------------- 1 | 5f778159293ec3d7189ee71b57fcacba44b8fb6c -------------------------------------------------------------------------------- /repo/com/pablisco/gradle/automodule/plugin/0.15/plugin-0.15.pom.sha1: -------------------------------------------------------------------------------- 1 | a043da851d0325d80b7ae2d00a1ab57005cdceb9 -------------------------------------------------------------------------------- /repo/com/pablisco/gradle/automodule/plugin/maven-metadata.xml.sha1: -------------------------------------------------------------------------------- 1 | 187cf2d700c1399e4c13be25dc7182b174d8fd65 -------------------------------------------------------------------------------- /plugin/src/test/resources/test-cases/custom_versions_location/library/build.gradle.kts: -------------------------------------------------------------------------------- 1 | plugins { kotlin("jvm") } -------------------------------------------------------------------------------- /plugin/src/test/resources/test-cases/remote_versions_location/library/build.gradle.kts: -------------------------------------------------------------------------------- 1 | plugins { kotlin("jvm") } -------------------------------------------------------------------------------- /repo/com/pablisco/gradle/automodule/core/0.12/core-0.12-sources.jar.sha1: -------------------------------------------------------------------------------- 1 | d5a948acb0954f0b60c65d1f51f30bfcb674e826 -------------------------------------------------------------------------------- /repo/com/pablisco/gradle/automodule/plugin/0.12/plugin-0.12.module.sha1: -------------------------------------------------------------------------------- 1 | 7be5daf7870c58aa5703bc5e0a03acbd22ac634c -------------------------------------------------------------------------------- /repo/com/pablisco/gradle/automodule/plugin/0.13/plugin-0.13.module.sha1: -------------------------------------------------------------------------------- 1 | e4d52504328b513282bacb313bbc41b0026ad1bb -------------------------------------------------------------------------------- /repo/com/pablisco/gradle/automodule/plugin/0.14/plugin-0.14.module.sha1: -------------------------------------------------------------------------------- 1 | 22db18f8f59fc158e771022bd061150d645518f3 -------------------------------------------------------------------------------- /repo/com/pablisco/gradle/automodule/plugin/0.15/plugin-0.15.module.sha1: -------------------------------------------------------------------------------- 1 | c63aae643a6e85579eb19edeadefc5efcdfd38a5 -------------------------------------------------------------------------------- /plugin/src/test/resources/test-cases/ignore_modules/settingsKtIgnored/build.gradle.kts: -------------------------------------------------------------------------------- 1 | plugins { kotlin("jvm") } 2 | -------------------------------------------------------------------------------- /plugin/src/test/resources/test-cases/nested_modules/group/library/nested/build.gradle.kts: -------------------------------------------------------------------------------- 1 | plugins { kotlin("jvm") } -------------------------------------------------------------------------------- /repo/com/pablisco/gradle/automodule/plugin/0.12/plugin-0.12-sources.jar.sha1: -------------------------------------------------------------------------------- 1 | 13e5fc69db8070eb034352781dba2b68138f9270 -------------------------------------------------------------------------------- /repo/com/pablisco/gradle/automodule/plugin/0.13/plugin-0.13-sources.jar.sha1: -------------------------------------------------------------------------------- 1 | 2170b26e94b0f8325eb969266f3446e974d82abb -------------------------------------------------------------------------------- /repo/com/pablisco/gradle/automodule/plugin/0.14/plugin-0.14-sources.jar.sha1: -------------------------------------------------------------------------------- 1 | 271e70feb00789073bca138ae7e2d2adac334b11 -------------------------------------------------------------------------------- /repo/com/pablisco/gradle/automodule/plugin/0.15/plugin-0.15-sources.jar.sha1: -------------------------------------------------------------------------------- 1 | 21c28c626a07d9690d473786535e5d00e870754a -------------------------------------------------------------------------------- /gradle/wrapper/gradle-wrapper.jar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/suhtai/auto-module/HEAD/gradle/wrapper/gradle-wrapper.jar -------------------------------------------------------------------------------- /plugin/src/test/resources/test-cases/build_modules/gradle/buildStuff/src/main/kotlin/value.kt: -------------------------------------------------------------------------------- 1 | const val value = "Gradle" -------------------------------------------------------------------------------- /plugin/src/test/resources/test-cases/custom_versions_location/config/versions.properties: -------------------------------------------------------------------------------- 1 | org.jetbrains.kotlin=1.4.0 2 | -------------------------------------------------------------------------------- /plugin/src/test/resources/test-cases/ignore_modules/extensionIgnored/build.gradle.kts.ignored: -------------------------------------------------------------------------------- 1 | plugins { kotlin("jvm") } 2 | -------------------------------------------------------------------------------- /repo/com/pablisco/gradle/automodule/core/0.12/core-0.12.jar.sha256: -------------------------------------------------------------------------------- 1 | a098f5aa60178aaf8ce4da3f3eecc773665358f676f9fb1adf19f549802e72ae -------------------------------------------------------------------------------- /repo/com/pablisco/gradle/automodule/core/0.12/core-0.12.module.sha256: -------------------------------------------------------------------------------- 1 | d0cf1c63f8fe8b67d885e803c1722103b635c9e34579945593ad83ec713ab543 -------------------------------------------------------------------------------- /repo/com/pablisco/gradle/automodule/core/0.12/core-0.12.pom.sha256: -------------------------------------------------------------------------------- 1 | c60092dd24429991bb699d658a5b8bdc5a1a6b09a8366bc125fe5cb5df4412c0 -------------------------------------------------------------------------------- /repo/com/pablisco/gradle/automodule/core/maven-metadata.xml.sha256: -------------------------------------------------------------------------------- 1 | cf1907db7dd8c802d737a240c5e27e90149a7181a171b3349e97c0ea7ba63076 -------------------------------------------------------------------------------- /repo/com/pablisco/gradle/automodule/plugin/maven-metadata.xml.sha256: -------------------------------------------------------------------------------- 1 | 9414c26d158b2e2f5fed99cde847af0ca0d1f2815eb1635110e12e9abd312885 -------------------------------------------------------------------------------- /plugin/src/test/resources/test-cases/build_modules/settings.gradle.kts: -------------------------------------------------------------------------------- 1 | plugins { 2 | id("com.pablisco.gradle.automodule") 3 | } 4 | -------------------------------------------------------------------------------- /plugin/src/test/resources/test-cases/groovy_support/settings.gradle.kts: -------------------------------------------------------------------------------- 1 | plugins { 2 | id("com.pablisco.gradle.automodule") 3 | } 4 | -------------------------------------------------------------------------------- /plugin/src/test/resources/test-cases/multiple_modules/settings.gradle.kts: -------------------------------------------------------------------------------- 1 | plugins { 2 | id("com.pablisco.gradle.automodule") 3 | } 4 | -------------------------------------------------------------------------------- /plugin/src/test/resources/test-cases/nested_modules/settings.gradle.kts: -------------------------------------------------------------------------------- 1 | plugins { 2 | id("com.pablisco.gradle.automodule") 3 | } 4 | -------------------------------------------------------------------------------- /plugin/src/test/resources/test-cases/simple_module/settings.gradle.kts: -------------------------------------------------------------------------------- 1 | plugins { 2 | id("com.pablisco.gradle.automodule") 3 | } 4 | -------------------------------------------------------------------------------- /repo/com/pablisco/gradle/automodule/com.pablisco.gradle.automodule.gradle.plugin/maven-metadata.xml.md5: -------------------------------------------------------------------------------- 1 | 4b3383d5465a123b98d9568f7df23202 -------------------------------------------------------------------------------- /repo/com/pablisco/gradle/automodule/core/0.12/core-0.12-sources.jar.sha256: -------------------------------------------------------------------------------- 1 | 3b6a7782aa947a9c871700d5d239b6e4ddf0fdb9531e7a1dc9357aa549e9aaa5 -------------------------------------------------------------------------------- /repo/com/pablisco/gradle/automodule/plugin/0.12/plugin-0.12.jar.sha256: -------------------------------------------------------------------------------- 1 | 0fb22c348e07b787924c06107ff29fad1c4be7db0ec55b1cf79d063c65cae1a6 -------------------------------------------------------------------------------- /repo/com/pablisco/gradle/automodule/plugin/0.12/plugin-0.12.module.sha256: -------------------------------------------------------------------------------- 1 | c71670a4e20658570cceb70f715d68cfae207f4114a4bafabeae6cd7c02b6a73 -------------------------------------------------------------------------------- /repo/com/pablisco/gradle/automodule/plugin/0.12/plugin-0.12.pom.sha256: -------------------------------------------------------------------------------- 1 | 98d403312ca343d23884b36c2e3ffb818124ee7cbd0cb32f44dd433afcede309 -------------------------------------------------------------------------------- /repo/com/pablisco/gradle/automodule/plugin/0.13/plugin-0.13.jar.sha256: -------------------------------------------------------------------------------- 1 | 74bf5c77bbe935d34955a62af4ed000c23e09d922e7e7a2cfebf49b2314851b5 -------------------------------------------------------------------------------- /repo/com/pablisco/gradle/automodule/plugin/0.13/plugin-0.13.module.sha256: -------------------------------------------------------------------------------- 1 | 345c94e7315dbdd7d3d4c56f38150f6eb93b84d68a1b3ebb815ab241b8ec9641 -------------------------------------------------------------------------------- /repo/com/pablisco/gradle/automodule/plugin/0.13/plugin-0.13.pom.sha256: -------------------------------------------------------------------------------- 1 | b99bce53abe765ed70ce3d53caca8b4e4a9d146d0fd47c0f005050d0c234886e -------------------------------------------------------------------------------- /repo/com/pablisco/gradle/automodule/plugin/0.14/plugin-0.14.jar.sha256: -------------------------------------------------------------------------------- 1 | ea7de1783a2064f55b3102c829839c683bd01c6547d82683a81b057269b8c174 -------------------------------------------------------------------------------- /repo/com/pablisco/gradle/automodule/plugin/0.14/plugin-0.14.module.sha256: -------------------------------------------------------------------------------- 1 | da3f1b137076923998467a82ca9b7fff3a33dea75d9e85bf00cec372c0e8991c -------------------------------------------------------------------------------- /repo/com/pablisco/gradle/automodule/plugin/0.14/plugin-0.14.pom.sha256: -------------------------------------------------------------------------------- 1 | 2ebcd7d5cb83c8bfd5b0384fdbe37b9cc0224314ff5c9c9fc0361b48c0c582cb -------------------------------------------------------------------------------- /repo/com/pablisco/gradle/automodule/plugin/0.15/plugin-0.15.jar.sha256: -------------------------------------------------------------------------------- 1 | 545bdbd9c5ce22e2d0bac0e6ba03cad8e0dfc6eb165d3a9646f1cbc78e6d1270 -------------------------------------------------------------------------------- /repo/com/pablisco/gradle/automodule/plugin/0.15/plugin-0.15.module.sha256: -------------------------------------------------------------------------------- 1 | f8be32780068c7b5b57a0cd7ce744cdd33cea253ec38d10378846b7f1a4e0da3 -------------------------------------------------------------------------------- /repo/com/pablisco/gradle/automodule/plugin/0.15/plugin-0.15.pom.sha256: -------------------------------------------------------------------------------- 1 | 819ce2f22acabaca66291a7d17df8cae6111ac98f9c35315d3ddf3ca245f8a4a -------------------------------------------------------------------------------- /repo/com/pablisco/gradle/automodule/plugin/0.12/plugin-0.12-sources.jar.sha256: -------------------------------------------------------------------------------- 1 | 50a283e39624b73f3cf0b8cf35c2238bd3637c2a4b8c49b0a16913772d0ef2d0 -------------------------------------------------------------------------------- /repo/com/pablisco/gradle/automodule/plugin/0.13/plugin-0.13-sources.jar.sha256: -------------------------------------------------------------------------------- 1 | 8a7edadbb0ffdf7b599efbf21e78bbeb94aaae4adbb292153106f5df24212938 -------------------------------------------------------------------------------- /repo/com/pablisco/gradle/automodule/plugin/0.14/plugin-0.14-sources.jar.sha256: -------------------------------------------------------------------------------- 1 | 8fc3ba658463c4036a8054077cc3a91e69c89eb502f1a4fe73bca4b0a54a2aa6 -------------------------------------------------------------------------------- /repo/com/pablisco/gradle/automodule/plugin/0.15/plugin-0.15-sources.jar.sha256: -------------------------------------------------------------------------------- 1 | 8737b98a8ba3c8dce94f0b39085f280b922a3053dc2ce7f8bbbaf14b0f03cce7 -------------------------------------------------------------------------------- /repo/com/pablisco/gradle/automodule/com.pablisco.gradle.automodule.gradle.plugin/maven-metadata.xml.sha1: -------------------------------------------------------------------------------- 1 | e05d424eb48e2e1504942550034248e4f676530a -------------------------------------------------------------------------------- /plugin/src/test/resources/test-cases/build_modules/consumer/build.gradle.kts: -------------------------------------------------------------------------------- 1 | plugins { kotlin("jvm") } 2 | 3 | logger.lifecycle("Hello $value!") 4 | -------------------------------------------------------------------------------- /demos/simple_module/gradle/wrapper/gradle-wrapper.jar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/suhtai/auto-module/HEAD/demos/simple_module/gradle/wrapper/gradle-wrapper.jar -------------------------------------------------------------------------------- /plugin/src/main/kotlin/com/pablisco/gradle/automodule/utils/lang.kt: -------------------------------------------------------------------------------- 1 | package com.pablisco.gradle.automodule.utils 2 | 3 | inline fun Any.castAs(): A? = this as? A -------------------------------------------------------------------------------- /repo/com/pablisco/gradle/automodule/com.pablisco.gradle.automodule.gradle.plugin/maven-metadata.xml.sha256: -------------------------------------------------------------------------------- 1 | 36226544bf8b36d2e7e0deb8d8cee956f6771a5d0d2e5423a39a54c96187a173 -------------------------------------------------------------------------------- /repo/com/pablisco/gradle/automodule/core/0.12/core-0.12.jar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/suhtai/auto-module/HEAD/repo/com/pablisco/gradle/automodule/core/0.12/core-0.12.jar -------------------------------------------------------------------------------- /plugin/src/test/resources/test-cases/build_modules/versions.properties: -------------------------------------------------------------------------------- 1 | 2 | # dependencies 3 | com.squareup.retrofit2=2.9.0 4 | 5 | # plugins 6 | org.jetbrains.kotlin=1.4.0 7 | -------------------------------------------------------------------------------- /plugin/src/test/resources/test-cases/groovy_support/groovyConsumer/build.gradle: -------------------------------------------------------------------------------- 1 | apply plugin: 'java' 2 | dependencies { 3 | implementation project(autoModules.library) 4 | } -------------------------------------------------------------------------------- /repo/com/pablisco/gradle/automodule/com.pablisco.gradle.automodule.gradle.plugin/0.12/com.pablisco.gradle.automodule.gradle.plugin-0.12.pom.md5: -------------------------------------------------------------------------------- 1 | d1740d2044953f4046a117b35ced4fce -------------------------------------------------------------------------------- /repo/com/pablisco/gradle/automodule/com.pablisco.gradle.automodule.gradle.plugin/0.13/com.pablisco.gradle.automodule.gradle.plugin-0.13.pom.md5: -------------------------------------------------------------------------------- 1 | cb9d3e7f9bc42b41d45ce0481269e5f9 -------------------------------------------------------------------------------- /repo/com/pablisco/gradle/automodule/com.pablisco.gradle.automodule.gradle.plugin/0.14/com.pablisco.gradle.automodule.gradle.plugin-0.14.pom.md5: -------------------------------------------------------------------------------- 1 | f202b14c34a19b937ec492c732908879 -------------------------------------------------------------------------------- /repo/com/pablisco/gradle/automodule/com.pablisco.gradle.automodule.gradle.plugin/0.15/com.pablisco.gradle.automodule.gradle.plugin-0.15.pom.md5: -------------------------------------------------------------------------------- 1 | 878292c584aa4f3ad7dd9ee0237e4a51 -------------------------------------------------------------------------------- /repo/com/pablisco/gradle/automodule/plugin/0.12/plugin-0.12.jar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/suhtai/auto-module/HEAD/repo/com/pablisco/gradle/automodule/plugin/0.12/plugin-0.12.jar -------------------------------------------------------------------------------- /repo/com/pablisco/gradle/automodule/plugin/0.13/plugin-0.13.jar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/suhtai/auto-module/HEAD/repo/com/pablisco/gradle/automodule/plugin/0.13/plugin-0.13.jar -------------------------------------------------------------------------------- /repo/com/pablisco/gradle/automodule/plugin/0.14/plugin-0.14.jar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/suhtai/auto-module/HEAD/repo/com/pablisco/gradle/automodule/plugin/0.14/plugin-0.14.jar -------------------------------------------------------------------------------- /repo/com/pablisco/gradle/automodule/plugin/0.15/plugin-0.15.jar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/suhtai/auto-module/HEAD/repo/com/pablisco/gradle/automodule/plugin/0.15/plugin-0.15.jar -------------------------------------------------------------------------------- /plugin/src/test/resources/test-cases/simple_module/consumer/build.gradle.kts: -------------------------------------------------------------------------------- 1 | plugins { kotlin("jvm") } 2 | 3 | dependencies { 4 | implementation(project(autoModules.library)) 5 | } -------------------------------------------------------------------------------- /repo/com/pablisco/gradle/automodule/com.pablisco.gradle.automodule.gradle.plugin/0.12/com.pablisco.gradle.automodule.gradle.plugin-0.12.pom.sha1: -------------------------------------------------------------------------------- 1 | 240469e99a1c4fb409ceae4946617108f024e225 -------------------------------------------------------------------------------- /repo/com/pablisco/gradle/automodule/com.pablisco.gradle.automodule.gradle.plugin/0.13/com.pablisco.gradle.automodule.gradle.plugin-0.13.pom.sha1: -------------------------------------------------------------------------------- 1 | 320903733c2a6297abedf1941fccaf2176be44d5 -------------------------------------------------------------------------------- /repo/com/pablisco/gradle/automodule/com.pablisco.gradle.automodule.gradle.plugin/0.14/com.pablisco.gradle.automodule.gradle.plugin-0.14.pom.sha1: -------------------------------------------------------------------------------- 1 | 752e88cb000ea614db1dd6ba7cbd3b2e29aefdae -------------------------------------------------------------------------------- /repo/com/pablisco/gradle/automodule/com.pablisco.gradle.automodule.gradle.plugin/0.15/com.pablisco.gradle.automodule.gradle.plugin-0.15.pom.sha1: -------------------------------------------------------------------------------- 1 | 6967ddd534353ed8d5c3a59dbdc06b42cd097539 -------------------------------------------------------------------------------- /repo/com/pablisco/gradle/automodule/core/0.12/core-0.12-sources.jar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/suhtai/auto-module/HEAD/repo/com/pablisco/gradle/automodule/core/0.12/core-0.12-sources.jar -------------------------------------------------------------------------------- /.idea/codeStyles/codeStyleConfig.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 5 | -------------------------------------------------------------------------------- /plugin/src/test/resources/test-cases/custom_versions_location/consumer/build.gradle.kts: -------------------------------------------------------------------------------- 1 | plugins { kotlin("jvm") } 2 | 3 | dependencies { 4 | implementation(project(autoModules.library)) 5 | } -------------------------------------------------------------------------------- /plugin/src/test/resources/test-cases/remote_versions_location/consumer/build.gradle.kts: -------------------------------------------------------------------------------- 1 | plugins { kotlin("jvm") } 2 | 3 | dependencies { 4 | implementation(project(autoModules.library)) 5 | } -------------------------------------------------------------------------------- /repo/com/pablisco/gradle/automodule/core/0.12/core-0.12.jar.sha512: -------------------------------------------------------------------------------- 1 | 6a61353cc8b9e040bcba9623247cd956ca263ba43b03f5bbb4e1e4aeb599eaa96b1c0a727f37eefb1be980182c83a1d41845b69f472def8f620d9870adadaa14 -------------------------------------------------------------------------------- /repo/com/pablisco/gradle/automodule/core/0.12/core-0.12.module.sha512: -------------------------------------------------------------------------------- 1 | 5e7f6aa1fcfdc26b4195af629416d699a23f260aa320ffe58c1d8cbd0be48764ec89853408b94b22cbdaebecfcff1ef373d458f1597cdd586a11c80d0b1a5e6e -------------------------------------------------------------------------------- /repo/com/pablisco/gradle/automodule/core/0.12/core-0.12.pom.sha512: -------------------------------------------------------------------------------- 1 | 18e118ab0bf9b5183eb4e63916ded4f61b733c81ac532c6bed45cf46045faf3c8cc0262109b7217b29512398d35b9e1e753e86fb816abb000da0db54a05728e8 -------------------------------------------------------------------------------- /repo/com/pablisco/gradle/automodule/core/maven-metadata.xml.sha512: -------------------------------------------------------------------------------- 1 | 1a727d56e7f332488dd03c69ee5e60611c525e02da96f037a8baf445e705ebbe0617965dcab0ee13bf0b8d28d447ee12acb84eb40502b577c1685ebd35ce6d23 -------------------------------------------------------------------------------- /repo/com/pablisco/gradle/automodule/plugin/0.12/plugin-0.12-sources.jar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/suhtai/auto-module/HEAD/repo/com/pablisco/gradle/automodule/plugin/0.12/plugin-0.12-sources.jar -------------------------------------------------------------------------------- /repo/com/pablisco/gradle/automodule/plugin/0.12/plugin-0.12.jar.sha512: -------------------------------------------------------------------------------- 1 | 34252321cb5bfb6bf5bbfa5a6a8e7fb8f22c70dbb054a398812383b8427fec3429bb0d846d3283b5281f6954f887a716911bfad975a3ebbe21f06a08a870bb21 -------------------------------------------------------------------------------- /repo/com/pablisco/gradle/automodule/plugin/0.12/plugin-0.12.pom.sha512: -------------------------------------------------------------------------------- 1 | 621f4306a011148bf3781f7905ec320461fd21ef888005a535502c062e73aca91c63985eea30d09a7986c7d8104c4462c9cb566e54e68bd929bdc0cd31e2dd34 -------------------------------------------------------------------------------- /repo/com/pablisco/gradle/automodule/plugin/0.13/plugin-0.13-sources.jar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/suhtai/auto-module/HEAD/repo/com/pablisco/gradle/automodule/plugin/0.13/plugin-0.13-sources.jar -------------------------------------------------------------------------------- /repo/com/pablisco/gradle/automodule/plugin/0.13/plugin-0.13.jar.sha512: -------------------------------------------------------------------------------- 1 | 9a6e11bd14f20f609e2c4fddc3445f3a86389407f8792898ae0c47d17df56062fc4eac04dd70fce1c6da55c0a6c0908e1a22ffe4151c31b456d763bcf0e97835 -------------------------------------------------------------------------------- /repo/com/pablisco/gradle/automodule/plugin/0.13/plugin-0.13.pom.sha512: -------------------------------------------------------------------------------- 1 | bedadd37e49c950cda2bcb7044e4021672135de164924009bc1c661a9fabd2ee335a45191e889eb42c0368fc538856af31bb01412162d1e6357ac1608e635f27 -------------------------------------------------------------------------------- /repo/com/pablisco/gradle/automodule/plugin/0.14/plugin-0.14-sources.jar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/suhtai/auto-module/HEAD/repo/com/pablisco/gradle/automodule/plugin/0.14/plugin-0.14-sources.jar -------------------------------------------------------------------------------- /repo/com/pablisco/gradle/automodule/plugin/0.14/plugin-0.14.jar.sha512: -------------------------------------------------------------------------------- 1 | b79dc4a23b09184696ada3c7d8296356f822f6d95d3bec7e6826d29d2de8930700544732d9645f2f952ff8aac4a2d293d29b995d26325a5e94ec312a656bf112 -------------------------------------------------------------------------------- /repo/com/pablisco/gradle/automodule/plugin/0.14/plugin-0.14.pom.sha512: -------------------------------------------------------------------------------- 1 | 4eb7340c3f75938ac0cea3ae01565b2abd8525b43e5e77660d11c6a45ed034dcd79101243e934a4cdb58467daba60f864ba4f86d7f9dfa6beb258905488712a9 -------------------------------------------------------------------------------- /repo/com/pablisco/gradle/automodule/plugin/0.15/plugin-0.15-sources.jar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/suhtai/auto-module/HEAD/repo/com/pablisco/gradle/automodule/plugin/0.15/plugin-0.15-sources.jar -------------------------------------------------------------------------------- /repo/com/pablisco/gradle/automodule/plugin/0.15/plugin-0.15.jar.sha512: -------------------------------------------------------------------------------- 1 | af9e87297acee21ead635a1d5f7f2cf6fd38a936e6f35f78376c6c89c86bc8e9f30ffd702522a3a7df87c72a945b33c6c2c3a4e33c3a307051cd3594b5836045 -------------------------------------------------------------------------------- /repo/com/pablisco/gradle/automodule/plugin/0.15/plugin-0.15.pom.sha512: -------------------------------------------------------------------------------- 1 | 4140577a34889ff49d9c0eae07150aab61966f34f6d470d0c655c8b7ebe481e98f4e52c6a06854021d0c0ce8d7ae12512a9fb419568e08d02e40b1ed9ea78fd6 -------------------------------------------------------------------------------- /repo/com/pablisco/gradle/automodule/plugin/maven-metadata.xml.sha512: -------------------------------------------------------------------------------- 1 | 198ccc45f1689cbcb3c4675f1e39c58c43c323d55348d961adced68005d12787f04fd89540f89d55a43729fffcde556b36fa289ce14b713143698fc4cf0ad3ac -------------------------------------------------------------------------------- /plugin/src/test/resources/test-cases/ignore_modules/settings.gradle.kts: -------------------------------------------------------------------------------- 1 | plugins { 2 | id("com.pablisco.gradle.automodule") 3 | } 4 | 5 | autoModule { 6 | ignore(":settingsKtIgnored") 7 | } 8 | -------------------------------------------------------------------------------- /repo/com/pablisco/gradle/automodule/core/0.12/core-0.12-sources.jar.sha512: -------------------------------------------------------------------------------- 1 | 1ef66c2af79e6fcbb3502f937631a7de248b71372a3ff88cc7f2989d64b3bd239dc3a2b88b50fc812cc7a9eaff8e301fa7ef81036007e3e208cbe128b6e82717 -------------------------------------------------------------------------------- /repo/com/pablisco/gradle/automodule/plugin/0.12/plugin-0.12.module.sha512: -------------------------------------------------------------------------------- 1 | fec89169f6b08eb5ed12c71d0ba79f15e92a8f2a8e480128b5447181a9e75fc65838183a0497f6940be061dd18619da467491113b87b1e5c75b5ff354501e16b -------------------------------------------------------------------------------- /repo/com/pablisco/gradle/automodule/plugin/0.13/plugin-0.13.module.sha512: -------------------------------------------------------------------------------- 1 | a9af2b9022c5ba1de5c05d29f99c62640a5b6bcf978e0cd39353dbc509ab7fcbf5907e34142ac7bfb24cfb167d098f4abff67844799e845344b800b65f7b328b -------------------------------------------------------------------------------- /repo/com/pablisco/gradle/automodule/plugin/0.14/plugin-0.14.module.sha512: -------------------------------------------------------------------------------- 1 | 492a0b364b290e41975fc44194603523726e9eff813b0cd0abaa5d19cf8de95b9ea2ad385da912e358207c1489048f87b2c35870d9a766ba516310f83baebc3e -------------------------------------------------------------------------------- /repo/com/pablisco/gradle/automodule/plugin/0.15/plugin-0.15.module.sha512: -------------------------------------------------------------------------------- 1 | 37b52814857097f9fe7ba3754ff2d5511f112bb5dc9efa7fcbb16fd115f0d047a4fce7aa3504be9a6c23dbdcbfa59430140e832a295002cf938c4c0741408590 -------------------------------------------------------------------------------- /repo/com/pablisco/gradle/automodule/plugin/0.12/plugin-0.12-sources.jar.sha512: -------------------------------------------------------------------------------- 1 | 8e2babbbfb2def475b6300937c494e86dafd04042aae0763254a5d517b0f1b2d2680b72db140e2d5e43cc848e7403494f402828aa7451ed024f7a8ba1c916de3 -------------------------------------------------------------------------------- /repo/com/pablisco/gradle/automodule/plugin/0.13/plugin-0.13-sources.jar.sha512: -------------------------------------------------------------------------------- 1 | 56ace2689206557f8b6f7509535dbe9705f9bab9e92c8a959ecc37b2d0de2c3f4d21bcd34b01ce0df48abca21f70ea9c991708cdcd254c5109e51dbe6cc22363 -------------------------------------------------------------------------------- /repo/com/pablisco/gradle/automodule/plugin/0.14/plugin-0.14-sources.jar.sha512: -------------------------------------------------------------------------------- 1 | b334c04a6f5233e32bdd021f78344951b7c0723302ff58340d7f901c3a3889ae42aff64f943a915d3a86bef127dcacc36fc9d3bc3191c605730234e2a8ed3ce9 -------------------------------------------------------------------------------- /repo/com/pablisco/gradle/automodule/plugin/0.15/plugin-0.15-sources.jar.sha512: -------------------------------------------------------------------------------- 1 | dc38005bf2c9610f03449d9c0198f1b5fc78b13e4233f596d481096911d73b0e3c456b844120c4dcccedd47d2345b3003f01bb1cc26a85d55cbaac8c7b6e86cb -------------------------------------------------------------------------------- /gradle/dependencies/build.gradle.kts: -------------------------------------------------------------------------------- 1 | plugins { 2 | kotlin("jvm") 3 | } 4 | 5 | repositories { 6 | jcenter() 7 | } 8 | 9 | dependencies { 10 | implementation(kotlin("stdlib")) 11 | } 12 | -------------------------------------------------------------------------------- /repo/com/pablisco/gradle/automodule/com.pablisco.gradle.automodule.gradle.plugin/0.12/com.pablisco.gradle.automodule.gradle.plugin-0.12.pom.sha256: -------------------------------------------------------------------------------- 1 | c3223d06e776b5e2776bc31cf57402aa7c516209b74b650e18d51b9cd213746c -------------------------------------------------------------------------------- /repo/com/pablisco/gradle/automodule/com.pablisco.gradle.automodule.gradle.plugin/0.13/com.pablisco.gradle.automodule.gradle.plugin-0.13.pom.sha256: -------------------------------------------------------------------------------- 1 | d6560e3f497647d64773343fa33f56fa1191ddfc3c7ba440e9c314042fcaac16 -------------------------------------------------------------------------------- /repo/com/pablisco/gradle/automodule/com.pablisco.gradle.automodule.gradle.plugin/0.14/com.pablisco.gradle.automodule.gradle.plugin-0.14.pom.sha256: -------------------------------------------------------------------------------- 1 | 312883c9ce336f92d853153cf2063721621f75b40610854759334e55bf368502 -------------------------------------------------------------------------------- /repo/com/pablisco/gradle/automodule/com.pablisco.gradle.automodule.gradle.plugin/0.15/com.pablisco.gradle.automodule.gradle.plugin-0.15.pom.sha256: -------------------------------------------------------------------------------- 1 | e7ff51253478d89e1b55a5659e570e1c8ecdc18355e07f9cf821b208291876e4 -------------------------------------------------------------------------------- /plugin/src/test/resources/test-cases/custom_versions_location/settings.gradle.kts: -------------------------------------------------------------------------------- 1 | plugins { 2 | id("com.pablisco.gradle.automodule") 3 | } 4 | 5 | autoModule { 6 | versions = "config/versions.properties" 7 | } 8 | -------------------------------------------------------------------------------- /plugin/src/test/resources/test-cases/build_modules/gradle/buildStuff/settings.gradle.kts: -------------------------------------------------------------------------------- 1 | plugins { 2 | id("com.pablisco.gradle.automodule") 3 | } 4 | 5 | autoModule { 6 | versions = "../../versions.properties" 7 | } 8 | -------------------------------------------------------------------------------- /plugin/src/test/resources/test-cases/build_modules/gradle/buildStuff/build.gradle.kts: -------------------------------------------------------------------------------- 1 | repositories { jcenter() } 2 | 3 | plugins { kotlin("jvm") } 4 | 5 | dependencies { 6 | implementation("com.squareup.retrofit2:retrofit") 7 | } -------------------------------------------------------------------------------- /repo/com/pablisco/gradle/automodule/com.pablisco.gradle.automodule.gradle.plugin/maven-metadata.xml.sha512: -------------------------------------------------------------------------------- 1 | d9bb6cef5f29b17f26cfcf91267f754135951ccb892cd80419539543a9671b2024caeec5aa39bc076bbc3d3c009c5d43b188b276d26c28fadfed08a445a7bed3 -------------------------------------------------------------------------------- /plugin/src/test/resources/test-cases/multiple_modules/consumer/build.gradle.kts: -------------------------------------------------------------------------------- 1 | plugins { kotlin("jvm") } 2 | 3 | dependencies { 4 | implementation(project(autoModules.libraryOne)) 5 | implementation(project(autoModules.libraryTwo)) 6 | } -------------------------------------------------------------------------------- /plugin/src/test/resources/test-cases/template_task/settings.gradle.kts: -------------------------------------------------------------------------------- 1 | plugins { 2 | id("com.pablisco.gradle.automodule") 3 | } 4 | 5 | autoModule { 6 | template("default") { 7 | emptyFile( "build.gradle.kts") 8 | } 9 | } 10 | -------------------------------------------------------------------------------- /gradle/wrapper/gradle-wrapper.properties: -------------------------------------------------------------------------------- 1 | distributionBase=GRADLE_USER_HOME 2 | distributionPath=wrapper/dists 3 | distributionUrl=https\://services.gradle.org/distributions/gradle-6.6.1-bin.zip 4 | zipStoreBase=GRADLE_USER_HOME 5 | zipStorePath=wrapper/dists 6 | -------------------------------------------------------------------------------- /demos/simple_module/consumer/build.gradle.kts: -------------------------------------------------------------------------------- 1 | plugins { 2 | kotlin("jvm") 3 | } 4 | 5 | dependencies { 6 | 7 | autoModules { 8 | implementation(project(library)) 9 | } 10 | 11 | implementation(project(autoModules.library)) 12 | 13 | } 14 | -------------------------------------------------------------------------------- /repo/com/pablisco/gradle/automodule/com.pablisco.gradle.automodule.gradle.plugin/0.12/com.pablisco.gradle.automodule.gradle.plugin-0.12.pom.sha512: -------------------------------------------------------------------------------- 1 | 522a33764fd62cba91129793e8412654fbd5550f3710d90048eeae1cadd589cb06f235461abb3740e66e0dc182f444d252a0298366441828f308a625cd076992 -------------------------------------------------------------------------------- /repo/com/pablisco/gradle/automodule/com.pablisco.gradle.automodule.gradle.plugin/0.13/com.pablisco.gradle.automodule.gradle.plugin-0.13.pom.sha512: -------------------------------------------------------------------------------- 1 | 3b9188a3a14838e3810fbb44e5dffeb422feabcb15a1a23f3dd8749e767c90b11d108070d95bebde14f8b36a043163c916c9378d9a71f29d691a6207d009c6bf -------------------------------------------------------------------------------- /repo/com/pablisco/gradle/automodule/com.pablisco.gradle.automodule.gradle.plugin/0.14/com.pablisco.gradle.automodule.gradle.plugin-0.14.pom.sha512: -------------------------------------------------------------------------------- 1 | fa2dd1cfb0506dc38592ffe5caa05f9f99f1c899569dad3658e721c122da328e45e4fdad391a594516eaf6747b4585ff2b4fd304b12d30285d08ef7c47b9a274 -------------------------------------------------------------------------------- /repo/com/pablisco/gradle/automodule/com.pablisco.gradle.automodule.gradle.plugin/0.15/com.pablisco.gradle.automodule.gradle.plugin-0.15.pom.sha512: -------------------------------------------------------------------------------- 1 | 82452c63dc5828604cd9153b0bb0c2052de1456420e8458301accbf861c9cc0b26f43987f5a893f3f3061224d2f748318a1eba183d5ac60169170f7ff3f180ea -------------------------------------------------------------------------------- /demos/simple_module/gradle/wrapper/gradle-wrapper.properties: -------------------------------------------------------------------------------- 1 | distributionBase=GRADLE_USER_HOME 2 | distributionPath=wrapper/dists 3 | distributionUrl=https\://services.gradle.org/distributions/gradle-6.5-all.zip 4 | zipStoreBase=GRADLE_USER_HOME 5 | zipStorePath=wrapper/dists 6 | -------------------------------------------------------------------------------- /.github/workflows/test.yml: -------------------------------------------------------------------------------- 1 | name: Test 2 | 3 | on: 4 | push: 5 | branches-ignore: 6 | - master 7 | 8 | jobs: 9 | build: 10 | runs-on: ubuntu-latest 11 | steps: 12 | - uses: actions/checkout@v2 13 | - name: Test 14 | run: ./gradlew test -i 15 | -------------------------------------------------------------------------------- /plugin/src/test/resources/test-cases/nested_modules/consumer/build.gradle.kts: -------------------------------------------------------------------------------- 1 | plugins { kotlin("jvm") } 2 | 3 | dependencies { 4 | implementation(project(autoModules.library)) 5 | implementation(project(autoModules.group.library)) 6 | implementation(project(autoModules.group.library.nested)) 7 | } 8 | -------------------------------------------------------------------------------- /plugin/src/test/resources/test-cases/remote_versions_location/settings.gradle.kts: -------------------------------------------------------------------------------- 1 | plugins { 2 | id("com.pablisco.gradle.automodule") 3 | } 4 | 5 | autoModule { 6 | versions = "https://gist.githubusercontent.com/pablisco/d50ff9bb587e06cb8a88e39923a74ed6/raw/400503984f247428017b1d207f2bf63c78c0fb72/versions.properties" 7 | } 8 | -------------------------------------------------------------------------------- /plugin/src/test/resources/test-cases/groovy_support/build.gradle.kts: -------------------------------------------------------------------------------- 1 | buildscript { 2 | repositories { 3 | jcenter() 4 | maven(url = rootDir.resolve("../../../../repo")) 5 | gradlePluginPortal() 6 | } 7 | dependencies { 8 | classpath("org.jetbrains.kotlin:kotlin-gradle-plugin:1.4.0") 9 | } 10 | } 11 | -------------------------------------------------------------------------------- /plugin/src/test/resources/test-cases/ignore_modules/build.gradle.kts: -------------------------------------------------------------------------------- 1 | buildscript { 2 | repositories { 3 | jcenter() 4 | maven(url = rootDir.resolve("../../../../repo")) 5 | gradlePluginPortal() 6 | } 7 | dependencies { 8 | classpath("org.jetbrains.kotlin:kotlin-gradle-plugin:1.4.0") 9 | } 10 | } 11 | -------------------------------------------------------------------------------- /plugin/src/test/resources/test-cases/nested_modules/build.gradle.kts: -------------------------------------------------------------------------------- 1 | buildscript { 2 | repositories { 3 | jcenter() 4 | maven(url = rootDir.resolve("../../../../repo")) 5 | gradlePluginPortal() 6 | } 7 | dependencies { 8 | classpath("org.jetbrains.kotlin:kotlin-gradle-plugin:1.4.0") 9 | } 10 | } 11 | -------------------------------------------------------------------------------- /plugin/src/test/resources/test-cases/template_task/build.gradle.kts: -------------------------------------------------------------------------------- 1 | buildscript { 2 | repositories { 3 | jcenter() 4 | maven(url = rootDir.resolve("../../../../repo")) 5 | gradlePluginPortal() 6 | } 7 | dependencies { 8 | classpath("org.jetbrains.kotlin:kotlin-gradle-plugin:1.4.0") 9 | } 10 | } 11 | -------------------------------------------------------------------------------- /plugin/src/test/resources/test-cases/multiple_modules/build.gradle.kts: -------------------------------------------------------------------------------- 1 | buildscript { 2 | repositories { 3 | jcenter() 4 | maven(url = rootDir.resolve("../../../../repo")) 5 | gradlePluginPortal() 6 | } 7 | dependencies { 8 | classpath("org.jetbrains.kotlin:kotlin-gradle-plugin:1.4.0") 9 | } 10 | } 11 | -------------------------------------------------------------------------------- /gradle/dependencies/include.settings.gradle.kts: -------------------------------------------------------------------------------- 1 | includeBuild(file(".")) { 2 | dependencySubstitution { 3 | substitute(module("gradle:dependencies")).with(project(":")) 4 | } 5 | } 6 | 7 | gradle.rootProject { 8 | buildscript { 9 | dependencies { 10 | classpath("gradle:dependencies") 11 | } 12 | } 13 | } 14 | -------------------------------------------------------------------------------- /demos/simple_module/build.gradle.kts: -------------------------------------------------------------------------------- 1 | // Enable for local testing 2 | //buildscript { 3 | // repositories { 4 | // maven(url = rootDir.parentFile.parentFile.resolve("repo")) 5 | // } 6 | //} 7 | 8 | plugins { 9 | kotlin("jvm") version "1.4.0" apply false 10 | } 11 | 12 | allprojects { 13 | repositories { 14 | jcenter() 15 | } 16 | } 17 | -------------------------------------------------------------------------------- /plugin/src/main/kotlin/_Versions.kt: -------------------------------------------------------------------------------- 1 | import com.pablisco.gradle.automodule.Versions 2 | import org.gradle.api.plugins.ExtensionAware 3 | import org.gradle.kotlin.dsl.getByType 4 | 5 | /** 6 | * The versions set in settings by [com.pablisco.gradle.automodule.AutoModule.versions] 7 | */ 8 | @Suppress("unused") // Api 9 | val ExtensionAware.versions: Versions get() = extensions.getByType() 10 | -------------------------------------------------------------------------------- /.github/workflows/publish.yml: -------------------------------------------------------------------------------- 1 | name: Publish 2 | 3 | on: 4 | push: 5 | branches: 6 | - master 7 | 8 | jobs: 9 | build: 10 | runs-on: ubuntu-latest 11 | steps: 12 | - uses: actions/checkout@v2 13 | - name: Publish 14 | run: ./gradlew build publishPlugins -Pgradle.publish.key=${{ secrets.GRADLE_KEY }} -Pgradle.publish.secret=${{ secrets.GRADLE_SECRET }} 15 | -------------------------------------------------------------------------------- /plugin/src/main/kotlin/_AutoModule.kt: -------------------------------------------------------------------------------- 1 | import com.pablisco.gradle.automodule.AutoModule 2 | import org.gradle.api.initialization.Settings 3 | import org.gradle.kotlin.dsl.configure 4 | 5 | /** 6 | * Extension to be used from scripts. Using default package to avoid imports. 7 | */ 8 | @Suppress("unused") // Api 9 | fun Settings.autoModule(block: AutoModule.() -> Unit): Unit = configure(block) 10 | -------------------------------------------------------------------------------- /plugin/src/main/kotlin/com/pablisco/gradle/automodule/utils/_Settings.kt: -------------------------------------------------------------------------------- 1 | package com.pablisco.gradle.automodule.utils 2 | 3 | import org.gradle.api.initialization.Settings 4 | 5 | /** 6 | * Adds an extension to [Settings] as well as every project. 7 | */ 8 | fun Settings.addGlobalExtension(name: String, extension: T) { 9 | extensions.add(name, extension) 10 | gradle.allprojects { extensions.add(name, extension) } 11 | } -------------------------------------------------------------------------------- /repo/com/pablisco/gradle/automodule/core/maven-metadata.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | com.pablisco.gradle.automodule 4 | core 5 | 6 | 0.12 7 | 0.12 8 | 9 | 0.12 10 | 11 | 20200714165634 12 | 13 | 14 | -------------------------------------------------------------------------------- /versions.properties: -------------------------------------------------------------------------------- 1 | # suppress inspection "UnusedProperty" for whole file 2 | 3 | # dependencies 4 | org.jetbrains.kotlin=1.4.0 5 | kotlinx-coroutines-core=1.3.9 6 | org.junit.jupiter=5.6.2 7 | org.amshove.kluent=1.61 8 | com.squareup.retrofit2=2.9.0 9 | com.squareup_kotlinpoet=1.6.0 10 | 11 | # plugins 12 | com.palantir.idea-test-fix=0.1.0 13 | com.gradle.plugin-publish=0.12.0 14 | com.pablisco.gradle.automodule=0.15 15 | com.github.blueboxware.tocme=1.2 16 | -------------------------------------------------------------------------------- /gradle/dependencies/settings.gradle.kts: -------------------------------------------------------------------------------- 1 | rootProject.name = "dependencies" 2 | 3 | pluginManagement { 4 | repositories { 5 | // load local repo 6 | maven(url = rootDir.resolve("../../repo")) 7 | gradlePluginPortal() 8 | } 9 | } 10 | 11 | plugins { 12 | id("com.pablisco.gradle.automodule") version "0.15" 13 | } 14 | 15 | autoModule { 16 | versions = "../../versions.properties" 17 | pluginRepository(rootDir.resolve("../../repo")) 18 | } -------------------------------------------------------------------------------- /demos/simple_module/settings.gradle.kts: -------------------------------------------------------------------------------- 1 | rootProject.name = "simple_module" 2 | 3 | // Enable for local testing 4 | //pluginManagement { 5 | // repositories { 6 | // maven(url = rootDir.resolve("../../repo")) 7 | // mavenCentral() 8 | // } 9 | //} 10 | 11 | plugins { 12 | id("com.pablisco.gradle.automodule") version "0.15" 13 | } 14 | 15 | // Enable for local testing 16 | //autoModule { 17 | // pluginRepository(rootDir.resolve("../../repo")) 18 | //} 19 | -------------------------------------------------------------------------------- /gradle/maven-version-check/src/main/kotlin/AutoModuleMavenMetadata.kt: -------------------------------------------------------------------------------- 1 | import kotlinx.coroutines.runBlocking 2 | 3 | object AutoModuleMavenMetadata { 4 | 5 | private val api by lazy { MavenMetadataApi.gradlePlugins } 6 | 7 | val versions: List by lazy { 8 | runBlocking { 9 | MavenMetadataApi.gradlePlugins 10 | .pluginMetadata(Plugin("com.pablisco.gradle.automodule")) 11 | .versioning.versions 12 | } 13 | } 14 | 15 | } 16 | -------------------------------------------------------------------------------- /plugin/src/main/kotlin/com/pablisco/gradle/automodule/utils/log.kt: -------------------------------------------------------------------------------- 1 | package com.pablisco.gradle.automodule.utils 2 | 3 | import com.pablisco.gradle.automodule.AutoModule 4 | import org.gradle.api.logging.LogLevel 5 | import org.gradle.api.logging.Logger 6 | import org.gradle.api.logging.Logging 7 | 8 | internal fun log(message: String, logLevel: LogLevel = LogLevel.INFO) { 9 | logger.log(logLevel, "[Auto-Module] $message") 10 | } 11 | 12 | private val logger: Logger by lazy { Logging.getLogger(AutoModule::class.java) } 13 | -------------------------------------------------------------------------------- /repo/com/pablisco/gradle/automodule/plugin/maven-metadata.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | com.pablisco.gradle.automodule 4 | plugin 5 | 6 | 0.15 7 | 0.15 8 | 9 | 0.12 10 | 0.13 11 | 0.14 12 | 0.15 13 | 14 | 20200902230732 15 | 16 | 17 | -------------------------------------------------------------------------------- /gradle/maven-version-check/build.gradle.kts: -------------------------------------------------------------------------------- 1 | plugins { 2 | kotlin("jvm") 3 | } 4 | 5 | repositories { 6 | jcenter() 7 | } 8 | 9 | dependencies { 10 | implementation(libs.kotlin.jdk8) 11 | implementation(libs.kotlin.x.coroutines) 12 | implementation(libs.square.retrofit) 13 | implementation(libs.square.retrofitXml) 14 | } 15 | 16 | 17 | tasks { 18 | compileKotlin { 19 | kotlinOptions { 20 | jvmTarget = JavaVersion.VERSION_1_8.toString() 21 | freeCompilerArgs = listOf("-Xinline-classes") 22 | } 23 | } 24 | } 25 | -------------------------------------------------------------------------------- /plugin/src/main/kotlin/com/pablisco/gradle/automodule/GroovyAutoModules.kt: -------------------------------------------------------------------------------- 1 | package com.pablisco.gradle.automodule 2 | 3 | /** 4 | * Used from Groovy Gradle scripts to access modules similarly to how they are accessed with Kotlin Gradle scripts. 5 | */ 6 | open class GroovyAutoModules { 7 | 8 | /** 9 | * Entry point for [GroovyAutoModuleDependency] instances. 10 | */ 11 | @Suppress("unused") // groovy dynamic property 12 | fun propertyMissing(property: String): GroovyAutoModuleDependency = 13 | GroovyAutoModuleDependency(path =":$property") 14 | 15 | } -------------------------------------------------------------------------------- /repo/com/pablisco/gradle/automodule/com.pablisco.gradle.automodule.gradle.plugin/maven-metadata.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | com.pablisco.gradle.automodule 4 | com.pablisco.gradle.automodule.gradle.plugin 5 | 6 | 0.15 7 | 0.15 8 | 9 | 0.12 10 | 0.13 11 | 0.14 12 | 0.15 13 | 14 | 20200902230732 15 | 16 | 17 | -------------------------------------------------------------------------------- /settings.gradle.kts: -------------------------------------------------------------------------------- 1 | rootProject.name = "auto-module" 2 | 3 | pluginManagement { 4 | repositories { 5 | // load self from local repo 6 | maven(url = rootDir.resolve("repo")) 7 | gradlePluginPortal() 8 | } 9 | } 10 | 11 | plugins { 12 | id("com.pablisco.gradle.automodule") version "0.15" 13 | } 14 | 15 | autoModule { 16 | // Ignore tests cases and build folder 17 | ignore(":plugin:build") 18 | ignore(":demos") 19 | ignore(":gradle") 20 | ignore(":plugin:src:test:resources") 21 | ignore(":plugin:out") 22 | ignore(":plugin:src") 23 | 24 | pluginRepository(rootDir.resolve("repo")) 25 | } 26 | -------------------------------------------------------------------------------- /plugin/src/main/kotlin/com/pablisco/gradle/automodule/GroovyAutoModuleDependency.kt: -------------------------------------------------------------------------------- 1 | package com.pablisco.gradle.automodule 2 | 3 | /** 4 | * Uses Groovy dynamic properties to define `project()` dependencies in a dynamic way. 5 | * This allows to use the same usage as we would have in Gradle Kotlin Scripts aiding 6 | * with future migrations. 7 | */ 8 | class GroovyAutoModuleDependency( 9 | private val path: String 10 | ) : Map by mapOf("path" to path) { 11 | 12 | @Suppress("unused") // groovy dynamic property 13 | fun propertyMissing(property: String) = 14 | GroovyAutoModuleDependency(path = "$path:$property") 15 | 16 | } -------------------------------------------------------------------------------- /plugin/src/main/kotlin/com/pablisco/gradle/automodule/utils/_String.kt: -------------------------------------------------------------------------------- 1 | package com.pablisco.gradle.automodule.utils 2 | 3 | internal fun String.camelCase(): String = 4 | sanitize().split(' ').joinToString("") { it.capitalize() } 5 | 6 | internal fun String.snakeCase(): String = 7 | sanitize().split(' ') 8 | .mapIndexed { index, s -> if (index == 0) s else s.capitalize() } 9 | .joinToString("") 10 | 11 | private fun String.sanitize(replacement: Char = ' '): String = 12 | toCharArray().joinToString("") { c -> 13 | when { 14 | !c.isJavaIdentifierPart() -> replacement 15 | this[0] == c && !c.isJavaIdentifierStart() -> replacement 16 | else -> c 17 | }.toString() 18 | } -------------------------------------------------------------------------------- /plugin/src/main/kotlin/AutoModuleDependency.kt: -------------------------------------------------------------------------------- 1 | typealias AutoModuleDependency = Map 2 | 3 | @Suppress("unused") // Api 4 | fun autoModuleDependency( 5 | path: String, 6 | configuration: String? = null 7 | ): AutoModuleDependency = mapOfNonNull( 8 | "path" to path, 9 | "configuration" to configuration 10 | ) 11 | 12 | val AutoModuleDependency.path: String 13 | get() = this["path"] ?: error("Missing dependency path in $this") 14 | 15 | @Suppress("unused") // Api 16 | infix fun AutoModuleDependency.configuration(configuration: String): AutoModuleDependency = 17 | this + mapOf("configuration" to configuration) 18 | 19 | private fun mapOfNonNull(vararg entries: Pair): Map = 20 | entries.mapNotNull { (k, v) -> v?.let { k to v } }.toMap() 21 | -------------------------------------------------------------------------------- /gradle/maven-version-check/settings.gradle.kts: -------------------------------------------------------------------------------- 1 | rootProject.name = "maven-version-check" 2 | 3 | pluginManagement { 4 | repositories { 5 | // load local repo 6 | maven(url = rootDir.resolve("../../repo")) 7 | gradlePluginPortal() 8 | } 9 | } 10 | 11 | plugins { 12 | id("com.pablisco.gradle.automodule") version "0.15" 13 | } 14 | 15 | autoModule { 16 | versions = "../../versions.properties" 17 | pluginRepository(rootDir.resolve("../../repo")) 18 | } 19 | 20 | includeBuild("../dependencies") { 21 | dependencySubstitution { 22 | substitute(module("gradle:dependencies:local")).with(project(":")) 23 | } 24 | } 25 | gradle.rootProject { 26 | buildscript { 27 | dependencies { 28 | classpath("gradle:dependencies:local") 29 | } 30 | } 31 | } 32 | -------------------------------------------------------------------------------- /plugin/src/test/kotlin/com/pablisco/gradle/automodule/gradle/GradleFileFixtures.kt: -------------------------------------------------------------------------------- 1 | package com.pablisco.gradle.automodule.gradle 2 | 3 | import com.pablisco.gradle.automodule.filetree.FileTreeScope 4 | 5 | internal fun FileTreeScope.kotlinModule(name: String, vararg dependencies: String) { 6 | name { 7 | "build.gradle.kts" += """ 8 | plugins { kotlin("jvm") } 9 | 10 | ${writeDependencies(dependencies)} 11 | """ 12 | } 13 | } 14 | 15 | private fun writeDependencies(paths: Array): String = when { 16 | paths.isEmpty() -> "" 17 | else -> """ 18 | dependencies { 19 | ${paths.joinToString("\n") { "implementation(project(automodule.$it))" }} 20 | } 21 | """.trimIndent() 22 | } 23 | 24 | internal const val defaultSettingsGradleScript = """ 25 | plugins { 26 | id("com.pablisco.gradle.automodule") 27 | } 28 | """ -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | # User-specific stuff 2 | **/.idea/**/workspace.xml 3 | **/.idea/**/tasks.xml 4 | **/.idea/**/usage.statistics.xml 5 | **/.idea/**/dictionaries 6 | **/.idea/**/shelf 7 | **/.idea/**/runConfigurations.xml 8 | 9 | # Generated files 10 | **/.idea/**/contentModel.xml 11 | 12 | # Gradle 13 | **/.idea/**/gradle.xml 14 | **/.idea/**/libraries 15 | .gradle 16 | **/build 17 | **/out 18 | 19 | # Not required with Gradle auto import 20 | **/.idea/artifacts 21 | **/.idea/compiler.xml 22 | **/.idea/jarRepositories.xml 23 | **/.idea/modules.xml 24 | **/.idea/modules 25 | **/.idea/misc.xml 26 | **/.idea/vcs.xml 27 | **/.idea/.name 28 | *.iml 29 | *.ipr 30 | 31 | # Android Studio 32 | /local.properties 33 | /captures 34 | .idea/caches/build_file_checksums.ser 35 | 36 | # Mac OS 37 | .DS_Store 38 | /buildSrc/src/main/kotlin/modules.kt 39 | /projectFilesBackup/.idea/workspace.xml 40 | -------------------------------------------------------------------------------- /repo/com/pablisco/gradle/automodule/com.pablisco.gradle.automodule.gradle.plugin/0.12/com.pablisco.gradle.automodule.gradle.plugin-0.12.pom: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4.0.0 4 | com.pablisco.gradle.automodule 5 | com.pablisco.gradle.automodule.gradle.plugin 6 | 0.12 7 | pom 8 | Auto Module 9 | A Gradle plugin to generate the module graph and include the modules 10 | 11 | 12 | com.pablisco.gradle.automodule 13 | plugin 14 | 0.12 15 | 16 | 17 | 18 | -------------------------------------------------------------------------------- /repo/com/pablisco/gradle/automodule/com.pablisco.gradle.automodule.gradle.plugin/0.13/com.pablisco.gradle.automodule.gradle.plugin-0.13.pom: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4.0.0 4 | com.pablisco.gradle.automodule 5 | com.pablisco.gradle.automodule.gradle.plugin 6 | 0.13 7 | pom 8 | Auto Module 9 | A Gradle plugin to generate the module graph and include the modules 10 | 11 | 12 | com.pablisco.gradle.automodule 13 | plugin 14 | 0.13 15 | 16 | 17 | 18 | -------------------------------------------------------------------------------- /repo/com/pablisco/gradle/automodule/com.pablisco.gradle.automodule.gradle.plugin/0.14/com.pablisco.gradle.automodule.gradle.plugin-0.14.pom: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4.0.0 4 | com.pablisco.gradle.automodule 5 | com.pablisco.gradle.automodule.gradle.plugin 6 | 0.14 7 | pom 8 | Auto Module 9 | A Gradle plugin to generate the module graph and include the modules 10 | 11 | 12 | com.pablisco.gradle.automodule 13 | plugin 14 | 0.14 15 | 16 | 17 | 18 | -------------------------------------------------------------------------------- /repo/com/pablisco/gradle/automodule/com.pablisco.gradle.automodule.gradle.plugin/0.15/com.pablisco.gradle.automodule.gradle.plugin-0.15.pom: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4.0.0 4 | com.pablisco.gradle.automodule 5 | com.pablisco.gradle.automodule.gradle.plugin 6 | 0.15 7 | pom 8 | Auto Module 9 | A Gradle plugin to generate the module graph and include the modules 10 | 11 | 12 | com.pablisco.gradle.automodule 13 | plugin 14 | 0.15 15 | 16 | 17 | 18 | -------------------------------------------------------------------------------- /plugin/src/test/kotlin/com/pablisco/gradle/automodule/gradle/_GradleRunner.kt: -------------------------------------------------------------------------------- 1 | package com.pablisco.gradle.automodule.gradle 2 | 3 | import org.amshove.kluent.shouldBeEqualTo 4 | import org.gradle.testkit.runner.BuildResult 5 | import org.gradle.testkit.runner.GradleRunner 6 | import org.gradle.testkit.runner.TaskOutcome 7 | import java.nio.file.Path 8 | 9 | internal fun Path.runGradleProjects(): BuildResult = 10 | runGradle { 11 | withArguments("projects", "--stacktrace") 12 | } 13 | 14 | internal fun Path.runGradle(extras: GradleRunner.() -> GradleRunner = { this }): BuildResult = 15 | kotlin.runCatching { 16 | GradleRunner.create() 17 | .withProjectDir(toFile()) 18 | .withPluginClasspath() 19 | .forwardOutput() 20 | .withDebug(true) 21 | .run(extras) 22 | .build() 23 | }.getOrThrow() 24 | 25 | internal fun BuildResult.shouldBeSuccess() = 26 | task(":projects")?.outcome shouldBeEqualTo TaskOutcome.SUCCESS -------------------------------------------------------------------------------- /license.md: -------------------------------------------------------------------------------- 1 | MIT License 2 | 3 | Copyright (c) [2020] pablisco 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. 22 | -------------------------------------------------------------------------------- /gradle/dependencies/src/main/kotlin/dependencies.kt: -------------------------------------------------------------------------------- 1 | 2 | val libs = Libs 3 | val tests = Tests 4 | 5 | object Libs { 6 | val kotlin = Kotlin 7 | val square = Square 8 | const val kotlinPoet = "com.squareup:kotlinpoet" 9 | 10 | object Square { 11 | const val retrofit = "com.squareup.retrofit2:retrofit" 12 | const val retrofitXml = "com.squareup.retrofit2:converter-jaxb" 13 | } 14 | 15 | object Kotlin { 16 | val jdk8 = kotlin("stdlib-jdk8") 17 | val io = kotlin("util-io") 18 | val x = X 19 | object X { 20 | val coroutines = kotlinx("coroutines-core") 21 | } 22 | } 23 | } 24 | 25 | object Tests { 26 | val junit5 = Junit5 27 | const val kluent = "org.amshove.kluent:kluent" 28 | 29 | object Junit5 { 30 | const val jupiter = "org.junit.jupiter:junit-jupiter" 31 | const val jupiterApi = "org.junit.jupiter:junit-jupiter-api" 32 | const val jupiterParams = "org.junit.jupiter:junit-jupiter-params" 33 | } 34 | 35 | } 36 | 37 | private fun kotlin(module: String) = "org.jetbrains.kotlin:kotlin-$module" 38 | private fun kotlinx(module: String) = "org.jetbrains.kotlinx:kotlinx-$module" 39 | -------------------------------------------------------------------------------- /gradle.properties: -------------------------------------------------------------------------------- 1 | # Project-wide Gradle settings. 2 | # IDE (e.g. Android Studio) users: 3 | # Gradle settings configured through the IDE *will override* 4 | # any settings specified in this file. 5 | # For more details on how to configure your build environment visit 6 | # http://www.gradle.org/docs/current/userguide/build_environment.html 7 | # Specifies the JVM arguments used for the daemon process. 8 | # The setting is particularly useful for tweaking memory settings. 9 | org.gradle.jvmargs=-Xmx1536m 10 | # When configured, Gradle will run in incubating parallel mode. 11 | # This option should only be used with decoupled projects. More details, visit 12 | # http://www.gradle.org/docs/current/userguide/multi_project_builds.html#sec:decoupled_projects 13 | # org.gradle.parallel=true 14 | # AndroidX package structure to make it clearer which packages are bundled with the 15 | # Android operating system, and which are packaged with your app's APK 16 | # https://developer.android.com/topic/libraries/support-library/androidx-rn 17 | android.useAndroidX=true 18 | # Automatically convert third-party libraries to use AndroidX 19 | android.enableJetifier=true 20 | # Kotlin code style for this project: "official" or "obsolete": 21 | kotlin.code.style=official 22 | -------------------------------------------------------------------------------- /.idea/codeStyles/Project.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 11 | 20 | 22 | 23 | 25 | 26 | 28 | 29 | -------------------------------------------------------------------------------- /plugin/src/main/kotlin/com/pablisco/gradle/automodule/SettingsScope.kt: -------------------------------------------------------------------------------- 1 | package com.pablisco.gradle.automodule 2 | 3 | import com.pablisco.gradle.automodule.utils.toGradlePath 4 | import org.gradle.api.initialization.Settings 5 | import java.nio.file.Path 6 | 7 | internal class SettingsScope( 8 | val autoModule: AutoModule, 9 | settings: Settings 10 | ) : Settings by settings { 11 | 12 | private val workingDirectory = rootDir.toPath().resolve(".gradle/automodule") 13 | internal val graphModuleName = "${settings.rootProject.name}-modules" 14 | internal val generatedGraphModule = workingDirectory.resolve(graphModuleName) 15 | internal val generatedGraphSource = generatedGraphModule.resolve("src/main/kotlin/") 16 | internal val directoriesHashFile = workingDirectory.resolve("directories") 17 | internal val generatedMd5File = workingDirectory.resolve("generated") 18 | internal val versionFile = workingDirectory.resolve("version") 19 | internal val modulesFileName = "modules" 20 | 21 | val rootModule: ModuleNode by lazy { 22 | rootDir.toPath().rootModule( 23 | ignored = autoModule.ignored, 24 | name = rootProject.name 25 | ) 26 | } 27 | 28 | val scriptsHash: Int 29 | get() = rootDir.toPath().scriptsHash(autoModule.ignored) 30 | 31 | } 32 | 33 | private fun Path.scriptsHash(ignored: List) = 34 | findScripts() 35 | .map { relativize(parent).toGradlePath() } 36 | .filterNot { it in ignored } 37 | .hashCode() -------------------------------------------------------------------------------- /repo/com/pablisco/gradle/automodule/core/0.12/core-0.12.pom: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 4.0.0 9 | com.pablisco.gradle.automodule 10 | core 11 | 0.12 12 | 13 | 14 | org.jetbrains.kotlin 15 | kotlin-stdlib-jdk8 16 | 1.3.72 17 | runtime 18 | 19 | 20 | org.jetbrains.kotlin 21 | kotlin-util-io 22 | 1.3.72 23 | runtime 24 | 25 | 26 | com.squareup 27 | kotlinpoet 28 | 1.5.0 29 | runtime 30 | 31 | 32 | 33 | -------------------------------------------------------------------------------- /repo/com/pablisco/gradle/automodule/plugin/0.14/plugin-0.14.pom: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 4.0.0 9 | com.pablisco.gradle.automodule 10 | plugin 11 | 0.14 12 | 13 | 14 | org.jetbrains.kotlin 15 | kotlin-stdlib-jdk8 16 | 1.4.0 17 | runtime 18 | 19 | 20 | org.jetbrains.kotlin 21 | kotlin-util-io 22 | 1.4.0 23 | runtime 24 | 25 | 26 | com.squareup 27 | kotlinpoet 28 | 1.6.0 29 | runtime 30 | 31 | 32 | 33 | -------------------------------------------------------------------------------- /repo/com/pablisco/gradle/automodule/plugin/0.15/plugin-0.15.pom: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 4.0.0 9 | com.pablisco.gradle.automodule 10 | plugin 11 | 0.15 12 | 13 | 14 | org.jetbrains.kotlin 15 | kotlin-stdlib-jdk8 16 | 1.4.0 17 | runtime 18 | 19 | 20 | org.jetbrains.kotlin 21 | kotlin-util-io 22 | 1.4.0 23 | runtime 24 | 25 | 26 | com.squareup 27 | kotlinpoet 28 | 1.6.0 29 | runtime 30 | 31 | 32 | 33 | -------------------------------------------------------------------------------- /repo/com/pablisco/gradle/automodule/plugin/0.12/plugin-0.12.pom: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 4.0.0 9 | com.pablisco.gradle.automodule 10 | plugin 11 | 0.12 12 | 13 | 14 | org.jetbrains.kotlin 15 | kotlin-stdlib-jdk8 16 | 1.3.72 17 | runtime 18 | 19 | 20 | org.jetbrains.kotlin 21 | kotlin-util-io 22 | 1.3.72 23 | runtime 24 | 25 | 26 | com.squareup 27 | kotlinpoet 28 | 1.5.0 29 | runtime 30 | 31 | 32 | 33 | -------------------------------------------------------------------------------- /repo/com/pablisco/gradle/automodule/plugin/0.13/plugin-0.13.pom: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 4.0.0 9 | com.pablisco.gradle.automodule 10 | plugin 11 | 0.13 12 | 13 | 14 | org.jetbrains.kotlin 15 | kotlin-stdlib-jdk8 16 | 1.3.72 17 | runtime 18 | 19 | 20 | org.jetbrains.kotlin 21 | kotlin-util-io 22 | 1.3.72 23 | runtime 24 | 25 | 26 | com.squareup 27 | kotlinpoet 28 | 1.5.0 29 | runtime 30 | 31 | 32 | 33 | -------------------------------------------------------------------------------- /plugin/src/main/kotlin/com/pablisco/gradle/automodule/AutoModule.kt: -------------------------------------------------------------------------------- 1 | package com.pablisco.gradle.automodule 2 | 3 | import com.pablisco.gradle.automodule.filetree.FileTreeScope 4 | import java.io.File 5 | import java.nio.file.Path 6 | 7 | data class AutoModule internal constructor( 8 | var buildModulesRoot: String = "gradle", 9 | var versions: String = "versions.properties", 10 | internal val ignored: MutableList = mutableListOf(), 11 | internal var pluginRepositoryPath: String? = null, 12 | internal val templates: MutableList = mutableListOf() 13 | ) { 14 | 15 | /** 16 | * Used, in development, to add a repository to the generated code to look for itself. 17 | */ 18 | @Suppress("unused") // Api 19 | fun pluginRepository(repositoryPath: Path) { 20 | pluginRepositoryPath = repositoryPath.toUri().toString() 21 | } 22 | 23 | @Suppress("unused") // Api 24 | fun pluginRepository(repositoryFile: File) { 25 | pluginRepository(repositoryFile.toPath()) 26 | } 27 | 28 | /** 29 | * Adds the **absolute** path to any module that we want to ignore. 30 | * 31 | * @see [ignored] 32 | */ 33 | @Suppress("unused") // Api 34 | fun ignore(vararg modules: String) { 35 | ignored += modules 36 | } 37 | 38 | /** 39 | * Add a new template to generate a task with the name `create{Name}Module` that can be used 40 | * to create new module 41 | * 42 | * @param type The type for the modules generated by this template 43 | * @param path Optional path for where to create the modules 44 | * @param files Lambda in charge of creating the files for the created module 45 | */ 46 | @Suppress("unused") // Api 47 | fun template(type: String, path: String? = null, files: FileTreeScope.() -> Unit) { 48 | templates += AutoModuleTemplate(type, path, files) 49 | } 50 | 51 | } 52 | 53 | internal data class AutoModuleTemplate( 54 | val name: String, 55 | val path: String?, 56 | val files: ApplyTemplateScope.() -> Unit 57 | ) 58 | -------------------------------------------------------------------------------- /plugin/src/main/kotlin/com/pablisco/gradle/automodule/ModuleNode.kt: -------------------------------------------------------------------------------- 1 | package com.pablisco.gradle.automodule 2 | 3 | import com.pablisco.gradle.automodule.utils.isDirectory 4 | import com.pablisco.gradle.automodule.utils.list 5 | import com.pablisco.gradle.automodule.utils.name 6 | import com.pablisco.gradle.automodule.utils.toGradlePath 7 | import com.pablisco.gradle.automodule.utils.walk 8 | import java.nio.file.Path 9 | 10 | internal data class ModuleNode( 11 | val name: String, 12 | val path: String?, 13 | val children: Sequence 14 | ) 15 | 16 | internal fun Path.rootModule( 17 | ignored: List, 18 | name: String 19 | ) = ModuleNode( 20 | name = name, 21 | path = null, 22 | children = findChildModules( 23 | ignored = ignored, 24 | scriptPaths = findScripts() 25 | ) 26 | ) 27 | 28 | internal fun Path.findScripts(isValidScript: Path.() -> Boolean = Path::isValidScript) = 29 | walk().filter { it.isValidScript() }.toList() 30 | 31 | internal fun Path.findChildModules( 32 | ignored: List, 33 | scriptPaths: List, 34 | rootPath: Path = this 35 | ): Sequence = list() 36 | .filterNot { it.name == "buildSrc" } 37 | .filterNot { it.name.startsWith(".") } 38 | .filter { it.isDirectory() } 39 | .filter { child -> scriptPaths.any { it.startsWith(child) } } 40 | .map { it to rootPath.relativize(it).toGradlePath() } 41 | .filterNot { (_, coordinates) -> coordinates in ignored } 42 | .map { (path, coordinates) -> 43 | ModuleNode( 44 | name = path.name, 45 | path = coordinates, 46 | children = path.findChildModules(ignored, scriptPaths, rootPath) 47 | ) 48 | } 49 | 50 | internal fun ModuleNode.walk(): Sequence = 51 | children + children.flatMap { sequenceOf(this) + it.walk() } 52 | 53 | private fun Path.isValidScript(): Boolean = 54 | isGroovyBuildScript() or isKotlinBuildScript() 55 | 56 | private fun Path.isGroovyBuildScript(): Boolean = 57 | toString().endsWith("build.gradle") 58 | 59 | private fun Path.isKotlinBuildScript(): Boolean = 60 | toString().endsWith("build.gradle.kts") -------------------------------------------------------------------------------- /gradle/maven-version-check/src/main/kotlin/MavenMetadataApi.kt: -------------------------------------------------------------------------------- 1 | import retrofit2.Retrofit 2 | import retrofit2.converter.jaxb.JaxbConverterFactory 3 | import retrofit2.create 4 | import retrofit2.http.GET 5 | import retrofit2.http.Path 6 | import javax.xml.bind.annotation.* 7 | 8 | class MavenMetadataApi internal constructor( 9 | repository: String, 10 | private val retrofit: Retrofit = Retrofit.Builder() 11 | .baseUrl(repository) 12 | .addConverterFactory(JaxbConverterFactory.create()) 13 | .build(), 14 | private val api: MavenApi = retrofit.create() 15 | ) : MavenApi by api { 16 | companion object { 17 | @Suppress("MemberVisibilityCanBePrivate") // Api 18 | fun withUrl(url: String): MavenMetadataApi = MavenMetadataApi(url) 19 | val gradlePlugins: MavenMetadataApi by lazy { withUrl("https://plugins.gradle.org/m2/") } 20 | } 21 | } 22 | 23 | @XmlRootElement 24 | @XmlAccessorType(XmlAccessType.FIELD) 25 | data class Metadata @JvmOverloads constructor( 26 | val groupId: String = "", 27 | val artifactId: String = "", 28 | val version: String = "", 29 | val versioning: Versioning = Versioning() 30 | ) 31 | 32 | @XmlAccessorType(XmlAccessType.FIELD) 33 | data class Versioning @JvmOverloads constructor( 34 | val latest: String = "", 35 | val release: String = "", 36 | @field:XmlElementWrapper(name = "versions") 37 | @field:XmlElement(name = "version") 38 | val versions: List = mutableListOf(), 39 | val lastUpdated: Long = 0 40 | ) 41 | 42 | interface MavenApi { 43 | 44 | @GET("{groupPath}/{artifactId}/maven-metadata.xml") 45 | suspend fun metadata( 46 | @Path("groupPath", encoded = true) groupPath: String, 47 | @Path("artifactId") artifact: Artifact 48 | ): Metadata 49 | 50 | } 51 | 52 | suspend fun MavenApi.metadata(group: Group, artifact: Artifact): Metadata = 53 | metadata(artifact = artifact, groupPath = group.id.replace(".", "/")) 54 | 55 | suspend fun MavenApi.pluginMetadata(plugin: Plugin): Metadata = 56 | metadata(artifact = Artifact("${plugin.name}.gradle.plugin"), group = Group(plugin.name)) 57 | 58 | inline class Plugin(val name: String) 59 | inline class Group(val id: String) 60 | inline class Artifact(val id: String) -------------------------------------------------------------------------------- /plugin/src/main/kotlin/com/pablisco/gradle/automodule/ModulesWriter.kt: -------------------------------------------------------------------------------- 1 | package com.pablisco.gradle.automodule 2 | 3 | import com.pablisco.gradle.automodule.utils.camelCase 4 | import com.pablisco.gradle.automodule.utils.snakeCase 5 | import com.squareup.kotlinpoet.* 6 | import com.squareup.kotlinpoet.TypeSpec.Companion.objectBuilder 7 | import java.nio.file.Path 8 | import com.squareup.kotlinpoet.FileSpec.Companion.builder as file 9 | 10 | internal fun ModuleNode.writeTo(directory: Path, fileName: String) { 11 | file("", fileName).apply { 12 | addComment("Generated by AutoModule - DO NOT EDIT - it'll be overridden") 13 | addAnnotation(AnnotationSpec.builder(Suppress::class).addMember("\"ClassName\"").build()) 14 | addType(toType(name = "autoModules")) 15 | }.build().writeTo(directory) 16 | } 17 | 18 | private fun ModuleNode.toType(name: String = nameAsType): TypeSpec = 19 | objectWith(name = name) { 20 | if(path != null) { 21 | addDependencyInterface(path) 22 | } 23 | children.forEach { child -> 24 | addType(child.toType()) 25 | addProperty(child.asPropertySpec()) 26 | } 27 | if (children.firstOrNull() != null) { 28 | addFunction(dslInvokeFun(ClassName("", name))) 29 | } 30 | } 31 | 32 | private fun dslInvokeFun(victim: ClassName): FunSpec = 33 | FunSpec.builder("invoke") 34 | .addParameter("block", LambdaTypeName.get(receiver = victim, returnType = UNIT)) 35 | .addModifiers(KModifier.OPERATOR) 36 | .addCode("apply(block)") 37 | .build() 38 | 39 | private fun ModuleNode.asPropertySpec(): PropertySpec = 40 | PropertySpec.builder(nameAsProperty, ClassName("", nameAsType)) 41 | .initializer(nameAsType) 42 | .build() 43 | 44 | private val ModuleNode.nameAsProperty : String get() = name.snakeCase() 45 | private val ModuleNode.nameAsType : String get() = name.camelCase() 46 | 47 | private fun TypeSpec.Builder.addDependencyInterface(path: String): TypeSpec.Builder = 48 | addSuperinterface( 49 | superinterface = AutoModuleDependencyClassName, 50 | delegate = CodeBlock.of("autoModuleDependency(\"$path\")") 51 | ) 52 | 53 | private fun objectWith(name: String, block: TypeSpec.Builder.() -> Unit): TypeSpec = 54 | objectBuilder(name).apply(block).build() 55 | 56 | private val AutoModuleDependencyClassName = ClassName("", "AutoModuleDependency") 57 | -------------------------------------------------------------------------------- /plugin/build.gradle.kts: -------------------------------------------------------------------------------- 1 | plugins { 2 | kotlin("jvm") 3 | idea 4 | `kotlin-dsl` 5 | `java-gradle-plugin` 6 | `maven-publish` 7 | id("com.palantir.idea-test-fix") 8 | id("com.gradle.plugin-publish") 9 | } 10 | 11 | dependencies { 12 | implementation(libs.kotlin.jdk8) 13 | implementation(libs.kotlin.io) 14 | implementation(libs.kotlinPoet) 15 | 16 | testImplementation(tests.junit5.jupiter) 17 | testImplementation(tests.junit5.jupiterApi) 18 | testImplementation(tests.junit5.jupiterParams) 19 | testImplementation(tests.kluent) 20 | testImplementation(gradleTestKit()) 21 | } 22 | 23 | tasks { 24 | test { 25 | useJUnitPlatform() 26 | } 27 | compileKotlin { 28 | kotlinOptions.jvmTarget = "1.8" 29 | } 30 | 31 | val copyTestResources by registering(Copy::class) { 32 | from("${projectDir}/src/test/resources") 33 | into("${buildDir}/classes/kotlin/test") 34 | } 35 | 36 | processTestResources.configure { 37 | dependsOn(copyTestResources) 38 | } 39 | 40 | "publishPlugins" { 41 | onlyIf { version !in AutoModuleMavenMetadata.versions } 42 | } 43 | } 44 | 45 | val sourcesJar = tasks.register("sourcesJar") { 46 | archiveClassifier.set("sources") 47 | from(sourceSets.main.map { it.allSource }) 48 | } 49 | 50 | pluginBundle { 51 | website = "https://github.com/pablisco/auto-module/" 52 | vcsUrl = "https://github.com/pablisco/auto-module/" 53 | tags = listOf("automodule") 54 | } 55 | 56 | gradlePlugin { 57 | plugins { 58 | create("auto-module-plugin") { 59 | id = "com.pablisco.gradle.automodule" 60 | displayName = "Auto Module" 61 | description = "A Gradle plugin to generate the module graph and include the modules" 62 | implementationClass = "com.pablisco.gradle.automodule.AutoModulePlugin" 63 | } 64 | } 65 | } 66 | 67 | publishing { 68 | repositories { 69 | maven(url = rootDir.resolve("repo")) 70 | } 71 | } 72 | 73 | afterEvaluate { 74 | publishing.publications.withType() 75 | .configureEach { 76 | versionMapping { 77 | allVariants { 78 | fromResolutionResult() 79 | } 80 | } 81 | } 82 | } 83 | 84 | idea { 85 | module { 86 | // hides test kts files so they are not parsed by the IDE 87 | excludeDirs = setOf(file("src/test/resources/test-cases")) 88 | } 89 | } 90 | -------------------------------------------------------------------------------- /plugin/src/main/kotlin/com/pablisco/gradle/automodule/Versions.kt: -------------------------------------------------------------------------------- 1 | @file:Suppress("FunctionName") 2 | 3 | package com.pablisco.gradle.automodule 4 | 5 | import com.pablisco.gradle.automodule.utils.castAs 6 | import org.gradle.api.artifacts.ModuleVersionSelector 7 | import java.io.File 8 | import java.net.HttpURLConnection 9 | import java.net.HttpURLConnection.HTTP_OK 10 | import java.net.URL 11 | import java.util.* 12 | 13 | private fun Properties(f: Properties.() -> Unit) = Properties().apply(f) 14 | 15 | class Versions internal constructor(private val path: String, private val properties: Properties) { 16 | 17 | internal constructor(rootDir: File, path: String) : this(path, 18 | Properties { 19 | val local = rootDir.resolve(path) 20 | val remote = runCatching { URL(path) }.getOrNull() 21 | 22 | if (local.exists()) { 23 | load(local.reader()) 24 | } else { 25 | remote?.openConnection() 26 | ?.castAs() 27 | ?.takeIf { it.responseCode == HTTP_OK } 28 | ?.also { load(it.inputStream) } 29 | } 30 | } 31 | ) 32 | 33 | private val keyValues = properties.mapNotNull { (k, v) -> 34 | if (k is String && v is String) k to v else null 35 | } 36 | 37 | fun getDependencyVersion(group: String, name: String): String = 38 | sequenceOf("${group}_${name}", name, group) 39 | .mapNotNull { properties[it] as? String }.firstOrNull() 40 | ?: error("no version present on $path for plugin: ${group}:${name}") 41 | 42 | fun getDependencyVersion(notation: String): String = 43 | notation.split(":").let { (group, name) -> getDependencyVersion(group, name) } 44 | 45 | fun getDependencyVersion(selector: ModuleVersionSelector): String = 46 | selector.run { getDependencyVersion(group, name) } 47 | 48 | fun findDependencyVersion(group: String, name: String): String? = 49 | sequenceOf("${group}_${name}", name, group) 50 | .mapNotNull { properties[it] as? String }.firstOrNull() 51 | 52 | fun findDependencyVersion(notation: String): String? = 53 | notation.split(":").let { (group, name) -> findDependencyVersion(group, name) } 54 | 55 | fun findDependencyVersion(selector: ModuleVersionSelector): String? = 56 | selector.run { findDependencyVersion(group, name) } 57 | 58 | fun findPluginVersion(id: String): String? = 59 | keyValues.firstOrNull { (k, _) -> id.startsWith(k) }?.second 60 | 61 | } 62 | -------------------------------------------------------------------------------- /plugin/src/main/kotlin/com/pablisco/gradle/automodule/utils/_Path.kt: -------------------------------------------------------------------------------- 1 | package com.pablisco.gradle.automodule.utils 2 | 3 | import java.io.InputStream 4 | import java.math.BigInteger 5 | import java.nio.file.Files 6 | import java.nio.file.OpenOption 7 | import java.nio.file.Path 8 | import java.nio.file.attribute.FileAttribute 9 | import java.security.MessageDigest 10 | import kotlin.streams.asSequence 11 | 12 | internal fun Path.walk(): Sequence = 13 | sequence { yieldAll(Files.walk(this@walk).asSequence()) } 14 | 15 | internal fun Path.list(): Sequence = when { 16 | Files.isDirectory(this) -> sequence { yieldAll(Files.list(this@list).asSequence()) } 17 | else -> emptySequence() 18 | } 19 | 20 | internal val Path.name: String 21 | get() = fileName.toString() 22 | 23 | internal fun Path.exists(): Boolean = Files.exists(this) 24 | 25 | internal fun Path.delete() = Files.delete(this) 26 | 27 | internal fun Path.isDirectory(): Boolean = Files.isDirectory(this) 28 | 29 | internal fun Path.deleteRecursively() { 30 | if (exists()) { 31 | walk().sortedDescending().forEach(Path::delete) 32 | } 33 | } 34 | 35 | internal val Path.inputStream: InputStream 36 | get() = Files.newInputStream(this) 37 | 38 | internal fun Path.readText(): String? = Files.readAllLines(this).joinToString("\n") 39 | 40 | internal fun Path.createFile(content: String): Path = 41 | apply { parent.createDirectories() }.ifExists { delete() }.createFile().write(content) 42 | 43 | internal fun Path.ifExists(block: Path.() -> Unit): Path = apply { if (exists) block() } 44 | 45 | internal val Path.exists get() = Files.exists(this) 46 | 47 | internal fun Path.write(bytes: ByteArray, vararg openOption: OpenOption): Path = 48 | Files.write(this, bytes, *openOption) 49 | internal fun Path.write(string: String, vararg openOption: OpenOption): Path = 50 | write(string.toByteArray(), *openOption) 51 | 52 | internal fun Path.createFile(): Path = Files.createFile(this) 53 | 54 | internal fun Path.createDirectories( 55 | vararg fileAttributes: FileAttribute<*> = emptyArray() 56 | ): Path = Files.createDirectories(this, *fileAttributes) 57 | 58 | internal fun Path.maybeReadText(): String? = 59 | takeIf { it.exists() }?.readText() 60 | 61 | internal fun Path.md5(): String = when { 62 | exists() -> inputStream.use { 63 | val md5 = MessageDigest.getInstance("MD5") 64 | BigInteger(md5.digest(it.readBytes())) 65 | .toString(16) 66 | 67 | } 68 | else -> "" 69 | }.padStart(32, '0') 70 | 71 | internal fun Path.toGradlePath(): String = joinToString(separator = ":", prefix = ":") { it.name } 72 | 73 | 74 | 75 | -------------------------------------------------------------------------------- /gradlew.bat: -------------------------------------------------------------------------------- 1 | @rem 2 | @rem Copyright 2015 the original author or authors. 3 | @rem 4 | @rem Licensed under the Apache License, Version 2.0 (the "License"); 5 | @rem you may not use this file except in compliance with the License. 6 | @rem You may obtain a copy of the License at 7 | @rem 8 | @rem https://www.apache.org/licenses/LICENSE-2.0 9 | @rem 10 | @rem Unless required by applicable law or agreed to in writing, software 11 | @rem distributed under the License is distributed on an "AS IS" BASIS, 12 | @rem WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | @rem See the License for the specific language governing permissions and 14 | @rem limitations under the License. 15 | @rem 16 | 17 | @if "%DEBUG%" == "" @echo off 18 | @rem ########################################################################## 19 | @rem 20 | @rem Gradle startup script for Windows 21 | @rem 22 | @rem ########################################################################## 23 | 24 | @rem Set local scope for the variables with windows NT shell 25 | if "%OS%"=="Windows_NT" setlocal 26 | 27 | set DIRNAME=%~dp0 28 | if "%DIRNAME%" == "" set DIRNAME=. 29 | set APP_BASE_NAME=%~n0 30 | set APP_HOME=%DIRNAME% 31 | 32 | @rem Resolve any "." and ".." in APP_HOME to make it shorter. 33 | for %%i in ("%APP_HOME%") do set APP_HOME=%%~fi 34 | 35 | @rem Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script. 36 | set DEFAULT_JVM_OPTS="-Xmx64m" "-Xms64m" 37 | 38 | @rem Find java.exe 39 | if defined JAVA_HOME goto findJavaFromJavaHome 40 | 41 | set JAVA_EXE=java.exe 42 | %JAVA_EXE% -version >NUL 2>&1 43 | if "%ERRORLEVEL%" == "0" goto execute 44 | 45 | echo. 46 | echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. 47 | echo. 48 | echo Please set the JAVA_HOME variable in your environment to match the 49 | echo location of your Java installation. 50 | 51 | goto fail 52 | 53 | :findJavaFromJavaHome 54 | set JAVA_HOME=%JAVA_HOME:"=% 55 | set JAVA_EXE=%JAVA_HOME%/bin/java.exe 56 | 57 | if exist "%JAVA_EXE%" goto execute 58 | 59 | echo. 60 | echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME% 61 | echo. 62 | echo Please set the JAVA_HOME variable in your environment to match the 63 | echo location of your Java installation. 64 | 65 | goto fail 66 | 67 | :execute 68 | @rem Setup the command line 69 | 70 | set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar 71 | 72 | 73 | @rem Execute Gradle 74 | "%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %* 75 | 76 | :end 77 | @rem End local scope for the variables with windows NT shell 78 | if "%ERRORLEVEL%"=="0" goto mainEnd 79 | 80 | :fail 81 | rem Set variable GRADLE_EXIT_CONSOLE if you need the _script_ return code instead of 82 | rem the _cmd.exe /c_ return code! 83 | if not "" == "%GRADLE_EXIT_CONSOLE%" exit 1 84 | exit /b 1 85 | 86 | :mainEnd 87 | if "%OS%"=="Windows_NT" endlocal 88 | 89 | :omega 90 | -------------------------------------------------------------------------------- /repo/com/pablisco/gradle/automodule/core/0.12/core-0.12.module: -------------------------------------------------------------------------------- 1 | { 2 | "formatVersion": "1.1", 3 | "component": { 4 | "group": "com.pablisco.gradle.automodule", 5 | "module": "core", 6 | "version": "0.12", 7 | "attributes": { 8 | "org.gradle.status": "release" 9 | } 10 | }, 11 | "createdBy": { 12 | "gradle": { 13 | "version": "6.5", 14 | "buildId": "cfrizijbhjhira7gtgto3ezogu" 15 | } 16 | }, 17 | "variants": [ 18 | { 19 | "name": "apiElements", 20 | "attributes": { 21 | "org.gradle.category": "library", 22 | "org.gradle.dependency.bundling": "external", 23 | "org.gradle.jvm.version": 8, 24 | "org.gradle.libraryelements": "jar", 25 | "org.gradle.usage": "java-api", 26 | "org.jetbrains.kotlin.localToProject": "public", 27 | "org.jetbrains.kotlin.platform.type": "jvm" 28 | }, 29 | "files": [ 30 | { 31 | "name": "core-0.12.jar", 32 | "url": "core-0.12.jar", 33 | "size": 89247, 34 | "sha512": "6a61353cc8b9e040bcba9623247cd956ca263ba43b03f5bbb4e1e4aeb599eaa96b1c0a727f37eefb1be980182c83a1d41845b69f472def8f620d9870adadaa14", 35 | "sha256": "a098f5aa60178aaf8ce4da3f3eecc773665358f676f9fb1adf19f549802e72ae", 36 | "sha1": "bdabbc2820b817f6ac20fca4111cddbc4d0c25d2", 37 | "md5": "2eb15aa53f9d294583d7bbe8a51a1c85" 38 | } 39 | ] 40 | }, 41 | { 42 | "name": "runtimeElements", 43 | "attributes": { 44 | "org.gradle.category": "library", 45 | "org.gradle.dependency.bundling": "external", 46 | "org.gradle.jvm.version": 8, 47 | "org.gradle.libraryelements": "jar", 48 | "org.gradle.usage": "java-runtime", 49 | "org.jetbrains.kotlin.localToProject": "public", 50 | "org.jetbrains.kotlin.platform.type": "jvm" 51 | }, 52 | "dependencies": [ 53 | { 54 | "group": "org.jetbrains.kotlin", 55 | "module": "kotlin-stdlib-jdk8", 56 | "version": { 57 | "requires": "1.3.72" 58 | } 59 | }, 60 | { 61 | "group": "org.jetbrains.kotlin", 62 | "module": "kotlin-util-io", 63 | "version": { 64 | "requires": "1.3.72" 65 | } 66 | }, 67 | { 68 | "group": "com.squareup", 69 | "module": "kotlinpoet", 70 | "version": { 71 | "requires": "1.5.0" 72 | } 73 | } 74 | ], 75 | "files": [ 76 | { 77 | "name": "core-0.12.jar", 78 | "url": "core-0.12.jar", 79 | "size": 89247, 80 | "sha512": "6a61353cc8b9e040bcba9623247cd956ca263ba43b03f5bbb4e1e4aeb599eaa96b1c0a727f37eefb1be980182c83a1d41845b69f472def8f620d9870adadaa14", 81 | "sha256": "a098f5aa60178aaf8ce4da3f3eecc773665358f676f9fb1adf19f549802e72ae", 82 | "sha1": "bdabbc2820b817f6ac20fca4111cddbc4d0c25d2", 83 | "md5": "2eb15aa53f9d294583d7bbe8a51a1c85" 84 | } 85 | ] 86 | } 87 | ] 88 | } 89 | -------------------------------------------------------------------------------- /repo/com/pablisco/gradle/automodule/plugin/0.14/plugin-0.14.module: -------------------------------------------------------------------------------- 1 | { 2 | "formatVersion": "1.1", 3 | "component": { 4 | "group": "com.pablisco.gradle.automodule", 5 | "module": "plugin", 6 | "version": "0.14", 7 | "attributes": { 8 | "org.gradle.status": "release" 9 | } 10 | }, 11 | "createdBy": { 12 | "gradle": { 13 | "version": "6.5", 14 | "buildId": "dab3avoylnbgnh3c43cvynzygm" 15 | } 16 | }, 17 | "variants": [ 18 | { 19 | "name": "apiElements", 20 | "attributes": { 21 | "org.gradle.category": "library", 22 | "org.gradle.dependency.bundling": "external", 23 | "org.gradle.jvm.version": 8, 24 | "org.gradle.libraryelements": "jar", 25 | "org.gradle.usage": "java-api", 26 | "org.jetbrains.kotlin.localToProject": "public", 27 | "org.jetbrains.kotlin.platform.type": "jvm" 28 | }, 29 | "files": [ 30 | { 31 | "name": "plugin-0.14.jar", 32 | "url": "plugin-0.14.jar", 33 | "size": 95318, 34 | "sha512": "b79dc4a23b09184696ada3c7d8296356f822f6d95d3bec7e6826d29d2de8930700544732d9645f2f952ff8aac4a2d293d29b995d26325a5e94ec312a656bf112", 35 | "sha256": "ea7de1783a2064f55b3102c829839c683bd01c6547d82683a81b057269b8c174", 36 | "sha1": "f0b892383a7315d618ca89dfe806d532bfa8894f", 37 | "md5": "21fe689996a3f117156ffb75eced9027" 38 | } 39 | ] 40 | }, 41 | { 42 | "name": "runtimeElements", 43 | "attributes": { 44 | "org.gradle.category": "library", 45 | "org.gradle.dependency.bundling": "external", 46 | "org.gradle.jvm.version": 8, 47 | "org.gradle.libraryelements": "jar", 48 | "org.gradle.usage": "java-runtime", 49 | "org.jetbrains.kotlin.localToProject": "public", 50 | "org.jetbrains.kotlin.platform.type": "jvm" 51 | }, 52 | "dependencies": [ 53 | { 54 | "group": "org.jetbrains.kotlin", 55 | "module": "kotlin-stdlib-jdk8", 56 | "version": { 57 | "requires": "1.4.0" 58 | } 59 | }, 60 | { 61 | "group": "org.jetbrains.kotlin", 62 | "module": "kotlin-util-io", 63 | "version": { 64 | "requires": "1.4.0" 65 | } 66 | }, 67 | { 68 | "group": "com.squareup", 69 | "module": "kotlinpoet", 70 | "version": { 71 | "requires": "1.6.0" 72 | } 73 | } 74 | ], 75 | "files": [ 76 | { 77 | "name": "plugin-0.14.jar", 78 | "url": "plugin-0.14.jar", 79 | "size": 95318, 80 | "sha512": "b79dc4a23b09184696ada3c7d8296356f822f6d95d3bec7e6826d29d2de8930700544732d9645f2f952ff8aac4a2d293d29b995d26325a5e94ec312a656bf112", 81 | "sha256": "ea7de1783a2064f55b3102c829839c683bd01c6547d82683a81b057269b8c174", 82 | "sha1": "f0b892383a7315d618ca89dfe806d532bfa8894f", 83 | "md5": "21fe689996a3f117156ffb75eced9027" 84 | } 85 | ] 86 | } 87 | ] 88 | } 89 | -------------------------------------------------------------------------------- /repo/com/pablisco/gradle/automodule/plugin/0.12/plugin-0.12.module: -------------------------------------------------------------------------------- 1 | { 2 | "formatVersion": "1.1", 3 | "component": { 4 | "group": "com.pablisco.gradle.automodule", 5 | "module": "plugin", 6 | "version": "0.12", 7 | "attributes": { 8 | "org.gradle.status": "release" 9 | } 10 | }, 11 | "createdBy": { 12 | "gradle": { 13 | "version": "6.5", 14 | "buildId": "aszibp6xljdipc7vrflsulctzi" 15 | } 16 | }, 17 | "variants": [ 18 | { 19 | "name": "apiElements", 20 | "attributes": { 21 | "org.gradle.category": "library", 22 | "org.gradle.dependency.bundling": "external", 23 | "org.gradle.jvm.version": 8, 24 | "org.gradle.libraryelements": "jar", 25 | "org.gradle.usage": "java-api", 26 | "org.jetbrains.kotlin.localToProject": "public", 27 | "org.jetbrains.kotlin.platform.type": "jvm" 28 | }, 29 | "files": [ 30 | { 31 | "name": "plugin-0.12.jar", 32 | "url": "plugin-0.12.jar", 33 | "size": 93702, 34 | "sha512": "34252321cb5bfb6bf5bbfa5a6a8e7fb8f22c70dbb054a398812383b8427fec3429bb0d846d3283b5281f6954f887a716911bfad975a3ebbe21f06a08a870bb21", 35 | "sha256": "0fb22c348e07b787924c06107ff29fad1c4be7db0ec55b1cf79d063c65cae1a6", 36 | "sha1": "6cd3a5c1a2091b218fdc3e0194f219c956ff66a4", 37 | "md5": "01befb0c97d584f07665bb005c7c11f4" 38 | } 39 | ] 40 | }, 41 | { 42 | "name": "runtimeElements", 43 | "attributes": { 44 | "org.gradle.category": "library", 45 | "org.gradle.dependency.bundling": "external", 46 | "org.gradle.jvm.version": 8, 47 | "org.gradle.libraryelements": "jar", 48 | "org.gradle.usage": "java-runtime", 49 | "org.jetbrains.kotlin.localToProject": "public", 50 | "org.jetbrains.kotlin.platform.type": "jvm" 51 | }, 52 | "dependencies": [ 53 | { 54 | "group": "org.jetbrains.kotlin", 55 | "module": "kotlin-stdlib-jdk8", 56 | "version": { 57 | "requires": "1.3.72" 58 | } 59 | }, 60 | { 61 | "group": "org.jetbrains.kotlin", 62 | "module": "kotlin-util-io", 63 | "version": { 64 | "requires": "1.3.72" 65 | } 66 | }, 67 | { 68 | "group": "com.squareup", 69 | "module": "kotlinpoet", 70 | "version": { 71 | "requires": "1.5.0" 72 | } 73 | } 74 | ], 75 | "files": [ 76 | { 77 | "name": "plugin-0.12.jar", 78 | "url": "plugin-0.12.jar", 79 | "size": 93702, 80 | "sha512": "34252321cb5bfb6bf5bbfa5a6a8e7fb8f22c70dbb054a398812383b8427fec3429bb0d846d3283b5281f6954f887a716911bfad975a3ebbe21f06a08a870bb21", 81 | "sha256": "0fb22c348e07b787924c06107ff29fad1c4be7db0ec55b1cf79d063c65cae1a6", 82 | "sha1": "6cd3a5c1a2091b218fdc3e0194f219c956ff66a4", 83 | "md5": "01befb0c97d584f07665bb005c7c11f4" 84 | } 85 | ] 86 | } 87 | ] 88 | } 89 | -------------------------------------------------------------------------------- /repo/com/pablisco/gradle/automodule/plugin/0.13/plugin-0.13.module: -------------------------------------------------------------------------------- 1 | { 2 | "formatVersion": "1.1", 3 | "component": { 4 | "group": "com.pablisco.gradle.automodule", 5 | "module": "plugin", 6 | "version": "0.13", 7 | "attributes": { 8 | "org.gradle.status": "release" 9 | } 10 | }, 11 | "createdBy": { 12 | "gradle": { 13 | "version": "6.5", 14 | "buildId": "3tkvixilljhvdjo35cpatn25ai" 15 | } 16 | }, 17 | "variants": [ 18 | { 19 | "name": "apiElements", 20 | "attributes": { 21 | "org.gradle.category": "library", 22 | "org.gradle.dependency.bundling": "external", 23 | "org.gradle.jvm.version": 8, 24 | "org.gradle.libraryelements": "jar", 25 | "org.gradle.usage": "java-api", 26 | "org.jetbrains.kotlin.localToProject": "public", 27 | "org.jetbrains.kotlin.platform.type": "jvm" 28 | }, 29 | "files": [ 30 | { 31 | "name": "plugin-0.13.jar", 32 | "url": "plugin-0.13.jar", 33 | "size": 95424, 34 | "sha512": "9a6e11bd14f20f609e2c4fddc3445f3a86389407f8792898ae0c47d17df56062fc4eac04dd70fce1c6da55c0a6c0908e1a22ffe4151c31b456d763bcf0e97835", 35 | "sha256": "74bf5c77bbe935d34955a62af4ed000c23e09d922e7e7a2cfebf49b2314851b5", 36 | "sha1": "a1120b781bbde6eb22f0976a8aa45b8c5b8dfd75", 37 | "md5": "54c5a08871e7b127c118c26c6075fc51" 38 | } 39 | ] 40 | }, 41 | { 42 | "name": "runtimeElements", 43 | "attributes": { 44 | "org.gradle.category": "library", 45 | "org.gradle.dependency.bundling": "external", 46 | "org.gradle.jvm.version": 8, 47 | "org.gradle.libraryelements": "jar", 48 | "org.gradle.usage": "java-runtime", 49 | "org.jetbrains.kotlin.localToProject": "public", 50 | "org.jetbrains.kotlin.platform.type": "jvm" 51 | }, 52 | "dependencies": [ 53 | { 54 | "group": "org.jetbrains.kotlin", 55 | "module": "kotlin-stdlib-jdk8", 56 | "version": { 57 | "requires": "1.3.72" 58 | } 59 | }, 60 | { 61 | "group": "org.jetbrains.kotlin", 62 | "module": "kotlin-util-io", 63 | "version": { 64 | "requires": "1.3.72" 65 | } 66 | }, 67 | { 68 | "group": "com.squareup", 69 | "module": "kotlinpoet", 70 | "version": { 71 | "requires": "1.5.0" 72 | } 73 | } 74 | ], 75 | "files": [ 76 | { 77 | "name": "plugin-0.13.jar", 78 | "url": "plugin-0.13.jar", 79 | "size": 95424, 80 | "sha512": "9a6e11bd14f20f609e2c4fddc3445f3a86389407f8792898ae0c47d17df56062fc4eac04dd70fce1c6da55c0a6c0908e1a22ffe4151c31b456d763bcf0e97835", 81 | "sha256": "74bf5c77bbe935d34955a62af4ed000c23e09d922e7e7a2cfebf49b2314851b5", 82 | "sha1": "a1120b781bbde6eb22f0976a8aa45b8c5b8dfd75", 83 | "md5": "54c5a08871e7b127c118c26c6075fc51" 84 | } 85 | ] 86 | } 87 | ] 88 | } 89 | -------------------------------------------------------------------------------- /repo/com/pablisco/gradle/automodule/plugin/0.15/plugin-0.15.module: -------------------------------------------------------------------------------- 1 | { 2 | "formatVersion": "1.1", 3 | "component": { 4 | "group": "com.pablisco.gradle.automodule", 5 | "module": "plugin", 6 | "version": "0.15", 7 | "attributes": { 8 | "org.gradle.status": "release" 9 | } 10 | }, 11 | "createdBy": { 12 | "gradle": { 13 | "version": "6.6.1", 14 | "buildId": "q23zt62w3nelxa7wpaswnhosnm" 15 | } 16 | }, 17 | "variants": [ 18 | { 19 | "name": "apiElements", 20 | "attributes": { 21 | "org.gradle.category": "library", 22 | "org.gradle.dependency.bundling": "external", 23 | "org.gradle.jvm.version": 8, 24 | "org.gradle.libraryelements": "jar", 25 | "org.gradle.usage": "java-api", 26 | "org.jetbrains.kotlin.localToProject": "public", 27 | "org.jetbrains.kotlin.platform.type": "jvm" 28 | }, 29 | "files": [ 30 | { 31 | "name": "plugin-0.15.jar", 32 | "url": "plugin-0.15.jar", 33 | "size": 136271, 34 | "sha512": "af9e87297acee21ead635a1d5f7f2cf6fd38a936e6f35f78376c6c89c86bc8e9f30ffd702522a3a7df87c72a945b33c6c2c3a4e33c3a307051cd3594b5836045", 35 | "sha256": "545bdbd9c5ce22e2d0bac0e6ba03cad8e0dfc6eb165d3a9646f1cbc78e6d1270", 36 | "sha1": "5f778159293ec3d7189ee71b57fcacba44b8fb6c", 37 | "md5": "850a3c198302ac7747ee1d9ddd3a5280" 38 | } 39 | ] 40 | }, 41 | { 42 | "name": "runtimeElements", 43 | "attributes": { 44 | "org.gradle.category": "library", 45 | "org.gradle.dependency.bundling": "external", 46 | "org.gradle.jvm.version": 8, 47 | "org.gradle.libraryelements": "jar", 48 | "org.gradle.usage": "java-runtime", 49 | "org.jetbrains.kotlin.localToProject": "public", 50 | "org.jetbrains.kotlin.platform.type": "jvm" 51 | }, 52 | "dependencies": [ 53 | { 54 | "group": "org.jetbrains.kotlin", 55 | "module": "kotlin-stdlib-jdk8", 56 | "version": { 57 | "requires": "1.4.0" 58 | } 59 | }, 60 | { 61 | "group": "org.jetbrains.kotlin", 62 | "module": "kotlin-util-io", 63 | "version": { 64 | "requires": "1.4.0" 65 | } 66 | }, 67 | { 68 | "group": "com.squareup", 69 | "module": "kotlinpoet", 70 | "version": { 71 | "requires": "1.6.0" 72 | } 73 | } 74 | ], 75 | "files": [ 76 | { 77 | "name": "plugin-0.15.jar", 78 | "url": "plugin-0.15.jar", 79 | "size": 136271, 80 | "sha512": "af9e87297acee21ead635a1d5f7f2cf6fd38a936e6f35f78376c6c89c86bc8e9f30ffd702522a3a7df87c72a945b33c6c2c3a4e33c3a307051cd3594b5836045", 81 | "sha256": "545bdbd9c5ce22e2d0bac0e6ba03cad8e0dfc6eb165d3a9646f1cbc78e6d1270", 82 | "sha1": "5f778159293ec3d7189ee71b57fcacba44b8fb6c", 83 | "md5": "850a3c198302ac7747ee1d9ddd3a5280" 84 | } 85 | ] 86 | } 87 | ] 88 | } 89 | -------------------------------------------------------------------------------- /plugin/src/main/kotlin/com/pablisco/gradle/automodule/CreateModuleTask.kt: -------------------------------------------------------------------------------- 1 | package com.pablisco.gradle.automodule 2 | 3 | import com.pablisco.gradle.automodule.filetree.FileTreeScope 4 | import com.pablisco.gradle.automodule.filetree.fileTree 5 | import org.gradle.api.DefaultTask 6 | import org.gradle.api.tasks.TaskAction 7 | import org.gradle.api.tasks.options.Option 8 | import java.nio.file.Path 9 | import java.nio.file.Paths 10 | import javax.inject.Inject 11 | 12 | internal open class CreateModuleTask @Inject constructor( 13 | private val template: AutoModuleTemplate 14 | ) : DefaultTask() { 15 | 16 | private val projectPath = project.rootDir.toPath() 17 | private val defaultPath: Path = template.path.asPath { Paths.get("") } 18 | 19 | private var templateDirectory: String? = null 20 | private var workingDirectory: String? = null 21 | 22 | @Option(option = "templateDirectory", description = "Name of the new module") 23 | fun templateDirectory(templateDirectory: String) { 24 | this.templateDirectory = templateDirectory 25 | } 26 | 27 | @Option(option = "workingDirectory", description = "Path of the new module. Root by default.") 28 | fun workingDirectory(workingDirectory: String) { 29 | this.workingDirectory = workingDirectory 30 | } 31 | 32 | @TaskAction 33 | fun createModule() { 34 | val templateDirectory = checkNotNull(templateDirectory) { 35 | """ 36 | Must provide the name of the module as a command line parameter: 37 | ./gradlew $name --templateDirectory={moduleName} 38 | """.trimIndent() 39 | } 40 | 41 | val workingDirectory = workingDirectory.asPath { defaultPath } 42 | workingDirectory 43 | .let { projectPath.resolve(it) } 44 | .fileTree { 45 | templateDirectory { 46 | template.files( 47 | ApplyTemplateScope( 48 | fileTreeScope = this, 49 | templateDirectory = templateDirectory, 50 | workingDirectory = workingDirectory, 51 | properties = project.properties.entries 52 | .mapNotNull { (k, v) -> 53 | (v as? String)?.let { k to it } 54 | }.toMap() 55 | ) 56 | ) 57 | } 58 | } 59 | } 60 | 61 | } 62 | 63 | @Suppress("unused") // API 64 | class ApplyTemplateScope( 65 | fileTreeScope: FileTreeScope, 66 | val templateDirectory: String, 67 | val workingDirectory: Path, 68 | val properties: Map 69 | ) : FileTreeScope by fileTreeScope 70 | 71 | @Suppress("unused") // API 72 | fun ApplyTemplateScope.require(name: String): String = 73 | optional(name) ?: error( 74 | """ 75 | Expected a value for '$name'. 76 | You need to add a command line option like: -P$name={value} 77 | """.trimIndent() 78 | ) 79 | 80 | fun ApplyTemplateScope.optional(name: String): String? = 81 | properties[name] 82 | 83 | private fun String?.asPath(default: () -> Path): Path = 84 | this?.let { Paths.get(it) } ?: default() -------------------------------------------------------------------------------- /demos/simple_module/gradlew.bat: -------------------------------------------------------------------------------- 1 | @rem 2 | @rem Copyright 2015 the original author or authors. 3 | @rem 4 | @rem Licensed under the Apache License, Version 2.0 (the "License"); 5 | @rem you may not use this file except in compliance with the License. 6 | @rem You may obtain a copy of the License at 7 | @rem 8 | @rem https://www.apache.org/licenses/LICENSE-2.0 9 | @rem 10 | @rem Unless required by applicable law or agreed to in writing, software 11 | @rem distributed under the License is distributed on an "AS IS" BASIS, 12 | @rem WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | @rem See the License for the specific language governing permissions and 14 | @rem limitations under the License. 15 | @rem 16 | 17 | @if "%DEBUG%" == "" @echo off 18 | @rem ########################################################################## 19 | @rem 20 | @rem Gradle startup script for Windows 21 | @rem 22 | @rem ########################################################################## 23 | 24 | @rem Set local scope for the variables with windows NT shell 25 | if "%OS%"=="Windows_NT" setlocal 26 | 27 | set DIRNAME=%~dp0 28 | if "%DIRNAME%" == "" set DIRNAME=. 29 | set APP_BASE_NAME=%~n0 30 | set APP_HOME=%DIRNAME% 31 | 32 | @rem Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script. 33 | set DEFAULT_JVM_OPTS="-Xmx64m" "-Xms64m" 34 | 35 | @rem Find java.exe 36 | if defined JAVA_HOME goto findJavaFromJavaHome 37 | 38 | set JAVA_EXE=java.exe 39 | %JAVA_EXE% -version >NUL 2>&1 40 | if "%ERRORLEVEL%" == "0" goto init 41 | 42 | echo. 43 | echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. 44 | echo. 45 | echo Please set the JAVA_HOME variable in your environment to match the 46 | echo location of your Java installation. 47 | 48 | goto fail 49 | 50 | :findJavaFromJavaHome 51 | set JAVA_HOME=%JAVA_HOME:"=% 52 | set JAVA_EXE=%JAVA_HOME%/bin/java.exe 53 | 54 | if exist "%JAVA_EXE%" goto init 55 | 56 | echo. 57 | echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME% 58 | echo. 59 | echo Please set the JAVA_HOME variable in your environment to match the 60 | echo location of your Java installation. 61 | 62 | goto fail 63 | 64 | :init 65 | @rem Get command-line arguments, handling Windows variants 66 | 67 | if not "%OS%" == "Windows_NT" goto win9xME_args 68 | 69 | :win9xME_args 70 | @rem Slurp the command line arguments. 71 | set CMD_LINE_ARGS= 72 | set _SKIP=2 73 | 74 | :win9xME_args_slurp 75 | if "x%~1" == "x" goto execute 76 | 77 | set CMD_LINE_ARGS=%* 78 | 79 | :execute 80 | @rem Setup the command line 81 | 82 | set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar 83 | 84 | @rem Execute Gradle 85 | "%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %CMD_LINE_ARGS% 86 | 87 | :end 88 | @rem End local scope for the variables with windows NT shell 89 | if "%ERRORLEVEL%"=="0" goto mainEnd 90 | 91 | :fail 92 | rem Set variable GRADLE_EXIT_CONSOLE if you need the _script_ return code instead of 93 | rem the _cmd.exe /c_ return code! 94 | if not "" == "%GRADLE_EXIT_CONSOLE%" exit 1 95 | exit /b 1 96 | 97 | :mainEnd 98 | if "%OS%"=="Windows_NT" endlocal 99 | 100 | :omega 101 | -------------------------------------------------------------------------------- /plugin/src/main/kotlin/com/pablisco/gradle/automodule/filetree/FileTreeScope.kt: -------------------------------------------------------------------------------- 1 | package com.pablisco.gradle.automodule.filetree 2 | 3 | import com.pablisco.gradle.automodule.utils.createDirectories 4 | import java.nio.file.Files 5 | import java.nio.file.Path 6 | 7 | /** 8 | * Used to generate a tree of files and directories. 9 | * 10 | * Inside this scope we can define file structures: 11 | * 12 | * ``` 13 | * path.fileTree { 14 | * "parent" { // creates: "$path/parent/" 15 | * "child" { // creates: "$path/parent/child/" 16 | * "file.txt"() // creates: "$path/parent/child/file.txt" 17 | * "file2.txt" += "file content" // creates: "$path/parent/child/file2.txt" with content 18 | * } 19 | * } 20 | * } 21 | * ``` 22 | * 23 | * In a similar fashion the same can be done using a flat definition: 24 | * ``` 25 | * path.fileTree { 26 | * // creates: "$path/parent/child/file.txt" 27 | * "parent/child/file.txt"() 28 | * // creates: "$path/parent/child/file2.txt" with content 29 | * "parent/child/file2.txt" += "file content" 30 | * } 31 | * ``` 32 | * 33 | */ 34 | interface FileTreeScope { 35 | /** 36 | * Creates a new folder with [this] as the name of the folder. 37 | * 38 | * @param block Used to continue deeper in the tree of files. 39 | */ 40 | operator fun String.invoke(block: FileTreeScope.() -> Unit) 41 | 42 | fun folder(path: String, block: FileTreeScope.() -> Unit) 43 | /** 44 | * Creates an empty file with [this] as the path of the file (local or absolute) 45 | */ 46 | operator fun String.invoke() 47 | 48 | @Suppress("MemberVisibilityCanBePrivate") // Api 49 | fun emptyFile(path: String) 50 | 51 | /** 52 | * Creates a file with the given content and [this] as the path of the file (local or absolute) 53 | * 54 | * @param this Location of the file relative to the current scope 55 | * @param content Text to be written in the file 56 | */ 57 | @Suppress("KDocUnresolvedReference") 58 | infix operator fun String.plusAssign(content: String) 59 | 60 | /** 61 | * Creates a file with the given [content] and the [path] of the file (local or absolute) 62 | * 63 | * @param path Location of the file relative to the current scope 64 | * @param content Text to be written in the file 65 | */ 66 | fun file(path: String, content: String) 67 | } 68 | 69 | private class DefaultFileTreeScope(private val path: Path) : FileTreeScope { 70 | 71 | override operator fun String.invoke(block: FileTreeScope.() -> Unit) { 72 | folder(this, block) 73 | } 74 | 75 | override fun folder(path: String, block: FileTreeScope.() -> Unit) { 76 | val branch = this.path.resolve(path) 77 | branch.createDirectories() 78 | DefaultFileTreeScope(branch).block() 79 | } 80 | 81 | override operator fun String.invoke() { 82 | emptyFile(this) 83 | } 84 | 85 | @Suppress("MemberVisibilityCanBePrivate") 86 | override // Api 87 | fun emptyFile(path: String) { 88 | file(path, "") 89 | } 90 | 91 | @Suppress("KDocUnresolvedReference") 92 | override infix operator fun String.plusAssign(content: String) { 93 | file(this, content) 94 | } 95 | 96 | override fun file(path: String, content: String) { 97 | val finalPath = this.path.resolve(path) 98 | finalPath.parent.createDirectories() 99 | Files.write(finalPath, content.toByteArray()) 100 | } 101 | 102 | } 103 | 104 | /** 105 | * Entry point for [FileTreeScope] 106 | */ 107 | internal fun Path.fileTree(block: FileTreeScope.() -> Unit = {}): FileTreeScope = 108 | DefaultFileTreeScope(this).apply(block) -------------------------------------------------------------------------------- /plugin/src/test/kotlin/com/pablisco/gradle/automodule/AutoModulePluginBenchmarks.kt: -------------------------------------------------------------------------------- 1 | package com.pablisco.gradle.automodule 2 | 3 | import com.pablisco.gradle.automodule.filetree.FileTreeScope 4 | import com.pablisco.gradle.automodule.filetree.fileTree 5 | import com.pablisco.gradle.automodule.gradle.defaultSettingsGradleScript 6 | import com.pablisco.gradle.automodule.gradle.runGradle 7 | import com.pablisco.gradle.automodule.utils.createDirectories 8 | import org.junit.jupiter.api.Disabled 9 | import org.junit.jupiter.api.Test 10 | import org.junit.jupiter.api.io.TempDir 11 | import java.nio.file.Path 12 | import kotlin.system.measureTimeMillis 13 | 14 | private typealias Modules = Sequence 15 | 16 | @Disabled("Not fully working") 17 | class AutoModulePluginBenchmarks { 18 | 19 | @Test 20 | fun `measure manual vs AutoModule`( 21 | @TempDir tmp: Path 22 | ) = measure { 23 | val manualProjectDir = tmp.resolve("manual").createDirectories() 24 | val autoModuleProjectDir = tmp.resolve("autoModule").createDirectories() 25 | 26 | manualProjectDir.fileTree { 27 | val modules = generateModules() 28 | manualSettings(modules) 29 | "build.gradle.kts" += """ 30 | plugins { kotlin("jvm") version "1.4.0" } 31 | dependencies { 32 | ${dependencies(modules.asManualNotation())} 33 | } 34 | """.trimIndent() 35 | createModules(modules) 36 | } 37 | 38 | autoModuleProjectDir.fileTree { 39 | val modules = generateModules() 40 | "settings.gradle.kts" += defaultSettingsGradleScript 41 | "build.gradle.kts" += """ 42 | buildscript { 43 | repositories { 44 | jcenter() 45 | mavenLocal() 46 | } 47 | dependencies { 48 | classpath("org.jetbrains.kotlin:kotlin-gradle-plugin:1.4.0") 49 | } 50 | } 51 | 52 | allprojects { 53 | repositories { 54 | mavenCentral() 55 | jcenter() 56 | } 57 | } 58 | """.trimIndent() 59 | "consumer/build.gradle.kts" += """ 60 | plugins { kotlin("jvm") } 61 | dependencies { 62 | ${dependencies(modules.asAutoModuleNotation())} 63 | } 64 | """.trimIndent() 65 | createModules(modules) 66 | } 67 | 68 | "Warm up - Manual build" { manualProjectDir.runGradle() } 69 | "Warm up - AutoModule build" { autoModuleProjectDir.runGradle() } 70 | 71 | "AutoModule build"(runCount = 10) { autoModuleProjectDir.runGradle() } 72 | "Manual build"(runCount = 10) { manualProjectDir.runGradle() } 73 | } 74 | 75 | } 76 | 77 | private fun generateModules(): Modules = 78 | (0..100).asSequence().map { "module$it" } 79 | 80 | private fun FileTreeScope.manualSettings(modules: Modules) { 81 | "settings.gradle.kts" += modules 82 | .asManualNotation() 83 | .joinToString("\n") { """include($it)""" } 84 | } 85 | 86 | private fun FileTreeScope.createModules(modules: Modules) { 87 | modules.forEach { moduleName -> 88 | moduleName { 89 | emptyFile("build.gradle.kts") 90 | } 91 | } 92 | } 93 | 94 | private fun dependencies(modules: Sequence): String = 95 | modules.joinToString("\n") { """implementation(project($it))""" } 96 | 97 | private fun Modules.asManualNotation(): Sequence = 98 | map { "\":$it\"" } 99 | 100 | private fun Modules.asAutoModuleNotation(): Sequence = 101 | map { "autoModules.$it" } 102 | 103 | private fun measure(block: MeasureScope.() -> Unit) { 104 | println(MeasureScope().apply(block).log) 105 | } 106 | 107 | private class MeasureScope { 108 | 109 | var log = "[Measurements]\n" 110 | 111 | operator fun String.invoke(block: () -> Unit) { 112 | val timeTaken = measureTimeMillis(block) 113 | log += "\t$this: ${timeTaken}ms\n" 114 | } 115 | 116 | operator fun String.invoke(runCount: Int, block: () -> Unit) { 117 | val times = (0 until runCount).map { measureTimeMillis(block) } 118 | val max = times.max() ?: -1 119 | val min = times.min() ?: -1 120 | val average = times.average() 121 | val error = max - min 122 | log += "\t$this: avg ${average}ms, max ${max}ms, min ${min}ms, error ${error}ms\n" 123 | } 124 | 125 | } 126 | -------------------------------------------------------------------------------- /plugin/src/test/kotlin/com/pablisco/gradle/automodule/AutoModulePluginTest.kt: -------------------------------------------------------------------------------- 1 | package com.pablisco.gradle.automodule 2 | 3 | import com.pablisco.gradle.automodule.filetree.fileTree 4 | import com.pablisco.gradle.automodule.gradle.kotlinModule 5 | import com.pablisco.gradle.automodule.gradle.runGradle 6 | import com.pablisco.gradle.automodule.gradle.runGradleProjects 7 | import com.pablisco.gradle.automodule.gradle.shouldBeSuccess 8 | import com.pablisco.gradle.automodule.utils.* 9 | import org.amshove.kluent.shouldBeEqualTo 10 | import org.amshove.kluent.shouldContain 11 | import org.amshove.kluent.shouldNotContain 12 | import org.jetbrains.kotlin.konan.file.recursiveCopyTo 13 | import org.junit.jupiter.api.Test 14 | import java.nio.file.Files 15 | import java.nio.file.Path 16 | import java.nio.file.Paths 17 | import java.nio.file.StandardOpenOption 18 | import java.nio.file.attribute.FileTime 19 | 20 | class AutoModulePluginTest { 21 | 22 | @Test 23 | fun `generates modules code WITH simple module`() = testCase("simple_module") { 24 | val result = workingDir.runGradleProjects() 25 | result.shouldBeSuccess() 26 | } 27 | 28 | @Test 29 | fun `generates modules code WITH multiple modules`() = testCase("multiple_modules") { 30 | val result = workingDir.runGradleProjects() 31 | result.shouldBeSuccess() 32 | } 33 | 34 | @Test 35 | fun `generates modules code WITH nested modules`() = testCase("nested_modules") { 36 | val result = workingDir.runGradleProjects() 37 | result.shouldBeSuccess() 38 | } 39 | 40 | @Test 41 | fun `versions are loaded WITH custom versions location`() = testCase("custom_versions_location") { 42 | val result = workingDir.runGradleProjects() 43 | result.shouldBeSuccess() 44 | } 45 | 46 | @Test 47 | fun `versions are loaded WITH remote versions location`() = testCase("remote_versions_location") { 48 | val result = workingDir.runGradleProjects() 49 | result.shouldBeSuccess() 50 | } 51 | 52 | @Test 53 | fun `ignores modules`() = testCase("ignore_modules") { 54 | val result = workingDir.runGradleProjects() 55 | 56 | result.output shouldNotContain "Project ':settingsKtIgnored'" 57 | result.output shouldNotContain "Project ':extensionIgnored'" 58 | result.output shouldContain "Project ':included'" 59 | } 60 | 61 | @Test 62 | fun `can use from groovy gradle script`() = testCase("groovy_support") { 63 | val result = workingDir.runGradleProjects() 64 | 65 | result.shouldBeSuccess() 66 | } 67 | 68 | @Test 69 | fun `no code generation occurs with cache enabled`() = testCase( 70 | path = "simple_module", 71 | workingPath = "no_code_gen_with_cache" 72 | ) { 73 | val modulesKt = workingDir.modulesKt("no_code_gen_with_cache") 74 | workingDir.runGradleProjects() 75 | val initialRunLastModified = modulesKt.lastModified 76 | workingDir.runGradleProjects() 77 | val cachedRunLastModified = modulesKt.lastModified 78 | 79 | initialRunLastModified shouldBeEqualTo cachedRunLastModified 80 | } 81 | 82 | @Test 83 | fun `generates task for a given template`() = testCase("template_task") { 84 | workingDir.runGradle { 85 | withArguments("createDefaultModule", "--templateDirectory=simpleModule") 86 | } 87 | 88 | check(workingDir.resolve("simpleModule/build.gradle.kts").exists()) 89 | } 90 | 91 | @Test 92 | fun `files are generated after manual deletion with cache enabled`() = testCase( 93 | path = "simple_module", 94 | workingPath = "files_are_generated_after_manual_delete" 95 | ) { 96 | val modulesKt = workingDir.modulesKt("files_are_generated_after_manual_delete") 97 | workingDir.runGradleProjects() 98 | modulesKt.delete() 99 | workingDir.runGradleProjects() 100 | 101 | check(modulesKt.exists()) 102 | } 103 | 104 | @Test 105 | fun `files are generated after changing script with cache enabled`() = testCase( 106 | path = "simple_module", 107 | workingPath = "files_are_generated_after_script_changes" 108 | ) { 109 | workingDir.runGradleProjects() 110 | 111 | workingDir.fileTree().kotlinModule("newModule") 112 | 113 | val output = workingDir.runGradleProjects().output 114 | 115 | output shouldContain "Project ':newModule'" 116 | } 117 | 118 | @Test 119 | fun `classpath includes build modules`() = testCase("build_modules") { 120 | workingDir.resolve("gradle/buildStuff").addLocalRepository() 121 | val result = workingDir.runGradleProjects() 122 | 123 | result.shouldBeSuccess() 124 | result.output shouldContain "Hello Gradle!" 125 | } 126 | 127 | } 128 | 129 | class TestCase( 130 | path: String, 131 | workingPath: String, 132 | projectDir: Path = Paths.get(".").toAbsolutePath(), 133 | val testCaseDir: Path = projectDir.resolve("src/test/resources/test-cases/$path"), 134 | val workingDir: Path = projectDir.resolve("build/test-workspace/$workingPath") 135 | ) 136 | 137 | private fun testCase( 138 | path: String, 139 | workingPath: String = path, 140 | block: TestCase.() -> Unit 141 | ) { 142 | TestCase(path, workingPath).apply { 143 | workingDir.deleteRecursively() 144 | workingDir.createDirectories() 145 | testCaseDir.recursiveCopyTo(workingDir) 146 | workingDir.addLocalRepository() 147 | }.run(block) 148 | } 149 | 150 | private fun Path.addLocalRepository() { 151 | with(resolve("settings.gradle.kts")) { 152 | write( 153 | """autoModule { pluginRepository(file("${Paths.get("../repo").toRealPath()}")) }""", 154 | StandardOpenOption.APPEND 155 | ) 156 | } 157 | } 158 | 159 | private fun Path.modulesKt(projectName: String): Path = 160 | resolve(".gradle/automodule/${projectName}-modules/src/main/kotlin/modules.kt") 161 | 162 | private val Path.lastModified: FileTime 163 | get() = Files.getLastModifiedTime(this) 164 | -------------------------------------------------------------------------------- /gradlew: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env sh 2 | 3 | # 4 | # Copyright 2015 the original author or authors. 5 | # 6 | # Licensed under the Apache License, Version 2.0 (the "License"); 7 | # you may not use this file except in compliance with the License. 8 | # You may obtain a copy of the License at 9 | # 10 | # https://www.apache.org/licenses/LICENSE-2.0 11 | # 12 | # Unless required by applicable law or agreed to in writing, software 13 | # distributed under the License is distributed on an "AS IS" BASIS, 14 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 15 | # See the License for the specific language governing permissions and 16 | # limitations under the License. 17 | # 18 | 19 | ############################################################################## 20 | ## 21 | ## Gradle start up script for UN*X 22 | ## 23 | ############################################################################## 24 | 25 | # Attempt to set APP_HOME 26 | # Resolve links: $0 may be a link 27 | PRG="$0" 28 | # Need this for relative symlinks. 29 | while [ -h "$PRG" ] ; do 30 | ls=`ls -ld "$PRG"` 31 | link=`expr "$ls" : '.*-> \(.*\)$'` 32 | if expr "$link" : '/.*' > /dev/null; then 33 | PRG="$link" 34 | else 35 | PRG=`dirname "$PRG"`"/$link" 36 | fi 37 | done 38 | SAVED="`pwd`" 39 | cd "`dirname \"$PRG\"`/" >/dev/null 40 | APP_HOME="`pwd -P`" 41 | cd "$SAVED" >/dev/null 42 | 43 | APP_NAME="Gradle" 44 | APP_BASE_NAME=`basename "$0"` 45 | 46 | # Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script. 47 | DEFAULT_JVM_OPTS='"-Xmx64m" "-Xms64m"' 48 | 49 | # Use the maximum available, or set MAX_FD != -1 to use that value. 50 | MAX_FD="maximum" 51 | 52 | warn () { 53 | echo "$*" 54 | } 55 | 56 | die () { 57 | echo 58 | echo "$*" 59 | echo 60 | exit 1 61 | } 62 | 63 | # OS specific support (must be 'true' or 'false'). 64 | cygwin=false 65 | msys=false 66 | darwin=false 67 | nonstop=false 68 | case "`uname`" in 69 | CYGWIN* ) 70 | cygwin=true 71 | ;; 72 | Darwin* ) 73 | darwin=true 74 | ;; 75 | MINGW* ) 76 | msys=true 77 | ;; 78 | NONSTOP* ) 79 | nonstop=true 80 | ;; 81 | esac 82 | 83 | CLASSPATH=$APP_HOME/gradle/wrapper/gradle-wrapper.jar 84 | 85 | 86 | # Determine the Java command to use to start the JVM. 87 | if [ -n "$JAVA_HOME" ] ; then 88 | if [ -x "$JAVA_HOME/jre/sh/java" ] ; then 89 | # IBM's JDK on AIX uses strange locations for the executables 90 | JAVACMD="$JAVA_HOME/jre/sh/java" 91 | else 92 | JAVACMD="$JAVA_HOME/bin/java" 93 | fi 94 | if [ ! -x "$JAVACMD" ] ; then 95 | die "ERROR: JAVA_HOME is set to an invalid directory: $JAVA_HOME 96 | 97 | Please set the JAVA_HOME variable in your environment to match the 98 | location of your Java installation." 99 | fi 100 | else 101 | JAVACMD="java" 102 | which java >/dev/null 2>&1 || die "ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. 103 | 104 | Please set the JAVA_HOME variable in your environment to match the 105 | location of your Java installation." 106 | fi 107 | 108 | # Increase the maximum file descriptors if we can. 109 | if [ "$cygwin" = "false" -a "$darwin" = "false" -a "$nonstop" = "false" ] ; then 110 | MAX_FD_LIMIT=`ulimit -H -n` 111 | if [ $? -eq 0 ] ; then 112 | if [ "$MAX_FD" = "maximum" -o "$MAX_FD" = "max" ] ; then 113 | MAX_FD="$MAX_FD_LIMIT" 114 | fi 115 | ulimit -n $MAX_FD 116 | if [ $? -ne 0 ] ; then 117 | warn "Could not set maximum file descriptor limit: $MAX_FD" 118 | fi 119 | else 120 | warn "Could not query maximum file descriptor limit: $MAX_FD_LIMIT" 121 | fi 122 | fi 123 | 124 | # For Darwin, add options to specify how the application appears in the dock 125 | if $darwin; then 126 | GRADLE_OPTS="$GRADLE_OPTS \"-Xdock:name=$APP_NAME\" \"-Xdock:icon=$APP_HOME/media/gradle.icns\"" 127 | fi 128 | 129 | # For Cygwin or MSYS, switch paths to Windows format before running java 130 | if [ "$cygwin" = "true" -o "$msys" = "true" ] ; then 131 | APP_HOME=`cygpath --path --mixed "$APP_HOME"` 132 | CLASSPATH=`cygpath --path --mixed "$CLASSPATH"` 133 | 134 | JAVACMD=`cygpath --unix "$JAVACMD"` 135 | 136 | # We build the pattern for arguments to be converted via cygpath 137 | ROOTDIRSRAW=`find -L / -maxdepth 1 -mindepth 1 -type d 2>/dev/null` 138 | SEP="" 139 | for dir in $ROOTDIRSRAW ; do 140 | ROOTDIRS="$ROOTDIRS$SEP$dir" 141 | SEP="|" 142 | done 143 | OURCYGPATTERN="(^($ROOTDIRS))" 144 | # Add a user-defined pattern to the cygpath arguments 145 | if [ "$GRADLE_CYGPATTERN" != "" ] ; then 146 | OURCYGPATTERN="$OURCYGPATTERN|($GRADLE_CYGPATTERN)" 147 | fi 148 | # Now convert the arguments - kludge to limit ourselves to /bin/sh 149 | i=0 150 | for arg in "$@" ; do 151 | CHECK=`echo "$arg"|egrep -c "$OURCYGPATTERN" -` 152 | CHECK2=`echo "$arg"|egrep -c "^-"` ### Determine if an option 153 | 154 | if [ $CHECK -ne 0 ] && [ $CHECK2 -eq 0 ] ; then ### Added a condition 155 | eval `echo args$i`=`cygpath --path --ignore --mixed "$arg"` 156 | else 157 | eval `echo args$i`="\"$arg\"" 158 | fi 159 | i=`expr $i + 1` 160 | done 161 | case $i in 162 | 0) set -- ;; 163 | 1) set -- "$args0" ;; 164 | 2) set -- "$args0" "$args1" ;; 165 | 3) set -- "$args0" "$args1" "$args2" ;; 166 | 4) set -- "$args0" "$args1" "$args2" "$args3" ;; 167 | 5) set -- "$args0" "$args1" "$args2" "$args3" "$args4" ;; 168 | 6) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" ;; 169 | 7) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" ;; 170 | 8) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" ;; 171 | 9) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" "$args8" ;; 172 | esac 173 | fi 174 | 175 | # Escape application args 176 | save () { 177 | for i do printf %s\\n "$i" | sed "s/'/'\\\\''/g;1s/^/'/;\$s/\$/' \\\\/" ; done 178 | echo " " 179 | } 180 | APP_ARGS=`save "$@"` 181 | 182 | # Collect all arguments for the java command, following the shell quoting and substitution rules 183 | eval set -- $DEFAULT_JVM_OPTS $JAVA_OPTS $GRADLE_OPTS "\"-Dorg.gradle.appname=$APP_BASE_NAME\"" -classpath "\"$CLASSPATH\"" org.gradle.wrapper.GradleWrapperMain "$APP_ARGS" 184 | 185 | exec "$JAVACMD" "$@" 186 | -------------------------------------------------------------------------------- /demos/simple_module/gradlew: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env sh 2 | 3 | # 4 | # Copyright 2015 the original author or authors. 5 | # 6 | # Licensed under the Apache License, Version 2.0 (the "License"); 7 | # you may not use this file except in compliance with the License. 8 | # You may obtain a copy of the License at 9 | # 10 | # https://www.apache.org/licenses/LICENSE-2.0 11 | # 12 | # Unless required by applicable law or agreed to in writing, software 13 | # distributed under the License is distributed on an "AS IS" BASIS, 14 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 15 | # See the License for the specific language governing permissions and 16 | # limitations under the License. 17 | # 18 | 19 | ############################################################################## 20 | ## 21 | ## Gradle start up script for UN*X 22 | ## 23 | ############################################################################## 24 | 25 | # Attempt to set APP_HOME 26 | # Resolve links: $0 may be a link 27 | PRG="$0" 28 | # Need this for relative symlinks. 29 | while [ -h "$PRG" ] ; do 30 | ls=`ls -ld "$PRG"` 31 | link=`expr "$ls" : '.*-> \(.*\)$'` 32 | if expr "$link" : '/.*' > /dev/null; then 33 | PRG="$link" 34 | else 35 | PRG=`dirname "$PRG"`"/$link" 36 | fi 37 | done 38 | SAVED="`pwd`" 39 | cd "`dirname \"$PRG\"`/" >/dev/null 40 | APP_HOME="`pwd -P`" 41 | cd "$SAVED" >/dev/null 42 | 43 | APP_NAME="Gradle" 44 | APP_BASE_NAME=`basename "$0"` 45 | 46 | # Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script. 47 | DEFAULT_JVM_OPTS='"-Xmx64m" "-Xms64m"' 48 | 49 | # Use the maximum available, or set MAX_FD != -1 to use that value. 50 | MAX_FD="maximum" 51 | 52 | warn () { 53 | echo "$*" 54 | } 55 | 56 | die () { 57 | echo 58 | echo "$*" 59 | echo 60 | exit 1 61 | } 62 | 63 | # OS specific support (must be 'true' or 'false'). 64 | cygwin=false 65 | msys=false 66 | darwin=false 67 | nonstop=false 68 | case "`uname`" in 69 | CYGWIN* ) 70 | cygwin=true 71 | ;; 72 | Darwin* ) 73 | darwin=true 74 | ;; 75 | MINGW* ) 76 | msys=true 77 | ;; 78 | NONSTOP* ) 79 | nonstop=true 80 | ;; 81 | esac 82 | 83 | CLASSPATH=$APP_HOME/gradle/wrapper/gradle-wrapper.jar 84 | 85 | # Determine the Java command to use to start the JVM. 86 | if [ -n "$JAVA_HOME" ] ; then 87 | if [ -x "$JAVA_HOME/jre/sh/java" ] ; then 88 | # IBM's JDK on AIX uses strange locations for the executables 89 | JAVACMD="$JAVA_HOME/jre/sh/java" 90 | else 91 | JAVACMD="$JAVA_HOME/bin/java" 92 | fi 93 | if [ ! -x "$JAVACMD" ] ; then 94 | die "ERROR: JAVA_HOME is set to an invalid directory: $JAVA_HOME 95 | 96 | Please set the JAVA_HOME variable in your environment to match the 97 | location of your Java installation." 98 | fi 99 | else 100 | JAVACMD="java" 101 | which java >/dev/null 2>&1 || die "ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. 102 | 103 | Please set the JAVA_HOME variable in your environment to match the 104 | location of your Java installation." 105 | fi 106 | 107 | # Increase the maximum file descriptors if we can. 108 | if [ "$cygwin" = "false" -a "$darwin" = "false" -a "$nonstop" = "false" ] ; then 109 | MAX_FD_LIMIT=`ulimit -H -n` 110 | if [ $? -eq 0 ] ; then 111 | if [ "$MAX_FD" = "maximum" -o "$MAX_FD" = "max" ] ; then 112 | MAX_FD="$MAX_FD_LIMIT" 113 | fi 114 | ulimit -n $MAX_FD 115 | if [ $? -ne 0 ] ; then 116 | warn "Could not set maximum file descriptor limit: $MAX_FD" 117 | fi 118 | else 119 | warn "Could not query maximum file descriptor limit: $MAX_FD_LIMIT" 120 | fi 121 | fi 122 | 123 | # For Darwin, add options to specify how the application appears in the dock 124 | if $darwin; then 125 | GRADLE_OPTS="$GRADLE_OPTS \"-Xdock:name=$APP_NAME\" \"-Xdock:icon=$APP_HOME/media/gradle.icns\"" 126 | fi 127 | 128 | # For Cygwin or MSYS, switch paths to Windows format before running java 129 | if [ "$cygwin" = "true" -o "$msys" = "true" ] ; then 130 | APP_HOME=`cygpath --path --mixed "$APP_HOME"` 131 | CLASSPATH=`cygpath --path --mixed "$CLASSPATH"` 132 | JAVACMD=`cygpath --unix "$JAVACMD"` 133 | 134 | # We build the pattern for arguments to be converted via cygpath 135 | ROOTDIRSRAW=`find -L / -maxdepth 1 -mindepth 1 -type d 2>/dev/null` 136 | SEP="" 137 | for dir in $ROOTDIRSRAW ; do 138 | ROOTDIRS="$ROOTDIRS$SEP$dir" 139 | SEP="|" 140 | done 141 | OURCYGPATTERN="(^($ROOTDIRS))" 142 | # Add a user-defined pattern to the cygpath arguments 143 | if [ "$GRADLE_CYGPATTERN" != "" ] ; then 144 | OURCYGPATTERN="$OURCYGPATTERN|($GRADLE_CYGPATTERN)" 145 | fi 146 | # Now convert the arguments - kludge to limit ourselves to /bin/sh 147 | i=0 148 | for arg in "$@" ; do 149 | CHECK=`echo "$arg"|egrep -c "$OURCYGPATTERN" -` 150 | CHECK2=`echo "$arg"|egrep -c "^-"` ### Determine if an option 151 | 152 | if [ $CHECK -ne 0 ] && [ $CHECK2 -eq 0 ] ; then ### Added a condition 153 | eval `echo args$i`=`cygpath --path --ignore --mixed "$arg"` 154 | else 155 | eval `echo args$i`="\"$arg\"" 156 | fi 157 | i=`expr $i + 1` 158 | done 159 | case $i in 160 | 0) set -- ;; 161 | 1) set -- "$args0" ;; 162 | 2) set -- "$args0" "$args1" ;; 163 | 3) set -- "$args0" "$args1" "$args2" ;; 164 | 4) set -- "$args0" "$args1" "$args2" "$args3" ;; 165 | 5) set -- "$args0" "$args1" "$args2" "$args3" "$args4" ;; 166 | 6) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" ;; 167 | 7) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" ;; 168 | 8) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" ;; 169 | 9) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" "$args8" ;; 170 | esac 171 | fi 172 | 173 | # Escape application args 174 | save () { 175 | for i do printf %s\\n "$i" | sed "s/'/'\\\\''/g;1s/^/'/;\$s/\$/' \\\\/" ; done 176 | echo " " 177 | } 178 | APP_ARGS=`save "$@"` 179 | 180 | # Collect all arguments for the java command, following the shell quoting and substitution rules 181 | eval set -- $DEFAULT_JVM_OPTS $JAVA_OPTS $GRADLE_OPTS "\"-Dorg.gradle.appname=$APP_BASE_NAME\"" -classpath "\"$CLASSPATH\"" org.gradle.wrapper.GradleWrapperMain "$APP_ARGS" 182 | 183 | exec "$JAVACMD" "$@" 184 | -------------------------------------------------------------------------------- /plugin/src/main/kotlin/com/pablisco/gradle/automodule/AutoModulePlugin.kt: -------------------------------------------------------------------------------- 1 | package com.pablisco.gradle.automodule 2 | 3 | import com.pablisco.gradle.automodule.filetree.fileTree 4 | import com.pablisco.gradle.automodule.utils.* 5 | import org.gradle.api.Plugin 6 | import org.gradle.api.Project 7 | import org.gradle.api.artifacts.Configuration 8 | import org.gradle.api.artifacts.ModuleVersionSelector 9 | import org.gradle.api.initialization.Settings 10 | import org.gradle.api.tasks.Delete 11 | import org.gradle.kotlin.dsl.buildscript 12 | import org.gradle.kotlin.dsl.create 13 | import org.gradle.kotlin.dsl.maven 14 | import org.gradle.kotlin.dsl.repositories 15 | import java.io.File 16 | 17 | private const val version = "0.15" 18 | 19 | class AutoModulePlugin : Plugin { 20 | 21 | private val autoModule = AutoModule() 22 | 23 | override fun apply(target: Settings) { 24 | target.extensions.add("autoModule", autoModule) 25 | SettingsScope(autoModule, target).whenEvaluated { 26 | val versions = Versions(rootDir, autoModule.versions) 27 | addGlobalExtension("versions", extension = versions) 28 | notifyIgnoredModules() 29 | includeModulesToSettings() 30 | generateModuleGraph() 31 | injectVersionResolution(versions) 32 | includeGeneratedGraphModule() 33 | includeBuildModules() 34 | createTemplateTasks() 35 | addDebugArtifactRepository() 36 | addGroovySupport() 37 | createCleanTask() 38 | } 39 | } 40 | 41 | } 42 | 43 | private fun SettingsScope.createCleanTask() = gradle.rootProject { 44 | tasks.create("cleanAutoModule") { 45 | delete(directoriesHashFile, generatedMd5File) 46 | } 47 | } 48 | 49 | private fun SettingsScope.addGroovySupport() = gradle.rootProject { 50 | extensions.create("autoModules") 51 | } 52 | 53 | private fun SettingsScope.addDebugArtifactRepository() = gradle.rootProject { 54 | buildscript { 55 | repositories { 56 | autoModule.pluginRepositoryPath?.let { maven(url = it) } 57 | gradlePluginPortal() 58 | } 59 | } 60 | } 61 | 62 | private fun SettingsScope.includeBuildModules() { 63 | val buildModulesRoot = rootDir.resolve(autoModule.buildModulesRoot) 64 | 65 | val buildModules = buildModulesRoot.children() 66 | .filter { it.isDirectory } 67 | .filter { dir -> dir.children().any { it.name == "build.gradle.kts" } } 68 | buildModules.forEach { dir -> 69 | includeBuild(dir) { 70 | dependencySubstitution { 71 | substitute(module("gradle:${dir.name}:local")).with(project(":")) 72 | } 73 | } 74 | gradle.rootProject { 75 | buildscript { 76 | dependencies { 77 | classpath("gradle:${dir.name}:local") 78 | } 79 | } 80 | } 81 | } 82 | } 83 | 84 | private fun File.children(): List = listFiles()?.toList() ?: emptyList() 85 | 86 | private fun SettingsScope.whenEvaluated(f: SettingsScope.() -> Unit) { 87 | gradle.settingsEvaluated { f() } 88 | } 89 | 90 | private fun SettingsScope.includeGeneratedGraphModule() { 91 | includeBuild(generatedGraphModule) { 92 | dependencySubstitution { 93 | substitute(module("automodule:graph:local")).with(project(":")) 94 | } 95 | } 96 | gradle.rootProject { 97 | buildscript { 98 | dependencies { classpath("automodule:graph:local") } 99 | } 100 | } 101 | } 102 | 103 | private fun SettingsScope.createTemplateTasks() = gradle.rootProject { 104 | afterEvaluate { 105 | autoModule.templates.forEach { template -> createTemplateTask(template) } 106 | } 107 | } 108 | 109 | private fun Project.createTemplateTask(template: AutoModuleTemplate): CreateModuleTask = 110 | tasks.create( 111 | "create${template.name.capitalize()}Module", 112 | CreateModuleTask::class.java, 113 | template 114 | ) 115 | 116 | private fun SettingsScope.notifyIgnoredModules() { 117 | if (autoModule.ignored.isNotEmpty()) { 118 | log("Ignoring modules: ${autoModule.ignored}") 119 | } 120 | } 121 | 122 | private fun ModuleVersionSelector.hasVersion(): Boolean = 123 | version?.takeIf { it.isNotEmpty() } != null 124 | 125 | private fun SettingsScope.injectVersionResolution(versions: Versions) { 126 | val injectDependencies: Configuration.() -> Unit = { 127 | resolutionStrategy.eachDependency { 128 | requested.takeUnless { it.hasVersion() }?.also { versionSelector -> 129 | useVersion(versions.getDependencyVersion(versionSelector)) 130 | } 131 | } 132 | } 133 | 134 | gradle.allprojects { 135 | buildscript { configurations.all(injectDependencies) } 136 | configurations.all(injectDependencies) 137 | } 138 | 139 | pluginManagement { 140 | resolutionStrategy { 141 | eachPlugin { 142 | versions.findPluginVersion(requested.id.id)?.also { useVersion(it) } 143 | } 144 | } 145 | } 146 | } 147 | 148 | private fun SettingsScope.generateModuleGraph() { 149 | if (isCached() and isCodeUpToDate() and isSameVersion()) { 150 | log("Module Graph is UP-TO-DATE") 151 | } else { 152 | val extraRepository = autoModule.pluginRepositoryPath 153 | ?.let { "maven(url = \"${it}\")" } ?: "" 154 | generatedGraphModule.fileTree { 155 | "settings.gradle.kts" += "rootProject.name = \"$graphModuleName\"" 156 | "build.gradle.kts" += """ 157 | buildscript{ 158 | repositories { 159 | $extraRepository 160 | gradlePluginPortal() 161 | } 162 | } 163 | plugins { 164 | kotlin("jvm") version "1.4.0" 165 | } 166 | 167 | repositories { 168 | jcenter() 169 | $extraRepository 170 | gradlePluginPortal() 171 | } 172 | 173 | dependencies { 174 | implementation(kotlin("stdlib")) 175 | api("com.pablisco.gradle.automodule:plugin:$version") 176 | } 177 | """.trimIndent() 178 | } 179 | rootModule.writeTo( 180 | directory = generatedGraphSource, 181 | fileName = modulesFileName 182 | ) 183 | saveChecksums() 184 | log("Module Graph saved to $generatedGraphSource/$modulesFileName.kt") 185 | } 186 | } 187 | 188 | private fun SettingsScope.isCached(): Boolean = 189 | "$scriptsHash" == directoriesHashFile.maybeReadText() 190 | 191 | private fun SettingsScope.isCodeUpToDate(): Boolean = 192 | generatedCodeMd5 == generatedMd5File.maybeReadText() 193 | 194 | private fun SettingsScope.isSameVersion(): Boolean = 195 | version == versionFile.maybeReadText() 196 | 197 | private val SettingsScope.generatedCodeMd5: String 198 | get() = generatedGraphSource.resolve("$modulesFileName.kt").md5() 199 | 200 | private fun SettingsScope.saveChecksums() { 201 | directoriesHashFile.createFile(content = "$scriptsHash") 202 | generatedMd5File.createFile(content = generatedCodeMd5) 203 | versionFile.createFile(content = version) 204 | } 205 | 206 | private fun SettingsScope.includeModulesToSettings() { 207 | rootModule.walk().mapNotNull { it.path } 208 | .filterNot { it in autoModule.ignored } 209 | .forEach { path -> 210 | log("include($path)") 211 | include(path) 212 | } 213 | } 214 | -------------------------------------------------------------------------------- /.idea/uiDesigner.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | 33 | 34 | 35 | 36 | 37 | 38 | 39 | 40 | 41 | 42 | 43 | 44 | 45 | 46 | 47 | 48 | 49 | 50 | 51 | 52 | 53 | 54 | 55 | 56 | 57 | 58 | 59 | 60 | 61 | 62 | 63 | 64 | 65 | 66 | 67 | 68 | 69 | 70 | 71 | 72 | 73 | 74 | 75 | 76 | 77 | 78 | 79 | 80 | 81 | 82 | 83 | 84 | 85 | 86 | 87 | 88 | 89 | 90 | 91 | 92 | 93 | 94 | 95 | 96 | 97 | 98 | 99 | 100 | 101 | 102 | 103 | 104 | 105 | 106 | 107 | 108 | 109 | 110 | 111 | 112 | 113 | 114 | 115 | 116 | 117 | 118 | 119 | 120 | 121 | 122 | 123 | 124 | -------------------------------------------------------------------------------- /readme.md: -------------------------------------------------------------------------------- 1 | # Auto Module 2 | 3 | [![Actions](https://github.com/pablisco/auto-module/workflows/Publish/badge.svg)](https://github.com/pablisco/auto-module/actions) 4 | [![Gradle Plugin Portal](https://img.shields.io/maven-metadata/v/https/plugins.gradle.org/m2/com/pablisco/gradle/automodule/plugin/maven-metadata.xml.svg?label=Gradle)](https://plugins.gradle.org/plugin/com.pablisco.gradle.automodule) 5 | 6 | This Gradle plugin helps with module dependencies. And by help, it means it does the hard work for you. 7 | 8 | ## Why do I need this? 9 | 10 | So, these are some (but not all) of the reasons why you should use this: 11 | 12 | - __Avoid user error:__ It's quite common, specially with complex projects, to have a large and nested project graph with all the available modules. Updating it can be tedious and, frankly, you probably rather be doing other things. 13 | - __Type safety:__ After you rename a module, any reference to it will complain when evaluating the project's build, so you know where you need to change your dependencies. 14 | - __IDE Auto-complete:__ One of the benefits of using `kts` build scripts is that the IDE can provide auto complete. This will save you multiple trips to the `settings.gradle[.kt]` script or the project structure to remember the name of the module you are looking for. 15 | - __Progressive upgrade:__ It has support for Groovy gradle so you don't have to migrate all your modules to use kts if you are not quite there yet or don't need it on all of them. 16 | - __Module generation:__ You can define tasks that can be used from command line to generate a predefined module structure with the provided template. The IDE only allows to create modules in the root of the project, this allows to create it on any directory as well as provide the means for templating how certain modules are defined. 17 | 18 | 19 | ## Table of Contents 20 | 21 | 22 | - __[How do I use it?](#how-do-i-use-it)__ 23 | - __[Ignore modules](#ignore-modules)__ 24 | - __[Legacy Groovy Script support](#legacy-groovy-script-support)__ 25 | - __[Module generation tasks](#module-generation-tasks)__ 26 | - __[Automatic Version Resolution](#automatic-version-resolution)__ 27 | - __[By Group](#by-group)__ 28 | - __[By Group and/or Name](#by-group-andor-name)__ 29 | - __[Self resolution, not possible](#self-resolution-not-possible)__ 30 | - __[Composite Builds](#composite-builds)__ 31 | - __[versions.properties for Build Modules](#versionsproperties-for-build-modules)__ 32 | - __[History](#history)__ 33 | - __[Local development](#local-development)__ 34 | - __[License](#license)__ 35 | 36 | 37 | ## How do I use it? 38 | 39 | Remove all your `include()` instructions inside `settings.gradle[.kts]` and add this: 40 | 41 | ```kotlin 42 | plugins { 43 | id("com.pablisco.gradle.automodule") version "0.15" 44 | } 45 | ``` 46 | 47 | That's it! 48 | 49 | At least from the settings script sense. Now you will probably want to convert all the local project 50 | dependencies to use the type safe graph! 51 | 52 | If you have a project with the following structure: 53 | 54 | ``` 55 | root 56 | +-- app 57 | \-- features 58 | +-- home 59 | \-- settings 60 | ``` 61 | 62 | AutoModule generates a build module in `.gradle/automodule` with code similar to this: 63 | 64 | ```kotlin 65 | object autoModules { 66 | val app = App 67 | object App : AutoModuleDependency by autoModuleDependency(":app") 68 | val features = Features 69 | object Features : AutoModuleDependency by autoModuleDependency(":features") { 70 | val home = Home 71 | object Home : AutoModuleDependency by autoModuleDependency(":features:home") 72 | object settings : AutoModuleDependency by autoModuleDependency(":features:settings") 73 | } 74 | } 75 | ``` 76 | 77 | This will be accessible from any module, so you can add dependencies like: 78 | 79 | ```kotlin 80 | implementation(project(autoModules.features.home)) 81 | ``` 82 | 83 | ## Ignore modules 84 | 85 | If you want to make sure a module *is not* included to the Gradle graph you can do it in two ways: 86 | 87 | 1. Adding the `.ignore` extension at the end of the `build.gradle[.kts]` script. 88 | 2. Inside `settings.gradle[.kts]` you can configure `autoModule` to do so: 89 | 90 | ```kotlin 91 | autoModule { 92 | ignore(":modulePath", ":some:other:module") 93 | } 94 | ``` 95 | 96 | ## Legacy Groovy Script support 97 | 98 | When you have a large project, it may not be possible to migrate all your scripts to Kotlin. 99 | However, you can use the same semantics as you have in Kotlin with Groovy scripts: 100 | 101 | ```groovy 102 | implementation(autoModules.features.home) 103 | ``` 104 | 105 | This allows you to have a smooth migration to Kotlin Scripts in the future but remain with minimum 106 | changes in the meantime. 107 | 108 | If you want to keep using Gradle with Groovy scripts, instead of Kotlin, this plugin will still 109 | work. However, you still need to add support for kotlin scripts in `buildSrc/build.gradle`. 110 | 111 | ## Module generation tasks 112 | 113 | You can define tasks that can be used from command line to generate new modules: 114 | 115 | ```kotlin 116 | autoModule { 117 | template( 118 | path = Paths.get("features"), //optional, default is root 119 | type = "feature" 120 | ) { // this: ApplyTemplateScope 121 | file("build.gradle.kts", contents = """ 122 | plugins { 123 | kotlin("jvm") version kotlin_version 124 | } 125 | 126 | name = "com.example.$templateDirectory" 127 | 128 | dependencies { 129 | implementation(local.core) 130 | } 131 | """.trimIndent()) 132 | "src" { 133 | folder("main/kotlin") 134 | folder("test/kotlin") 135 | } 136 | } 137 | } 138 | ``` 139 | 140 | This generates a task called `createFeatureModule` that you can use from command line like this: 141 | 142 | ```bash 143 | ./gradlew createFeatureModule --templateDirectory=settings 144 | ``` 145 | 146 | Calling that task will create a new module inside `$rootDir/features/settings/` with the defined files and directories. 147 | 148 | AutoModule will pick up the new module and added it to the project as soon as any task or sync from the IDE is run 149 | 150 | If you want to change the target directory where the module is to be created you can also add the `path` parameter in command line: 151 | 152 | ```bash 153 | ./gradlew createFeatureModule --templateDirectory=settings --workingDirectory=notFeature 154 | ``` 155 | 156 | The "body" of the `template` function is a lambda that has a receiver of type `ApplyTemplateScope`. This scope exposes a `FileTreeScope` (*by* delegation) as well as `templateDirectory`, `workingDirectory` and `properties`. 157 | 158 | - __Template Directory:__ The name of the folder where we are starting to write our template. 159 | - __Working Directory:__ The place the module is going to be written. By default, this one is the root directory for the current project. 160 | - __Properties:__ These are the project's properties. These can be defined in the project's `gradle.properties` or the user one defined in `~/.gradle/gradle.properties`. 161 | Additionally, you can include extra properties via command line like `-Pkey=value`. 162 | 163 | The first two values can be accessed directly inside the lambda. The last one, Properties, is a Map, so we can access the values like: `properties["package"]` 164 | 165 | ## Automatic Version Resolution 166 | 167 | You can add `versions.properties` to the root of the project. AutoModule will pick it up and use it to resolve dependencies and plugins. 168 | There are 3 ways to define versions: 169 | 170 | ### By Group 171 | 172 | Let say that we define versions.properties like this: 173 | ```properties 174 | org.jetbrains.kotlin=1.4.0 175 | org.jetbrains.kotlinx=1.3.9 176 | ``` 177 | 178 | This means that versions will be resolved when a dependency or plugin has `org.jetbrains.kotlin` or `org.jetbrains.kotlinx` as the group of the dependency or plugin. 179 | 180 | So, instead of applying the kotlin plugin like this: 181 | ```kotlin 182 | plugins { 183 | kotlin("jvm") version "1.4.0" 184 | } 185 | ``` 186 | You can do: 187 | ```kotlin 188 | plugins { 189 | kotlin("jvm") 190 | } 191 | ``` 192 | This is because, underneath, `kotlin("xxx")` is mapped to `id("org.jetbrains.kotlin:kotlin-xxx")`. 193 | 194 | If you are adding plugin dependencies though the buildScript closure in a project, the same applies. 195 | There is no longer a need to add versions anywhere you need to use plugins. 196 | 197 | For dependencies is similar, you would normally add a library with the version at the end: 198 | 199 | ```kotlin 200 | dependencues { 201 | implementation("org.jetbrains.kotlinx:kotlinx-coroutines-core:1.3.9") 202 | } 203 | ``` 204 | 205 | If you have defined `versions.properties` then you can omit the version: 206 | 207 | ```kotlin 208 | dependencues { 209 | implementation("org.jetbrains.kotlinx:kotlinx-coroutines-core") 210 | } 211 | ``` 212 | 213 | AutoModule will resolve the version for you on all modules, so you only have to update it in one place: `versions.properties`. 214 | 215 | ### By Group and/or Name 216 | 217 | It's quite common to have multiple artifacts belonging to the same group but different version. 218 | 219 | For instance, you may have something like this: 220 | 221 | ```kotlin 222 | dependencies { 223 | implementation("org.jetbrains.kotlinx:kotlinx-coroutines-core:1.3.9") 224 | implementation("org.jetbrains.kotlinx:kotlinx-serialization-runtime:0.13.0") 225 | } 226 | ``` 227 | 228 | Since both libraries have different versions, assigning a version to the group will lead to a Gradle error.It doesn't 229 | find the version of the artifact that you are telling it to get. 230 | 231 | Here you have two options with `versions.properties`: 232 | 233 | - You can define the name instead of the group: 234 | ```properties 235 | kotlinx-coroutines-core=1.3.9 236 | kotlinx-serialization-runtime=0.13.0 237 | ``` 238 | - Or, if you have libraries that clash on the name you can indicate both separated by an underscore: 239 | 240 | ```properties 241 | org.jetbrains.kotlinx_kotlinx-coroutines-core=1.3.9 242 | org.jetbrains.kotlinx_kotlinx-serialization-runtime=0.13.0 243 | ``` 244 | 245 | Additionally, it's possible to define a custom location for the versions file: 246 | 247 | ```kotlin 248 | autoModule { 249 | versions = "gradle/versions.properties" 250 | } 251 | ``` 252 | 253 | Or, you can even provide a remote `properties` file with an url: 254 | 255 | ```kotlin 256 | autoModule { 257 | versions = "https://path.to/remote.properties" 258 | } 259 | ``` 260 | 261 | Self resolution, not possible 262 | ---- 263 | 264 | For obvious, or not so obvious, reasons it's not possible to resolve the version of autoModule itself :) 265 | 266 | ## Composite Builds 267 | 268 | The most common way to add logic or custom plugins to your build script is to use the `buildSrc` folder. 269 | 270 | This is, in simple terms, a special project that is compiled before Gradle evaluates and runs the main build script. 271 | It's quite common to use that to define versions values, specially when using Gradle kotlin DSL as it provide auto-complete. 272 | 273 | The problem with `buildSrc` is that it doesn't use cache, and it's compiled and tested (if you have tests) every time 274 | you run your build. You can read more about this on [this article](https://proandroiddev.com/stop-using-gradle-buildsrc-use-composite-builds-instead-3c38ac7a2ab3). 275 | A better alternative is to use [composite builds](https://docs.gradle.org/current/userguide/composite_builds.html). 276 | 277 | They are also run before the main build script, with the added benefit of using build cache and allowing to have multiple 278 | modules for different build features you may have on your code base. If you look at the source code of this plugin, you 279 | will see that we have two different modules, inside the `gradle` folder that we use for dependencies and to check the 280 | version of the current version before publishing. 281 | 282 | The standard procedure with composite builds is to create a "root" project anywhere on the code base and add it inside `settings.gradle[.kts]`: 283 | 284 | ```kotlin 285 | includeBuild("gradle/dependencies") 286 | ``` 287 | 288 | Then you would have to create a plugin class and make sure it's applied in one of the modules, in order to access the code defined on that build modules. 289 | If you don't define and apply the plugin then the code will not be accessible. 290 | 291 | With autoModule, things are a lot easier. If you create a build module inside the `gradle` folder, where you may have set 292 | up the gradle wrapper, then it'll get picked up and added to the build script. Quite similar to what happens with the normal modules. 293 | 294 | On top of that, you no longer need to define a gradle plugin, which adds compile time on a clean build. The code will 295 | automatically be added to the classpath of the build script. 296 | 297 | versions.properties for Build Modules 298 | ---- 299 | 300 | One more thing, if you have `versions.properties` defined on the root project, then you can also include it to 301 | the `settings.gradle[.kts]` of the build module: 302 | 303 | ```kotlin 304 | plugins { 305 | id("com.pablisco.gradle.automodule") version "0.15" 306 | } 307 | 308 | autoModule { 309 | versions = "../../versions.properties" 310 | } 311 | ``` 312 | 313 | This was a traditional problem of both `buildSrc` and composite builds because they defined versions on there, so they 314 | couldn't make use of them. AutoModule has you covered :) 315 | 316 | ## History 317 | 318 | All this started with this Gist: 319 | 320 | https://gist.github.com/pablisco/e50c792f1febb77af0fbc2d4f8f2810e 321 | 322 | As well as this tweet: 323 | 324 | https://twitter.com/pablisc0/status/1227933148622860289 325 | 326 | Couple of weeks of sleepless evenings, auto-module was born, and the rest is history... that I'm trying to continue to write 327 | 328 | ## Local development 329 | 330 | If you want to run this project locally there are a few things to consider: 331 | 332 | - If you want to use the current version (the one you are editing) of the plugin, you will have to deploy it to the 333 | local `repo` with the `publish` gradle task. This is why all the `settings.gradle.kts`, including the ones for the local 334 | plugins, have code to include `./repo` as a plugin repository. 335 | 336 | - More to come here :) 337 | 338 | ## License 339 | 340 | This project falls under the MIT License - see the [license.md](license.md) file for details 341 | --------------------------------------------------------------------------------