├── .github └── workflows │ └── build.yaml ├── .gitignore ├── 01_The_Settings_File ├── README.MD ├── my-build-logic │ └── .gitignore ├── my-other-project │ └── .gitignore └── my-project │ ├── app │ └── .gitignore │ ├── business-logic │ └── .gitignore │ ├── data-model │ └── .gitignore │ └── settings.gradle.kts ├── 02_The_Build_Files ├── README.MD ├── my-build-logic │ └── .gitignore ├── my-other-project │ └── .gitignore └── my-project │ ├── app │ └── build.gradle.kts │ ├── business-logic │ └── build.gradle.kts │ ├── data-model │ └── build.gradle.kts │ └── settings.gradle.kts ├── 03_Plugins ├── README.MD ├── my-build-logic │ ├── java-plugins │ │ ├── build.gradle.kts │ │ └── src │ │ │ └── main │ │ │ └── kotlin │ │ │ ├── my-java-application.gradle.kts │ │ │ └── my-java-library.gradle.kts │ └── settings.gradle.kts ├── my-other-project │ └── .gitignore └── my-project │ ├── app │ └── build.gradle.kts │ ├── business-logic │ └── build.gradle.kts │ ├── data-model │ └── build.gradle.kts │ └── settings.gradle.kts ├── 04_Tasks ├── README.MD ├── my-build-logic │ ├── java-plugins │ │ ├── build.gradle.kts │ │ └── src │ │ │ └── main │ │ │ └── kotlin │ │ │ ├── my-java-application.gradle.kts │ │ │ └── my-java-library.gradle.kts │ └── settings.gradle.kts ├── my-other-project │ └── .gitignore └── my-project │ ├── app │ ├── build.gradle.kts │ └── src │ │ └── main │ │ └── java │ │ └── myproject │ │ └── MyApplication.java │ ├── business-logic │ ├── build.gradle.kts │ └── src │ │ └── main │ │ └── java │ │ └── myproject │ │ └── services │ │ └── Service.java │ ├── data-model │ ├── build.gradle.kts │ └── src │ │ └── main │ │ └── java │ │ └── myproject │ │ └── data │ │ └── MessageModel.java │ ├── gradle.properties │ └── settings.gradle.kts ├── 05_Lifecycle_Tasks ├── README.MD ├── my-build-logic │ ├── build.gradle.kts │ ├── java-plugins │ │ ├── build.gradle.kts │ │ └── src │ │ │ └── main │ │ │ └── kotlin │ │ │ ├── my-java-application.gradle.kts │ │ │ ├── my-java-base.gradle.kts │ │ │ └── my-java-library.gradle.kts │ └── settings.gradle.kts ├── my-other-project │ ├── build.gradle.kts │ └── settings.gradle.kts └── my-project │ ├── app │ ├── build.gradle.kts │ └── src │ │ └── main │ │ └── java │ │ └── myproject │ │ └── MyApplication.java │ ├── build.gradle.kts │ ├── business-logic │ ├── build.gradle.kts │ └── src │ │ ├── main │ │ └── java │ │ │ └── myproject │ │ │ └── services │ │ │ └── Service.java │ │ └── test │ │ └── java │ │ └── myproject │ │ └── data │ │ └── ServiceTest.java │ ├── config │ └── checkstyle │ │ └── checkstyle.xml │ ├── data-model │ ├── build.gradle.kts │ └── src │ │ └── main │ │ └── java │ │ └── myproject │ │ └── data │ │ └── MessageModel.java │ ├── gradle.properties │ └── settings.gradle.kts ├── 06_Configuring_Task_Inputs_And_Outputs ├── README.MD ├── my-build-logic │ ├── java-plugins │ │ ├── build.gradle.kts │ │ └── src │ │ │ └── main │ │ │ └── kotlin │ │ │ ├── my-java-application.gradle.kts │ │ │ ├── my-java-base.gradle.kts │ │ │ └── my-java-library.gradle.kts │ └── settings.gradle.kts ├── my-other-project │ └── .gitignore └── my-project │ ├── app │ ├── build.gradle.kts │ ├── run.sh │ └── src │ │ └── main │ │ └── java │ │ └── myproject │ │ └── MyApplication.java │ ├── business-logic │ ├── build.gradle.kts │ └── src │ │ └── main │ │ └── java │ │ └── myproject │ │ └── services │ │ └── Service.java │ ├── data-model │ ├── build.gradle.kts │ └── src │ │ └── main │ │ └── java │ │ └── myproject │ │ └── data │ │ └── MessageModel.java │ └── settings.gradle.kts ├── 07_Implementing_Tasks_and_Extensions ├── README.MD ├── my-build-logic │ ├── java-plugins │ │ ├── build.gradle.kts │ │ └── src │ │ │ └── main │ │ │ └── kotlin │ │ │ ├── my-java-application.gradle.kts │ │ │ ├── my-java-base.gradle.kts │ │ │ ├── my-java-library.gradle.kts │ │ │ └── myproject │ │ │ └── tasks │ │ │ ├── GenerateStartScript.kt │ │ │ └── MyAppExtension.kt │ └── settings.gradle.kts ├── my-other-project │ └── .gitignore └── my-project │ ├── app │ ├── build.gradle.kts │ └── src │ │ └── main │ │ └── java │ │ └── myproject │ │ └── MyApplication.java │ ├── business-logic │ ├── build.gradle.kts │ └── src │ │ └── main │ │ └── java │ │ └── myproject │ │ └── services │ │ └── Service.java │ ├── data-model │ ├── build.gradle.kts │ └── src │ │ └── main │ │ └── java │ │ └── myproject │ │ └── data │ │ └── MessageModel.java │ └── settings.gradle.kts ├── 08_Declaring_Dependencis ├── README.MD ├── my-build-logic │ ├── java-plugins │ │ ├── build.gradle.kts │ │ └── src │ │ │ └── main │ │ │ └── kotlin │ │ │ ├── my-java-application.gradle.kts │ │ │ ├── my-java-base.gradle.kts │ │ │ └── my-java-library.gradle.kts │ └── settings.gradle.kts ├── my-other-project │ ├── settings.gradle.kts │ └── shared-utils │ │ ├── build.gradle.kts │ │ └── src │ │ └── main │ │ └── java │ │ └── myproject │ │ └── shared │ │ └── util │ │ └── EmojiEncodeUtil.java └── my-project │ ├── app │ ├── build.gradle.kts │ └── src │ │ └── main │ │ └── java │ │ └── myproject │ │ └── MyApplication.java │ ├── business-logic │ ├── build.gradle.kts │ └── src │ │ └── main │ │ └── java │ │ └── myproject │ │ └── services │ │ └── Service.java │ ├── data-model │ ├── build.gradle.kts │ └── src │ │ └── main │ │ └── java │ │ └── myproject │ │ └── data │ │ └── MessageModel.java │ └── settings.gradle.kts ├── 09_Centralizing_Dependency_Versions ├── A_Dependency_Constrains_in_Convention_Plugin │ ├── my-build-logic │ │ ├── java-plugins │ │ │ ├── build.gradle.kts │ │ │ └── src │ │ │ │ └── main │ │ │ │ └── kotlin │ │ │ │ ├── my-java-application.gradle.kts │ │ │ │ ├── my-java-base.gradle.kts │ │ │ │ └── my-java-library.gradle.kts │ │ └── settings.gradle.kts │ ├── my-other-project │ │ ├── settings.gradle.kts │ │ └── shared-utils │ │ │ ├── build.gradle.kts │ │ │ └── src │ │ │ └── main │ │ │ └── java │ │ │ └── mypproject │ │ │ └── shared │ │ │ └── util │ │ │ └── EmojiEncodeUtil.java │ └── my-project │ │ ├── app │ │ ├── build.gradle.kts │ │ └── src │ │ │ └── main │ │ │ └── java │ │ │ └── myproject │ │ │ └── MyApplication.java │ │ ├── business-logic │ │ ├── build.gradle.kts │ │ └── src │ │ │ └── main │ │ │ └── java │ │ │ └── myproject │ │ │ └── services │ │ │ └── Service.java │ │ ├── data-model │ │ ├── build.gradle.kts │ │ └── src │ │ │ └── main │ │ │ └── java │ │ │ └── myproject │ │ │ └── data │ │ │ └── MessageModel.java │ │ └── settings.gradle.kts ├── B_Platform_Project │ ├── my-build-logic │ │ ├── java-plugins │ │ │ ├── build.gradle.kts │ │ │ └── src │ │ │ │ └── main │ │ │ │ └── kotlin │ │ │ │ ├── my-java-application.gradle.kts │ │ │ │ ├── my-java-base.gradle.kts │ │ │ │ └── my-java-library.gradle.kts │ │ └── settings.gradle.kts │ ├── my-other-project │ │ ├── settings.gradle.kts │ │ └── shared-utils │ │ │ ├── build.gradle.kts │ │ │ └── src │ │ │ └── main │ │ │ └── java │ │ │ └── mypproject │ │ │ └── shared │ │ │ └── util │ │ │ └── EmojiEncodeUtil.java │ ├── my-platform │ │ ├── settings.gradle.kts │ │ └── shared-platform │ │ │ └── build.gradle.kts │ └── my-project │ │ ├── app │ │ ├── build.gradle.kts │ │ └── src │ │ │ └── main │ │ │ └── java │ │ │ └── myproject │ │ │ └── MyApplication.java │ │ ├── business-logic │ │ ├── build.gradle.kts │ │ └── src │ │ │ └── main │ │ │ └── java │ │ │ └── myproject │ │ │ └── services │ │ │ └── Service.java │ │ ├── data-model │ │ ├── build.gradle.kts │ │ └── src │ │ │ └── main │ │ │ └── java │ │ │ └── myproject │ │ │ └── data │ │ │ └── MessageModel.java │ │ └── settings.gradle.kts ├── C_Version_Catalog │ ├── my-build-logic │ │ ├── java-plugins │ │ │ ├── build.gradle.kts │ │ │ └── src │ │ │ │ └── main │ │ │ │ └── kotlin │ │ │ │ ├── my-java-application.gradle.kts │ │ │ │ ├── my-java-base.gradle.kts │ │ │ │ └── my-java-library.gradle.kts │ │ └── settings.gradle.kts │ ├── my-other-project │ │ ├── settings.gradle.kts │ │ └── shared-utils │ │ │ ├── build.gradle.kts │ │ │ └── src │ │ │ └── main │ │ │ └── java │ │ │ └── mypproject │ │ │ └── shared │ │ │ └── util │ │ │ └── EmojiEncodeUtil.java │ └── my-project │ │ ├── app │ │ ├── build.gradle.kts │ │ └── src │ │ │ └── main │ │ │ └── java │ │ │ └── myproject │ │ │ └── MyApplication.java │ │ ├── business-logic │ │ ├── build.gradle.kts │ │ └── src │ │ │ └── main │ │ │ └── java │ │ │ └── myproject │ │ │ └── services │ │ │ └── Service.java │ │ ├── data-model │ │ ├── build.gradle.kts │ │ └── src │ │ │ └── main │ │ │ └── java │ │ │ └── myproject │ │ │ └── data │ │ │ └── MessageModel.java │ │ ├── gradle │ │ └── libs.versions.toml │ │ └── settings.gradle.kts ├── D_Dependency_Locking │ ├── my-build-logic │ │ ├── java-plugins │ │ │ ├── build.gradle.kts │ │ │ └── src │ │ │ │ └── main │ │ │ │ └── kotlin │ │ │ │ ├── my-java-application.gradle.kts │ │ │ │ ├── my-java-base.gradle.kts │ │ │ │ ├── my-java-library.gradle.kts │ │ │ │ └── my-root-project.gradle.kts │ │ └── settings.gradle.kts │ ├── my-other-project │ │ ├── build.gradle.kts │ │ ├── settings.gradle.kts │ │ └── shared-utils │ │ │ ├── build.gradle.kts │ │ │ ├── gradle.lockfile │ │ │ └── src │ │ │ └── main │ │ │ └── java │ │ │ └── mypproject │ │ │ └── shared │ │ │ └── util │ │ │ └── EmojiEncodeUtil.java │ └── my-project │ │ ├── app │ │ ├── build.gradle.kts │ │ ├── gradle.lockfile │ │ └── src │ │ │ └── main │ │ │ └── java │ │ │ └── myproject │ │ │ └── MyApplication.java │ │ ├── build.gradle.kts │ │ ├── business-logic │ │ ├── build.gradle.kts │ │ ├── gradle.lockfile │ │ └── src │ │ │ └── main │ │ │ └── java │ │ │ └── myproject │ │ │ └── services │ │ │ └── Service.java │ │ ├── data-model │ │ ├── build.gradle.kts │ │ ├── gradle.lockfile │ │ └── src │ │ │ └── main │ │ │ └── java │ │ │ └── myproject │ │ │ └── data │ │ │ └── MessageModel.java │ │ └── settings.gradle.kts └── README.MD ├── 10_Dependency_Version_Conflicts ├── README.MD ├── my-build-logic │ ├── java-plugins │ │ ├── build.gradle.kts │ │ └── src │ │ │ └── main │ │ │ └── kotlin │ │ │ ├── my-java-application.gradle.kts │ │ │ ├── my-java-base.gradle.kts │ │ │ └── my-java-library.gradle.kts │ └── settings.gradle.kts ├── my-other-project │ └── settings.gradle.kts └── my-project │ ├── app │ ├── build.gradle.kts │ └── src │ │ └── main │ │ └── java │ │ └── myproject │ │ └── MyApplication.java │ ├── business-logic │ ├── build.gradle.kts │ └── src │ │ ├── main │ │ └── java │ │ │ └── myproject │ │ │ └── services │ │ │ └── Service.java │ │ └── test │ │ └── java │ │ └── myproject │ │ └── data │ │ └── ServiceTest.java │ ├── data-model │ ├── build.gradle.kts │ └── src │ │ └── main │ │ └── java │ │ └── myproject │ │ └── data │ │ └── MessageModel.java │ └── settings.gradle.kts ├── 11_Capability_Conflicts ├── README.MD ├── my-build-logic │ ├── java-plugins │ │ ├── build.gradle.kts │ │ └── src │ │ │ └── main │ │ │ └── kotlin │ │ │ ├── metadata-rules.gradle.kts │ │ │ ├── my-java-application.gradle.kts │ │ │ ├── my-java-base.gradle.kts │ │ │ ├── my-java-library.gradle.kts │ │ │ └── myproject │ │ │ └── metadatarules │ │ │ └── Slf4JImplRule.kt │ └── settings.gradle.kts ├── my-other-project │ └── settings.gradle.kts ├── my-project │ ├── app │ │ ├── build.gradle.kts │ │ └── src │ │ │ └── main │ │ │ └── java │ │ │ └── myproject │ │ │ └── MyApplication.java │ ├── business-logic │ │ ├── build.gradle.kts │ │ └── src │ │ │ ├── main │ │ │ └── java │ │ │ │ └── myproject │ │ │ │ └── services │ │ │ │ └── Service.java │ │ │ └── test │ │ │ └── java │ │ │ └── myproject │ │ │ └── data │ │ │ └── ServiceTest.java │ ├── data-model │ │ ├── build.gradle.kts │ │ └── src │ │ │ └── main │ │ │ └── java │ │ │ └── myproject │ │ │ └── data │ │ │ └── MessageModel.java │ └── settings.gradle.kts └── patched-repo │ ├── ch │ └── qos │ │ └── logback │ │ └── logback-classic │ │ └── 1.2.5 │ │ ├── logback-classic-1.2.5.jar │ │ ├── logback-classic-1.2.5.module │ │ └── logback-classic-1.2.5.pom │ └── org │ └── slf4j │ └── slf4j-simple │ └── 1.7.32 │ ├── slf4j-simple-1.7.32.jar │ ├── slf4j-simple-1.7.32.module │ └── slf4j-simple-1.7.32.pom ├── 12_Publishing_Libraries ├── README.MD ├── my-build-logic │ ├── java-plugins │ │ ├── build.gradle.kts │ │ └── src │ │ │ └── main │ │ │ └── kotlin │ │ │ ├── my-java-application.gradle.kts │ │ │ ├── my-java-base.gradle.kts │ │ │ └── my-java-library.gradle.kts │ └── settings.gradle.kts ├── my-other-project │ ├── settings.gradle.kts │ └── shared-utils │ │ ├── build.gradle.kts │ │ └── src │ │ └── main │ │ └── java │ │ └── mypproject │ │ └── shared │ │ └── util │ │ └── EmojiEncodeUtil.java └── my-project │ ├── app │ ├── build.gradle.kts │ └── src │ │ └── main │ │ └── java │ │ └── myproject │ │ └── MyApplication.java │ ├── business-logic │ ├── build.gradle.kts │ └── src │ │ └── main │ │ └── java │ │ └── myproject │ │ └── services │ │ └── Service.java │ ├── data-model │ ├── build.gradle.kts │ └── src │ │ └── main │ │ └── java │ │ └── myproject │ │ └── data │ │ └── MessageModel.java │ └── settings.gradle.kts ├── 13_Aggregating_Custom_Artifacts ├── README.MD ├── my-build-logic │ ├── java-plugins │ │ ├── build.gradle.kts │ │ └── src │ │ │ └── main │ │ │ └── kotlin │ │ │ ├── my-java-application.gradle.kts │ │ │ ├── my-java-base.gradle.kts │ │ │ └── my-java-library.gradle.kts │ └── settings.gradle.kts ├── my-other-project │ └── settings.gradle.kts └── my-project │ ├── app │ ├── build.gradle.kts │ └── src │ │ └── main │ │ └── java │ │ └── myproject │ │ └── MyApplication.java │ ├── business-logic │ ├── build.gradle.kts │ └── src │ │ └── main │ │ └── java │ │ └── myproject │ │ └── services │ │ └── Service.java │ ├── data-model │ ├── build.gradle.kts │ └── src │ │ └── main │ │ └── java │ │ └── myproject │ │ └── data │ │ └── MessageModel.java │ └── settings.gradle.kts ├── 14_Settings_Plugins ├── README.MD ├── my-build-logic │ ├── java-plugins │ │ ├── build.gradle.kts │ │ └── src │ │ │ └── main │ │ │ └── kotlin │ │ │ ├── my-java-application.gradle.kts │ │ │ ├── my-java-base.gradle.kts │ │ │ └── my-java-library.gradle.kts │ ├── settings.gradle.kts │ └── structure-plugins │ │ ├── build.gradle.kts │ │ └── src │ │ └── main │ │ └── kotlin │ │ └── my-project-structure.settings.gradle.kts ├── my-other-project │ ├── settings.gradle.kts │ └── shared-utils │ │ ├── build.gradle.kts │ │ └── src │ │ └── main │ │ └── java │ │ └── myproject │ │ └── shared │ │ └── util │ │ └── EmojiEncodeUtil.java └── my-project │ ├── app │ ├── build.gradle.kts │ └── src │ │ └── main │ │ └── java │ │ └── myproject │ │ └── MyApplication.java │ ├── business-logic │ ├── build.gradle.kts │ └── src │ │ └── main │ │ └── java │ │ └── myproject │ │ └── services │ │ └── Service.java │ ├── data-model │ ├── build.gradle.kts │ └── src │ │ └── main │ │ └── java │ │ └── myproject │ │ └── data │ │ └── MessageModel.java │ └── settings.gradle.kts ├── 16_Source_Sets ├── README.MD ├── my-android-project │ ├── app-android │ │ ├── build.gradle.kts │ │ └── src │ │ │ └── main │ │ │ ├── AndroidManifest.xml │ │ │ └── java │ │ │ └── myproject │ │ │ └── shared │ │ │ └── util │ │ │ └── EmojiEncodeUtil.java │ ├── gradle.properties │ └── settings.gradle.kts ├── my-build-logic │ ├── android-plugins │ │ ├── build.gradle.kts │ │ └── src │ │ │ └── main │ │ │ └── kotlin │ │ │ └── my-android-application.gradle.kts │ ├── java-plugins │ │ ├── build.gradle.kts │ │ └── src │ │ │ └── main │ │ │ └── kotlin │ │ │ ├── my-java-application.gradle.kts │ │ │ ├── my-java-base.gradle.kts │ │ │ └── my-java-library.gradle.kts │ ├── kotlin-plugins │ │ ├── build.gradle.kts │ │ └── src │ │ │ └── main │ │ │ └── kotlin │ │ │ └── my-kotlin-multiplatform-lib.gradle.kts │ ├── settings.gradle.kts │ └── structure-plugins │ │ ├── build.gradle.kts │ │ └── src │ │ └── main │ │ └── kotlin │ │ └── my-project-structure.settings.gradle.kts ├── my-kotlin-multi-platform-project │ ├── gradle.properties │ ├── settings.gradle.kts │ └── utils-kotlin │ │ ├── build.gradle.kts │ │ └── src │ │ └── commonMain │ │ └── kotlin │ │ └── myproject │ │ └── shared │ │ └── util │ │ └── EncodeUtils.kt └── my-project │ ├── app │ ├── build.gradle.kts │ └── src │ │ ├── extraFeature │ │ ├── groovy │ │ │ └── .gitignore │ │ └── java │ │ │ └── myproject │ │ │ └── extra │ │ │ └── ExtraFeature.java │ │ ├── main │ │ ├── groovy │ │ │ └── .gitignore │ │ ├── java │ │ │ └── myproject │ │ │ │ └── MyApplication.java │ │ ├── java17 │ │ │ └── myproject │ │ │ │ └── MyApplication.java │ │ └── resources │ │ │ └── myproject │ │ │ └── message.txt │ │ └── test │ │ ├── groovy │ │ └── .gitignore │ │ └── java │ │ └── myproject │ │ └── MyApplicationTest.java │ ├── business-logic │ ├── build.gradle.kts │ └── src │ │ └── main │ │ └── java │ │ └── myproject │ │ └── services │ │ └── Service.java │ ├── data-model │ ├── build.gradle.kts │ └── src │ │ └── main │ │ └── java │ │ └── myproject │ │ └── data │ │ └── MessageModel.java │ ├── gradle.properties │ └── settings.gradle.kts ├── 17_Feature_Variants ├── README.MD ├── my-build-logic │ ├── java-plugins │ │ ├── build.gradle.kts │ │ └── src │ │ │ └── main │ │ │ └── kotlin │ │ │ ├── my-java-application.gradle.kts │ │ │ ├── my-java-base.gradle.kts │ │ │ └── my-java-library.gradle.kts │ ├── settings.gradle.kts │ └── structure-plugins │ │ ├── build.gradle.kts │ │ └── src │ │ └── main │ │ └── kotlin │ │ └── my-project-structure.settings.gradle.kts └── my-project │ ├── app │ ├── build.gradle.kts │ ├── data │ │ ├── message.json │ │ └── message.xml │ └── src │ │ └── main │ │ └── java │ │ └── myproject │ │ └── MyApplication.java │ ├── business-logic │ ├── build.gradle.kts │ └── src │ │ └── main │ │ └── java │ │ └── myproject │ │ └── services │ │ └── Service.java │ ├── data-model │ ├── build.gradle.kts │ └── src │ │ ├── json │ │ └── java │ │ │ └── myproject │ │ │ └── data │ │ │ └── serialization │ │ │ └── Serializer.java │ │ ├── main │ │ └── java │ │ │ └── myproject │ │ │ └── data │ │ │ └── MessageModel.java │ │ └── xml │ │ └── java │ │ └── myproject │ │ └── data │ │ └── serialization │ │ └── Serializer.java │ └── settings.gradle.kts ├── 18_Configuring_Testing ├── README.MD ├── my-build-logic │ ├── java-plugins │ │ ├── build.gradle.kts │ │ └── src │ │ │ └── main │ │ │ └── kotlin │ │ │ ├── my-java-application.gradle.kts │ │ │ ├── my-java-base.gradle.kts │ │ │ └── my-java-library.gradle.kts │ ├── settings.gradle.kts │ └── structure-plugins │ │ ├── build.gradle.kts │ │ └── src │ │ └── main │ │ └── kotlin │ │ └── my-project-structure.settings.gradle.kts └── my-project │ ├── app │ ├── build.gradle.kts │ └── src │ │ └── main │ │ └── java │ │ └── myproject │ │ └── MyApplication.java │ ├── business-logic │ ├── build.gradle.kts │ └── src │ │ ├── integrationTest │ │ └── java │ │ │ └── myproject │ │ │ └── services │ │ │ └── test │ │ │ └── ServiceIntegrationTest.java │ │ ├── main │ │ └── java │ │ │ └── myproject │ │ │ └── services │ │ │ └── Service.java │ │ └── test │ │ └── java │ │ └── myproject │ │ └── services │ │ └── ServiceTest.java │ ├── data-model │ ├── build.gradle.kts │ └── src │ │ └── main │ │ └── java │ │ └── myproject │ │ └── data │ │ └── MessageModel.java │ └── settings.gradle.kts ├── 19_The_Test_Task ├── README.MD ├── my-build-logic │ ├── java-plugins │ │ ├── build.gradle.kts │ │ └── src │ │ │ └── main │ │ │ └── kotlin │ │ │ ├── my-java-application.gradle.kts │ │ │ ├── my-java-base.gradle.kts │ │ │ └── my-java-library.gradle.kts │ ├── settings.gradle.kts │ └── structure-plugins │ │ ├── build.gradle.kts │ │ └── src │ │ └── main │ │ └── kotlin │ │ └── my-project-structure.settings.gradle.kts └── my-project │ ├── app │ ├── build.gradle.kts │ └── src │ │ └── main │ │ └── java │ │ └── myproject │ │ └── MyApplication.java │ ├── business-logic │ ├── build.gradle.kts │ └── src │ │ ├── main │ │ └── java │ │ │ └── myproject │ │ │ └── services │ │ │ └── Service.java │ │ └── test │ │ └── java │ │ └── myproject │ │ └── services │ │ ├── Service0Test.java │ │ ├── Service1Test.java │ │ ├── Service2Test.java │ │ ├── Service3Test.java │ │ ├── Service4Test.java │ │ ├── Service5Test.java │ │ ├── Service6Test.java │ │ ├── Service7Test.java │ │ ├── Service8Test.java │ │ ├── Service9Test.java │ │ ├── ServiceATest.java │ │ ├── ServiceBTest.java │ │ └── ServiceCTest.java │ ├── data-model │ ├── build.gradle.kts │ └── src │ │ └── main │ │ └── java │ │ └── myproject │ │ └── data │ │ └── MessageModel.java │ ├── gradle.properties │ └── settings.gradle.kts ├── 20_Test_Fixtures ├── README.MD ├── my-build-logic │ ├── java-plugins │ │ ├── build.gradle.kts │ │ └── src │ │ │ └── main │ │ │ └── kotlin │ │ │ ├── my-java-application.gradle.kts │ │ │ ├── my-java-base.gradle.kts │ │ │ └── my-java-library.gradle.kts │ ├── settings.gradle.kts │ └── structure-plugins │ │ ├── build.gradle.kts │ │ └── src │ │ └── main │ │ └── kotlin │ │ └── my-project-structure.settings.gradle.kts └── my-project │ ├── app │ ├── build.gradle.kts │ ├── data │ │ ├── message.json │ │ └── message.xml │ └── src │ │ └── main │ │ └── java │ │ └── myproject │ │ └── MyApplication.java │ ├── business-logic │ ├── build.gradle.kts │ └── src │ │ ├── main │ │ └── java │ │ │ └── myproject │ │ │ └── services │ │ │ └── Service.java │ │ └── test │ │ └── java │ │ └── myproject │ │ └── services │ │ └── ServiceTest.java │ ├── data-model │ ├── build.gradle.kts │ └── src │ │ ├── main │ │ └── java │ │ │ └── myproject │ │ │ └── data │ │ │ └── MessageModel.java │ │ ├── test │ │ └── java │ │ │ └── myproject │ │ │ └── data │ │ │ └── test │ │ │ └── MessageModelTest.java │ │ └── testFixtures │ │ └── java │ │ └── myproject │ │ └── data │ │ └── test │ │ └── MessageModelFixture.java │ └── settings.gradle.kts ├── 21_Test_and_Code_Coverage_Reporting ├── README.MD ├── my-build-logic │ ├── java-plugins │ │ ├── build.gradle.kts │ │ └── src │ │ │ └── main │ │ │ └── kotlin │ │ │ ├── my-java-application.gradle.kts │ │ │ ├── my-java-base.gradle.kts │ │ │ └── my-java-library.gradle.kts │ ├── settings.gradle.kts │ └── structure-plugins │ │ ├── build.gradle.kts │ │ └── src │ │ └── main │ │ └── kotlin │ │ └── my-project-structure.settings.gradle.kts └── my-project │ ├── app │ ├── build.gradle.kts │ └── src │ │ └── main │ │ └── java │ │ └── myproject │ │ └── MyApplication.java │ ├── business-logic │ ├── build.gradle.kts │ └── src │ │ ├── integrationTest │ │ └── java │ │ │ └── myproject │ │ │ └── services │ │ │ └── ServiceIntegrationTest.java │ │ ├── main │ │ └── java │ │ │ └── myproject │ │ │ └── services │ │ │ └── Service.java │ │ └── test │ │ └── java │ │ └── myproject │ │ └── services │ │ ├── ServiceSlowTest.java │ │ └── ServiceTest.java │ ├── data-model │ ├── build.gradle.kts │ └── src │ │ ├── main │ │ └── java │ │ │ └── myproject │ │ │ └── data │ │ │ └── MessageModel.java │ │ └── test │ │ └── java │ │ └── myproject │ │ └── data │ │ └── MessageModelTest.java │ └── settings.gradle.kts ├── 22_The_JavaCompile_Task ├── README.MD ├── my-build-logic │ ├── java-plugins │ │ ├── build.gradle.kts │ │ └── src │ │ │ └── main │ │ │ └── kotlin │ │ │ ├── my-java-application.gradle.kts │ │ │ ├── my-java-base.gradle.kts │ │ │ └── my-java-library.gradle.kts │ ├── settings.gradle.kts │ └── structure-plugins │ │ ├── build.gradle.kts │ │ └── src │ │ └── main │ │ └── kotlin │ │ └── my-project-structure.settings.gradle.kts └── my-project │ ├── app │ ├── build.gradle.kts │ └── src │ │ └── main │ │ └── java │ │ └── myproject │ │ └── MyApplication.java │ ├── business-logic │ ├── build.gradle.kts │ └── src │ │ ├── main │ │ └── java │ │ │ └── myproject │ │ │ └── services │ │ │ └── Service.java │ │ └── test │ │ └── java │ │ └── myproject │ │ └── services │ │ └── ServiceTest.java │ ├── data-model │ ├── build.gradle.kts │ └── src │ │ ├── main │ │ └── java │ │ │ └── myproject │ │ │ └── data │ │ │ └── MessageModel.java │ │ └── test │ │ └── java │ │ └── myproject │ │ └── data │ │ └── MessageModelTest.java │ ├── gradle.properties │ └── settings.gradle.kts ├── 23_Caching ├── README.MD ├── my-build-logic │ ├── java-plugins │ │ ├── build.gradle.kts │ │ └── src │ │ │ └── main │ │ │ └── kotlin │ │ │ ├── my-java-application.gradle.kts │ │ │ ├── my-java-base.gradle.kts │ │ │ └── my-java-library.gradle.kts │ └── settings.gradle.kts └── my-project │ ├── app │ ├── build.gradle.kts │ └── src │ │ └── main │ │ └── java │ │ └── myproject │ │ └── MyApplication.java │ ├── business-logic │ ├── build.gradle.kts │ └── src │ │ └── main │ │ └── java │ │ └── myproject │ │ └── services │ │ └── Service.java │ ├── data-model │ ├── build.gradle.kts │ └── src │ │ └── main │ │ └── java │ │ └── myproject │ │ └── data │ │ └── MessageModel.java │ ├── gradle.properties │ └── settings.gradle.kts ├── 24_Kotlin_DSL_and_Groovy_DSL ├── README.MD ├── my-build-logic │ ├── java-plugins │ │ ├── build.gradle.kts │ │ └── src │ │ │ └── main │ │ │ └── kotlin │ │ │ ├── my-java-application.gradle.kts │ │ │ ├── my-java-base.gradle.kts │ │ │ └── my-java-library.gradle.kts │ ├── settings.gradle.kts │ └── structure-plugins │ │ ├── build.gradle.kts │ │ └── src │ │ └── main │ │ └── kotlin │ │ └── my-project-structure.settings.gradle.kts └── my-project │ ├── app │ ├── build.gradle.kts │ └── src │ │ └── main │ │ └── java │ │ └── myproject │ │ └── MyApplication.java │ ├── business-logic │ ├── build.gradle.kts │ └── src │ │ └── main │ │ └── java │ │ └── myproject │ │ └── services │ │ └── Service.java │ ├── data-model │ ├── build.gradle.kts │ └── src │ │ └── main │ │ └── java │ │ └── myproject │ │ └── data │ │ └── MessageModel.java │ └── settings.gradle.kts ├── 25_Using_Java_to_configure_builds ├── README.MD ├── my-build-logic │ ├── java-plugins │ │ ├── build.gradle.kts │ │ └── src │ │ │ └── main │ │ │ └── java │ │ │ └── myproject │ │ │ └── gradle │ │ │ ├── GenerateStartScript.java │ │ │ ├── MyAppExtension.java │ │ │ ├── MyJavaApplicationPlugin.java │ │ │ ├── MyJavaBasePlugin.java │ │ │ └── MyJavaLibraryPlugin.java │ ├── settings.gradle.kts │ └── structure-plugins │ │ ├── build.gradle.kts │ │ └── src │ │ └── main │ │ └── java │ │ └── myproject │ │ └── gradle │ │ └── MyProjectStructureSettingsPlugin.java └── my-project │ ├── app │ ├── build.gradle.kts │ └── src │ │ └── main │ │ └── java │ │ └── myproject │ │ └── MyApplication.java │ ├── business-logic │ ├── build.gradle.kts │ └── src │ │ └── main │ │ └── java │ │ └── myproject │ │ └── services │ │ └── Service.java │ ├── data-model │ ├── build.gradle.kts │ └── src │ │ └── main │ │ └── java │ │ └── myproject │ │ └── data │ │ └── MessageModel.java │ └── settings.gradle.kts ├── 26_The_Classpath ├── README.MD └── my-project │ ├── build.gradle.kts │ ├── settings.gradle.kts │ └── src │ └── mypackage │ ├── App.java │ └── AppTest.java ├── 27_Multiple_Compile_Classpaths ├── README.MD └── my-project │ ├── app │ ├── build.gradle.kts │ └── src │ │ └── mypackage │ │ └── App.java │ ├── module │ ├── build.gradle.kts │ └── src │ │ └── mypackage │ │ └── modulea │ │ └── ModuleA.java │ └── settings.gradle.kts ├── 28_Dependency_Analysis_Plugin ├── README.MD ├── my-build-logic │ ├── java-plugins │ │ ├── build.gradle.kts │ │ └── src │ │ │ └── main │ │ │ └── kotlin │ │ │ ├── my-java-application.gradle.kts │ │ │ ├── my-java-base.gradle.kts │ │ │ ├── my-java-library.gradle.kts │ │ │ └── my-root.gradle.kts │ └── settings.gradle.kts └── my-project │ ├── app │ ├── build.gradle.kts │ └── src │ │ └── main │ │ └── java │ │ └── mypackage │ │ └── App.java │ ├── build.gradle.kts │ ├── module │ ├── build.gradle.kts │ └── src │ │ └── main │ │ └── java │ │ └── mypackage │ │ └── modulea │ │ └── ModuleA.java │ └── settings.gradle.kts ├── 29_Classpath_Collisions ├── README.MD ├── my-build-logic │ ├── java-plugins │ │ ├── build.gradle.kts │ │ └── src │ │ │ └── main │ │ │ └── kotlin │ │ │ ├── my-java-application.gradle.kts │ │ │ ├── my-java-base.gradle.kts │ │ │ └── my-java-library.gradle.kts │ └── settings.gradle.kts └── my-project │ ├── app │ ├── build.gradle.kts │ └── src │ │ └── main │ │ └── java │ │ └── mypackage │ │ └── App.java │ ├── libs │ ├── activation-1.1.1.jar │ ├── activation-1.1.jar │ └── jakarta.activation-api-1.2.2.jar │ ├── module │ ├── build.gradle.kts │ └── src │ │ └── main │ │ └── java │ │ └── mypackage │ │ └── modulea │ │ └── ModuleA.java │ └── settings.gradle.kts ├── 30_Security_Vulnerabilities ├── README.MD ├── my-build-logic │ ├── java-plugins │ │ ├── build.gradle.kts │ │ └── src │ │ │ └── main │ │ │ └── kotlin │ │ │ ├── my-java-application.gradle.kts │ │ │ ├── my-java-base.gradle.kts │ │ │ └── my-java-library.gradle.kts │ └── settings.gradle.kts └── my-project │ ├── app │ ├── build.gradle.kts │ └── src │ │ └── main │ │ └── java │ │ └── mypackage │ │ └── App.java │ ├── module │ ├── build.gradle.kts │ └── src │ │ └── main │ │ └── java │ │ └── mypackage │ │ └── modulea │ │ └── ModuleA.java │ └── settings.gradle.kts ├── 31_The_Module_Path ├── README.MD ├── my-build-logic │ ├── java-plugins │ │ ├── build.gradle.kts │ │ └── src │ │ │ └── main │ │ │ └── kotlin │ │ │ ├── my-java-application.gradle.kts │ │ │ ├── my-java-base.gradle.kts │ │ │ └── my-java-library.gradle.kts │ └── settings.gradle.kts └── my-project │ ├── app │ ├── build.gradle.kts │ └── src │ │ └── main │ │ └── java │ │ ├── module-info.java │ │ └── mypackage │ │ └── App.java │ ├── modulea │ ├── build.gradle.kts │ └── src │ │ └── main │ │ └── java │ │ ├── module-info.java │ │ └── mypackage │ │ └── modulea │ │ └── ModuleA.java │ └── settings.gradle.kts ├── 32_Artifact_Transforms ├── README.MD ├── my-build-logic │ ├── java-plugins │ │ ├── build.gradle.kts │ │ └── src │ │ │ └── main │ │ │ ├── kotlin │ │ │ ├── my-java-application.gradle.kts │ │ │ ├── my-java-base.gradle.kts │ │ │ ├── my-java-library.gradle.kts │ │ │ └── org │ │ │ │ └── example │ │ │ │ └── JavaModuleTransform.kt │ │ │ └── resources │ │ │ └── org │ │ │ └── example │ │ │ ├── commons-lang3-3.12.0 │ │ │ └── module-info.class │ │ │ └── commons-text-1.10.0 │ │ │ └── module-info.class │ └── settings.gradle.kts └── my-project │ ├── app │ ├── build.gradle.kts │ └── src │ │ └── main │ │ └── java │ │ ├── module-info.java │ │ └── org │ │ └── example │ │ └── App.java │ └── settings.gradle.kts ├── 33_Classpath_and_Module_Path_in_Testing ├── README.MD ├── my-build-logic │ ├── java-plugins │ │ ├── build.gradle.kts │ │ └── src │ │ │ └── main │ │ │ └── kotlin │ │ │ ├── my-java-application.gradle.kts │ │ │ ├── my-java-base.gradle.kts │ │ │ └── my-java-library.gradle.kts │ └── settings.gradle.kts └── my-project │ ├── app │ ├── build.gradle.kts │ └── src │ │ ├── main │ │ └── java │ │ │ ├── module-info.java │ │ │ └── org │ │ │ └── example │ │ │ └── app │ │ │ └── App.java │ │ └── test │ │ ├── java │ │ └── org │ │ │ └── example │ │ │ └── app │ │ │ └── AppTest.java │ │ └── resources │ │ └── test-data.txt │ └── settings.gradle.kts ├── 34_Properties_and_Providers ├── README.MD ├── my-build-logic │ ├── java-plugins │ │ ├── build.gradle.kts │ │ └── src │ │ │ └── main │ │ │ └── kotlin │ │ │ ├── my-java-application.gradle.kts │ │ │ └── org │ │ │ └── example │ │ │ ├── ApplicationReportTask.kt │ │ │ └── MyEnum.kt │ └── settings.gradle.kts └── my-project │ ├── app │ ├── build.gradle.kts │ ├── src │ │ └── main │ │ │ └── java │ │ │ └── org │ │ │ └── example │ │ │ └── app │ │ │ ├── App.java │ │ │ └── PrintUtil.java │ └── version.txt │ └── settings.gradle.kts ├── 35_Working_with_Files ├── README.MD ├── my-build-logic │ ├── java-plugins │ │ ├── build.gradle.kts │ │ └── src │ │ │ └── main │ │ │ └── kotlin │ │ │ ├── my-java-application.gradle.kts │ │ │ └── org │ │ │ └── example │ │ │ └── GenerateStartScript.kt │ └── settings.gradle.kts └── my-project │ ├── app │ ├── build.gradle.kts │ ├── src │ │ └── main │ │ │ └── java │ │ │ └── org │ │ │ └── example │ │ │ └── app │ │ │ └── App.java │ └── version.txt │ └── settings.gradle.kts ├── 36_Task_Actions ├── README.MD ├── my-build-logic │ ├── java-plugins │ │ ├── build.gradle.kts │ │ └── src │ │ │ └── main │ │ │ └── kotlin │ │ │ ├── PrintVersion.kt │ │ │ └── my-java-application.gradle.kts │ └── settings.gradle.kts └── my-project │ ├── app │ ├── build.gradle.kts │ └── src │ │ └── main │ │ └── java │ │ └── org │ │ └── example │ │ └── app │ │ └── App.java │ ├── gradle.properties │ └── settings.gradle.kts ├── LICENSE └── README.MD /.gitignore: -------------------------------------------------------------------------------- 1 | .gradle 2 | .idea 3 | build 4 | -------------------------------------------------------------------------------- /01_The_Settings_File/my-build-logic/.gitignore: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jjohannes/understanding-gradle/d3a158774e2f0eb7c007046955f858906c5b11c6/01_The_Settings_File/my-build-logic/.gitignore -------------------------------------------------------------------------------- /01_The_Settings_File/my-other-project/.gitignore: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jjohannes/understanding-gradle/d3a158774e2f0eb7c007046955f858906c5b11c6/01_The_Settings_File/my-other-project/.gitignore -------------------------------------------------------------------------------- /01_The_Settings_File/my-project/app/.gitignore: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jjohannes/understanding-gradle/d3a158774e2f0eb7c007046955f858906c5b11c6/01_The_Settings_File/my-project/app/.gitignore -------------------------------------------------------------------------------- /01_The_Settings_File/my-project/business-logic/.gitignore: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jjohannes/understanding-gradle/d3a158774e2f0eb7c007046955f858906c5b11c6/01_The_Settings_File/my-project/business-logic/.gitignore -------------------------------------------------------------------------------- /01_The_Settings_File/my-project/data-model/.gitignore: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jjohannes/understanding-gradle/d3a158774e2f0eb7c007046955f858906c5b11c6/01_The_Settings_File/my-project/data-model/.gitignore -------------------------------------------------------------------------------- /01_The_Settings_File/my-project/settings.gradle.kts: -------------------------------------------------------------------------------- 1 | pluginManagement { 2 | repositories { 3 | gradlePluginPortal() 4 | google() 5 | } 6 | includeBuild("../my-build-logic") 7 | } 8 | 9 | dependencyResolutionManagement { 10 | repositories { 11 | mavenCentral() 12 | } 13 | includeBuild("../my-other-project") 14 | } 15 | 16 | rootProject.name = "my-project" 17 | 18 | include("app") 19 | include("business-logic") 20 | include("data-model") 21 | -------------------------------------------------------------------------------- /02_The_Build_Files/my-build-logic/.gitignore: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jjohannes/understanding-gradle/d3a158774e2f0eb7c007046955f858906c5b11c6/02_The_Build_Files/my-build-logic/.gitignore -------------------------------------------------------------------------------- /02_The_Build_Files/my-other-project/.gitignore: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jjohannes/understanding-gradle/d3a158774e2f0eb7c007046955f858906c5b11c6/02_The_Build_Files/my-other-project/.gitignore -------------------------------------------------------------------------------- /02_The_Build_Files/my-project/app/build.gradle.kts: -------------------------------------------------------------------------------- 1 | plugins { 2 | id("application") 3 | } 4 | 5 | java { 6 | toolchain.languageVersion.set(JavaLanguageVersion.of(17)) 7 | } 8 | 9 | dependencies { 10 | implementation(project(":business-logic")) 11 | } 12 | -------------------------------------------------------------------------------- /02_The_Build_Files/my-project/business-logic/build.gradle.kts: -------------------------------------------------------------------------------- 1 | plugins { 2 | id("java-library") 3 | } 4 | 5 | java { 6 | toolchain.languageVersion.set(JavaLanguageVersion.of(17)) 7 | } 8 | 9 | dependencies { 10 | implementation(project(":data-model")) 11 | implementation("org.apache.commons:commons-lang3:3.9") 12 | } 13 | -------------------------------------------------------------------------------- /02_The_Build_Files/my-project/data-model/build.gradle.kts: -------------------------------------------------------------------------------- 1 | plugins { 2 | id("java-library") 3 | } 4 | 5 | java { 6 | toolchain.languageVersion.set(JavaLanguageVersion.of(17)) 7 | } 8 | -------------------------------------------------------------------------------- /02_The_Build_Files/my-project/settings.gradle.kts: -------------------------------------------------------------------------------- 1 | pluginManagement { 2 | repositories { 3 | gradlePluginPortal() 4 | google() 5 | } 6 | includeBuild("../my-build-logic") 7 | } 8 | 9 | dependencyResolutionManagement { 10 | repositories { 11 | mavenCentral() 12 | } 13 | includeBuild("../my-other-project") 14 | } 15 | 16 | rootProject.name = "my-project" 17 | 18 | include("app") 19 | include("business-logic") 20 | include("data-model") 21 | -------------------------------------------------------------------------------- /03_Plugins/my-build-logic/java-plugins/build.gradle.kts: -------------------------------------------------------------------------------- 1 | plugins { 2 | `kotlin-dsl` 3 | } 4 | 5 | dependencies { 6 | implementation("org.jetbrains.kotlin:kotlin-gradle-plugin:2.1.20") 7 | } -------------------------------------------------------------------------------- /03_Plugins/my-build-logic/java-plugins/src/main/kotlin/my-java-application.gradle.kts: -------------------------------------------------------------------------------- 1 | plugins { 2 | id("application") 3 | } 4 | 5 | java { 6 | toolchain.languageVersion.set(JavaLanguageVersion.of(17)) 7 | } 8 | 9 | tasks.test { 10 | useJUnitPlatform() 11 | } 12 | -------------------------------------------------------------------------------- /03_Plugins/my-build-logic/java-plugins/src/main/kotlin/my-java-library.gradle.kts: -------------------------------------------------------------------------------- 1 | plugins { 2 | id("java-library") 3 | id("org.jetbrains.kotlin.jvm") 4 | } 5 | 6 | java { 7 | toolchain.languageVersion.set(JavaLanguageVersion.of(17)) 8 | } 9 | 10 | tasks.test { 11 | useJUnitPlatform() 12 | } 13 | 14 | kotlin { 15 | // ... 16 | } -------------------------------------------------------------------------------- /03_Plugins/my-build-logic/settings.gradle.kts: -------------------------------------------------------------------------------- 1 | dependencyResolutionManagement { 2 | repositories.gradlePluginPortal() 3 | } 4 | 5 | include("java-plugins") -------------------------------------------------------------------------------- /03_Plugins/my-other-project/.gitignore: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jjohannes/understanding-gradle/d3a158774e2f0eb7c007046955f858906c5b11c6/03_Plugins/my-other-project/.gitignore -------------------------------------------------------------------------------- /03_Plugins/my-project/app/build.gradle.kts: -------------------------------------------------------------------------------- 1 | plugins { 2 | id("my-java-application") 3 | } 4 | -------------------------------------------------------------------------------- /03_Plugins/my-project/business-logic/build.gradle.kts: -------------------------------------------------------------------------------- 1 | plugins { 2 | id("my-java-library") 3 | } 4 | dependencies { 5 | implementation(project(":data-model")) 6 | implementation("org.apache.commons:commons-lang3:3.9") 7 | } 8 | -------------------------------------------------------------------------------- /03_Plugins/my-project/data-model/build.gradle.kts: -------------------------------------------------------------------------------- 1 | plugins { 2 | id("my-java-library") 3 | } 4 | -------------------------------------------------------------------------------- /03_Plugins/my-project/settings.gradle.kts: -------------------------------------------------------------------------------- 1 | pluginManagement { 2 | repositories.gradlePluginPortal() 3 | repositories.google() 4 | includeBuild("../my-build-logic") 5 | } 6 | 7 | dependencyResolutionManagement { 8 | repositories.mavenCentral() 9 | includeBuild("../my-other-project") 10 | } 11 | 12 | rootProject.name = "my-project" 13 | 14 | include("app") 15 | include("business-logic") 16 | include("data-model") 17 | -------------------------------------------------------------------------------- /04_Tasks/my-build-logic/java-plugins/build.gradle.kts: -------------------------------------------------------------------------------- 1 | plugins { 2 | `kotlin-dsl` 3 | } 4 | -------------------------------------------------------------------------------- /04_Tasks/my-build-logic/java-plugins/src/main/kotlin/my-java-application.gradle.kts: -------------------------------------------------------------------------------- 1 | plugins { 2 | id("application") 3 | } 4 | 5 | java { 6 | toolchain.languageVersion.set(JavaLanguageVersion.of(17)) 7 | } 8 | -------------------------------------------------------------------------------- /04_Tasks/my-build-logic/java-plugins/src/main/kotlin/my-java-library.gradle.kts: -------------------------------------------------------------------------------- 1 | plugins { 2 | id("java-library") 3 | } 4 | 5 | java { 6 | toolchain.languageVersion.set(JavaLanguageVersion.of(17)) 7 | } 8 | -------------------------------------------------------------------------------- /04_Tasks/my-build-logic/settings.gradle.kts: -------------------------------------------------------------------------------- 1 | dependencyResolutionManagement { 2 | repositories.gradlePluginPortal() 3 | } 4 | 5 | include("java-plugins") 6 | -------------------------------------------------------------------------------- /04_Tasks/my-other-project/.gitignore: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jjohannes/understanding-gradle/d3a158774e2f0eb7c007046955f858906c5b11c6/04_Tasks/my-other-project/.gitignore -------------------------------------------------------------------------------- /04_Tasks/my-project/app/build.gradle.kts: -------------------------------------------------------------------------------- 1 | plugins { 2 | id("my-java-application") 3 | } 4 | 5 | application { 6 | mainClass.set("myproject.MyApplication") 7 | } 8 | 9 | dependencies { 10 | implementation(project(":business-logic")) 11 | } 12 | -------------------------------------------------------------------------------- /04_Tasks/my-project/app/src/main/java/myproject/MyApplication.java: -------------------------------------------------------------------------------- 1 | package myproject; 2 | 3 | import myproject.services.Service; 4 | 5 | public class MyApplication { 6 | 7 | public static void main(String[] args) { 8 | Service.printMessage(); 9 | } 10 | } 11 | -------------------------------------------------------------------------------- /04_Tasks/my-project/business-logic/build.gradle.kts: -------------------------------------------------------------------------------- 1 | plugins { 2 | id("my-java-library") 3 | } 4 | 5 | dependencies { 6 | implementation(project(":data-model")) 7 | implementation("org.apache.commons:commons-lang3:3.9") 8 | } 9 | -------------------------------------------------------------------------------- /04_Tasks/my-project/business-logic/src/main/java/myproject/services/Service.java: -------------------------------------------------------------------------------- 1 | package myproject.services; 2 | 3 | import myproject.data.MessageModel; 4 | import org.apache.commons.lang3.StringUtils; 5 | 6 | public class Service { 7 | 8 | public static void printMessage() { 9 | MessageModel m1 = new MessageModel(); 10 | String m = StringUtils.trimToEmpty(m1.getMessage()); 11 | System.out.println(m); 12 | } 13 | } 14 | -------------------------------------------------------------------------------- /04_Tasks/my-project/data-model/build.gradle.kts: -------------------------------------------------------------------------------- 1 | plugins { 2 | id("my-java-library") 3 | } 4 | -------------------------------------------------------------------------------- /04_Tasks/my-project/data-model/src/main/java/myproject/data/MessageModel.java: -------------------------------------------------------------------------------- 1 | package myproject.data; 2 | 3 | public class MessageModel { 4 | public String getMessage() { 5 | return "Hello!"; 6 | } 7 | } 8 | -------------------------------------------------------------------------------- /04_Tasks/my-project/gradle.properties: -------------------------------------------------------------------------------- 1 | org.gradle.caching=true 2 | -------------------------------------------------------------------------------- /04_Tasks/my-project/settings.gradle.kts: -------------------------------------------------------------------------------- 1 | pluginManagement { 2 | repositories.gradlePluginPortal() 3 | includeBuild("../my-build-logic") 4 | } 5 | 6 | dependencyResolutionManagement { 7 | repositories.mavenCentral() 8 | includeBuild("../my-other-project") 9 | } 10 | 11 | rootProject.name = "my-project" 12 | 13 | include("app") 14 | include("business-logic") 15 | include("data-model") 16 | -------------------------------------------------------------------------------- /05_Lifecycle_Tasks/my-build-logic/build.gradle.kts: -------------------------------------------------------------------------------- 1 | tasks.register("checkAll") { 2 | dependsOn(subprojects.map { ":${it.name}:check" }) 3 | } 4 | -------------------------------------------------------------------------------- /05_Lifecycle_Tasks/my-build-logic/java-plugins/build.gradle.kts: -------------------------------------------------------------------------------- 1 | plugins { 2 | `kotlin-dsl` 3 | } 4 | -------------------------------------------------------------------------------- /05_Lifecycle_Tasks/my-build-logic/java-plugins/src/main/kotlin/my-java-application.gradle.kts: -------------------------------------------------------------------------------- 1 | plugins { 2 | id("my-java-base") 3 | id("application") 4 | } 5 | 6 | val myBuildGroup = "my project build" 7 | 8 | tasks.named("run") { 9 | group = myBuildGroup 10 | } -------------------------------------------------------------------------------- /05_Lifecycle_Tasks/my-build-logic/java-plugins/src/main/kotlin/my-java-library.gradle.kts: -------------------------------------------------------------------------------- 1 | plugins { 2 | id("my-java-base") 3 | id("java-library") 4 | } 5 | -------------------------------------------------------------------------------- /05_Lifecycle_Tasks/my-build-logic/settings.gradle.kts: -------------------------------------------------------------------------------- 1 | dependencyResolutionManagement { 2 | repositories.gradlePluginPortal() 3 | } 4 | 5 | include("java-plugins") 6 | -------------------------------------------------------------------------------- /05_Lifecycle_Tasks/my-other-project/build.gradle.kts: -------------------------------------------------------------------------------- 1 | tasks.register("checkAll") { 2 | dependsOn(subprojects.map { ":${it.name}:check" }) 3 | } 4 | -------------------------------------------------------------------------------- /05_Lifecycle_Tasks/my-other-project/settings.gradle.kts: -------------------------------------------------------------------------------- 1 | rootProject.name = "my-other-project" 2 | -------------------------------------------------------------------------------- /05_Lifecycle_Tasks/my-project/app/build.gradle.kts: -------------------------------------------------------------------------------- 1 | plugins { 2 | id("my-java-application") 3 | } 4 | 5 | application { 6 | mainClass.set("myproject.MyApplication") 7 | } 8 | 9 | dependencies { 10 | implementation(project(":business-logic")) 11 | } 12 | -------------------------------------------------------------------------------- /05_Lifecycle_Tasks/my-project/app/src/main/java/myproject/MyApplication.java: -------------------------------------------------------------------------------- 1 | package myproject; 2 | 3 | import myproject.services.Service; 4 | 5 | /** 6 | * The application. 7 | */ 8 | public final class MyApplication { 9 | 10 | /** 11 | * Run the application. 12 | * 13 | * @param args command line arguments are ignored 14 | */ 15 | public static void main(final String[] args) { 16 | Service.printMessage(); 17 | } 18 | } 19 | -------------------------------------------------------------------------------- /05_Lifecycle_Tasks/my-project/build.gradle.kts: -------------------------------------------------------------------------------- 1 | val globalBuildGroup = "My global build" 2 | val ciBuildGroup = "My CI build" 3 | 4 | tasks.named("tasks") { 5 | displayGroup = globalBuildGroup 6 | } 7 | 8 | tasks.register("qualityCheckAll") { 9 | group = globalBuildGroup 10 | dependsOn(subprojects.map { ":${it.name}:qualityCheck" }) 11 | } 12 | 13 | tasks.register("checkAll") { 14 | group = ciBuildGroup 15 | dependsOn(subprojects.map { ":${it.name}:check" }) 16 | dependsOn(gradle.includedBuilds.map { it.task(":checkAll") }) 17 | } 18 | -------------------------------------------------------------------------------- /05_Lifecycle_Tasks/my-project/business-logic/build.gradle.kts: -------------------------------------------------------------------------------- 1 | plugins { 2 | id("my-java-library") 3 | } 4 | 5 | dependencies { 6 | implementation(project(":data-model")) 7 | implementation("org.apache.commons:commons-lang3:3.9") 8 | } 9 | -------------------------------------------------------------------------------- /05_Lifecycle_Tasks/my-project/business-logic/src/main/java/myproject/services/Service.java: -------------------------------------------------------------------------------- 1 | package myproject.services; 2 | 3 | import myproject.data.MessageModel; 4 | import org.apache.commons.lang3.StringUtils; 5 | 6 | /** 7 | * Our main service. 8 | */ 9 | public final class Service { 10 | 11 | /** 12 | * Prints the main message to screen. 13 | */ 14 | public static void printMessage() { 15 | MessageModel m1 = new MessageModel(); 16 | String m = StringUtils.trimToEmpty(m1.getMessage()); 17 | System.out.println(m); 18 | } 19 | } 20 | -------------------------------------------------------------------------------- /05_Lifecycle_Tasks/my-project/business-logic/src/test/java/myproject/data/ServiceTest.java: -------------------------------------------------------------------------------- 1 | package myproject.data; 2 | 3 | import org.junit.jupiter.api.Test; 4 | 5 | import java.util.concurrent.TimeUnit; 6 | 7 | /** 8 | * Test suite for our service. 9 | */ 10 | public class ServiceTest { 11 | 12 | private static final int CONNECTION_TEST_ATTEMPTS = 20; 13 | 14 | /** 15 | * The ultimate test for our service. 16 | */ 17 | @Test 18 | void testConnection() throws Exception { 19 | for (int i = 0; i < CONNECTION_TEST_ATTEMPTS; i++) { 20 | System.out.println("Connection Attempt " + (i + 1) 21 | + "/" + CONNECTION_TEST_ATTEMPTS); 22 | Thread.sleep(TimeUnit.SECONDS.toMillis(1)); 23 | } 24 | } 25 | } 26 | -------------------------------------------------------------------------------- /05_Lifecycle_Tasks/my-project/data-model/build.gradle.kts: -------------------------------------------------------------------------------- 1 | plugins { 2 | id("my-java-library") 3 | } 4 | -------------------------------------------------------------------------------- /05_Lifecycle_Tasks/my-project/data-model/src/main/java/myproject/data/MessageModel.java: -------------------------------------------------------------------------------- 1 | package myproject.data; 2 | 3 | /** 4 | * Represents a message that is sent around. 5 | */ 6 | public final class MessageModel { 7 | 8 | /** 9 | * @return the message as String 10 | */ 11 | public String getMessage() { 12 | return "Hello!"; 13 | } 14 | } 15 | -------------------------------------------------------------------------------- /05_Lifecycle_Tasks/my-project/gradle.properties: -------------------------------------------------------------------------------- 1 | org.gradle.caching=true 2 | -------------------------------------------------------------------------------- /05_Lifecycle_Tasks/my-project/settings.gradle.kts: -------------------------------------------------------------------------------- 1 | pluginManagement { 2 | repositories.gradlePluginPortal() 3 | includeBuild("../my-build-logic") 4 | } 5 | 6 | dependencyResolutionManagement { 7 | repositories.mavenCentral() 8 | includeBuild("../my-other-project") 9 | } 10 | 11 | rootProject.name = "my-project" 12 | 13 | include("app") 14 | include("business-logic") 15 | include("data-model") 16 | -------------------------------------------------------------------------------- /06_Configuring_Task_Inputs_And_Outputs/my-build-logic/java-plugins/build.gradle.kts: -------------------------------------------------------------------------------- 1 | plugins { 2 | `kotlin-dsl` 3 | } 4 | -------------------------------------------------------------------------------- /06_Configuring_Task_Inputs_And_Outputs/my-build-logic/java-plugins/src/main/kotlin/my-java-application.gradle.kts: -------------------------------------------------------------------------------- 1 | plugins { 2 | id("my-java-base") 3 | } 4 | 5 | val packageApp = tasks.register("packageApp") { 6 | from(layout.projectDirectory.file("run.sh")) 7 | from(tasks.jar) { 8 | into("libs") 9 | } 10 | from(configurations.runtimeClasspath) { 11 | into("libs") 12 | } 13 | 14 | destinationDirectory.set(layout.buildDirectory.dir("dist")) 15 | archiveFileName.set("myApplication.zip") 16 | } 17 | 18 | tasks.build { 19 | dependsOn(packageApp) 20 | } 21 | 22 | -------------------------------------------------------------------------------- /06_Configuring_Task_Inputs_And_Outputs/my-build-logic/java-plugins/src/main/kotlin/my-java-base.gradle.kts: -------------------------------------------------------------------------------- 1 | plugins { 2 | id("java") 3 | } 4 | 5 | java { 6 | toolchain.languageVersion.set(JavaLanguageVersion.of(17)) 7 | } 8 | -------------------------------------------------------------------------------- /06_Configuring_Task_Inputs_And_Outputs/my-build-logic/java-plugins/src/main/kotlin/my-java-library.gradle.kts: -------------------------------------------------------------------------------- 1 | plugins { 2 | id("my-java-base") 3 | id("java-library") 4 | } 5 | -------------------------------------------------------------------------------- /06_Configuring_Task_Inputs_And_Outputs/my-build-logic/settings.gradle.kts: -------------------------------------------------------------------------------- 1 | dependencyResolutionManagement { 2 | repositories.gradlePluginPortal() 3 | } 4 | 5 | include("java-plugins") 6 | -------------------------------------------------------------------------------- /06_Configuring_Task_Inputs_And_Outputs/my-other-project/.gitignore: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jjohannes/understanding-gradle/d3a158774e2f0eb7c007046955f858906c5b11c6/06_Configuring_Task_Inputs_And_Outputs/my-other-project/.gitignore -------------------------------------------------------------------------------- /06_Configuring_Task_Inputs_And_Outputs/my-project/app/build.gradle.kts: -------------------------------------------------------------------------------- 1 | plugins { 2 | id("my-java-application") 3 | } 4 | 5 | dependencies { 6 | implementation(project(":business-logic")) 7 | } 8 | -------------------------------------------------------------------------------- /06_Configuring_Task_Inputs_And_Outputs/my-project/app/run.sh: -------------------------------------------------------------------------------- 1 | java -cp 'libs/*' myproject.MyApplication 2 | -------------------------------------------------------------------------------- /06_Configuring_Task_Inputs_And_Outputs/my-project/app/src/main/java/myproject/MyApplication.java: -------------------------------------------------------------------------------- 1 | package myproject; 2 | 3 | import myproject.services.Service; 4 | 5 | public final class MyApplication { 6 | 7 | public static void main(final String[] args) { 8 | Service.printMessage(); 9 | } 10 | } 11 | -------------------------------------------------------------------------------- /06_Configuring_Task_Inputs_And_Outputs/my-project/business-logic/build.gradle.kts: -------------------------------------------------------------------------------- 1 | plugins { 2 | id("my-java-library") 3 | } 4 | 5 | dependencies { 6 | implementation(project(":data-model")) 7 | implementation("org.apache.commons:commons-lang3:3.9") 8 | } 9 | -------------------------------------------------------------------------------- /06_Configuring_Task_Inputs_And_Outputs/my-project/business-logic/src/main/java/myproject/services/Service.java: -------------------------------------------------------------------------------- 1 | package myproject.services; 2 | 3 | import myproject.data.MessageModel; 4 | import org.apache.commons.lang3.StringUtils; 5 | 6 | public final class Service { 7 | 8 | public static void printMessage() { 9 | MessageModel m1 = new MessageModel(); 10 | String m = StringUtils.trimToEmpty(m1.getMessage()); 11 | System.out.println(m); 12 | } 13 | } 14 | -------------------------------------------------------------------------------- /06_Configuring_Task_Inputs_And_Outputs/my-project/data-model/build.gradle.kts: -------------------------------------------------------------------------------- 1 | plugins { 2 | id("my-java-library") 3 | } 4 | -------------------------------------------------------------------------------- /06_Configuring_Task_Inputs_And_Outputs/my-project/data-model/src/main/java/myproject/data/MessageModel.java: -------------------------------------------------------------------------------- 1 | package myproject.data; 2 | 3 | public final class MessageModel { 4 | 5 | public String getMessage() { 6 | return "Hello!"; 7 | } 8 | } 9 | -------------------------------------------------------------------------------- /06_Configuring_Task_Inputs_And_Outputs/my-project/settings.gradle.kts: -------------------------------------------------------------------------------- 1 | pluginManagement { 2 | repositories.gradlePluginPortal() 3 | includeBuild("../my-build-logic") 4 | } 5 | 6 | dependencyResolutionManagement { 7 | repositories.mavenCentral() 8 | includeBuild("../my-other-project") 9 | } 10 | 11 | rootProject.name = "my-project" 12 | 13 | include("app") 14 | include("business-logic") 15 | include("data-model") 16 | -------------------------------------------------------------------------------- /07_Implementing_Tasks_and_Extensions/my-build-logic/java-plugins/build.gradle.kts: -------------------------------------------------------------------------------- 1 | plugins { 2 | `kotlin-dsl` 3 | } 4 | -------------------------------------------------------------------------------- /07_Implementing_Tasks_and_Extensions/my-build-logic/java-plugins/src/main/kotlin/my-java-base.gradle.kts: -------------------------------------------------------------------------------- 1 | plugins { 2 | id("java") 3 | } 4 | 5 | java { 6 | toolchain.languageVersion.set(JavaLanguageVersion.of(17)) 7 | } 8 | -------------------------------------------------------------------------------- /07_Implementing_Tasks_and_Extensions/my-build-logic/java-plugins/src/main/kotlin/my-java-library.gradle.kts: -------------------------------------------------------------------------------- 1 | plugins { 2 | id("my-java-base") 3 | id("java-library") 4 | } 5 | -------------------------------------------------------------------------------- /07_Implementing_Tasks_and_Extensions/my-build-logic/java-plugins/src/main/kotlin/myproject/tasks/MyAppExtension.kt: -------------------------------------------------------------------------------- 1 | package myproject.tasks 2 | 3 | import org.gradle.api.provider.Property 4 | 5 | interface MyAppExtension { 6 | val mainClass: Property 7 | } 8 | -------------------------------------------------------------------------------- /07_Implementing_Tasks_and_Extensions/my-build-logic/settings.gradle.kts: -------------------------------------------------------------------------------- 1 | dependencyResolutionManagement { 2 | repositories.gradlePluginPortal() 3 | } 4 | 5 | include("java-plugins") -------------------------------------------------------------------------------- /07_Implementing_Tasks_and_Extensions/my-other-project/.gitignore: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jjohannes/understanding-gradle/d3a158774e2f0eb7c007046955f858906c5b11c6/07_Implementing_Tasks_and_Extensions/my-other-project/.gitignore -------------------------------------------------------------------------------- /07_Implementing_Tasks_and_Extensions/my-project/app/build.gradle.kts: -------------------------------------------------------------------------------- 1 | plugins { 2 | id("my-java-application") 3 | } 4 | 5 | myApp { 6 | mainClass.set("myproject.MyApplication") 7 | } 8 | 9 | dependencies { 10 | implementation(project(":business-logic")) 11 | } 12 | -------------------------------------------------------------------------------- /07_Implementing_Tasks_and_Extensions/my-project/app/src/main/java/myproject/MyApplication.java: -------------------------------------------------------------------------------- 1 | package myproject; 2 | 3 | import myproject.services.Service; 4 | 5 | /** 6 | * The application. 7 | */ 8 | public final class MyApplication { 9 | 10 | /** 11 | * Run the application. 12 | * 13 | * @param args command line arguments are ignored 14 | */ 15 | public static void main(final String[] args) { 16 | Service.printMessage(); 17 | } 18 | } 19 | -------------------------------------------------------------------------------- /07_Implementing_Tasks_and_Extensions/my-project/business-logic/build.gradle.kts: -------------------------------------------------------------------------------- 1 | plugins { 2 | id("my-java-library") 3 | } 4 | 5 | dependencies { 6 | implementation(project(":data-model")) 7 | implementation("org.apache.commons:commons-lang3:3.9") 8 | } 9 | -------------------------------------------------------------------------------- /07_Implementing_Tasks_and_Extensions/my-project/business-logic/src/main/java/myproject/services/Service.java: -------------------------------------------------------------------------------- 1 | package myproject.services; 2 | 3 | import myproject.data.MessageModel; 4 | import org.apache.commons.lang3.StringUtils; 5 | 6 | /** 7 | * Our main service. 8 | */ 9 | public final class Service { 10 | 11 | /** 12 | * Prints the main message to screen. 13 | */ 14 | public static void printMessage() { 15 | String x = ""; 16 | MessageModel m1 = new MessageModel(); 17 | String m = StringUtils.trimToEmpty(m1.getMessage()); 18 | System.out.println(m + x); 19 | } 20 | } 21 | -------------------------------------------------------------------------------- /07_Implementing_Tasks_and_Extensions/my-project/data-model/build.gradle.kts: -------------------------------------------------------------------------------- 1 | plugins { 2 | id("my-java-library") 3 | } 4 | -------------------------------------------------------------------------------- /07_Implementing_Tasks_and_Extensions/my-project/data-model/src/main/java/myproject/data/MessageModel.java: -------------------------------------------------------------------------------- 1 | package myproject.data; 2 | 3 | /** 4 | * Represents a message that is sent around. 5 | */ 6 | public final class MessageModel { 7 | 8 | /** 9 | * @return the message as String 10 | */ 11 | public String getMessage() { 12 | return "Hello!"; 13 | } 14 | } 15 | -------------------------------------------------------------------------------- /07_Implementing_Tasks_and_Extensions/my-project/settings.gradle.kts: -------------------------------------------------------------------------------- 1 | pluginManagement { 2 | repositories.gradlePluginPortal() 3 | includeBuild("../my-build-logic") 4 | } 5 | 6 | dependencyResolutionManagement { 7 | repositories.mavenCentral() 8 | includeBuild("../my-other-project") 9 | } 10 | 11 | rootProject.name = "my-project" 12 | 13 | include("app") 14 | include("business-logic") 15 | include("data-model") 16 | -------------------------------------------------------------------------------- /08_Declaring_Dependencis/my-build-logic/java-plugins/build.gradle.kts: -------------------------------------------------------------------------------- 1 | plugins { 2 | `kotlin-dsl` 3 | } 4 | -------------------------------------------------------------------------------- /08_Declaring_Dependencis/my-build-logic/java-plugins/src/main/kotlin/my-java-application.gradle.kts: -------------------------------------------------------------------------------- 1 | plugins { 2 | id("my-java-base") 3 | id("application") 4 | } 5 | -------------------------------------------------------------------------------- /08_Declaring_Dependencis/my-build-logic/java-plugins/src/main/kotlin/my-java-base.gradle.kts: -------------------------------------------------------------------------------- 1 | plugins { 2 | id("java") 3 | } 4 | 5 | group = "org.example.my-app" 6 | 7 | dependencies.constraints { 8 | implementation("org.apache.commons:commons-lang3:3.9") 9 | implementation("com.google.errorprone:error_prone_annotations:2.9.0") 10 | implementation("org.slf4j:slf4j-api:1.7.32") 11 | implementation("org.slf4j:slf4j-simple:1.7.32") 12 | } 13 | 14 | java { 15 | toolchain.languageVersion.set(JavaLanguageVersion.of(17)) 16 | } 17 | 18 | -------------------------------------------------------------------------------- /08_Declaring_Dependencis/my-build-logic/java-plugins/src/main/kotlin/my-java-library.gradle.kts: -------------------------------------------------------------------------------- 1 | plugins { 2 | id("my-java-base") 3 | id("java-library") 4 | } 5 | -------------------------------------------------------------------------------- /08_Declaring_Dependencis/my-build-logic/settings.gradle.kts: -------------------------------------------------------------------------------- 1 | dependencyResolutionManagement { 2 | repositories.gradlePluginPortal() 3 | } 4 | 5 | include("java-plugins") -------------------------------------------------------------------------------- /08_Declaring_Dependencis/my-other-project/settings.gradle.kts: -------------------------------------------------------------------------------- 1 | pluginManagement { 2 | repositories.gradlePluginPortal() 3 | includeBuild("../my-build-logic") 4 | } 5 | 6 | dependencyResolutionManagement { 7 | repositories.mavenCentral() 8 | } 9 | 10 | rootProject.name = "my-other-project" 11 | 12 | include("shared-utils") 13 | -------------------------------------------------------------------------------- /08_Declaring_Dependencis/my-other-project/shared-utils/build.gradle.kts: -------------------------------------------------------------------------------- 1 | plugins { 2 | id("my-java-library") 3 | } 4 | -------------------------------------------------------------------------------- /08_Declaring_Dependencis/my-other-project/shared-utils/src/main/java/myproject/shared/util/EmojiEncodeUtil.java: -------------------------------------------------------------------------------- 1 | package myproject.shared.util; 2 | 3 | public final class EmojiEncodeUtil { 4 | 5 | public static String encode(String s) { 6 | return s.replace(":)", "\uD83D\uDE03"); 7 | } 8 | 9 | } 10 | -------------------------------------------------------------------------------- /08_Declaring_Dependencis/my-project/app/build.gradle.kts: -------------------------------------------------------------------------------- 1 | plugins { 2 | id("my-java-application") 3 | } 4 | 5 | application { 6 | mainClass.set("myproject.MyApplication") 7 | } 8 | 9 | dependencies { 10 | implementation("org.example.my-app:business-logic") 11 | 12 | runtimeOnly("org.slf4j:slf4j-simple") 13 | } 14 | -------------------------------------------------------------------------------- /08_Declaring_Dependencis/my-project/app/src/main/java/myproject/MyApplication.java: -------------------------------------------------------------------------------- 1 | package myproject; 2 | 3 | import myproject.data.MessageModel; 4 | import myproject.services.Service; 5 | 6 | public final class MyApplication { 7 | 8 | public static void main(final String[] args) { 9 | Service.printMessage(new MessageModel("Hello there :)")); 10 | } 11 | } 12 | -------------------------------------------------------------------------------- /08_Declaring_Dependencis/my-project/business-logic/build.gradle.kts: -------------------------------------------------------------------------------- 1 | plugins { 2 | id("my-java-library") 3 | } 4 | 5 | dependencies { 6 | implementation("org.apache.commons:commons-lang3") 7 | implementation("org.slf4j:slf4j-api") 8 | implementation("org.example.my-app:shared-utils") 9 | 10 | api("org.example.my-app:data-model") //alternative: project(":data-model") 11 | 12 | compileOnlyApi("com.google.errorprone:error_prone_annotations") 13 | } 14 | -------------------------------------------------------------------------------- /08_Declaring_Dependencis/my-project/data-model/build.gradle.kts: -------------------------------------------------------------------------------- 1 | plugins { 2 | id("my-java-library") 3 | } 4 | -------------------------------------------------------------------------------- /08_Declaring_Dependencis/my-project/data-model/src/main/java/myproject/data/MessageModel.java: -------------------------------------------------------------------------------- 1 | package myproject.data; 2 | 3 | public final class MessageModel { 4 | 5 | private final String message; 6 | 7 | public MessageModel(String message) { 8 | this.message = message; 9 | } 10 | 11 | public String getMessage() { 12 | return message; 13 | } 14 | } 15 | -------------------------------------------------------------------------------- /08_Declaring_Dependencis/my-project/settings.gradle.kts: -------------------------------------------------------------------------------- 1 | // Locations of Gradle plugins 2 | pluginManagement { 3 | repositories.gradlePluginPortal() 4 | includeBuild("../my-build-logic") 5 | } 6 | 7 | // Location of other components 8 | dependencyResolutionManagement { 9 | repositories.mavenCentral() 10 | includeBuild("../my-other-project") 11 | includeBuild(".") 12 | } 13 | 14 | rootProject.name = "my-project" 15 | 16 | include("app") 17 | include("business-logic") 18 | include("data-model") 19 | 20 | -------------------------------------------------------------------------------- /09_Centralizing_Dependency_Versions/A_Dependency_Constrains_in_Convention_Plugin/my-build-logic/java-plugins/build.gradle.kts: -------------------------------------------------------------------------------- 1 | plugins { 2 | `kotlin-dsl` 3 | } 4 | -------------------------------------------------------------------------------- /09_Centralizing_Dependency_Versions/A_Dependency_Constrains_in_Convention_Plugin/my-build-logic/java-plugins/src/main/kotlin/my-java-application.gradle.kts: -------------------------------------------------------------------------------- 1 | plugins { 2 | id("my-java-base") 3 | id("application") 4 | } 5 | -------------------------------------------------------------------------------- /09_Centralizing_Dependency_Versions/A_Dependency_Constrains_in_Convention_Plugin/my-build-logic/java-plugins/src/main/kotlin/my-java-base.gradle.kts: -------------------------------------------------------------------------------- 1 | plugins { 2 | id("java") 3 | } 4 | 5 | group = "org.example.my-app" 6 | 7 | java { 8 | toolchain.languageVersion.set(JavaLanguageVersion.of(17)) 9 | } 10 | 11 | dependencies.constraints { 12 | implementation("org.apache.commons:commons-lang3:3.12.0") 13 | implementation("org.slf4j:slf4j-api:1.7.32") 14 | implementation("org.slf4j:slf4j-simple:1.7.32") 15 | } 16 | 17 | 18 | -------------------------------------------------------------------------------- /09_Centralizing_Dependency_Versions/A_Dependency_Constrains_in_Convention_Plugin/my-build-logic/java-plugins/src/main/kotlin/my-java-library.gradle.kts: -------------------------------------------------------------------------------- 1 | plugins { 2 | id("my-java-base") 3 | id("java-library") 4 | } 5 | -------------------------------------------------------------------------------- /09_Centralizing_Dependency_Versions/A_Dependency_Constrains_in_Convention_Plugin/my-build-logic/settings.gradle.kts: -------------------------------------------------------------------------------- 1 | dependencyResolutionManagement { 2 | repositories.gradlePluginPortal() 3 | } 4 | 5 | include("java-plugins") -------------------------------------------------------------------------------- /09_Centralizing_Dependency_Versions/A_Dependency_Constrains_in_Convention_Plugin/my-other-project/settings.gradle.kts: -------------------------------------------------------------------------------- 1 | pluginManagement { 2 | repositories.gradlePluginPortal() 3 | includeBuild("../my-build-logic") 4 | } 5 | 6 | dependencyResolutionManagement { 7 | repositories.mavenCentral() 8 | } 9 | 10 | rootProject.name = "my-other-project" 11 | 12 | include("shared-utils") 13 | -------------------------------------------------------------------------------- /09_Centralizing_Dependency_Versions/A_Dependency_Constrains_in_Convention_Plugin/my-other-project/shared-utils/build.gradle.kts: -------------------------------------------------------------------------------- 1 | plugins { 2 | id("my-java-library") 3 | } 4 | -------------------------------------------------------------------------------- /09_Centralizing_Dependency_Versions/A_Dependency_Constrains_in_Convention_Plugin/my-other-project/shared-utils/src/main/java/mypproject/shared/util/EmojiEncodeUtil.java: -------------------------------------------------------------------------------- 1 | package mypproject.shared.util; 2 | 3 | public final class EmojiEncodeUtil { 4 | 5 | public static String encode(String s) { 6 | return s.replace(":)", "\uD83D\uDE03"); 7 | } 8 | 9 | } 10 | -------------------------------------------------------------------------------- /09_Centralizing_Dependency_Versions/A_Dependency_Constrains_in_Convention_Plugin/my-project/app/build.gradle.kts: -------------------------------------------------------------------------------- 1 | plugins { 2 | id("my-java-application") 3 | } 4 | 5 | application { 6 | mainClass.set("myproject.MyApplication") 7 | } 8 | 9 | dependencies { 10 | implementation("org.example.my-app:business-logic") 11 | 12 | runtimeOnly("org.slf4j:slf4j-simple") 13 | } 14 | -------------------------------------------------------------------------------- /09_Centralizing_Dependency_Versions/A_Dependency_Constrains_in_Convention_Plugin/my-project/app/src/main/java/myproject/MyApplication.java: -------------------------------------------------------------------------------- 1 | package myproject; 2 | 3 | import myproject.data.MessageModel; 4 | import myproject.services.Service; 5 | 6 | /** 7 | * The application. 8 | */ 9 | public final class MyApplication { 10 | 11 | /** 12 | * Run the application. 13 | * 14 | * @param args command line arguments are ignored 15 | */ 16 | public static void main(final String[] args) { 17 | Service.printMessage(new MessageModel("Hello there :)")); 18 | } 19 | } 20 | -------------------------------------------------------------------------------- /09_Centralizing_Dependency_Versions/A_Dependency_Constrains_in_Convention_Plugin/my-project/business-logic/build.gradle.kts: -------------------------------------------------------------------------------- 1 | plugins { 2 | id("my-java-library") 3 | } 4 | 5 | dependencies { 6 | implementation("org.apache.commons:commons-lang3") 7 | implementation("org.slf4j:slf4j-api") 8 | 9 | implementation("org.example.my-app:shared-utils") // local component 10 | 11 | api("org.example.my-app:data-model") // alternative: project(":data-model") 12 | } 13 | -------------------------------------------------------------------------------- /09_Centralizing_Dependency_Versions/A_Dependency_Constrains_in_Convention_Plugin/my-project/data-model/build.gradle.kts: -------------------------------------------------------------------------------- 1 | plugins { 2 | id("my-java-library") 3 | } 4 | 5 | dependencies { 6 | implementation("org.apache.commons:commons-lang3") 7 | } 8 | -------------------------------------------------------------------------------- /09_Centralizing_Dependency_Versions/A_Dependency_Constrains_in_Convention_Plugin/my-project/data-model/src/main/java/myproject/data/MessageModel.java: -------------------------------------------------------------------------------- 1 | package myproject.data; 2 | 3 | public final class MessageModel { 4 | 5 | private final String message; 6 | 7 | public MessageModel(String message) { 8 | this.message = message; 9 | } 10 | 11 | public String getMessage() { 12 | return message; 13 | } 14 | } 15 | -------------------------------------------------------------------------------- /09_Centralizing_Dependency_Versions/A_Dependency_Constrains_in_Convention_Plugin/my-project/settings.gradle.kts: -------------------------------------------------------------------------------- 1 | pluginManagement { 2 | repositories.gradlePluginPortal() 3 | includeBuild("../my-build-logic") 4 | } 5 | 6 | dependencyResolutionManagement { 7 | repositories.mavenCentral() 8 | includeBuild("../my-other-project") 9 | includeBuild(".") 10 | } 11 | 12 | rootProject.name = "my-project" 13 | 14 | include("app") 15 | include("business-logic") 16 | include("data-model") 17 | 18 | -------------------------------------------------------------------------------- /09_Centralizing_Dependency_Versions/B_Platform_Project/my-build-logic/java-plugins/build.gradle.kts: -------------------------------------------------------------------------------- 1 | plugins { 2 | `kotlin-dsl` 3 | } 4 | 5 | dependencies { 6 | implementation(platform("org.example.my-app:shared-platform")) 7 | 8 | implementation("org.jetbrains.kotlin:kotlin-gradle-plugin") 9 | } -------------------------------------------------------------------------------- /09_Centralizing_Dependency_Versions/B_Platform_Project/my-build-logic/java-plugins/src/main/kotlin/my-java-application.gradle.kts: -------------------------------------------------------------------------------- 1 | plugins { 2 | id("my-java-base") 3 | id("application") 4 | } 5 | -------------------------------------------------------------------------------- /09_Centralizing_Dependency_Versions/B_Platform_Project/my-build-logic/java-plugins/src/main/kotlin/my-java-base.gradle.kts: -------------------------------------------------------------------------------- 1 | plugins { 2 | id("java") 3 | } 4 | 5 | group = "org.example.my-app" 6 | 7 | java { 8 | toolchain.languageVersion.set(JavaLanguageVersion.of(17)) 9 | } 10 | 11 | dependencies { 12 | implementation(platform("org.example.my-app:shared-platform")) 13 | } 14 | 15 | -------------------------------------------------------------------------------- /09_Centralizing_Dependency_Versions/B_Platform_Project/my-build-logic/java-plugins/src/main/kotlin/my-java-library.gradle.kts: -------------------------------------------------------------------------------- 1 | plugins { 2 | id("my-java-base") 3 | id("java-library") 4 | } 5 | -------------------------------------------------------------------------------- /09_Centralizing_Dependency_Versions/B_Platform_Project/my-build-logic/settings.gradle.kts: -------------------------------------------------------------------------------- 1 | dependencyResolutionManagement { 2 | repositories.gradlePluginPortal() 3 | includeBuild("../my-platform") 4 | } 5 | 6 | include("java-plugins") -------------------------------------------------------------------------------- /09_Centralizing_Dependency_Versions/B_Platform_Project/my-other-project/settings.gradle.kts: -------------------------------------------------------------------------------- 1 | pluginManagement { 2 | repositories.gradlePluginPortal() 3 | includeBuild("../my-build-logic") 4 | } 5 | 6 | dependencyResolutionManagement { 7 | repositories.mavenCentral() 8 | } 9 | 10 | rootProject.name = "my-other-project" 11 | 12 | include("shared-utils") 13 | -------------------------------------------------------------------------------- /09_Centralizing_Dependency_Versions/B_Platform_Project/my-other-project/shared-utils/build.gradle.kts: -------------------------------------------------------------------------------- 1 | plugins { 2 | id("my-java-library") 3 | } 4 | -------------------------------------------------------------------------------- /09_Centralizing_Dependency_Versions/B_Platform_Project/my-other-project/shared-utils/src/main/java/mypproject/shared/util/EmojiEncodeUtil.java: -------------------------------------------------------------------------------- 1 | package mypproject.shared.util; 2 | 3 | public final class EmojiEncodeUtil { 4 | 5 | public static String encode(String s) { 6 | return s.replace(":)", "\uD83D\uDE03"); 7 | } 8 | 9 | } 10 | -------------------------------------------------------------------------------- /09_Centralizing_Dependency_Versions/B_Platform_Project/my-platform/settings.gradle.kts: -------------------------------------------------------------------------------- 1 | include("shared-platform") 2 | -------------------------------------------------------------------------------- /09_Centralizing_Dependency_Versions/B_Platform_Project/my-project/app/build.gradle.kts: -------------------------------------------------------------------------------- 1 | plugins { 2 | id("my-java-application") 3 | } 4 | 5 | application { 6 | mainClass.set("myproject.MyApplication") 7 | } 8 | 9 | dependencies { 10 | implementation("org.example.my-app:business-logic") 11 | 12 | runtimeOnly("org.slf4j:slf4j-simple") 13 | } 14 | -------------------------------------------------------------------------------- /09_Centralizing_Dependency_Versions/B_Platform_Project/my-project/app/src/main/java/myproject/MyApplication.java: -------------------------------------------------------------------------------- 1 | package myproject; 2 | 3 | import myproject.data.MessageModel; 4 | import myproject.services.Service; 5 | 6 | /** 7 | * The application. 8 | */ 9 | public final class MyApplication { 10 | 11 | /** 12 | * Run the application. 13 | * 14 | * @param args command line arguments are ignored 15 | */ 16 | public static void main(final String[] args) { 17 | Service.printMessage(new MessageModel("Hello there :)")); 18 | } 19 | } 20 | -------------------------------------------------------------------------------- /09_Centralizing_Dependency_Versions/B_Platform_Project/my-project/business-logic/build.gradle.kts: -------------------------------------------------------------------------------- 1 | plugins { 2 | id("my-java-library") 3 | } 4 | 5 | dependencies { 6 | implementation("org.apache.commons:commons-lang3") 7 | implementation("org.slf4j:slf4j-api") 8 | 9 | implementation("org.example.my-app:shared-utils") // local component 10 | 11 | api("org.example.my-app:data-model") // alternative: project(":data-model") 12 | } 13 | -------------------------------------------------------------------------------- /09_Centralizing_Dependency_Versions/B_Platform_Project/my-project/business-logic/src/main/java/myproject/services/Service.java: -------------------------------------------------------------------------------- 1 | package myproject.services; 2 | 3 | import mypproject.shared.util.EmojiEncodeUtil; 4 | import myproject.data.MessageModel; 5 | import org.apache.commons.lang3.StringUtils; 6 | import org.slf4j.LoggerFactory; 7 | 8 | public final class Service { 9 | 10 | public static String printMessage(MessageModel message) { 11 | String trimmedMessage = StringUtils.trimToEmpty(message.getMessage()); 12 | String encodedMessage = EmojiEncodeUtil.encode(trimmedMessage); 13 | System.out.println(encodedMessage); 14 | LoggerFactory.getLogger(Service.class).info("Message printed"); 15 | return encodedMessage; 16 | } 17 | } 18 | -------------------------------------------------------------------------------- /09_Centralizing_Dependency_Versions/B_Platform_Project/my-project/data-model/build.gradle.kts: -------------------------------------------------------------------------------- 1 | plugins { 2 | id("my-java-library") 3 | } 4 | 5 | dependencies { 6 | implementation("org.apache.commons:commons-lang3") 7 | implementation("com.fasterxml.jackson.core:jackson-core") 8 | implementation("com.fasterxml.jackson.core:jackson-annotations") 9 | } 10 | -------------------------------------------------------------------------------- /09_Centralizing_Dependency_Versions/B_Platform_Project/my-project/data-model/src/main/java/myproject/data/MessageModel.java: -------------------------------------------------------------------------------- 1 | package myproject.data; 2 | 3 | public final class MessageModel { 4 | 5 | private final String message; 6 | 7 | public MessageModel(String message) { 8 | this.message = message; 9 | } 10 | 11 | public String getMessage() { 12 | return message; 13 | } 14 | } 15 | -------------------------------------------------------------------------------- /09_Centralizing_Dependency_Versions/B_Platform_Project/my-project/settings.gradle.kts: -------------------------------------------------------------------------------- 1 | pluginManagement { 2 | repositories.gradlePluginPortal() 3 | includeBuild("../my-build-logic") 4 | } 5 | 6 | dependencyResolutionManagement { 7 | repositories.mavenCentral() 8 | includeBuild("../my-other-project") 9 | includeBuild("../my-platform") 10 | includeBuild(".") 11 | } 12 | 13 | rootProject.name = "my-project" 14 | 15 | include("app") 16 | include("business-logic") 17 | include("data-model") 18 | -------------------------------------------------------------------------------- /09_Centralizing_Dependency_Versions/C_Version_Catalog/my-build-logic/java-plugins/build.gradle.kts: -------------------------------------------------------------------------------- 1 | plugins { 2 | `kotlin-dsl` 3 | } 4 | -------------------------------------------------------------------------------- /09_Centralizing_Dependency_Versions/C_Version_Catalog/my-build-logic/java-plugins/src/main/kotlin/my-java-application.gradle.kts: -------------------------------------------------------------------------------- 1 | plugins { 2 | id("my-java-base") 3 | id("application") 4 | } 5 | -------------------------------------------------------------------------------- /09_Centralizing_Dependency_Versions/C_Version_Catalog/my-build-logic/java-plugins/src/main/kotlin/my-java-base.gradle.kts: -------------------------------------------------------------------------------- 1 | plugins { 2 | id("java") 3 | } 4 | 5 | group = "org.example.my-app" 6 | 7 | java { 8 | toolchain.languageVersion.set(JavaLanguageVersion.of(17)) 9 | } 10 | 11 | 12 | -------------------------------------------------------------------------------- /09_Centralizing_Dependency_Versions/C_Version_Catalog/my-build-logic/java-plugins/src/main/kotlin/my-java-library.gradle.kts: -------------------------------------------------------------------------------- 1 | plugins { 2 | id("my-java-base") 3 | id("java-library") 4 | } 5 | -------------------------------------------------------------------------------- /09_Centralizing_Dependency_Versions/C_Version_Catalog/my-build-logic/settings.gradle.kts: -------------------------------------------------------------------------------- 1 | dependencyResolutionManagement { 2 | repositories.gradlePluginPortal() 3 | } 4 | 5 | include("java-plugins") -------------------------------------------------------------------------------- /09_Centralizing_Dependency_Versions/C_Version_Catalog/my-other-project/settings.gradle.kts: -------------------------------------------------------------------------------- 1 | pluginManagement { 2 | repositories.gradlePluginPortal() 3 | includeBuild("../my-build-logic") 4 | } 5 | 6 | dependencyResolutionManagement { 7 | repositories.mavenCentral() 8 | } 9 | 10 | rootProject.name = "my-other-project" 11 | 12 | include("shared-utils") 13 | -------------------------------------------------------------------------------- /09_Centralizing_Dependency_Versions/C_Version_Catalog/my-other-project/shared-utils/build.gradle.kts: -------------------------------------------------------------------------------- 1 | plugins { 2 | id("my-java-library") 3 | } 4 | -------------------------------------------------------------------------------- /09_Centralizing_Dependency_Versions/C_Version_Catalog/my-other-project/shared-utils/src/main/java/mypproject/shared/util/EmojiEncodeUtil.java: -------------------------------------------------------------------------------- 1 | package mypproject.shared.util; 2 | 3 | public final class EmojiEncodeUtil { 4 | 5 | public static String encode(String s) { 6 | return s.replace(":)", "\uD83D\uDE03"); 7 | } 8 | 9 | } 10 | -------------------------------------------------------------------------------- /09_Centralizing_Dependency_Versions/C_Version_Catalog/my-project/app/build.gradle.kts: -------------------------------------------------------------------------------- 1 | plugins { 2 | id("my-java-application") 3 | } 4 | 5 | application { 6 | mainClass.set("myproject.MyApplication") 7 | } 8 | 9 | dependencies { 10 | implementation("org.example.my-app:business-logic") 11 | 12 | runtimeOnly(libs.slf4j.simple) 13 | } 14 | -------------------------------------------------------------------------------- /09_Centralizing_Dependency_Versions/C_Version_Catalog/my-project/app/src/main/java/myproject/MyApplication.java: -------------------------------------------------------------------------------- 1 | package myproject; 2 | 3 | import myproject.data.MessageModel; 4 | import myproject.services.Service; 5 | 6 | /** 7 | * The application. 8 | */ 9 | public final class MyApplication { 10 | 11 | /** 12 | * Run the application. 13 | * 14 | * @param args command line arguments are ignored 15 | */ 16 | public static void main(final String[] args) { 17 | Service.printMessage(new MessageModel("Hello there :)")); 18 | } 19 | } 20 | -------------------------------------------------------------------------------- /09_Centralizing_Dependency_Versions/C_Version_Catalog/my-project/business-logic/build.gradle.kts: -------------------------------------------------------------------------------- 1 | plugins { 2 | id("my-java-library") 3 | } 4 | 5 | dependencies { 6 | implementation(libs.commons.lang3) 7 | implementation(libs.slf4j.api) 8 | 9 | implementation("org.example.my-app:shared-utils") // local component 10 | 11 | api("org.example.my-app:data-model") // alternative: project(":data-model") 12 | } 13 | -------------------------------------------------------------------------------- /09_Centralizing_Dependency_Versions/C_Version_Catalog/my-project/business-logic/src/main/java/myproject/services/Service.java: -------------------------------------------------------------------------------- 1 | package myproject.services; 2 | 3 | import mypproject.shared.util.EmojiEncodeUtil; 4 | import myproject.data.MessageModel; 5 | import org.apache.commons.lang3.StringUtils; 6 | import org.slf4j.LoggerFactory; 7 | 8 | public final class Service { 9 | 10 | public static String printMessage(MessageModel message) { 11 | String trimmedMessage = StringUtils.trimToEmpty(message.getMessage()); 12 | String encodedMessage = EmojiEncodeUtil.encode(trimmedMessage); 13 | System.out.println(encodedMessage); 14 | LoggerFactory.getLogger(Service.class).info("Message printed"); 15 | return encodedMessage; 16 | } 17 | } 18 | -------------------------------------------------------------------------------- /09_Centralizing_Dependency_Versions/C_Version_Catalog/my-project/data-model/build.gradle.kts: -------------------------------------------------------------------------------- 1 | plugins { 2 | id("my-java-library") 3 | } 4 | 5 | dependencies { 6 | implementation(libs.commons.lang3) 7 | } 8 | -------------------------------------------------------------------------------- /09_Centralizing_Dependency_Versions/C_Version_Catalog/my-project/data-model/src/main/java/myproject/data/MessageModel.java: -------------------------------------------------------------------------------- 1 | package myproject.data; 2 | 3 | public final class MessageModel { 4 | 5 | private final String message; 6 | 7 | public MessageModel(String message) { 8 | this.message = message; 9 | } 10 | 11 | public String getMessage() { 12 | return message; 13 | } 14 | } 15 | -------------------------------------------------------------------------------- /09_Centralizing_Dependency_Versions/C_Version_Catalog/my-project/gradle/libs.versions.toml: -------------------------------------------------------------------------------- 1 | [libraries] 2 | commons-lang3 = { module = "org.apache.commons:commons-lang3", version = "3.12.0" } 3 | slf4j-api = { module = "org.slf4j:slf4j-api", version = "1.7.32"} 4 | slf4j-simple = { module = "org.slf4j:slf4j-simple", version = "1.7.32"} -------------------------------------------------------------------------------- /09_Centralizing_Dependency_Versions/C_Version_Catalog/my-project/settings.gradle.kts: -------------------------------------------------------------------------------- 1 | pluginManagement { 2 | repositories.gradlePluginPortal() 3 | includeBuild("../my-build-logic") 4 | } 5 | 6 | dependencyResolutionManagement { 7 | repositories.mavenCentral() 8 | includeBuild("../my-other-project") 9 | includeBuild(".") 10 | } 11 | 12 | rootProject.name = "my-project" 13 | 14 | include("app") 15 | include("business-logic") 16 | include("data-model") 17 | -------------------------------------------------------------------------------- /09_Centralizing_Dependency_Versions/D_Dependency_Locking/my-build-logic/java-plugins/build.gradle.kts: -------------------------------------------------------------------------------- 1 | plugins { 2 | `kotlin-dsl` 3 | } 4 | -------------------------------------------------------------------------------- /09_Centralizing_Dependency_Versions/D_Dependency_Locking/my-build-logic/java-plugins/src/main/kotlin/my-java-application.gradle.kts: -------------------------------------------------------------------------------- 1 | plugins { 2 | id("my-java-base") 3 | id("application") 4 | } 5 | -------------------------------------------------------------------------------- /09_Centralizing_Dependency_Versions/D_Dependency_Locking/my-build-logic/java-plugins/src/main/kotlin/my-java-library.gradle.kts: -------------------------------------------------------------------------------- 1 | plugins { 2 | id("my-java-base") 3 | id("java-library") 4 | } 5 | -------------------------------------------------------------------------------- /09_Centralizing_Dependency_Versions/D_Dependency_Locking/my-build-logic/java-plugins/src/main/kotlin/my-root-project.gradle.kts: -------------------------------------------------------------------------------- 1 | tasks.register("allDependencies") { 2 | group = "My project build" 3 | description = "Run ':allDependencies --write-locks' to update all the dependency lock files" 4 | // Resolve dependencies of all subprojects of 'this build' 5 | dependsOn(subprojects.map { ":${it.name}:dependencies" }) 6 | // Resolve dependencies of all subprojects of included builds that are not 'this build' or the 'build-logic build' 7 | dependsOn(gradle.includedBuilds.filter { 8 | it.name !in listOf(project.name, "my-build-logic") 9 | }.map { it.task(":allDependencies") }) 10 | } 11 | -------------------------------------------------------------------------------- /09_Centralizing_Dependency_Versions/D_Dependency_Locking/my-build-logic/settings.gradle.kts: -------------------------------------------------------------------------------- 1 | dependencyResolutionManagement { 2 | repositories.gradlePluginPortal() 3 | } 4 | 5 | include("java-plugins") -------------------------------------------------------------------------------- /09_Centralizing_Dependency_Versions/D_Dependency_Locking/my-other-project/build.gradle.kts: -------------------------------------------------------------------------------- 1 | plugins { 2 | id("my-root-project") 3 | } -------------------------------------------------------------------------------- /09_Centralizing_Dependency_Versions/D_Dependency_Locking/my-other-project/settings.gradle.kts: -------------------------------------------------------------------------------- 1 | pluginManagement { 2 | repositories.gradlePluginPortal() 3 | includeBuild("../my-build-logic") 4 | } 5 | 6 | dependencyResolutionManagement { 7 | repositories.mavenCentral() 8 | } 9 | 10 | rootProject.name = "my-other-project" 11 | 12 | include("shared-utils") 13 | -------------------------------------------------------------------------------- /09_Centralizing_Dependency_Versions/D_Dependency_Locking/my-other-project/shared-utils/build.gradle.kts: -------------------------------------------------------------------------------- 1 | plugins { 2 | id("my-java-library") 3 | } 4 | 5 | dependencies { 6 | implementation("org.apache.commons:commons-configuration2") 7 | } -------------------------------------------------------------------------------- /09_Centralizing_Dependency_Versions/D_Dependency_Locking/my-other-project/shared-utils/gradle.lockfile: -------------------------------------------------------------------------------- 1 | # This is a Gradle generated file for dependency locking. 2 | # Manual edits can break the build and are not advised. 3 | # This file is expected to be part of source control. 4 | commons-logging:commons-logging:1.2=compileClasspath,runtimeClasspath,testCompileClasspath,testRuntimeClasspath 5 | org.apache.commons:commons-configuration2:2.7=compileClasspath,runtimeClasspath,testCompileClasspath,testRuntimeClasspath 6 | org.apache.commons:commons-lang3:3.9=compileClasspath,runtimeClasspath,testCompileClasspath,testRuntimeClasspath 7 | org.apache.commons:commons-text:1.8=compileClasspath,runtimeClasspath,testCompileClasspath,testRuntimeClasspath 8 | empty= 9 | -------------------------------------------------------------------------------- /09_Centralizing_Dependency_Versions/D_Dependency_Locking/my-other-project/shared-utils/src/main/java/mypproject/shared/util/EmojiEncodeUtil.java: -------------------------------------------------------------------------------- 1 | package mypproject.shared.util; 2 | 3 | public final class EmojiEncodeUtil { 4 | 5 | public static String encode(String s) { 6 | return s.replace(":)", "\uD83D\uDE03"); 7 | } 8 | 9 | } 10 | -------------------------------------------------------------------------------- /09_Centralizing_Dependency_Versions/D_Dependency_Locking/my-project/app/build.gradle.kts: -------------------------------------------------------------------------------- 1 | plugins { 2 | id("my-java-application") 3 | } 4 | 5 | application { 6 | mainClass.set("myproject.MyApplication") 7 | } 8 | 9 | dependencies { 10 | implementation("org.example.my-app:business-logic") 11 | 12 | runtimeOnly("org.slf4j:slf4j-simple") 13 | } 14 | -------------------------------------------------------------------------------- /09_Centralizing_Dependency_Versions/D_Dependency_Locking/my-project/app/gradle.lockfile: -------------------------------------------------------------------------------- 1 | # This is a Gradle generated file for dependency locking. 2 | # Manual edits can break the build and are not advised. 3 | # This file is expected to be part of source control. 4 | commons-logging:commons-logging:1.2=runtimeClasspath,testRuntimeClasspath 5 | org.apache.commons:commons-configuration2:2.7=runtimeClasspath,testRuntimeClasspath 6 | org.apache.commons:commons-lang3:3.12.0=runtimeClasspath,testRuntimeClasspath 7 | org.apache.commons:commons-text:1.8=runtimeClasspath,testRuntimeClasspath 8 | org.slf4j:slf4j-api:1.7.36=runtimeClasspath,testRuntimeClasspath 9 | org.slf4j:slf4j-simple:1.7.36=runtimeClasspath,testRuntimeClasspath 10 | empty=compileClasspath,testCompileClasspath 11 | -------------------------------------------------------------------------------- /09_Centralizing_Dependency_Versions/D_Dependency_Locking/my-project/app/src/main/java/myproject/MyApplication.java: -------------------------------------------------------------------------------- 1 | package myproject; 2 | 3 | import myproject.data.MessageModel; 4 | import myproject.services.Service; 5 | 6 | /** 7 | * The application. 8 | */ 9 | public final class MyApplication { 10 | 11 | /** 12 | * Run the application. 13 | * 14 | * @param args command line arguments are ignored 15 | */ 16 | public static void main(final String[] args) { 17 | Service.printMessage(new MessageModel("Hello there :)")); 18 | } 19 | } 20 | -------------------------------------------------------------------------------- /09_Centralizing_Dependency_Versions/D_Dependency_Locking/my-project/build.gradle.kts: -------------------------------------------------------------------------------- 1 | plugins { 2 | id("my-root-project") 3 | } -------------------------------------------------------------------------------- /09_Centralizing_Dependency_Versions/D_Dependency_Locking/my-project/business-logic/build.gradle.kts: -------------------------------------------------------------------------------- 1 | plugins { 2 | id("my-java-library") 3 | } 4 | 5 | dependencies { 6 | implementation("org.apache.commons:commons-lang3") 7 | implementation("org.slf4j:slf4j-api") 8 | 9 | implementation("org.example.my-app:shared-utils") // local component 10 | 11 | api("org.example.my-app:data-model") // alternative: project(":data-model") 12 | } 13 | -------------------------------------------------------------------------------- /09_Centralizing_Dependency_Versions/D_Dependency_Locking/my-project/business-logic/gradle.lockfile: -------------------------------------------------------------------------------- 1 | # This is a Gradle generated file for dependency locking. 2 | # Manual edits can break the build and are not advised. 3 | # This file is expected to be part of source control. 4 | commons-logging:commons-logging:1.2=runtimeClasspath,testRuntimeClasspath 5 | org.apache.commons:commons-configuration2:2.7=runtimeClasspath,testRuntimeClasspath 6 | org.apache.commons:commons-lang3:3.12.0=compileClasspath,runtimeClasspath,testCompileClasspath,testRuntimeClasspath 7 | org.apache.commons:commons-text:1.8=runtimeClasspath,testRuntimeClasspath 8 | org.slf4j:slf4j-api:1.7.36=compileClasspath,runtimeClasspath,testCompileClasspath,testRuntimeClasspath 9 | empty= 10 | -------------------------------------------------------------------------------- /09_Centralizing_Dependency_Versions/D_Dependency_Locking/my-project/business-logic/src/main/java/myproject/services/Service.java: -------------------------------------------------------------------------------- 1 | package myproject.services; 2 | 3 | import mypproject.shared.util.EmojiEncodeUtil; 4 | import myproject.data.MessageModel; 5 | import org.apache.commons.lang3.StringUtils; 6 | import org.slf4j.LoggerFactory; 7 | 8 | public final class Service { 9 | 10 | public static String printMessage(MessageModel message) { 11 | String trimmedMessage = StringUtils.trimToEmpty(message.getMessage()); 12 | String encodedMessage = EmojiEncodeUtil.encode(trimmedMessage); 13 | System.out.println(encodedMessage); 14 | LoggerFactory.getLogger(Service.class).info("Message printed"); 15 | return encodedMessage; 16 | } 17 | } 18 | -------------------------------------------------------------------------------- /09_Centralizing_Dependency_Versions/D_Dependency_Locking/my-project/data-model/build.gradle.kts: -------------------------------------------------------------------------------- 1 | plugins { 2 | id("my-java-library") 3 | } 4 | 5 | dependencies { 6 | implementation("org.apache.commons:commons-lang3") 7 | } 8 | -------------------------------------------------------------------------------- /09_Centralizing_Dependency_Versions/D_Dependency_Locking/my-project/data-model/gradle.lockfile: -------------------------------------------------------------------------------- 1 | # This is a Gradle generated file for dependency locking. 2 | # Manual edits can break the build and are not advised. 3 | # This file is expected to be part of source control. 4 | org.apache.commons:commons-lang3:3.12.0=compileClasspath,runtimeClasspath,testCompileClasspath,testRuntimeClasspath 5 | empty= 6 | -------------------------------------------------------------------------------- /09_Centralizing_Dependency_Versions/D_Dependency_Locking/my-project/data-model/src/main/java/myproject/data/MessageModel.java: -------------------------------------------------------------------------------- 1 | package myproject.data; 2 | 3 | public final class MessageModel { 4 | 5 | private final String message; 6 | 7 | public MessageModel(String message) { 8 | this.message = message; 9 | } 10 | 11 | public String getMessage() { 12 | return message; 13 | } 14 | } 15 | -------------------------------------------------------------------------------- /09_Centralizing_Dependency_Versions/D_Dependency_Locking/my-project/settings.gradle.kts: -------------------------------------------------------------------------------- 1 | pluginManagement { 2 | repositories.gradlePluginPortal() 3 | includeBuild("../my-build-logic") 4 | } 5 | 6 | dependencyResolutionManagement { 7 | repositories.mavenCentral() 8 | includeBuild("../my-other-project") 9 | includeBuild(".") 10 | } 11 | 12 | rootProject.name = "my-project" 13 | 14 | include("app") 15 | include("business-logic") 16 | include("data-model") 17 | -------------------------------------------------------------------------------- /10_Dependency_Version_Conflicts/my-build-logic/java-plugins/build.gradle.kts: -------------------------------------------------------------------------------- 1 | plugins { 2 | `kotlin-dsl` 3 | } 4 | -------------------------------------------------------------------------------- /10_Dependency_Version_Conflicts/my-build-logic/java-plugins/src/main/kotlin/my-java-application.gradle.kts: -------------------------------------------------------------------------------- 1 | plugins { 2 | id("my-java-base") 3 | id("application") 4 | } 5 | -------------------------------------------------------------------------------- /10_Dependency_Version_Conflicts/my-build-logic/java-plugins/src/main/kotlin/my-java-library.gradle.kts: -------------------------------------------------------------------------------- 1 | plugins { 2 | id("my-java-base") 3 | id("java-library") 4 | } 5 | -------------------------------------------------------------------------------- /10_Dependency_Version_Conflicts/my-build-logic/settings.gradle.kts: -------------------------------------------------------------------------------- 1 | dependencyResolutionManagement { 2 | repositories.gradlePluginPortal() 3 | } 4 | 5 | include("java-plugins") -------------------------------------------------------------------------------- /10_Dependency_Version_Conflicts/my-other-project/settings.gradle.kts: -------------------------------------------------------------------------------- 1 | rootProject.name = "my-other-project" -------------------------------------------------------------------------------- /10_Dependency_Version_Conflicts/my-project/app/build.gradle.kts: -------------------------------------------------------------------------------- 1 | plugins { 2 | id("my-java-application") 3 | } 4 | 5 | application { 6 | mainClass.set("myproject.MyApplication") 7 | } 8 | 9 | dependencies { 10 | implementation("org.apache.commons:commons-text") 11 | 12 | implementation("org.example.my-app:business-logic") // alternative: project(":business-logic") 13 | } 14 | -------------------------------------------------------------------------------- /10_Dependency_Version_Conflicts/my-project/app/src/main/java/myproject/MyApplication.java: -------------------------------------------------------------------------------- 1 | package myproject; 2 | 3 | import myproject.data.MessageModel; 4 | import myproject.services.Service; 5 | 6 | /** 7 | * The application. 8 | */ 9 | public final class MyApplication { 10 | 11 | /** 12 | * Run the application. 13 | * 14 | * @param args command line arguments are ignored 15 | */ 16 | public static void main(final String[] args) { 17 | Service.printMessage(new MessageModel("007.26")); 18 | } 19 | } 20 | -------------------------------------------------------------------------------- /10_Dependency_Version_Conflicts/my-project/business-logic/build.gradle.kts: -------------------------------------------------------------------------------- 1 | plugins { 2 | id("my-java-library") 3 | } 4 | 5 | dependencies { 6 | implementation("org.apache.commons:commons-lang3") 7 | 8 | api("org.example.my-app:data-model") // alternative: project(":data-model") 9 | } 10 | -------------------------------------------------------------------------------- /10_Dependency_Version_Conflicts/my-project/business-logic/src/main/java/myproject/services/Service.java: -------------------------------------------------------------------------------- 1 | package myproject.services; 2 | 3 | import myproject.data.MessageModel; 4 | import org.apache.commons.lang3.math.NumberUtils; 5 | 6 | public final class Service { 7 | 8 | public static String printMessage(MessageModel message) { 9 | String messageToPrint = message.getMessage(); 10 | if (NumberUtils.isCreatable(messageToPrint)) { 11 | messageToPrint += " has no leading zeros"; 12 | } 13 | System.out.println(messageToPrint); 14 | return messageToPrint; 15 | } 16 | } 17 | -------------------------------------------------------------------------------- /10_Dependency_Version_Conflicts/my-project/business-logic/src/test/java/myproject/data/ServiceTest.java: -------------------------------------------------------------------------------- 1 | package myproject.data; 2 | 3 | import myproject.services.Service; 4 | import org.junit.jupiter.api.Assertions; 5 | import org.junit.jupiter.api.Test; 6 | 7 | 8 | public class ServiceTest { 9 | 10 | @Test 11 | void testService() { 12 | String printed = Service.printMessage(new MessageModel("007.26")); 13 | Assertions.assertEquals("007.26", printed); 14 | } 15 | } 16 | -------------------------------------------------------------------------------- /10_Dependency_Version_Conflicts/my-project/data-model/build.gradle.kts: -------------------------------------------------------------------------------- 1 | plugins { 2 | id("my-java-library") 3 | } 4 | -------------------------------------------------------------------------------- /10_Dependency_Version_Conflicts/my-project/data-model/src/main/java/myproject/data/MessageModel.java: -------------------------------------------------------------------------------- 1 | package myproject.data; 2 | 3 | public final class MessageModel { 4 | 5 | private final String message; 6 | 7 | public MessageModel(String message) { 8 | this.message = message; 9 | } 10 | 11 | public String getMessage() { 12 | return message; 13 | } 14 | } 15 | -------------------------------------------------------------------------------- /10_Dependency_Version_Conflicts/my-project/settings.gradle.kts: -------------------------------------------------------------------------------- 1 | pluginManagement { 2 | repositories.gradlePluginPortal() 3 | includeBuild("../my-build-logic") 4 | } 5 | 6 | dependencyResolutionManagement { 7 | repositories.mavenCentral() 8 | includeBuild("../my-other-project") 9 | includeBuild(".") 10 | } 11 | 12 | rootProject.name = "my-project" 13 | 14 | include("app") 15 | include("business-logic") 16 | include("data-model") 17 | -------------------------------------------------------------------------------- /11_Capability_Conflicts/my-build-logic/java-plugins/build.gradle.kts: -------------------------------------------------------------------------------- 1 | plugins { 2 | `kotlin-dsl` 3 | } 4 | -------------------------------------------------------------------------------- /11_Capability_Conflicts/my-build-logic/java-plugins/src/main/kotlin/metadata-rules.gradle.kts: -------------------------------------------------------------------------------- 1 | import myproject.metadatarules.Slf4JImplRule 2 | 3 | dependencies.components { 4 | withModule("org.slf4j:slf4j-simple") 5 | withModule("ch.qos.logback:logback-classic") 6 | } -------------------------------------------------------------------------------- /11_Capability_Conflicts/my-build-logic/java-plugins/src/main/kotlin/my-java-application.gradle.kts: -------------------------------------------------------------------------------- 1 | plugins { 2 | id("my-java-base") 3 | id("application") 4 | } 5 | -------------------------------------------------------------------------------- /11_Capability_Conflicts/my-build-logic/java-plugins/src/main/kotlin/my-java-library.gradle.kts: -------------------------------------------------------------------------------- 1 | plugins { 2 | id("my-java-base") 3 | id("java-library") 4 | } 5 | -------------------------------------------------------------------------------- /11_Capability_Conflicts/my-build-logic/java-plugins/src/main/kotlin/myproject/metadatarules/Slf4JImplRule.kt: -------------------------------------------------------------------------------- 1 | package myproject.metadatarules 2 | 3 | import org.gradle.api.artifacts.CacheableRule 4 | import org.gradle.api.artifacts.ComponentMetadataContext 5 | import org.gradle.api.artifacts.ComponentMetadataRule 6 | 7 | @CacheableRule 8 | abstract class Slf4JImplRule : ComponentMetadataRule { 9 | 10 | override fun execute(context: ComponentMetadataContext) { 11 | val version = context.details.id.version 12 | context.details.allVariants { 13 | withCapabilities { 14 | addCapability("org.slf4j", "slf4j-impl", version) 15 | } 16 | } 17 | } 18 | } -------------------------------------------------------------------------------- /11_Capability_Conflicts/my-build-logic/settings.gradle.kts: -------------------------------------------------------------------------------- 1 | dependencyResolutionManagement { 2 | repositories.gradlePluginPortal() 3 | } 4 | 5 | include("java-plugins") -------------------------------------------------------------------------------- /11_Capability_Conflicts/my-other-project/settings.gradle.kts: -------------------------------------------------------------------------------- 1 | rootProject.name = "my-other-project" -------------------------------------------------------------------------------- /11_Capability_Conflicts/my-project/app/build.gradle.kts: -------------------------------------------------------------------------------- 1 | plugins { 2 | id("my-java-application") 3 | } 4 | 5 | application { 6 | mainClass.set("myproject.MyApplication") 7 | } 8 | 9 | dependencies { 10 | implementation("org.example.my-app:business-logic") 11 | implementation("io.dropwizard:dropwizard-core") 12 | runtimeOnly("org.slf4j:slf4j-simple") 13 | } 14 | -------------------------------------------------------------------------------- /11_Capability_Conflicts/my-project/app/src/main/java/myproject/MyApplication.java: -------------------------------------------------------------------------------- 1 | package myproject; 2 | 3 | import myproject.data.MessageModel; 4 | import myproject.services.Service; 5 | 6 | /** 7 | * The application. 8 | */ 9 | public final class MyApplication { 10 | 11 | /** 12 | * Run the application. 13 | * 14 | * @param args command line arguments are ignored 15 | */ 16 | public static void main(final String[] args) { 17 | Service.printMessage(new MessageModel("007.26")); 18 | } 19 | } 20 | -------------------------------------------------------------------------------- /11_Capability_Conflicts/my-project/business-logic/build.gradle.kts: -------------------------------------------------------------------------------- 1 | plugins { 2 | id("my-java-library") 3 | } 4 | 5 | dependencies { 6 | implementation("org.slf4j:slf4j-api") 7 | 8 | api("org.example.my-app:data-model") // alternative: project(":data-model") 9 | } 10 | -------------------------------------------------------------------------------- /11_Capability_Conflicts/my-project/business-logic/src/main/java/myproject/services/Service.java: -------------------------------------------------------------------------------- 1 | package myproject.services; 2 | 3 | import myproject.data.MessageModel; 4 | import org.slf4j.LoggerFactory; 5 | 6 | public final class Service { 7 | 8 | public static String printMessage(MessageModel message) { 9 | String messageToPrint = message.getMessage(); 10 | System.out.println(messageToPrint); 11 | LoggerFactory.getLogger(Service.class).info("Message printed"); 12 | return messageToPrint; 13 | } 14 | } 15 | -------------------------------------------------------------------------------- /11_Capability_Conflicts/my-project/business-logic/src/test/java/myproject/data/ServiceTest.java: -------------------------------------------------------------------------------- 1 | package myproject.data; 2 | 3 | import myproject.services.Service; 4 | import org.junit.jupiter.api.Assertions; 5 | import org.junit.jupiter.api.Test; 6 | 7 | 8 | public class ServiceTest { 9 | 10 | @Test 11 | void testService() { 12 | String printed = Service.printMessage(new MessageModel("007.26")); 13 | Assertions.assertEquals("007.26", printed); 14 | } 15 | } 16 | -------------------------------------------------------------------------------- /11_Capability_Conflicts/my-project/data-model/build.gradle.kts: -------------------------------------------------------------------------------- 1 | plugins { 2 | id("my-java-library") 3 | } 4 | -------------------------------------------------------------------------------- /11_Capability_Conflicts/my-project/data-model/src/main/java/myproject/data/MessageModel.java: -------------------------------------------------------------------------------- 1 | package myproject.data; 2 | 3 | public final class MessageModel { 4 | 5 | private final String message; 6 | 7 | public MessageModel(String message) { 8 | this.message = message; 9 | } 10 | 11 | public String getMessage() { 12 | return message; 13 | } 14 | } 15 | -------------------------------------------------------------------------------- /11_Capability_Conflicts/my-project/settings.gradle.kts: -------------------------------------------------------------------------------- 1 | pluginManagement { 2 | repositories.gradlePluginPortal() 3 | includeBuild("../my-build-logic") 4 | } 5 | 6 | dependencyResolutionManagement { 7 | // repositories.maven { url = uri("../patched-repo") } <- for demo purpose only 8 | repositories.mavenCentral() 9 | includeBuild("../my-other-project") 10 | includeBuild(".") 11 | } 12 | 13 | rootProject.name = "my-project" 14 | 15 | include("app") 16 | include("business-logic") 17 | include("data-model") 18 | -------------------------------------------------------------------------------- /11_Capability_Conflicts/patched-repo/ch/qos/logback/logback-classic/1.2.5/logback-classic-1.2.5.jar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jjohannes/understanding-gradle/d3a158774e2f0eb7c007046955f858906c5b11c6/11_Capability_Conflicts/patched-repo/ch/qos/logback/logback-classic/1.2.5/logback-classic-1.2.5.jar -------------------------------------------------------------------------------- /11_Capability_Conflicts/patched-repo/org/slf4j/slf4j-simple/1.7.32/slf4j-simple-1.7.32.jar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jjohannes/understanding-gradle/d3a158774e2f0eb7c007046955f858906c5b11c6/11_Capability_Conflicts/patched-repo/org/slf4j/slf4j-simple/1.7.32/slf4j-simple-1.7.32.jar -------------------------------------------------------------------------------- /12_Publishing_Libraries/my-build-logic/java-plugins/build.gradle.kts: -------------------------------------------------------------------------------- 1 | plugins { 2 | `kotlin-dsl` 3 | } 4 | -------------------------------------------------------------------------------- /12_Publishing_Libraries/my-build-logic/java-plugins/src/main/kotlin/my-java-application.gradle.kts: -------------------------------------------------------------------------------- 1 | plugins { 2 | id("my-java-base") 3 | id("application") 4 | } 5 | -------------------------------------------------------------------------------- /12_Publishing_Libraries/my-build-logic/java-plugins/src/main/kotlin/my-java-base.gradle.kts: -------------------------------------------------------------------------------- 1 | plugins { 2 | id("java") 3 | } 4 | 5 | group = "org.example.my-app" 6 | version = "1.0" 7 | 8 | dependencies.constraints { 9 | implementation("org.example.my-app:shared-utils:1.0") 10 | 11 | implementation("org.apache.commons:commons-lang3:3.9") 12 | implementation("org.slf4j:slf4j-api:1.7.32") 13 | implementation("org.slf4j:slf4j-simple:1.7.32") 14 | } 15 | 16 | java { 17 | toolchain.languageVersion.set(JavaLanguageVersion.of(17)) 18 | } 19 | 20 | -------------------------------------------------------------------------------- /12_Publishing_Libraries/my-build-logic/settings.gradle.kts: -------------------------------------------------------------------------------- 1 | dependencyResolutionManagement { 2 | repositories.gradlePluginPortal() 3 | } 4 | 5 | include("java-plugins") -------------------------------------------------------------------------------- /12_Publishing_Libraries/my-other-project/settings.gradle.kts: -------------------------------------------------------------------------------- 1 | pluginManagement { 2 | repositories.gradlePluginPortal() 3 | includeBuild("../my-build-logic") 4 | } 5 | 6 | dependencyResolutionManagement { 7 | repositories.mavenCentral() 8 | } 9 | 10 | rootProject.name = "my-other-project" 11 | 12 | include("shared-utils") 13 | -------------------------------------------------------------------------------- /12_Publishing_Libraries/my-other-project/shared-utils/build.gradle.kts: -------------------------------------------------------------------------------- 1 | plugins { 2 | id("my-java-library") 3 | } 4 | -------------------------------------------------------------------------------- /12_Publishing_Libraries/my-other-project/shared-utils/src/main/java/mypproject/shared/util/EmojiEncodeUtil.java: -------------------------------------------------------------------------------- 1 | package mypproject.shared.util; 2 | 3 | public final class EmojiEncodeUtil { 4 | 5 | public static String encode(String s) { 6 | return s.replace(":)", "\uD83D\uDE03"); 7 | } 8 | 9 | } 10 | -------------------------------------------------------------------------------- /12_Publishing_Libraries/my-project/app/build.gradle.kts: -------------------------------------------------------------------------------- 1 | plugins { 2 | id("my-java-application") 3 | } 4 | 5 | application { 6 | mainClass.set("myproject.MyApplication") 7 | } 8 | 9 | dependencies { 10 | implementation("org.example.my-app:business-logic") 11 | 12 | runtimeOnly("org.slf4j:slf4j-simple") 13 | } 14 | -------------------------------------------------------------------------------- /12_Publishing_Libraries/my-project/app/src/main/java/myproject/MyApplication.java: -------------------------------------------------------------------------------- 1 | package myproject; 2 | 3 | import myproject.data.MessageModel; 4 | import myproject.services.Service; 5 | 6 | public final class MyApplication { 7 | 8 | public static void main(final String[] args) { 9 | Service.printMessage(new MessageModel("Hello there :)")); 10 | } 11 | } 12 | -------------------------------------------------------------------------------- /12_Publishing_Libraries/my-project/business-logic/build.gradle.kts: -------------------------------------------------------------------------------- 1 | plugins { 2 | id("my-java-library") 3 | } 4 | 5 | dependencies { 6 | implementation("org.apache.commons:commons-lang3") 7 | implementation("org.slf4j:slf4j-api") 8 | implementation("org.example.my-app:shared-utils") 9 | 10 | api("org.example.my-app:data-model") //alternative: project(":data-model") 11 | } 12 | -------------------------------------------------------------------------------- /12_Publishing_Libraries/my-project/business-logic/src/main/java/myproject/services/Service.java: -------------------------------------------------------------------------------- 1 | package myproject.services; 2 | 3 | import mypproject.shared.util.EmojiEncodeUtil; 4 | import myproject.data.MessageModel; 5 | import org.apache.commons.lang3.StringUtils; 6 | import org.slf4j.LoggerFactory; 7 | 8 | public final class Service { 9 | 10 | public static String printMessage(MessageModel message) { 11 | String trimmedMessage = StringUtils.trimToEmpty(message.getMessage()); 12 | String encodedMessage = EmojiEncodeUtil.encode(trimmedMessage); 13 | System.out.println(encodedMessage); 14 | LoggerFactory.getLogger(Service.class).info("Message printed"); 15 | return encodedMessage; 16 | } 17 | } 18 | -------------------------------------------------------------------------------- /12_Publishing_Libraries/my-project/data-model/build.gradle.kts: -------------------------------------------------------------------------------- 1 | plugins { 2 | id("my-java-library") 3 | } 4 | -------------------------------------------------------------------------------- /12_Publishing_Libraries/my-project/data-model/src/main/java/myproject/data/MessageModel.java: -------------------------------------------------------------------------------- 1 | package myproject.data; 2 | 3 | public final class MessageModel { 4 | 5 | private final String message; 6 | 7 | public MessageModel(String message) { 8 | this.message = message; 9 | } 10 | 11 | public String getMessage() { 12 | return message; 13 | } 14 | } 15 | -------------------------------------------------------------------------------- /12_Publishing_Libraries/my-project/settings.gradle.kts: -------------------------------------------------------------------------------- 1 | // Locations of Gradle plugins 2 | pluginManagement { 3 | repositories.gradlePluginPortal() 4 | repositories.maven("/tmp/test-repo") 5 | includeBuild("../my-build-logic") 6 | } 7 | 8 | // Location of other components 9 | dependencyResolutionManagement { 10 | repositories.mavenCentral() 11 | repositories.maven("/tmp/test-repo") 12 | includeBuild("../my-other-project") // <-- remove includeBuild() to use published version 13 | includeBuild(".") 14 | } 15 | 16 | rootProject.name = "my-project" 17 | 18 | include("app") 19 | include("business-logic") 20 | include("data-model") 21 | 22 | -------------------------------------------------------------------------------- /13_Aggregating_Custom_Artifacts/my-build-logic/java-plugins/build.gradle.kts: -------------------------------------------------------------------------------- 1 | plugins { 2 | `kotlin-dsl` 3 | } 4 | -------------------------------------------------------------------------------- /13_Aggregating_Custom_Artifacts/my-build-logic/java-plugins/src/main/kotlin/my-java-application.gradle.kts: -------------------------------------------------------------------------------- 1 | plugins { 2 | id("my-java-base") 3 | id("application") 4 | } 5 | 6 | val sourcesPath = configurations.create("sourcesPath") { 7 | isCanBeResolved = true 8 | isCanBeConsumed = false 9 | extendsFrom(configurations.implementation.get()) 10 | attributes { 11 | attribute(Usage.USAGE_ATTRIBUTE, objects.named("java-sources")) 12 | } 13 | } 14 | 15 | val fullJavadoc = tasks.register("fullJavadoc") { 16 | classpath = configurations.runtimeClasspath.get() 17 | source = sourcesPath.incoming.artifactView { lenient(true) }.files.asFileTree 18 | } 19 | 20 | tasks.build { 21 | dependsOn(fullJavadoc) 22 | } 23 | -------------------------------------------------------------------------------- /13_Aggregating_Custom_Artifacts/my-build-logic/java-plugins/src/main/kotlin/my-java-base.gradle.kts: -------------------------------------------------------------------------------- 1 | plugins { 2 | id("java") 3 | } 4 | 5 | group = "org.example.my-app" 6 | version = "1.0" 7 | 8 | dependencies.constraints { 9 | implementation("org.apache.commons:commons-lang3:3.9") 10 | } 11 | 12 | java { 13 | toolchain.languageVersion.set(JavaLanguageVersion.of(17)) 14 | } 15 | 16 | configurations.create("sourcesElements") { 17 | isCanBeResolved = false 18 | isCanBeConsumed = true 19 | extendsFrom(configurations.implementation.get()) 20 | attributes { 21 | attribute(Usage.USAGE_ATTRIBUTE, objects.named("java-sources")) 22 | } 23 | sourceSets.main.get().java.srcDirs.forEach { 24 | outgoing.artifact(it) 25 | } 26 | } 27 | -------------------------------------------------------------------------------- /13_Aggregating_Custom_Artifacts/my-build-logic/java-plugins/src/main/kotlin/my-java-library.gradle.kts: -------------------------------------------------------------------------------- 1 | plugins { 2 | id("my-java-base") 3 | id("java-library") 4 | } 5 | -------------------------------------------------------------------------------- /13_Aggregating_Custom_Artifacts/my-build-logic/settings.gradle.kts: -------------------------------------------------------------------------------- 1 | dependencyResolutionManagement { 2 | repositories.gradlePluginPortal() 3 | } 4 | 5 | include("java-plugins") -------------------------------------------------------------------------------- /13_Aggregating_Custom_Artifacts/my-other-project/settings.gradle.kts: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jjohannes/understanding-gradle/d3a158774e2f0eb7c007046955f858906c5b11c6/13_Aggregating_Custom_Artifacts/my-other-project/settings.gradle.kts -------------------------------------------------------------------------------- /13_Aggregating_Custom_Artifacts/my-project/app/build.gradle.kts: -------------------------------------------------------------------------------- 1 | plugins { 2 | id("my-java-application") 3 | } 4 | 5 | application { 6 | mainClass.set("myproject.MyApplication") 7 | } 8 | 9 | dependencies { 10 | implementation("org.example.my-app:business-logic") 11 | } 12 | -------------------------------------------------------------------------------- /13_Aggregating_Custom_Artifacts/my-project/app/src/main/java/myproject/MyApplication.java: -------------------------------------------------------------------------------- 1 | package myproject; 2 | 3 | import myproject.data.MessageModel; 4 | import myproject.services.Service; 5 | 6 | public final class MyApplication { 7 | 8 | public static void main(final String[] args) { 9 | Service.printMessage(new MessageModel("Hello there :)")); 10 | } 11 | } 12 | -------------------------------------------------------------------------------- /13_Aggregating_Custom_Artifacts/my-project/business-logic/build.gradle.kts: -------------------------------------------------------------------------------- 1 | plugins { 2 | id("my-java-library") 3 | } 4 | 5 | dependencies { 6 | implementation("org.apache.commons:commons-lang3") 7 | 8 | api("org.example.my-app:data-model") //alternative: project(":data-model") 9 | } 10 | -------------------------------------------------------------------------------- /13_Aggregating_Custom_Artifacts/my-project/business-logic/src/main/java/myproject/services/Service.java: -------------------------------------------------------------------------------- 1 | package myproject.services; 2 | 3 | import myproject.data.MessageModel; 4 | import org.apache.commons.lang3.StringUtils; 5 | 6 | public final class Service { 7 | 8 | public static String printMessage(MessageModel message) { 9 | String trimmedMessage = StringUtils.trimToEmpty(message.getMessage()); 10 | System.out.println(trimmedMessage); 11 | return trimmedMessage; 12 | } 13 | } 14 | -------------------------------------------------------------------------------- /13_Aggregating_Custom_Artifacts/my-project/data-model/build.gradle.kts: -------------------------------------------------------------------------------- 1 | plugins { 2 | id("my-java-library") 3 | } 4 | -------------------------------------------------------------------------------- /13_Aggregating_Custom_Artifacts/my-project/data-model/src/main/java/myproject/data/MessageModel.java: -------------------------------------------------------------------------------- 1 | package myproject.data; 2 | 3 | public final class MessageModel { 4 | 5 | private final String message; 6 | 7 | public MessageModel(String message) { 8 | this.message = message; 9 | } 10 | 11 | public String getMessage() { 12 | return message; 13 | } 14 | } 15 | -------------------------------------------------------------------------------- /13_Aggregating_Custom_Artifacts/my-project/settings.gradle.kts: -------------------------------------------------------------------------------- 1 | // Locations of Gradle plugins 2 | pluginManagement { 3 | repositories.gradlePluginPortal() 4 | includeBuild("../my-build-logic") 5 | } 6 | 7 | // Location of other components 8 | dependencyResolutionManagement { 9 | repositories.mavenCentral() 10 | includeBuild("../my-other-project") 11 | includeBuild(".") 12 | } 13 | 14 | rootProject.name = "my-project" 15 | 16 | include("app") 17 | include("business-logic") 18 | include("data-model") 19 | 20 | -------------------------------------------------------------------------------- /14_Settings_Plugins/my-build-logic/java-plugins/build.gradle.kts: -------------------------------------------------------------------------------- 1 | plugins { 2 | `kotlin-dsl` 3 | } 4 | -------------------------------------------------------------------------------- /14_Settings_Plugins/my-build-logic/java-plugins/src/main/kotlin/my-java-application.gradle.kts: -------------------------------------------------------------------------------- 1 | plugins { 2 | id("my-java-base") 3 | id("application") 4 | } 5 | -------------------------------------------------------------------------------- /14_Settings_Plugins/my-build-logic/java-plugins/src/main/kotlin/my-java-base.gradle.kts: -------------------------------------------------------------------------------- 1 | plugins { 2 | id("java") 3 | } 4 | 5 | group = "org.example.my-app" 6 | version = "1.0" 7 | 8 | dependencies.constraints { 9 | implementation("org.apache.commons:commons-lang3:3.9") 10 | } 11 | 12 | java { 13 | toolchain.languageVersion.set(JavaLanguageVersion.of(17)) 14 | } 15 | -------------------------------------------------------------------------------- /14_Settings_Plugins/my-build-logic/java-plugins/src/main/kotlin/my-java-library.gradle.kts: -------------------------------------------------------------------------------- 1 | plugins { 2 | id("my-java-base") 3 | id("java-library") 4 | } 5 | -------------------------------------------------------------------------------- /14_Settings_Plugins/my-build-logic/settings.gradle.kts: -------------------------------------------------------------------------------- 1 | dependencyResolutionManagement { 2 | repositories.gradlePluginPortal() 3 | } 4 | 5 | include("structure-plugins") 6 | include("java-plugins") 7 | -------------------------------------------------------------------------------- /14_Settings_Plugins/my-build-logic/structure-plugins/build.gradle.kts: -------------------------------------------------------------------------------- 1 | plugins { 2 | `kotlin-dsl` 3 | } 4 | -------------------------------------------------------------------------------- /14_Settings_Plugins/my-build-logic/structure-plugins/src/main/kotlin/my-project-structure.settings.gradle.kts: -------------------------------------------------------------------------------- 1 | // Locations of Gradle plugins 2 | pluginManagement { 3 | repositories.gradlePluginPortal() 4 | } 5 | 6 | // Location of other components 7 | dependencyResolutionManagement { 8 | repositories.mavenCentral() 9 | rootDir.parentFile.listFiles()?.filter { 10 | File(it, "settings.gradle.kts").exists() 11 | }?.forEach { 12 | includeBuild(it.path) 13 | } 14 | } 15 | 16 | rootDir.listFiles()?.filter { 17 | File(it, "build.gradle.kts").exists() 18 | }?.forEach { 19 | include(it.name) 20 | } 21 | -------------------------------------------------------------------------------- /14_Settings_Plugins/my-other-project/settings.gradle.kts: -------------------------------------------------------------------------------- 1 | pluginManagement { 2 | includeBuild("../my-build-logic") 3 | } 4 | plugins { 5 | id("my-project-structure") 6 | } 7 | -------------------------------------------------------------------------------- /14_Settings_Plugins/my-other-project/shared-utils/build.gradle.kts: -------------------------------------------------------------------------------- 1 | plugins { 2 | id("my-java-library") 3 | } 4 | -------------------------------------------------------------------------------- /14_Settings_Plugins/my-other-project/shared-utils/src/main/java/myproject/shared/util/EmojiEncodeUtil.java: -------------------------------------------------------------------------------- 1 | package myproject.shared.util; 2 | 3 | public final class EmojiEncodeUtil { 4 | 5 | public static String encode(String s) { 6 | return s.replace(":)", "\uD83D\uDE03"); 7 | } 8 | 9 | } 10 | -------------------------------------------------------------------------------- /14_Settings_Plugins/my-project/app/build.gradle.kts: -------------------------------------------------------------------------------- 1 | plugins { 2 | id("my-java-application") 3 | } 4 | 5 | application { 6 | mainClass.set("myproject.MyApplication") 7 | } 8 | 9 | dependencies { 10 | implementation("org.example.my-app:business-logic") 11 | } 12 | -------------------------------------------------------------------------------- /14_Settings_Plugins/my-project/app/src/main/java/myproject/MyApplication.java: -------------------------------------------------------------------------------- 1 | package myproject; 2 | 3 | import myproject.data.MessageModel; 4 | import myproject.services.Service; 5 | 6 | public final class MyApplication { 7 | 8 | public static void main(final String[] args) { 9 | Service.printMessage(new MessageModel("Hello there :)")); 10 | } 11 | } 12 | -------------------------------------------------------------------------------- /14_Settings_Plugins/my-project/business-logic/build.gradle.kts: -------------------------------------------------------------------------------- 1 | plugins { 2 | id("my-java-library") 3 | } 4 | 5 | dependencies { 6 | implementation("org.apache.commons:commons-lang3") 7 | 8 | implementation("org.example.my-app:shared-utils") 9 | api("org.example.my-app:data-model") //alternative: project(":data-model") 10 | } 11 | -------------------------------------------------------------------------------- /14_Settings_Plugins/my-project/business-logic/src/main/java/myproject/services/Service.java: -------------------------------------------------------------------------------- 1 | package myproject.services; 2 | 3 | import myproject.shared.util.EmojiEncodeUtil; 4 | import myproject.data.MessageModel; 5 | import org.apache.commons.lang3.StringUtils; 6 | 7 | public final class Service { 8 | 9 | public static String printMessage(MessageModel message) { 10 | String trimmedMessage = StringUtils.trimToEmpty(message.getMessage()); 11 | String encodedMessage = EmojiEncodeUtil.encode(trimmedMessage); 12 | System.out.println(encodedMessage); 13 | return encodedMessage; 14 | } 15 | } 16 | -------------------------------------------------------------------------------- /14_Settings_Plugins/my-project/data-model/build.gradle.kts: -------------------------------------------------------------------------------- 1 | plugins { 2 | id("my-java-library") 3 | } 4 | -------------------------------------------------------------------------------- /14_Settings_Plugins/my-project/data-model/src/main/java/myproject/data/MessageModel.java: -------------------------------------------------------------------------------- 1 | package myproject.data; 2 | 3 | public final class MessageModel { 4 | 5 | private final String message; 6 | 7 | public MessageModel(String message) { 8 | this.message = message; 9 | } 10 | 11 | public String getMessage() { 12 | return message; 13 | } 14 | } 15 | -------------------------------------------------------------------------------- /14_Settings_Plugins/my-project/settings.gradle.kts: -------------------------------------------------------------------------------- 1 | pluginManagement { 2 | includeBuild("../my-build-logic") 3 | } 4 | plugins { 5 | id("my-project-structure") 6 | } 7 | -------------------------------------------------------------------------------- /16_Source_Sets/my-android-project/app-android/build.gradle.kts: -------------------------------------------------------------------------------- 1 | plugins { 2 | id("my-android-application") 3 | } 4 | -------------------------------------------------------------------------------- /16_Source_Sets/my-android-project/app-android/src/main/AndroidManifest.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | -------------------------------------------------------------------------------- /16_Source_Sets/my-android-project/app-android/src/main/java/myproject/shared/util/EmojiEncodeUtil.java: -------------------------------------------------------------------------------- 1 | package myproject.shared.util; 2 | 3 | public final class EmojiEncodeUtil { 4 | 5 | public static String encode(String s) { 6 | return s.replace(":)", "\uD83D\uDE03"); 7 | } 8 | 9 | } 10 | -------------------------------------------------------------------------------- /16_Source_Sets/my-android-project/gradle.properties: -------------------------------------------------------------------------------- 1 | org.gradle.jvmargs=-Xmx2g -------------------------------------------------------------------------------- /16_Source_Sets/my-android-project/settings.gradle.kts: -------------------------------------------------------------------------------- 1 | pluginManagement { 2 | includeBuild("../my-build-logic") 3 | } 4 | plugins { 5 | id("my-project-structure") 6 | } 7 | -------------------------------------------------------------------------------- /16_Source_Sets/my-build-logic/android-plugins/build.gradle.kts: -------------------------------------------------------------------------------- 1 | plugins { 2 | `kotlin-dsl` 3 | } 4 | 5 | dependencies { 6 | implementation("com.android.tools.build:gradle:8.11.0-alpha03") 7 | } -------------------------------------------------------------------------------- /16_Source_Sets/my-build-logic/android-plugins/src/main/kotlin/my-android-application.gradle.kts: -------------------------------------------------------------------------------- 1 | plugins { 2 | id("com.android.application") 3 | } 4 | 5 | android { 6 | compileSdk = 30 7 | defaultConfig { 8 | minSdk = 26 9 | targetSdk = 31 10 | } 11 | namespace = "myproject.android" 12 | 13 | sourceSets.getByName("main") { 14 | // get and configure an 'AndroidSourceSet' 15 | } 16 | 17 | applicationVariants.matching { it.name == "debug" }.all { 18 | sourceSets.find { it.name == "debug" }!!.apply { 19 | // get and configure an Android 'SourceProvider' (Build Type and Flavor specific) 20 | } 21 | } 22 | } 23 | -------------------------------------------------------------------------------- /16_Source_Sets/my-build-logic/java-plugins/build.gradle.kts: -------------------------------------------------------------------------------- 1 | plugins { 2 | `kotlin-dsl` 3 | } 4 | -------------------------------------------------------------------------------- /16_Source_Sets/my-build-logic/java-plugins/src/main/kotlin/my-java-application.gradle.kts: -------------------------------------------------------------------------------- 1 | plugins { 2 | id("my-java-base") 3 | id("application") 4 | } 5 | 6 | tasks.register("runJava17") { 7 | classpath = configurations.runtimeClasspath.get() + files(tasks.jar) 8 | javaLauncher.set(javaToolchains.launcherFor { 9 | languageVersion = JavaLanguageVersion.of(17) 10 | }) 11 | mainClass = application.mainClass 12 | group = "application" 13 | } -------------------------------------------------------------------------------- /16_Source_Sets/my-build-logic/java-plugins/src/main/kotlin/my-java-library.gradle.kts: -------------------------------------------------------------------------------- 1 | plugins { 2 | id("my-java-base") 3 | id("java-library") 4 | } 5 | -------------------------------------------------------------------------------- /16_Source_Sets/my-build-logic/kotlin-plugins/build.gradle.kts: -------------------------------------------------------------------------------- 1 | plugins { 2 | `kotlin-dsl` 3 | } 4 | 5 | dependencies { 6 | implementation("org.jetbrains.kotlin:kotlin-gradle-plugin:2.1.20") 7 | } -------------------------------------------------------------------------------- /16_Source_Sets/my-build-logic/kotlin-plugins/src/main/kotlin/my-kotlin-multiplatform-lib.gradle.kts: -------------------------------------------------------------------------------- 1 | plugins { 2 | id("org.jetbrains.kotlin.multiplatform") 3 | } 4 | 5 | kotlin { 6 | jvm() // activate Jvm target 7 | 8 | sourceSets.getByName("commonMain") { 9 | // get and configure a 'KotlinSourceSet' 10 | } 11 | } 12 | -------------------------------------------------------------------------------- /16_Source_Sets/my-build-logic/settings.gradle.kts: -------------------------------------------------------------------------------- 1 | dependencyResolutionManagement { 2 | repositories.gradlePluginPortal() 3 | repositories.google() 4 | } 5 | 6 | include("structure-plugins") 7 | include("java-plugins") 8 | include("android-plugins") 9 | include("kotlin-plugins") 10 | -------------------------------------------------------------------------------- /16_Source_Sets/my-build-logic/structure-plugins/build.gradle.kts: -------------------------------------------------------------------------------- 1 | plugins { 2 | `kotlin-dsl` 3 | } 4 | -------------------------------------------------------------------------------- /16_Source_Sets/my-build-logic/structure-plugins/src/main/kotlin/my-project-structure.settings.gradle.kts: -------------------------------------------------------------------------------- 1 | // Locations of Gradle plugins 2 | pluginManagement { 3 | repositories.gradlePluginPortal() 4 | repositories.google() 5 | } 6 | 7 | // Location of other components 8 | dependencyResolutionManagement { 9 | repositories.mavenCentral() 10 | repositories.google() 11 | rootDir.parentFile.listFiles()?.filter { 12 | File(it, "settings.gradle.kts").exists() 13 | }?.forEach { 14 | if (it.path != rootDir.path) { 15 | includeBuild(it.path) 16 | } 17 | } 18 | } 19 | 20 | rootDir.listFiles()?.filter { 21 | File(it, "build.gradle.kts").exists() 22 | }?.forEach { 23 | include(it.name) 24 | } 25 | -------------------------------------------------------------------------------- /16_Source_Sets/my-kotlin-multi-platform-project/gradle.properties: -------------------------------------------------------------------------------- 1 | org.gradle.jvmargs=-Xmx2g -------------------------------------------------------------------------------- /16_Source_Sets/my-kotlin-multi-platform-project/settings.gradle.kts: -------------------------------------------------------------------------------- 1 | pluginManagement { 2 | includeBuild("../my-build-logic") 3 | } 4 | plugins { 5 | id("my-project-structure") 6 | } 7 | -------------------------------------------------------------------------------- /16_Source_Sets/my-kotlin-multi-platform-project/utils-kotlin/build.gradle.kts: -------------------------------------------------------------------------------- 1 | plugins { 2 | id("my-kotlin-multiplatform-lib") 3 | } 4 | -------------------------------------------------------------------------------- /16_Source_Sets/my-kotlin-multi-platform-project/utils-kotlin/src/commonMain/kotlin/myproject/shared/util/EncodeUtils.kt: -------------------------------------------------------------------------------- 1 | package myproject.shared.util 2 | 3 | fun String.encodeEmoji() = replace(":)", "\uD83D\uDE03") 4 | -------------------------------------------------------------------------------- /16_Source_Sets/my-project/app/build.gradle.kts: -------------------------------------------------------------------------------- 1 | plugins { 2 | id("my-java-application") 3 | } 4 | 5 | application { 6 | mainClass.set("myproject.MyApplication") 7 | } 8 | 9 | dependencies { 10 | implementation("org.example.my-app:business-logic") 11 | 12 | extraFeatureImplementation("org.apache.commons:commons-lang3") 13 | } 14 | 15 | -------------------------------------------------------------------------------- /16_Source_Sets/my-project/app/src/extraFeature/groovy/.gitignore: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jjohannes/understanding-gradle/d3a158774e2f0eb7c007046955f858906c5b11c6/16_Source_Sets/my-project/app/src/extraFeature/groovy/.gitignore -------------------------------------------------------------------------------- /16_Source_Sets/my-project/app/src/extraFeature/java/myproject/extra/ExtraFeature.java: -------------------------------------------------------------------------------- 1 | package myproject.extra; 2 | 3 | import org.apache.commons.lang3.StringUtils; 4 | 5 | public class ExtraFeature { 6 | private String m2 = StringUtils.trimToEmpty(" a b"); 7 | } 8 | -------------------------------------------------------------------------------- /16_Source_Sets/my-project/app/src/main/groovy/.gitignore: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jjohannes/understanding-gradle/d3a158774e2f0eb7c007046955f858906c5b11c6/16_Source_Sets/my-project/app/src/main/groovy/.gitignore -------------------------------------------------------------------------------- /16_Source_Sets/my-project/app/src/main/java/myproject/MyApplication.java: -------------------------------------------------------------------------------- 1 | package myproject; 2 | 3 | import myproject.data.MessageModel; 4 | import myproject.services.Service; 5 | 6 | import java.util.Scanner; 7 | 8 | public final class MyApplication { 9 | 10 | public static void main(final String[] args) { 11 | Service.printMessage(new MessageModel(readeMessageTxt())); 12 | Service.printMessage(new MessageModel("Java 11")); 13 | } 14 | 15 | static String readeMessageTxt() { 16 | //noinspection ConstantConditions 17 | return new Scanner(MyApplication.class.getResourceAsStream("message.txt")) 18 | .useDelimiter("\n").next(); 19 | } 20 | } 21 | -------------------------------------------------------------------------------- /16_Source_Sets/my-project/app/src/main/java17/myproject/MyApplication.java: -------------------------------------------------------------------------------- 1 | package myproject; 2 | 3 | import myproject.data.MessageModel; 4 | import myproject.services.Service; 5 | 6 | import java.util.Scanner; 7 | 8 | public final class MyApplication { 9 | 10 | public static void main(final String[] args) { 11 | Service.printMessage(new MessageModel(readeMessageTxt())); 12 | Service.printMessage(new MessageModel("Java 17")); 13 | } 14 | 15 | static String readeMessageTxt() { 16 | //noinspection ConstantConditions 17 | return new Scanner(MyApplication.class.getResourceAsStream("message.txt")) 18 | .useDelimiter("\n").next(); 19 | } 20 | } 21 | -------------------------------------------------------------------------------- /16_Source_Sets/my-project/app/src/main/resources/myproject/message.txt: -------------------------------------------------------------------------------- 1 | Hello there :) -------------------------------------------------------------------------------- /16_Source_Sets/my-project/app/src/test/groovy/.gitignore: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jjohannes/understanding-gradle/d3a158774e2f0eb7c007046955f858906c5b11c6/16_Source_Sets/my-project/app/src/test/groovy/.gitignore -------------------------------------------------------------------------------- /16_Source_Sets/my-project/app/src/test/java/myproject/MyApplicationTest.java: -------------------------------------------------------------------------------- 1 | package myproject; 2 | 3 | import org.junit.Test; 4 | 5 | import static org.junit.Assert.assertEquals; 6 | 7 | public class MyApplicationTest { 8 | 9 | @Test 10 | public void testApp() { 11 | assertEquals("Hello there :)", MyApplication.readeMessageTxt()); 12 | } 13 | } 14 | -------------------------------------------------------------------------------- /16_Source_Sets/my-project/business-logic/build.gradle.kts: -------------------------------------------------------------------------------- 1 | plugins { 2 | id("my-java-library") 3 | } 4 | 5 | dependencies { 6 | implementation("org.apache.commons:commons-lang3") 7 | 8 | api("org.example.my-app:data-model") //alternative: project(":data-model") 9 | } 10 | -------------------------------------------------------------------------------- /16_Source_Sets/my-project/business-logic/src/main/java/myproject/services/Service.java: -------------------------------------------------------------------------------- 1 | package myproject.services; 2 | 3 | import myproject.data.MessageModel; 4 | import org.apache.commons.lang3.StringUtils; 5 | 6 | public final class Service { 7 | 8 | public static String printMessage(MessageModel message) { 9 | String trimmedMessage = StringUtils.trimToEmpty(message.getMessage()); 10 | String encodedMessage = encode(trimmedMessage); 11 | System.out.println(encodedMessage); 12 | return encodedMessage; 13 | } 14 | 15 | public static String encode(String s) { 16 | return s.replace(":)", "\uD83D\uDE03"); 17 | } 18 | } 19 | -------------------------------------------------------------------------------- /16_Source_Sets/my-project/data-model/build.gradle.kts: -------------------------------------------------------------------------------- 1 | plugins { 2 | id("my-java-library") 3 | } 4 | -------------------------------------------------------------------------------- /16_Source_Sets/my-project/data-model/src/main/java/myproject/data/MessageModel.java: -------------------------------------------------------------------------------- 1 | package myproject.data; 2 | 3 | public final class MessageModel { 4 | 5 | private final String message; 6 | 7 | public MessageModel(String message) { 8 | this.message = message; 9 | } 10 | 11 | public String getMessage() { 12 | return message; 13 | } 14 | } 15 | -------------------------------------------------------------------------------- /16_Source_Sets/my-project/gradle.properties: -------------------------------------------------------------------------------- 1 | org.gradle.jvmargs=-Xmx2g -------------------------------------------------------------------------------- /16_Source_Sets/my-project/settings.gradle.kts: -------------------------------------------------------------------------------- 1 | pluginManagement { 2 | includeBuild("../my-build-logic") 3 | } 4 | plugins { 5 | id("my-project-structure") 6 | } 7 | -------------------------------------------------------------------------------- /17_Feature_Variants/my-build-logic/java-plugins/build.gradle.kts: -------------------------------------------------------------------------------- 1 | plugins { 2 | `kotlin-dsl` 3 | } 4 | -------------------------------------------------------------------------------- /17_Feature_Variants/my-build-logic/java-plugins/src/main/kotlin/my-java-application.gradle.kts: -------------------------------------------------------------------------------- 1 | plugins { 2 | id("my-java-base") 3 | id("application") 4 | } 5 | -------------------------------------------------------------------------------- /17_Feature_Variants/my-build-logic/java-plugins/src/main/kotlin/my-java-base.gradle.kts: -------------------------------------------------------------------------------- 1 | plugins { 2 | id("java") 3 | } 4 | 5 | group = "org.example.my-app" 6 | version = "1.0" 7 | 8 | java { 9 | toolchain.languageVersion.set(JavaLanguageVersion.of(17)) 10 | } 11 | 12 | tasks.compileJava { 13 | options.compilerArgs = listOf("-parameters") 14 | } 15 | 16 | // Centralized versions 17 | dependencies.constraints { 18 | implementation("org.apache.commons:commons-lang3:3.9") 19 | } 20 | -------------------------------------------------------------------------------- /17_Feature_Variants/my-build-logic/settings.gradle.kts: -------------------------------------------------------------------------------- 1 | dependencyResolutionManagement { 2 | repositories.gradlePluginPortal() 3 | } 4 | 5 | include("structure-plugins") 6 | include("java-plugins") 7 | -------------------------------------------------------------------------------- /17_Feature_Variants/my-build-logic/structure-plugins/build.gradle.kts: -------------------------------------------------------------------------------- 1 | plugins { 2 | `kotlin-dsl` 3 | } 4 | -------------------------------------------------------------------------------- /17_Feature_Variants/my-build-logic/structure-plugins/src/main/kotlin/my-project-structure.settings.gradle.kts: -------------------------------------------------------------------------------- 1 | // Locations of Gradle plugins 2 | pluginManagement { 3 | repositories.gradlePluginPortal() 4 | } 5 | 6 | // Location of other components 7 | dependencyResolutionManagement { 8 | repositories.mavenCentral() 9 | rootDir.parentFile.listFiles()?.filter { 10 | File(it, "settings.gradle.kts").exists() 11 | }?.forEach { 12 | includeBuild(it.path) 13 | } 14 | } 15 | 16 | rootDir.listFiles()?.filter { 17 | File(it, "build.gradle.kts").exists() 18 | }?.forEach { 19 | include(it.name) 20 | } 21 | -------------------------------------------------------------------------------- /17_Feature_Variants/my-project/app/build.gradle.kts: -------------------------------------------------------------------------------- 1 | plugins { 2 | id("my-java-application") 3 | } 4 | 5 | application { 6 | mainClass.set("myproject.MyApplication") 7 | } 8 | 9 | dependencies { 10 | implementation("org.example.my-app:business-logic") 11 | 12 | implementation("org.example.my-app:data-model") { 13 | capabilities { requireCapability("org.example.my-app:data-model-json") } 14 | } 15 | } 16 | 17 | -------------------------------------------------------------------------------- /17_Feature_Variants/my-project/app/data/message.json: -------------------------------------------------------------------------------- 1 | {"message":"Hello there :) (this was JSON)"} -------------------------------------------------------------------------------- /17_Feature_Variants/my-project/app/data/message.xml: -------------------------------------------------------------------------------- 1 | Hello there :) (this was XML) -------------------------------------------------------------------------------- /17_Feature_Variants/my-project/app/src/main/java/myproject/MyApplication.java: -------------------------------------------------------------------------------- 1 | package myproject; 2 | 3 | import myproject.data.serialization.Serializer; 4 | import myproject.services.Service; 5 | 6 | import java.io.File; 7 | 8 | public final class MyApplication { 9 | 10 | public static void main(final String[] args) { 11 | Serializer serializer = new Serializer(new File("data")); 12 | Service.printMessage(serializer.parse()); 13 | } 14 | } 15 | -------------------------------------------------------------------------------- /17_Feature_Variants/my-project/business-logic/build.gradle.kts: -------------------------------------------------------------------------------- 1 | plugins { 2 | id("my-java-library") 3 | } 4 | 5 | dependencies { 6 | implementation("org.apache.commons:commons-lang3") 7 | 8 | api("org.example.my-app:data-model") //alternative: project(":data-model") 9 | } 10 | -------------------------------------------------------------------------------- /17_Feature_Variants/my-project/business-logic/src/main/java/myproject/services/Service.java: -------------------------------------------------------------------------------- 1 | package myproject.services; 2 | 3 | import myproject.data.MessageModel; 4 | import org.apache.commons.lang3.StringUtils; 5 | 6 | public final class Service { 7 | 8 | public static String printMessage(MessageModel message) { 9 | String trimmedMessage = StringUtils.trimToEmpty(message.getMessage()); 10 | String encodedMessage = encode(trimmedMessage); 11 | System.out.println(encodedMessage); 12 | return encodedMessage; 13 | } 14 | 15 | public static String encode(String s) { 16 | return s.replace(":)", "\uD83D\uDE03"); 17 | } 18 | } 19 | -------------------------------------------------------------------------------- /17_Feature_Variants/my-project/data-model/build.gradle.kts: -------------------------------------------------------------------------------- 1 | plugins { 2 | id("my-java-library") 3 | } 4 | 5 | dependencies { 6 | jsonImplementation(project(path)) 7 | jsonImplementation("com.fasterxml.jackson.core:jackson-databind") 8 | jsonImplementation("com.fasterxml.jackson.module:jackson-module-parameter-names") 9 | 10 | xmlImplementation(project(path)) 11 | xmlImplementation("com.fasterxml.jackson.core:jackson-databind") 12 | xmlImplementation("com.fasterxml.jackson.dataformat:jackson-dataformat-xml") 13 | xmlImplementation("com.fasterxml.jackson.module:jackson-module-parameter-names") 14 | } 15 | -------------------------------------------------------------------------------- /17_Feature_Variants/my-project/data-model/src/main/java/myproject/data/MessageModel.java: -------------------------------------------------------------------------------- 1 | package myproject.data; 2 | 3 | public final class MessageModel { 4 | 5 | private final String message; 6 | 7 | public MessageModel(String message) { 8 | this.message = message; 9 | } 10 | 11 | public String getMessage() { 12 | return message; 13 | } 14 | } 15 | -------------------------------------------------------------------------------- /17_Feature_Variants/my-project/settings.gradle.kts: -------------------------------------------------------------------------------- 1 | pluginManagement { 2 | includeBuild("../my-build-logic") 3 | } 4 | plugins { 5 | id("my-project-structure") 6 | } 7 | -------------------------------------------------------------------------------- /18_Configuring_Testing/my-build-logic/java-plugins/build.gradle.kts: -------------------------------------------------------------------------------- 1 | plugins { 2 | `kotlin-dsl` 3 | } 4 | -------------------------------------------------------------------------------- /18_Configuring_Testing/my-build-logic/java-plugins/src/main/kotlin/my-java-application.gradle.kts: -------------------------------------------------------------------------------- 1 | plugins { 2 | id("my-java-base") 3 | id("application") 4 | } 5 | -------------------------------------------------------------------------------- /18_Configuring_Testing/my-build-logic/java-plugins/src/main/kotlin/my-java-library.gradle.kts: -------------------------------------------------------------------------------- 1 | plugins { 2 | id("my-java-base") 3 | id("java-library") 4 | } 5 | -------------------------------------------------------------------------------- /18_Configuring_Testing/my-build-logic/settings.gradle.kts: -------------------------------------------------------------------------------- 1 | dependencyResolutionManagement { 2 | repositories.gradlePluginPortal() 3 | } 4 | 5 | include("structure-plugins") 6 | include("java-plugins") 7 | -------------------------------------------------------------------------------- /18_Configuring_Testing/my-build-logic/structure-plugins/build.gradle.kts: -------------------------------------------------------------------------------- 1 | plugins { 2 | `kotlin-dsl` 3 | } 4 | -------------------------------------------------------------------------------- /18_Configuring_Testing/my-build-logic/structure-plugins/src/main/kotlin/my-project-structure.settings.gradle.kts: -------------------------------------------------------------------------------- 1 | // Locations of Gradle plugins 2 | pluginManagement { 3 | repositories.gradlePluginPortal() 4 | } 5 | 6 | // Location of other components 7 | dependencyResolutionManagement { 8 | repositories.mavenCentral() 9 | rootDir.parentFile.listFiles()?.filter { 10 | File(it, "settings.gradle.kts").exists() 11 | }?.forEach { 12 | includeBuild(it.path) 13 | } 14 | } 15 | 16 | rootDir.listFiles()?.filter { 17 | File(it, "build.gradle.kts").exists() 18 | }?.forEach { 19 | include(it.name) 20 | } 21 | -------------------------------------------------------------------------------- /18_Configuring_Testing/my-project/app/build.gradle.kts: -------------------------------------------------------------------------------- 1 | plugins { 2 | id("my-java-application") 3 | } 4 | 5 | application { 6 | mainClass.set("myproject.MyApplication") 7 | } 8 | 9 | dependencies { 10 | implementation("org.example.my-app:business-logic") 11 | } 12 | -------------------------------------------------------------------------------- /18_Configuring_Testing/my-project/app/src/main/java/myproject/MyApplication.java: -------------------------------------------------------------------------------- 1 | package myproject; 2 | 3 | import myproject.data.MessageModel; 4 | import myproject.services.Service; 5 | 6 | public final class MyApplication { 7 | 8 | public static void main(final String[] args) { 9 | Service.printMessage(new MessageModel("Hello there :)")); 10 | } 11 | } 12 | -------------------------------------------------------------------------------- /18_Configuring_Testing/my-project/business-logic/build.gradle.kts: -------------------------------------------------------------------------------- 1 | plugins { 2 | id("my-java-library") 3 | } 4 | 5 | dependencies { 6 | implementation("org.apache.commons:commons-lang3") 7 | 8 | api("org.example.my-app:data-model") //alternative: project(":data-model") 9 | } 10 | -------------------------------------------------------------------------------- /18_Configuring_Testing/my-project/business-logic/src/integrationTest/java/myproject/services/test/ServiceIntegrationTest.java: -------------------------------------------------------------------------------- 1 | package myproject.services.test; 2 | 3 | import org.apache.commons.io.IOUtils; 4 | import org.junit.jupiter.api.Test; 5 | 6 | public class ServiceIntegrationTest { 7 | 8 | @Test 9 | void testService() { 10 | IOUtils.byteArray(); 11 | // ... 12 | } 13 | } 14 | -------------------------------------------------------------------------------- /18_Configuring_Testing/my-project/business-logic/src/main/java/myproject/services/Service.java: -------------------------------------------------------------------------------- 1 | package myproject.services; 2 | 3 | import myproject.data.MessageModel; 4 | import org.apache.commons.lang3.StringUtils; 5 | 6 | public final class Service { 7 | 8 | public static String printMessage(MessageModel message) { 9 | String trimmedMessage = StringUtils.trimToEmpty(message.getMessage()); 10 | String encodedMessage = encode(trimmedMessage); 11 | System.out.println(encodedMessage); 12 | return encodedMessage; 13 | } 14 | 15 | public static String encode(String s) { 16 | return s.replace(":)", "\uD83D\uDE03"); 17 | } 18 | } 19 | -------------------------------------------------------------------------------- /18_Configuring_Testing/my-project/business-logic/src/test/java/myproject/services/ServiceTest.java: -------------------------------------------------------------------------------- 1 | package myproject.services; 2 | 3 | import myproject.data.MessageModel; 4 | import org.junit.jupiter.api.Test; 5 | 6 | import static org.junit.jupiter.api.Assertions.assertEquals; 7 | 8 | public class ServiceTest { 9 | 10 | @Test 11 | void testEncoding() { 12 | assertEquals( 13 | "Hi \uD83D\uDE03", 14 | Service.printMessage(new MessageModel("Hi :)")) 15 | ); 16 | } 17 | } 18 | -------------------------------------------------------------------------------- /18_Configuring_Testing/my-project/data-model/build.gradle.kts: -------------------------------------------------------------------------------- 1 | plugins { 2 | id("my-java-library") 3 | } 4 | -------------------------------------------------------------------------------- /18_Configuring_Testing/my-project/data-model/src/main/java/myproject/data/MessageModel.java: -------------------------------------------------------------------------------- 1 | package myproject.data; 2 | 3 | public final class MessageModel { 4 | 5 | private final String message; 6 | 7 | public MessageModel(String message) { 8 | this.message = message; 9 | } 10 | 11 | public String getMessage() { 12 | return message; 13 | } 14 | } 15 | -------------------------------------------------------------------------------- /18_Configuring_Testing/my-project/settings.gradle.kts: -------------------------------------------------------------------------------- 1 | pluginManagement { 2 | includeBuild("../my-build-logic") 3 | } 4 | plugins { 5 | id("my-project-structure") 6 | } 7 | -------------------------------------------------------------------------------- /19_The_Test_Task/my-build-logic/java-plugins/build.gradle.kts: -------------------------------------------------------------------------------- 1 | plugins { 2 | `kotlin-dsl` 3 | } 4 | -------------------------------------------------------------------------------- /19_The_Test_Task/my-build-logic/java-plugins/src/main/kotlin/my-java-application.gradle.kts: -------------------------------------------------------------------------------- 1 | plugins { 2 | id("my-java-base") 3 | id("application") 4 | } 5 | -------------------------------------------------------------------------------- /19_The_Test_Task/my-build-logic/java-plugins/src/main/kotlin/my-java-library.gradle.kts: -------------------------------------------------------------------------------- 1 | plugins { 2 | id("my-java-base") 3 | id("java-library") 4 | } 5 | -------------------------------------------------------------------------------- /19_The_Test_Task/my-build-logic/settings.gradle.kts: -------------------------------------------------------------------------------- 1 | dependencyResolutionManagement { 2 | repositories.gradlePluginPortal() 3 | } 4 | 5 | include("structure-plugins") 6 | include("java-plugins") 7 | -------------------------------------------------------------------------------- /19_The_Test_Task/my-build-logic/structure-plugins/build.gradle.kts: -------------------------------------------------------------------------------- 1 | plugins { 2 | `kotlin-dsl` 3 | } 4 | -------------------------------------------------------------------------------- /19_The_Test_Task/my-build-logic/structure-plugins/src/main/kotlin/my-project-structure.settings.gradle.kts: -------------------------------------------------------------------------------- 1 | // Locations of Gradle plugins 2 | pluginManagement { 3 | repositories.gradlePluginPortal() 4 | } 5 | 6 | // Location of other components 7 | dependencyResolutionManagement { 8 | repositories.mavenCentral() 9 | rootDir.parentFile.listFiles()?.filter { 10 | File(it, "settings.gradle.kts").exists() 11 | }?.forEach { 12 | includeBuild(it.path) 13 | } 14 | } 15 | 16 | rootDir.listFiles()?.filter { 17 | File(it, "build.gradle.kts").exists() 18 | }?.forEach { 19 | include(it.name) 20 | } 21 | -------------------------------------------------------------------------------- /19_The_Test_Task/my-project/app/build.gradle.kts: -------------------------------------------------------------------------------- 1 | plugins { 2 | id("my-java-application") 3 | } 4 | 5 | application { 6 | mainClass.set("myproject.MyApplication") 7 | } 8 | 9 | dependencies { 10 | implementation("org.example.my-app:business-logic") 11 | } 12 | -------------------------------------------------------------------------------- /19_The_Test_Task/my-project/app/src/main/java/myproject/MyApplication.java: -------------------------------------------------------------------------------- 1 | package myproject; 2 | 3 | import myproject.data.MessageModel; 4 | import myproject.services.Service; 5 | 6 | public final class MyApplication { 7 | 8 | public static void main(final String[] args) { 9 | Service.printMessage(new MessageModel("Hello there :)")); 10 | } 11 | } 12 | -------------------------------------------------------------------------------- /19_The_Test_Task/my-project/business-logic/build.gradle.kts: -------------------------------------------------------------------------------- 1 | plugins { 2 | id("my-java-library") 3 | } 4 | 5 | dependencies { 6 | implementation("org.apache.commons:commons-lang3") 7 | 8 | api("org.example.my-app:data-model") //alternative: project(":data-model") 9 | } 10 | -------------------------------------------------------------------------------- /19_The_Test_Task/my-project/business-logic/src/main/java/myproject/services/Service.java: -------------------------------------------------------------------------------- 1 | package myproject.services; 2 | 3 | import myproject.data.MessageModel; 4 | import org.apache.commons.lang3.StringUtils; 5 | 6 | public final class Service { 7 | 8 | public static String printMessage(MessageModel message) { 9 | String trimmedMessage = StringUtils.trimToEmpty(message.getMessage()); 10 | String encodedMessage = encode(trimmedMessage); 11 | System.out.println(encodedMessage); 12 | return encodedMessage; 13 | } 14 | 15 | public static String encode(String s) { 16 | return s.replace(":)", "\uD83D\uDE03"); 17 | } 18 | } 19 | -------------------------------------------------------------------------------- /19_The_Test_Task/my-project/business-logic/src/test/java/myproject/services/Service0Test.java: -------------------------------------------------------------------------------- 1 | package myproject.services; 2 | 3 | import myproject.data.MessageModel; 4 | import org.junit.jupiter.api.Test; 5 | 6 | import static org.junit.jupiter.api.Assertions.assertEquals; 7 | 8 | public class Service0Test { 9 | 10 | @Test 11 | public void testEncoding() throws InterruptedException { 12 | assertEquals("Hi \uD83D\uDE03", Service.printMessage(new MessageModel("Hi :)"))); 13 | Thread.sleep(500); 14 | } 15 | } 16 | -------------------------------------------------------------------------------- /19_The_Test_Task/my-project/business-logic/src/test/java/myproject/services/Service1Test.java: -------------------------------------------------------------------------------- 1 | package myproject.services; 2 | 3 | import myproject.data.MessageModel; 4 | import org.junit.jupiter.api.Test; 5 | 6 | import static org.junit.jupiter.api.Assertions.assertEquals; 7 | 8 | public class Service1Test { 9 | 10 | @Test 11 | public void testEncoding() throws InterruptedException { 12 | assertEquals("Hi \uD83D\uDE03", Service.printMessage(new MessageModel("Hi :)"))); 13 | Thread.sleep(500); 14 | } 15 | } 16 | -------------------------------------------------------------------------------- /19_The_Test_Task/my-project/business-logic/src/test/java/myproject/services/Service2Test.java: -------------------------------------------------------------------------------- 1 | package myproject.services; 2 | 3 | import myproject.data.MessageModel; 4 | import org.junit.jupiter.api.Test; 5 | 6 | import static org.junit.jupiter.api.Assertions.assertEquals; 7 | 8 | public class Service2Test { 9 | 10 | @Test 11 | public void testEncoding() throws InterruptedException { 12 | assertEquals("Hi \uD83D\uDE03", Service.printMessage(new MessageModel("Hi :)"))); 13 | Thread.sleep(500); 14 | } 15 | } 16 | -------------------------------------------------------------------------------- /19_The_Test_Task/my-project/business-logic/src/test/java/myproject/services/Service3Test.java: -------------------------------------------------------------------------------- 1 | package myproject.services; 2 | 3 | import myproject.data.MessageModel; 4 | import org.junit.jupiter.api.Test; 5 | 6 | import static org.junit.jupiter.api.Assertions.assertEquals; 7 | 8 | public class Service3Test { 9 | 10 | @Test 11 | public void testEncoding() throws InterruptedException { 12 | assertEquals("Hi \uD83D\uDE03", Service.printMessage(new MessageModel("Hi :)"))); 13 | Thread.sleep(500); 14 | } 15 | } 16 | -------------------------------------------------------------------------------- /19_The_Test_Task/my-project/business-logic/src/test/java/myproject/services/Service4Test.java: -------------------------------------------------------------------------------- 1 | package myproject.services; 2 | 3 | import myproject.data.MessageModel; 4 | import org.junit.jupiter.api.Test; 5 | 6 | import static org.junit.jupiter.api.Assertions.assertEquals; 7 | 8 | public class Service4Test { 9 | 10 | @Test 11 | public void testEncoding() throws InterruptedException { 12 | assertEquals("Hi \uD83D\uDE03", Service.printMessage(new MessageModel("Hi :)"))); 13 | Thread.sleep(500); 14 | } 15 | } 16 | -------------------------------------------------------------------------------- /19_The_Test_Task/my-project/business-logic/src/test/java/myproject/services/Service5Test.java: -------------------------------------------------------------------------------- 1 | package myproject.services; 2 | 3 | import myproject.data.MessageModel; 4 | import org.junit.jupiter.api.Test; 5 | 6 | import static org.junit.jupiter.api.Assertions.assertEquals; 7 | 8 | public class Service5Test { 9 | 10 | @Test 11 | public void testEncoding() throws InterruptedException { 12 | assertEquals("Hi \uD83D\uDE03", Service.printMessage(new MessageModel("Hi :)"))); 13 | Thread.sleep(500); 14 | } 15 | } 16 | -------------------------------------------------------------------------------- /19_The_Test_Task/my-project/business-logic/src/test/java/myproject/services/Service6Test.java: -------------------------------------------------------------------------------- 1 | package myproject.services; 2 | 3 | import myproject.data.MessageModel; 4 | import org.junit.jupiter.api.Test; 5 | 6 | import static org.junit.jupiter.api.Assertions.assertEquals; 7 | 8 | public class Service6Test { 9 | 10 | @Test 11 | public void testEncoding() throws InterruptedException { 12 | assertEquals("Hi \uD83D\uDE03", Service.printMessage(new MessageModel("Hi :)"))); 13 | Thread.sleep(500); 14 | } 15 | } 16 | -------------------------------------------------------------------------------- /19_The_Test_Task/my-project/business-logic/src/test/java/myproject/services/Service7Test.java: -------------------------------------------------------------------------------- 1 | package myproject.services; 2 | 3 | import myproject.data.MessageModel; 4 | import org.junit.jupiter.api.Test; 5 | 6 | import static org.junit.jupiter.api.Assertions.assertEquals; 7 | 8 | public class Service7Test { 9 | 10 | @Test 11 | public void testEncoding() throws InterruptedException { 12 | assertEquals("Hi \uD83D\uDE03", Service.printMessage(new MessageModel("Hi :)"))); 13 | Thread.sleep(500); 14 | } 15 | } 16 | -------------------------------------------------------------------------------- /19_The_Test_Task/my-project/business-logic/src/test/java/myproject/services/Service8Test.java: -------------------------------------------------------------------------------- 1 | package myproject.services; 2 | 3 | import myproject.data.MessageModel; 4 | import org.junit.jupiter.api.Test; 5 | 6 | import static org.junit.jupiter.api.Assertions.assertEquals; 7 | 8 | public class Service8Test { 9 | 10 | @Test 11 | public void testEncoding() throws InterruptedException { 12 | assertEquals("Hi \uD83D\uDE03", Service.printMessage(new MessageModel("Hi :)"))); 13 | Thread.sleep(500); 14 | } 15 | } 16 | -------------------------------------------------------------------------------- /19_The_Test_Task/my-project/business-logic/src/test/java/myproject/services/Service9Test.java: -------------------------------------------------------------------------------- 1 | package myproject.services; 2 | 3 | import myproject.data.MessageModel; 4 | import org.junit.jupiter.api.Test; 5 | 6 | import static org.junit.jupiter.api.Assertions.assertEquals; 7 | 8 | public class Service9Test { 9 | 10 | @Test 11 | public void testEncoding() throws InterruptedException { 12 | assertEquals("Hi \uD83D\uDE03", Service.printMessage(new MessageModel("Hi :)"))); 13 | Thread.sleep(500); 14 | } 15 | } 16 | -------------------------------------------------------------------------------- /19_The_Test_Task/my-project/business-logic/src/test/java/myproject/services/ServiceATest.java: -------------------------------------------------------------------------------- 1 | package myproject.services; 2 | 3 | import myproject.data.MessageModel; 4 | import org.junit.jupiter.api.Test; 5 | 6 | import static org.junit.jupiter.api.Assertions.assertEquals; 7 | 8 | public class ServiceATest { 9 | 10 | @Test 11 | public void testEncoding() throws InterruptedException { 12 | assertEquals("Hi \uD83D\uDE03", Service.printMessage(new MessageModel("Hi :)"))); 13 | Thread.sleep(500); 14 | } 15 | } 16 | -------------------------------------------------------------------------------- /19_The_Test_Task/my-project/business-logic/src/test/java/myproject/services/ServiceBTest.java: -------------------------------------------------------------------------------- 1 | package myproject.services; 2 | 3 | import myproject.data.MessageModel; 4 | import org.junit.jupiter.api.Test; 5 | 6 | import static org.junit.jupiter.api.Assertions.assertEquals; 7 | 8 | public class ServiceBTest { 9 | 10 | @Test 11 | public void testEncoding() throws InterruptedException { 12 | assertEquals("Hi \uD83D\uDE03", Service.printMessage(new MessageModel("Hi :)"))); 13 | Thread.sleep(500); 14 | } 15 | } 16 | -------------------------------------------------------------------------------- /19_The_Test_Task/my-project/business-logic/src/test/java/myproject/services/ServiceCTest.java: -------------------------------------------------------------------------------- 1 | package myproject.services; 2 | 3 | import myproject.data.MessageModel; 4 | import org.junit.jupiter.api.Test; 5 | 6 | import static org.junit.jupiter.api.Assertions.assertEquals; 7 | 8 | public class ServiceCTest { 9 | 10 | @Test 11 | public void testEncoding() throws InterruptedException { 12 | assertEquals("Hi \uD83D\uDE03", Service.printMessage(new MessageModel("Hi :)"))); 13 | Thread.sleep(500); 14 | } 15 | } 16 | -------------------------------------------------------------------------------- /19_The_Test_Task/my-project/data-model/build.gradle.kts: -------------------------------------------------------------------------------- 1 | plugins { 2 | id("my-java-library") 3 | } 4 | -------------------------------------------------------------------------------- /19_The_Test_Task/my-project/data-model/src/main/java/myproject/data/MessageModel.java: -------------------------------------------------------------------------------- 1 | package myproject.data; 2 | 3 | public final class MessageModel { 4 | 5 | private final String message; 6 | 7 | public MessageModel(String message) { 8 | this.message = message; 9 | } 10 | 11 | public String getMessage() { 12 | return message; 13 | } 14 | } 15 | -------------------------------------------------------------------------------- /19_The_Test_Task/my-project/gradle.properties: -------------------------------------------------------------------------------- 1 | # Set a fixed max workers value 2 | # org.gradle.workers.max=4 -------------------------------------------------------------------------------- /19_The_Test_Task/my-project/settings.gradle.kts: -------------------------------------------------------------------------------- 1 | pluginManagement { 2 | includeBuild("../my-build-logic") 3 | } 4 | plugins { 5 | id("my-project-structure") 6 | } 7 | -------------------------------------------------------------------------------- /20_Test_Fixtures/my-build-logic/java-plugins/build.gradle.kts: -------------------------------------------------------------------------------- 1 | plugins { 2 | `kotlin-dsl` 3 | } 4 | -------------------------------------------------------------------------------- /20_Test_Fixtures/my-build-logic/java-plugins/src/main/kotlin/my-java-application.gradle.kts: -------------------------------------------------------------------------------- 1 | plugins { 2 | id("my-java-base") 3 | id("application") 4 | } 5 | -------------------------------------------------------------------------------- /20_Test_Fixtures/my-build-logic/java-plugins/src/main/kotlin/my-java-base.gradle.kts: -------------------------------------------------------------------------------- 1 | plugins { 2 | id("java") 3 | } 4 | 5 | group = "org.example.my-app" 6 | version = "1.0" 7 | 8 | java { 9 | toolchain.languageVersion.set(JavaLanguageVersion.of(17)) 10 | } 11 | 12 | tasks.test { 13 | useJUnitPlatform() // JUnit5 14 | } 15 | 16 | dependencies { 17 | testImplementation("org.junit.jupiter:junit-jupiter-api") 18 | testRuntimeOnly("org.junit.jupiter:junit-jupiter-engine") 19 | testRuntimeOnly("org.junit.platform:junit-platform-launcher") 20 | } 21 | 22 | // Centralized versions 23 | dependencies { 24 | testImplementation(platform("org.junit:junit-bom:5.8.2")) 25 | } 26 | dependencies.constraints { 27 | implementation("org.apache.commons:commons-lang3:3.9") 28 | } -------------------------------------------------------------------------------- /20_Test_Fixtures/my-build-logic/java-plugins/src/main/kotlin/my-java-library.gradle.kts: -------------------------------------------------------------------------------- 1 | plugins { 2 | id("my-java-base") 3 | id("java-library") 4 | id("java-test-fixtures") 5 | } 6 | 7 | val test = sourceSets.test.get() 8 | java.registerFeature(test.name) { 9 | usingSourceSet(test) 10 | } 11 | -------------------------------------------------------------------------------- /20_Test_Fixtures/my-build-logic/settings.gradle.kts: -------------------------------------------------------------------------------- 1 | dependencyResolutionManagement { 2 | repositories.gradlePluginPortal() 3 | } 4 | 5 | include("structure-plugins") 6 | include("java-plugins") 7 | -------------------------------------------------------------------------------- /20_Test_Fixtures/my-build-logic/structure-plugins/build.gradle.kts: -------------------------------------------------------------------------------- 1 | plugins { 2 | `kotlin-dsl` 3 | } 4 | -------------------------------------------------------------------------------- /20_Test_Fixtures/my-build-logic/structure-plugins/src/main/kotlin/my-project-structure.settings.gradle.kts: -------------------------------------------------------------------------------- 1 | // Locations of Gradle plugins 2 | pluginManagement { 3 | repositories.gradlePluginPortal() 4 | } 5 | 6 | // Location of other components 7 | dependencyResolutionManagement { 8 | repositories.mavenCentral() 9 | rootDir.parentFile.listFiles()?.filter { 10 | File(it, "settings.gradle.kts").exists() 11 | }?.forEach { 12 | includeBuild(it.path) 13 | } 14 | } 15 | 16 | rootDir.listFiles()?.filter { 17 | File(it, "build.gradle.kts").exists() 18 | }?.forEach { 19 | include(it.name) 20 | } 21 | -------------------------------------------------------------------------------- /20_Test_Fixtures/my-project/app/build.gradle.kts: -------------------------------------------------------------------------------- 1 | plugins { 2 | id("my-java-application") 3 | } 4 | 5 | application { 6 | mainClass.set("myproject.MyApplication") 7 | } 8 | 9 | dependencies { 10 | implementation("org.example.my-app:business-logic") 11 | } 12 | -------------------------------------------------------------------------------- /20_Test_Fixtures/my-project/app/data/message.json: -------------------------------------------------------------------------------- 1 | {"message":"Hello there :) (this was JSON)"} -------------------------------------------------------------------------------- /20_Test_Fixtures/my-project/app/data/message.xml: -------------------------------------------------------------------------------- 1 | Hello there :) (this was XML) -------------------------------------------------------------------------------- /20_Test_Fixtures/my-project/app/src/main/java/myproject/MyApplication.java: -------------------------------------------------------------------------------- 1 | package myproject; 2 | 3 | import myproject.data.MessageModel; 4 | import myproject.services.Service; 5 | 6 | public final class MyApplication { 7 | 8 | public static void main(final String[] args) { 9 | Service.printMessage(new MessageModel("Hello there :)")); 10 | } 11 | } 12 | -------------------------------------------------------------------------------- /20_Test_Fixtures/my-project/business-logic/build.gradle.kts: -------------------------------------------------------------------------------- 1 | plugins { 2 | id("my-java-library") 3 | } 4 | 5 | dependencies { 6 | implementation("org.apache.commons:commons-lang3") 7 | 8 | api("org.example.my-app:data-model") // alternative: project(":data-model") 9 | 10 | testImplementation(testFixtures("org.example.my-app:data-model")) // short notation for ↓ 11 | // testImplementation("org.example.my-app:data-model") { 12 | // capabilities { requireCapability("org.example.my-app:data-model-test-fixtures") } 13 | // } 14 | } 15 | -------------------------------------------------------------------------------- /20_Test_Fixtures/my-project/business-logic/src/main/java/myproject/services/Service.java: -------------------------------------------------------------------------------- 1 | package myproject.services; 2 | 3 | import myproject.data.MessageModel; 4 | import org.apache.commons.lang3.StringUtils; 5 | 6 | public final class Service { 7 | 8 | public static String printMessage(MessageModel message) { 9 | String trimmedMessage = StringUtils.trimToEmpty(message.getMessage()); 10 | String encodedMessage = encode(trimmedMessage); 11 | System.out.println(encodedMessage); 12 | return encodedMessage; 13 | } 14 | 15 | public static String encode(String s) { 16 | return s.replace(":)", "\uD83D\uDE03"); 17 | } 18 | } 19 | -------------------------------------------------------------------------------- /20_Test_Fixtures/my-project/business-logic/src/test/java/myproject/services/ServiceTest.java: -------------------------------------------------------------------------------- 1 | package myproject.services; 2 | 3 | import myproject.data.test.MessageModelFixture; 4 | import org.junit.jupiter.api.Test; 5 | 6 | import static org.junit.jupiter.api.Assertions.assertEquals; 7 | 8 | public class ServiceTest { 9 | 10 | @Test 11 | void emoji_in_message_is_encoded() { 12 | assertEquals( 13 | "Hi \uD83D\uDE03", 14 | Service.printMessage(MessageModelFixture.newMessage()) 15 | ); 16 | } 17 | } 18 | -------------------------------------------------------------------------------- /20_Test_Fixtures/my-project/data-model/build.gradle.kts: -------------------------------------------------------------------------------- 1 | plugins { 2 | id("my-java-library") 3 | } 4 | -------------------------------------------------------------------------------- /20_Test_Fixtures/my-project/data-model/src/main/java/myproject/data/MessageModel.java: -------------------------------------------------------------------------------- 1 | package myproject.data; 2 | 3 | public final class MessageModel { 4 | 5 | private final String message; 6 | 7 | public MessageModel(String message) { 8 | this.message = message; 9 | } 10 | 11 | public String getMessage() { 12 | return message; 13 | } 14 | } 15 | -------------------------------------------------------------------------------- /20_Test_Fixtures/my-project/data-model/src/test/java/myproject/data/test/MessageModelTest.java: -------------------------------------------------------------------------------- 1 | package myproject.data.test; 2 | 3 | import org.junit.jupiter.api.Test; 4 | 5 | import static org.junit.jupiter.api.Assertions.assertEquals; 6 | 7 | public class MessageModelTest { 8 | 9 | @Test 10 | void model_contains_message_text_it_was_created_with() { 11 | assertEquals( 12 | "Hi :)", 13 | MessageModelFixture.newMessage().getMessage()); 14 | } 15 | } 16 | -------------------------------------------------------------------------------- /20_Test_Fixtures/my-project/data-model/src/testFixtures/java/myproject/data/test/MessageModelFixture.java: -------------------------------------------------------------------------------- 1 | package myproject.data.test; 2 | 3 | import myproject.data.MessageModel; 4 | 5 | public class MessageModelFixture { 6 | 7 | public static MessageModel newMessage() { 8 | return new MessageModel("Hi :)"); 9 | } 10 | } 11 | -------------------------------------------------------------------------------- /20_Test_Fixtures/my-project/settings.gradle.kts: -------------------------------------------------------------------------------- 1 | pluginManagement { 2 | includeBuild("../my-build-logic") 3 | } 4 | plugins { 5 | id("my-project-structure") 6 | } 7 | -------------------------------------------------------------------------------- /21_Test_and_Code_Coverage_Reporting/my-build-logic/java-plugins/build.gradle.kts: -------------------------------------------------------------------------------- 1 | plugins { 2 | `kotlin-dsl` 3 | } 4 | -------------------------------------------------------------------------------- /21_Test_and_Code_Coverage_Reporting/my-build-logic/java-plugins/src/main/kotlin/my-java-library.gradle.kts: -------------------------------------------------------------------------------- 1 | plugins { 2 | id("my-java-base") 3 | id("java-library") 4 | } 5 | -------------------------------------------------------------------------------- /21_Test_and_Code_Coverage_Reporting/my-build-logic/settings.gradle.kts: -------------------------------------------------------------------------------- 1 | dependencyResolutionManagement { 2 | repositories.gradlePluginPortal() 3 | } 4 | 5 | include("structure-plugins") 6 | include("java-plugins") 7 | -------------------------------------------------------------------------------- /21_Test_and_Code_Coverage_Reporting/my-build-logic/structure-plugins/build.gradle.kts: -------------------------------------------------------------------------------- 1 | plugins { 2 | `kotlin-dsl` 3 | } 4 | -------------------------------------------------------------------------------- /21_Test_and_Code_Coverage_Reporting/my-build-logic/structure-plugins/src/main/kotlin/my-project-structure.settings.gradle.kts: -------------------------------------------------------------------------------- 1 | // Locations of Gradle plugins 2 | pluginManagement { 3 | repositories.gradlePluginPortal() 4 | } 5 | 6 | // Location of other components 7 | dependencyResolutionManagement { 8 | repositories.mavenCentral() 9 | rootDir.parentFile.listFiles()?.filter { 10 | File(it, "settings.gradle.kts").exists() 11 | }?.forEach { 12 | includeBuild(it.path) 13 | } 14 | } 15 | 16 | rootDir.listFiles()?.filter { 17 | File(it, "build.gradle.kts").exists() 18 | }?.forEach { 19 | include(it.name) 20 | } 21 | -------------------------------------------------------------------------------- /21_Test_and_Code_Coverage_Reporting/my-project/app/build.gradle.kts: -------------------------------------------------------------------------------- 1 | plugins { 2 | id("my-java-application") 3 | } 4 | 5 | application { 6 | mainClass.set("myproject.MyApplication") 7 | } 8 | 9 | dependencies { 10 | implementation("org.example.my-app:business-logic") 11 | } 12 | -------------------------------------------------------------------------------- /21_Test_and_Code_Coverage_Reporting/my-project/app/src/main/java/myproject/MyApplication.java: -------------------------------------------------------------------------------- 1 | package myproject; 2 | 3 | import myproject.data.MessageModel; 4 | import myproject.services.Service; 5 | 6 | public final class MyApplication { 7 | 8 | public static void main(final String[] args) { 9 | Service.printMessage(new MessageModel("Hello there :)")); 10 | } 11 | } 12 | -------------------------------------------------------------------------------- /21_Test_and_Code_Coverage_Reporting/my-project/business-logic/build.gradle.kts: -------------------------------------------------------------------------------- 1 | plugins { 2 | id("my-java-library") 3 | } 4 | 5 | dependencies { 6 | implementation("org.apache.commons:commons-lang3") 7 | 8 | api("org.example.my-app:data-model") //alternative: project(":data-model") 9 | 10 | integrationTestImplementation(project(path)) 11 | } 12 | -------------------------------------------------------------------------------- /21_Test_and_Code_Coverage_Reporting/my-project/business-logic/src/integrationTest/java/myproject/services/ServiceIntegrationTest.java: -------------------------------------------------------------------------------- 1 | package myproject.services; 2 | 3 | import myproject.data.MessageModel; 4 | import org.junit.jupiter.api.Test; 5 | 6 | import static org.junit.jupiter.api.Assertions.assertEquals; 7 | 8 | public class ServiceIntegrationTest { 9 | 10 | @Test 11 | void testService() { 12 | assertEquals( 13 | "Hi \uD83D\uDE03", 14 | Service.printMessage(new MessageModel("Hi :)")) 15 | ); 16 | } 17 | } 18 | -------------------------------------------------------------------------------- /21_Test_and_Code_Coverage_Reporting/my-project/business-logic/src/main/java/myproject/services/Service.java: -------------------------------------------------------------------------------- 1 | package myproject.services; 2 | 3 | import myproject.data.MessageModel; 4 | import org.apache.commons.lang3.StringUtils; 5 | 6 | public final class Service { 7 | 8 | public static String printMessage(MessageModel message) { 9 | String trimmedMessage = StringUtils.trimToEmpty(message.getMessage()); 10 | String encodedMessage = encode(trimmedMessage); 11 | System.out.println(encodedMessage); 12 | return encodedMessage; 13 | } 14 | 15 | public static String encode(String s) { 16 | return s.replace(":)", "\uD83D\uDE03"); 17 | } 18 | } 19 | -------------------------------------------------------------------------------- /21_Test_and_Code_Coverage_Reporting/my-project/business-logic/src/test/java/myproject/services/ServiceSlowTest.java: -------------------------------------------------------------------------------- 1 | package myproject.services; 2 | 3 | import org.junit.jupiter.api.Tag; 4 | import org.junit.jupiter.api.Test; 5 | 6 | import static org.junit.jupiter.api.Assertions.assertEquals; 7 | 8 | @Tag("slow") 9 | public class ServiceSlowTest { 10 | 11 | @Test 12 | void testEncodingSlow() { 13 | assertEquals( 14 | "Hi \uD83D\uDE03", 15 | Service.encode("Hi :)") 16 | ); 17 | } 18 | } 19 | -------------------------------------------------------------------------------- /21_Test_and_Code_Coverage_Reporting/my-project/business-logic/src/test/java/myproject/services/ServiceTest.java: -------------------------------------------------------------------------------- 1 | package myproject.services; 2 | 3 | import myproject.data.MessageModel; 4 | import org.junit.jupiter.api.Test; 5 | 6 | import static org.junit.jupiter.api.Assertions.assertEquals; 7 | 8 | public class ServiceTest { 9 | 10 | @Test 11 | void testEncoding() { 12 | assertEquals( 13 | "Hi \uD83D\uDE03", 14 | Service.encode("Hi :)") 15 | ); 16 | } 17 | } 18 | -------------------------------------------------------------------------------- /21_Test_and_Code_Coverage_Reporting/my-project/data-model/build.gradle.kts: -------------------------------------------------------------------------------- 1 | plugins { 2 | id("my-java-library") 3 | } 4 | -------------------------------------------------------------------------------- /21_Test_and_Code_Coverage_Reporting/my-project/data-model/src/main/java/myproject/data/MessageModel.java: -------------------------------------------------------------------------------- 1 | package myproject.data; 2 | 3 | public final class MessageModel { 4 | 5 | private final String message; 6 | 7 | public MessageModel(String message) { 8 | this.message = message; 9 | } 10 | 11 | public String getMessage() { 12 | return message; 13 | } 14 | } 15 | -------------------------------------------------------------------------------- /21_Test_and_Code_Coverage_Reporting/my-project/data-model/src/test/java/myproject/data/MessageModelTest.java: -------------------------------------------------------------------------------- 1 | package myproject.data; 2 | 3 | import org.junit.jupiter.api.Test; 4 | 5 | public class MessageModelTest { 6 | 7 | @Test 8 | void testMessageModel() { 9 | 10 | } 11 | } 12 | -------------------------------------------------------------------------------- /21_Test_and_Code_Coverage_Reporting/my-project/settings.gradle.kts: -------------------------------------------------------------------------------- 1 | pluginManagement { 2 | includeBuild("../my-build-logic") 3 | } 4 | plugins { 5 | id("my-project-structure") 6 | } 7 | -------------------------------------------------------------------------------- /22_The_JavaCompile_Task/my-build-logic/java-plugins/build.gradle.kts: -------------------------------------------------------------------------------- 1 | plugins { 2 | `kotlin-dsl` 3 | } 4 | -------------------------------------------------------------------------------- /22_The_JavaCompile_Task/my-build-logic/java-plugins/src/main/kotlin/my-java-application.gradle.kts: -------------------------------------------------------------------------------- 1 | plugins { 2 | id("my-java-base") 3 | id("application") 4 | } 5 | -------------------------------------------------------------------------------- /22_The_JavaCompile_Task/my-build-logic/java-plugins/src/main/kotlin/my-java-library.gradle.kts: -------------------------------------------------------------------------------- 1 | plugins { 2 | id("my-java-base") 3 | id("java-library") 4 | } 5 | -------------------------------------------------------------------------------- /22_The_JavaCompile_Task/my-build-logic/settings.gradle.kts: -------------------------------------------------------------------------------- 1 | dependencyResolutionManagement { 2 | repositories.gradlePluginPortal() 3 | } 4 | 5 | include("structure-plugins") 6 | include("java-plugins") 7 | -------------------------------------------------------------------------------- /22_The_JavaCompile_Task/my-build-logic/structure-plugins/build.gradle.kts: -------------------------------------------------------------------------------- 1 | plugins { 2 | `kotlin-dsl` 3 | } 4 | -------------------------------------------------------------------------------- /22_The_JavaCompile_Task/my-build-logic/structure-plugins/src/main/kotlin/my-project-structure.settings.gradle.kts: -------------------------------------------------------------------------------- 1 | // Locations of Gradle plugins 2 | pluginManagement { 3 | repositories.gradlePluginPortal() 4 | } 5 | 6 | // Location of other components 7 | dependencyResolutionManagement { 8 | repositories.mavenCentral() 9 | rootDir.parentFile.listFiles()?.filter { 10 | File(it, "settings.gradle.kts").exists() 11 | }?.forEach { 12 | includeBuild(it.path) 13 | } 14 | } 15 | 16 | rootDir.listFiles()?.filter { 17 | File(it, "build.gradle.kts").exists() 18 | }?.forEach { 19 | include(it.name) 20 | } 21 | -------------------------------------------------------------------------------- /22_The_JavaCompile_Task/my-project/app/build.gradle.kts: -------------------------------------------------------------------------------- 1 | plugins { 2 | id("my-java-application") 3 | } 4 | 5 | application { 6 | mainClass.set("myproject.MyApplication") 7 | } 8 | 9 | dependencies { 10 | implementation("org.example.my-app:business-logic") 11 | } 12 | -------------------------------------------------------------------------------- /22_The_JavaCompile_Task/my-project/app/src/main/java/myproject/MyApplication.java: -------------------------------------------------------------------------------- 1 | package myproject; 2 | 3 | import myproject.data.MessageModel; 4 | import myproject.services.Service; 5 | 6 | public final class MyApplication { 7 | 8 | public static void main(final String[] args) { 9 | Service.printMessage(new MessageModel("Hello there :)")); 10 | } 11 | } 12 | -------------------------------------------------------------------------------- /22_The_JavaCompile_Task/my-project/business-logic/build.gradle.kts: -------------------------------------------------------------------------------- 1 | plugins { 2 | id("my-java-library") 3 | } 4 | 5 | dependencies { 6 | implementation("org.apache.commons:commons-lang3") 7 | 8 | api("org.example.my-app:data-model") //alternative: project(":data-model") 9 | } 10 | -------------------------------------------------------------------------------- /22_The_JavaCompile_Task/my-project/business-logic/src/main/java/myproject/services/Service.java: -------------------------------------------------------------------------------- 1 | package myproject.services; 2 | 3 | import myproject.data.MessageModel; 4 | import org.apache.commons.lang3.StringUtils; 5 | 6 | public final class Service { 7 | 8 | public static String printMessage(MessageModel message) { 9 | String trimmedMessage = StringUtils.trimToEmpty(message.getMessage()); 10 | String encodedMessage = encode(trimmedMessage); 11 | System.out.println(encodedMessage); 12 | return encodedMessage; 13 | } 14 | 15 | public static String encode(String s) { 16 | return s.replace(":)", "\uD83D\uDE03"); 17 | } 18 | } 19 | -------------------------------------------------------------------------------- /22_The_JavaCompile_Task/my-project/business-logic/src/test/java/myproject/services/ServiceTest.java: -------------------------------------------------------------------------------- 1 | package myproject.services; 2 | 3 | import myproject.data.MessageModel; 4 | import org.junit.jupiter.api.Test; 5 | 6 | import static org.junit.jupiter.api.Assertions.assertEquals; 7 | 8 | public class ServiceTest { 9 | 10 | @Test 11 | void testEncoding() { 12 | assertEquals( 13 | "Hi \uD83D\uDE03", 14 | Service.printMessage(new MessageModel("Hi :)")) 15 | ); 16 | } 17 | } 18 | -------------------------------------------------------------------------------- /22_The_JavaCompile_Task/my-project/data-model/build.gradle.kts: -------------------------------------------------------------------------------- 1 | plugins { 2 | id("my-java-library") 3 | } 4 | -------------------------------------------------------------------------------- /22_The_JavaCompile_Task/my-project/data-model/src/main/java/myproject/data/MessageModel.java: -------------------------------------------------------------------------------- 1 | package myproject.data; 2 | 3 | public final class MessageModel { 4 | 5 | private final String message; 6 | 7 | public MessageModel(String message) { 8 | this.message = message; 9 | } 10 | 11 | public String getMessage() { 12 | return message; 13 | } 14 | } 15 | -------------------------------------------------------------------------------- /22_The_JavaCompile_Task/my-project/data-model/src/test/java/myproject/data/MessageModelTest.java: -------------------------------------------------------------------------------- 1 | package myproject.data; 2 | 3 | import org.junit.jupiter.api.Test; 4 | 5 | public class MessageModelTest { 6 | 7 | @Test 8 | void testMessageModel() { 9 | 10 | } 11 | } 12 | -------------------------------------------------------------------------------- /22_The_JavaCompile_Task/my-project/gradle.properties: -------------------------------------------------------------------------------- 1 | # Configure the Grade Daemon - memory and same encoding on all machines 2 | org.gradle.jvmargs=-Xmx2g -Dfile.encoding=UTF-8 3 | 4 | # activate parallel execution - run tasks from different subprojects in parallel 5 | org.gradle.parallel=true 6 | # org.gradle.workers.max=4 # --max-workers=4 7 | 8 | # activate Gradle build cache - switch between branches/commits without rebuilding every time 9 | org.gradle.caching=true 10 | -------------------------------------------------------------------------------- /22_The_JavaCompile_Task/my-project/settings.gradle.kts: -------------------------------------------------------------------------------- 1 | pluginManagement { 2 | includeBuild("../my-build-logic") 3 | } 4 | plugins { 5 | id("my-project-structure") 6 | } 7 | -------------------------------------------------------------------------------- /23_Caching/my-build-logic/java-plugins/build.gradle.kts: -------------------------------------------------------------------------------- 1 | plugins { 2 | `kotlin-dsl` 3 | } 4 | -------------------------------------------------------------------------------- /23_Caching/my-build-logic/java-plugins/src/main/kotlin/my-java-application.gradle.kts: -------------------------------------------------------------------------------- 1 | plugins { 2 | id("my-java-base") 3 | id("application") 4 | } 5 | -------------------------------------------------------------------------------- /23_Caching/my-build-logic/java-plugins/src/main/kotlin/my-java-base.gradle.kts: -------------------------------------------------------------------------------- 1 | plugins { 2 | id("java") 3 | } 4 | 5 | group = "org.example.my-app" 6 | version = "1.0" 7 | 8 | java { 9 | toolchain.languageVersion.set(JavaLanguageVersion.of(17)) 10 | } 11 | 12 | // Centralized versions 13 | dependencies.constraints { 14 | implementation("org.apache.commons:commons-lang3:3.9") 15 | } 16 | -------------------------------------------------------------------------------- /23_Caching/my-build-logic/java-plugins/src/main/kotlin/my-java-library.gradle.kts: -------------------------------------------------------------------------------- 1 | plugins { 2 | id("my-java-base") 3 | id("java-library") 4 | } 5 | -------------------------------------------------------------------------------- /23_Caching/my-build-logic/settings.gradle.kts: -------------------------------------------------------------------------------- 1 | dependencyResolutionManagement { 2 | repositories.gradlePluginPortal() 3 | } 4 | 5 | include("java-plugins") 6 | -------------------------------------------------------------------------------- /23_Caching/my-project/app/build.gradle.kts: -------------------------------------------------------------------------------- 1 | plugins { 2 | id("my-java-application") 3 | } 4 | 5 | application { 6 | mainClass.set("myproject.MyApplication") 7 | } 8 | 9 | dependencies { 10 | implementation(project(":business-logic")) 11 | } 12 | -------------------------------------------------------------------------------- /23_Caching/my-project/app/src/main/java/myproject/MyApplication.java: -------------------------------------------------------------------------------- 1 | package myproject; 2 | 3 | import myproject.data.MessageModel; 4 | import myproject.services.Service; 5 | 6 | public final class MyApplication { 7 | 8 | public static void main(final String[] args) { 9 | Service.printMessage(new MessageModel("Hello there :)")); 10 | } 11 | } 12 | -------------------------------------------------------------------------------- /23_Caching/my-project/business-logic/build.gradle.kts: -------------------------------------------------------------------------------- 1 | plugins { 2 | id("my-java-library") 3 | } 4 | 5 | dependencies { 6 | implementation("org.apache.commons:commons-lang3") 7 | 8 | api(project(":data-model")) 9 | } 10 | -------------------------------------------------------------------------------- /23_Caching/my-project/business-logic/src/main/java/myproject/services/Service.java: -------------------------------------------------------------------------------- 1 | package myproject.services; 2 | 3 | import myproject.data.MessageModel; 4 | import org.apache.commons.lang3.StringUtils; 5 | 6 | public final class Service { 7 | 8 | public static String printMessage(MessageModel message) { 9 | String trimmedMessage = StringUtils.trimToEmpty(message.getMessage()); 10 | String encodedMessage = encode(trimmedMessage); 11 | System.out.println(encodedMessage); 12 | return encodedMessage; 13 | } 14 | 15 | public static String encode(String s) { 16 | return s.replace(":)", "\uD83D\uDE03"); 17 | } 18 | } 19 | -------------------------------------------------------------------------------- /23_Caching/my-project/data-model/build.gradle.kts: -------------------------------------------------------------------------------- 1 | plugins { 2 | id("my-java-library") 3 | } 4 | -------------------------------------------------------------------------------- /23_Caching/my-project/data-model/src/main/java/myproject/data/MessageModel.java: -------------------------------------------------------------------------------- 1 | package myproject.data; 2 | 3 | public final class MessageModel { 4 | 5 | private final String message; 6 | 7 | public MessageModel(String message) { 8 | this.message = message; 9 | } 10 | 11 | public String getMessage() { 12 | return message; 13 | } 14 | } 15 | -------------------------------------------------------------------------------- /23_Caching/my-project/gradle.properties: -------------------------------------------------------------------------------- 1 | org.gradle.parallel=true 2 | org.gradle.jvmargs=-Xmx2g 3 | org.gradle.caching=true 4 | org.gradle.unsafe.configuration-cache=true 5 | -------------------------------------------------------------------------------- /24_Kotlin_DSL_and_Groovy_DSL/my-build-logic/java-plugins/build.gradle.kts: -------------------------------------------------------------------------------- 1 | plugins { 2 | `kotlin-dsl` 3 | } 4 | -------------------------------------------------------------------------------- /24_Kotlin_DSL_and_Groovy_DSL/my-build-logic/java-plugins/src/main/kotlin/my-java-application.gradle.kts: -------------------------------------------------------------------------------- 1 | plugins { 2 | id("my-java-base") 3 | id("application") 4 | } 5 | -------------------------------------------------------------------------------- /24_Kotlin_DSL_and_Groovy_DSL/my-build-logic/java-plugins/src/main/kotlin/my-java-base.gradle.kts: -------------------------------------------------------------------------------- 1 | plugins { 2 | id("java") 3 | } 4 | 5 | group = "org.example.my-app" 6 | version = "1.0" 7 | 8 | java { 9 | toolchain.languageVersion.set(JavaLanguageVersion.of(17)) 10 | } 11 | 12 | tasks.withType().configureEach { 13 | options.encoding = "UTF-8" 14 | } 15 | 16 | tasks.test { 17 | useJUnitPlatform() 18 | } 19 | 20 | // Centralized versions 21 | dependencies.constraints { 22 | implementation("org.apache.commons:commons-lang3:3.9") 23 | } 24 | -------------------------------------------------------------------------------- /24_Kotlin_DSL_and_Groovy_DSL/my-build-logic/java-plugins/src/main/kotlin/my-java-library.gradle.kts: -------------------------------------------------------------------------------- 1 | plugins { 2 | id("my-java-base") 3 | id("java-library") 4 | } 5 | -------------------------------------------------------------------------------- /24_Kotlin_DSL_and_Groovy_DSL/my-build-logic/settings.gradle.kts: -------------------------------------------------------------------------------- 1 | dependencyResolutionManagement { 2 | repositories.gradlePluginPortal() 3 | } 4 | 5 | include("structure-plugins") 6 | include("java-plugins") 7 | -------------------------------------------------------------------------------- /24_Kotlin_DSL_and_Groovy_DSL/my-build-logic/structure-plugins/build.gradle.kts: -------------------------------------------------------------------------------- 1 | plugins { 2 | `kotlin-dsl` 3 | } 4 | -------------------------------------------------------------------------------- /24_Kotlin_DSL_and_Groovy_DSL/my-build-logic/structure-plugins/src/main/kotlin/my-project-structure.settings.gradle.kts: -------------------------------------------------------------------------------- 1 | // Locations of Gradle plugins 2 | pluginManagement { 3 | repositories.gradlePluginPortal() 4 | } 5 | 6 | // Location of other components 7 | dependencyResolutionManagement { 8 | repositories.mavenCentral() 9 | rootDir.parentFile.listFiles()?.filter { 10 | File(it, "settings.gradle.kts").exists() || File(it, "settings.gradle").exists() 11 | }?.forEach { 12 | includeBuild(it.path) 13 | } 14 | } 15 | 16 | rootDir.listFiles()?.filter { 17 | File(it, "build.gradle.kts").exists() || File(it, "build.gradle").exists() 18 | }?.forEach { 19 | include(it.name) 20 | } 21 | -------------------------------------------------------------------------------- /24_Kotlin_DSL_and_Groovy_DSL/my-project/app/build.gradle.kts: -------------------------------------------------------------------------------- 1 | plugins { 2 | id("my-java-application") 3 | } 4 | 5 | application { 6 | mainClass.set("myproject.MyApplication") 7 | } 8 | 9 | dependencies { 10 | implementation("org.example.my-app:business-logic") 11 | } 12 | -------------------------------------------------------------------------------- /24_Kotlin_DSL_and_Groovy_DSL/my-project/app/src/main/java/myproject/MyApplication.java: -------------------------------------------------------------------------------- 1 | package myproject; 2 | 3 | import myproject.data.MessageModel; 4 | import myproject.services.Service; 5 | 6 | public final class MyApplication { 7 | 8 | public static void main(final String[] args) { 9 | Service.printMessage(new MessageModel("Hello there :)")); 10 | } 11 | } 12 | -------------------------------------------------------------------------------- /24_Kotlin_DSL_and_Groovy_DSL/my-project/business-logic/build.gradle.kts: -------------------------------------------------------------------------------- 1 | plugins { 2 | id("my-java-library") 3 | } 4 | 5 | dependencies { 6 | implementation("org.apache.commons:commons-lang3") 7 | 8 | api("org.example.my-app:data-model") 9 | } 10 | -------------------------------------------------------------------------------- /24_Kotlin_DSL_and_Groovy_DSL/my-project/business-logic/src/main/java/myproject/services/Service.java: -------------------------------------------------------------------------------- 1 | package myproject.services; 2 | 3 | import myproject.data.MessageModel; 4 | import org.apache.commons.lang3.StringUtils; 5 | 6 | public final class Service { 7 | 8 | public static String printMessage(MessageModel message) { 9 | String trimmedMessage = StringUtils.trimToEmpty(message.getMessage()); 10 | String encodedMessage = encode(trimmedMessage); 11 | System.out.println(encodedMessage); 12 | return encodedMessage; 13 | } 14 | 15 | public static String encode(String s) { 16 | return s.replace(":)", "\uD83D\uDE03"); 17 | } 18 | } 19 | -------------------------------------------------------------------------------- /24_Kotlin_DSL_and_Groovy_DSL/my-project/data-model/build.gradle.kts: -------------------------------------------------------------------------------- 1 | plugins { 2 | id("my-java-library") 3 | } 4 | -------------------------------------------------------------------------------- /24_Kotlin_DSL_and_Groovy_DSL/my-project/data-model/src/main/java/myproject/data/MessageModel.java: -------------------------------------------------------------------------------- 1 | package myproject.data; 2 | 3 | public final class MessageModel { 4 | 5 | private final String message; 6 | 7 | public MessageModel(String message) { 8 | this.message = message; 9 | } 10 | 11 | public String getMessage() { 12 | return message; 13 | } 14 | } 15 | -------------------------------------------------------------------------------- /24_Kotlin_DSL_and_Groovy_DSL/my-project/settings.gradle.kts: -------------------------------------------------------------------------------- 1 | pluginManagement { 2 | includeBuild("../my-build-logic") 3 | } 4 | plugins { 5 | id("my-project-structure") 6 | } 7 | -------------------------------------------------------------------------------- /25_Using_Java_to_configure_builds/my-build-logic/java-plugins/build.gradle.kts: -------------------------------------------------------------------------------- 1 | plugins { 2 | id("java-gradle-plugin") 3 | } 4 | 5 | gradlePlugin { 6 | plugins.create("my-java-base") { 7 | id = name 8 | implementationClass = "myproject.gradle.MyJavaBasePlugin" 9 | } 10 | plugins.create("my-java-library") { 11 | id = name 12 | implementationClass = "myproject.gradle.MyJavaLibraryPlugin" 13 | } 14 | plugins.create("my-java-application") { 15 | id = name 16 | implementationClass = "myproject.gradle.MyJavaApplicationPlugin" 17 | } 18 | } 19 | 20 | java.toolchain.languageVersion.set(JavaLanguageVersion.of(8)) 21 | -------------------------------------------------------------------------------- /25_Using_Java_to_configure_builds/my-build-logic/java-plugins/src/main/java/myproject/gradle/MyAppExtension.java: -------------------------------------------------------------------------------- 1 | package myproject.gradle; 2 | 3 | import org.gradle.api.provider.Property; 4 | 5 | public interface MyAppExtension { 6 | Property getMainClass(); 7 | } 8 | -------------------------------------------------------------------------------- /25_Using_Java_to_configure_builds/my-build-logic/java-plugins/src/main/java/myproject/gradle/MyJavaLibraryPlugin.java: -------------------------------------------------------------------------------- 1 | package myproject.gradle; 2 | 3 | import org.gradle.api.Plugin; 4 | import org.gradle.api.Project; 5 | import org.gradle.api.plugins.PluginContainer; 6 | 7 | abstract public class MyJavaLibraryPlugin implements Plugin { 8 | 9 | @Override 10 | public void apply(Project project) { 11 | PluginContainer plugins = project.getPlugins(); 12 | 13 | plugins.apply("java-library"); 14 | plugins.apply("my-java-base"); 15 | } 16 | } 17 | -------------------------------------------------------------------------------- /25_Using_Java_to_configure_builds/my-build-logic/settings.gradle.kts: -------------------------------------------------------------------------------- 1 | dependencyResolutionManagement { 2 | repositories.gradlePluginPortal() 3 | } 4 | 5 | include("structure-plugins") 6 | include("java-plugins") 7 | -------------------------------------------------------------------------------- /25_Using_Java_to_configure_builds/my-build-logic/structure-plugins/build.gradle.kts: -------------------------------------------------------------------------------- 1 | plugins { 2 | id("java-gradle-plugin") 3 | } 4 | 5 | gradlePlugin { 6 | plugins.create("my-project-structure") { 7 | id = name 8 | implementationClass = "myproject.gradle.MyProjectStructureSettingsPlugin" 9 | } 10 | } 11 | 12 | java.toolchain.languageVersion.set(JavaLanguageVersion.of(8)) 13 | -------------------------------------------------------------------------------- /25_Using_Java_to_configure_builds/my-project/app/build.gradle.kts: -------------------------------------------------------------------------------- 1 | plugins { 2 | id("my-java-application") 3 | } 4 | 5 | dependencies { 6 | implementation("org.example.my-app:business-logic") 7 | } 8 | -------------------------------------------------------------------------------- /25_Using_Java_to_configure_builds/my-project/app/src/main/java/myproject/MyApplication.java: -------------------------------------------------------------------------------- 1 | package myproject; 2 | 3 | import myproject.data.MessageModel; 4 | import myproject.services.Service; 5 | 6 | public final class MyApplication { 7 | 8 | public static void main(final String[] args) { 9 | Service.printMessage(new MessageModel("Hello there :)")); 10 | } 11 | } 12 | -------------------------------------------------------------------------------- /25_Using_Java_to_configure_builds/my-project/business-logic/build.gradle.kts: -------------------------------------------------------------------------------- 1 | plugins { 2 | id("my-java-library") 3 | } 4 | 5 | dependencies { 6 | implementation("org.apache.commons:commons-lang3") 7 | 8 | api("org.example.my-app:data-model") 9 | } 10 | -------------------------------------------------------------------------------- /25_Using_Java_to_configure_builds/my-project/business-logic/src/main/java/myproject/services/Service.java: -------------------------------------------------------------------------------- 1 | package myproject.services; 2 | 3 | import myproject.data.MessageModel; 4 | import org.apache.commons.lang3.StringUtils; 5 | 6 | public final class Service { 7 | 8 | public static String printMessage(MessageModel message) { 9 | String trimmedMessage = StringUtils.trimToEmpty(message.getMessage()); 10 | String encodedMessage = encode(trimmedMessage); 11 | System.out.println(encodedMessage); 12 | return encodedMessage; 13 | } 14 | 15 | public static String encode(String s) { 16 | return s.replace(":)", "\uD83D\uDE03"); 17 | } 18 | } 19 | -------------------------------------------------------------------------------- /25_Using_Java_to_configure_builds/my-project/data-model/build.gradle.kts: -------------------------------------------------------------------------------- 1 | plugins { 2 | id("my-java-library") 3 | } 4 | -------------------------------------------------------------------------------- /25_Using_Java_to_configure_builds/my-project/data-model/src/main/java/myproject/data/MessageModel.java: -------------------------------------------------------------------------------- 1 | package myproject.data; 2 | 3 | public final class MessageModel { 4 | 5 | private final String message; 6 | 7 | public MessageModel(String message) { 8 | this.message = message; 9 | } 10 | 11 | public String getMessage() { 12 | return message; 13 | } 14 | } 15 | -------------------------------------------------------------------------------- /25_Using_Java_to_configure_builds/my-project/settings.gradle.kts: -------------------------------------------------------------------------------- 1 | pluginManagement { 2 | includeBuild("../my-build-logic") 3 | } 4 | plugins { 5 | id("my-project-structure") 6 | } 7 | -------------------------------------------------------------------------------- /26_The_Classpath/my-project/settings.gradle.kts: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jjohannes/understanding-gradle/d3a158774e2f0eb7c007046955f858906c5b11c6/26_The_Classpath/my-project/settings.gradle.kts -------------------------------------------------------------------------------- /26_The_Classpath/my-project/src/mypackage/App.java: -------------------------------------------------------------------------------- 1 | package mypackage; 2 | 3 | import org.slf4j.LoggerFactory; 4 | 5 | public class App { 6 | public static void main(String[] args) { 7 | LoggerFactory.getLogger(App.class).info("running app"); 8 | } 9 | } 10 | -------------------------------------------------------------------------------- /26_The_Classpath/my-project/src/mypackage/AppTest.java: -------------------------------------------------------------------------------- 1 | package mypackage; 2 | 3 | import org.junit.Test; 4 | 5 | public class AppTest { 6 | 7 | @Test 8 | public void test() { 9 | 10 | } 11 | } -------------------------------------------------------------------------------- /27_Multiple_Compile_Classpaths/my-project/app/src/mypackage/App.java: -------------------------------------------------------------------------------- 1 | package mypackage; 2 | 3 | import mypackage.modulea.ModuleA; 4 | import org.slf4j.LoggerFactory; 5 | 6 | public class App extends ModuleA { 7 | 8 | public static void main(String[] args) { 9 | LoggerFactory.getLogger(App.class).info("running app"); 10 | new App().doWork(); 11 | } 12 | } 13 | -------------------------------------------------------------------------------- /27_Multiple_Compile_Classpaths/my-project/module/src/mypackage/modulea/ModuleA.java: -------------------------------------------------------------------------------- 1 | package mypackage.modulea; 2 | 3 | import org.apache.commons.io.FilenameUtils; 4 | import javax.activation.MimeType; 5 | 6 | public class ModuleA extends MimeType { 7 | 8 | public String doWork() { 9 | return FilenameUtils.normalize("/a/../b"); 10 | } 11 | } 12 | -------------------------------------------------------------------------------- /27_Multiple_Compile_Classpaths/my-project/settings.gradle.kts: -------------------------------------------------------------------------------- 1 | dependencyResolutionManagement { 2 | repositories.mavenCentral() 3 | } 4 | 5 | include("app") 6 | include("module") 7 | -------------------------------------------------------------------------------- /28_Dependency_Analysis_Plugin/my-build-logic/java-plugins/build.gradle.kts: -------------------------------------------------------------------------------- 1 | plugins { 2 | `kotlin-dsl` 3 | } 4 | 5 | dependencies { 6 | implementation("com.autonomousapps:dependency-analysis-gradle-plugin:2.5.0") 7 | } 8 | -------------------------------------------------------------------------------- /28_Dependency_Analysis_Plugin/my-build-logic/java-plugins/src/main/kotlin/my-java-application.gradle.kts: -------------------------------------------------------------------------------- 1 | plugins { 2 | id("my-java-base") 3 | id("application") 4 | } 5 | -------------------------------------------------------------------------------- /28_Dependency_Analysis_Plugin/my-build-logic/java-plugins/src/main/kotlin/my-java-library.gradle.kts: -------------------------------------------------------------------------------- 1 | plugins { 2 | id("my-java-base") 3 | id("java-library") 4 | } 5 | -------------------------------------------------------------------------------- /28_Dependency_Analysis_Plugin/my-build-logic/java-plugins/src/main/kotlin/my-root.gradle.kts: -------------------------------------------------------------------------------- 1 | plugins { 2 | id("com.autonomousapps.dependency-analysis") 3 | } 4 | 5 | dependencyAnalysis { 6 | abi { 7 | exclusions { 8 | // ... 9 | } 10 | } 11 | } 12 | -------------------------------------------------------------------------------- /28_Dependency_Analysis_Plugin/my-build-logic/settings.gradle.kts: -------------------------------------------------------------------------------- 1 | dependencyResolutionManagement { 2 | repositories.gradlePluginPortal() 3 | } 4 | 5 | include("java-plugins") -------------------------------------------------------------------------------- /28_Dependency_Analysis_Plugin/my-project/app/build.gradle.kts: -------------------------------------------------------------------------------- 1 | plugins { 2 | id("my-java-application") 3 | } 4 | 5 | application { 6 | mainClass.set("mypackage.App") 7 | } 8 | 9 | dependencies { 10 | implementation(project(":module")) 11 | implementation("org.slf4j:slf4j-api:2.0.3") 12 | implementation("org.slf4j:slf4j-simple:2.0.3") 13 | } 14 | -------------------------------------------------------------------------------- /28_Dependency_Analysis_Plugin/my-project/app/src/main/java/mypackage/App.java: -------------------------------------------------------------------------------- 1 | package mypackage; 2 | 3 | import mypackage.modulea.ModuleA; 4 | import org.slf4j.LoggerFactory; 5 | import javax.activation.MimeType; 6 | 7 | public class App extends ModuleA { 8 | 9 | public static void main(String[] args) { 10 | LoggerFactory.getLogger(App.class).info("running app"); 11 | new App().doWork(new MimeType()); 12 | } 13 | } 14 | -------------------------------------------------------------------------------- /28_Dependency_Analysis_Plugin/my-project/build.gradle.kts: -------------------------------------------------------------------------------- 1 | plugins { 2 | id("my-root") 3 | } 4 | -------------------------------------------------------------------------------- /28_Dependency_Analysis_Plugin/my-project/module/build.gradle.kts: -------------------------------------------------------------------------------- 1 | plugins { 2 | id("my-java-library") 3 | } 4 | 5 | dependencies { 6 | api("javax.activation:activation:1.1.1") 7 | implementation("commons-io:commons-io:2.6") 8 | } 9 | -------------------------------------------------------------------------------- /28_Dependency_Analysis_Plugin/my-project/module/src/main/java/mypackage/modulea/ModuleA.java: -------------------------------------------------------------------------------- 1 | package mypackage.modulea; 2 | 3 | import org.apache.commons.io.FilenameUtils; 4 | import javax.activation.MimeType; 5 | 6 | public class ModuleA { 7 | 8 | public String doWork(MimeType mimeType) { 9 | return FilenameUtils.normalize("/a/../b"); 10 | } 11 | } 12 | -------------------------------------------------------------------------------- /28_Dependency_Analysis_Plugin/my-project/settings.gradle.kts: -------------------------------------------------------------------------------- 1 | // Locations of Gradle plugins 2 | pluginManagement { 3 | repositories.gradlePluginPortal() 4 | includeBuild("../my-build-logic") 5 | } 6 | 7 | // Location of other components 8 | dependencyResolutionManagement { 9 | repositories.mavenCentral() 10 | } 11 | 12 | include("app") 13 | include("module") 14 | -------------------------------------------------------------------------------- /29_Classpath_Collisions/my-build-logic/java-plugins/build.gradle.kts: -------------------------------------------------------------------------------- 1 | plugins { 2 | `kotlin-dsl` 3 | } 4 | 5 | dependencies { 6 | implementation("io.fuchs.gradle.classpath-collision-detector:classpath-collision-detector:1.0.0") 7 | implementation("org.gradlex:jvm-dependency-conflict-resolution:2.1.2") 8 | } 9 | -------------------------------------------------------------------------------- /29_Classpath_Collisions/my-build-logic/java-plugins/src/main/kotlin/my-java-application.gradle.kts: -------------------------------------------------------------------------------- 1 | plugins { 2 | id("my-java-base") 3 | id("application") 4 | id("io.fuchs.gradle.classpath-collision-detector") 5 | } 6 | 7 | -------------------------------------------------------------------------------- /29_Classpath_Collisions/my-build-logic/java-plugins/src/main/kotlin/my-java-base.gradle.kts: -------------------------------------------------------------------------------- 1 | plugins { 2 | id("java") 3 | id("org.gradlex.jvm-dependency-conflict-resolution") 4 | } 5 | 6 | group = "org.example.my-app" 7 | 8 | java { 9 | toolchain.languageVersion.set(JavaLanguageVersion.of(17)) 10 | } 11 | -------------------------------------------------------------------------------- /29_Classpath_Collisions/my-build-logic/java-plugins/src/main/kotlin/my-java-library.gradle.kts: -------------------------------------------------------------------------------- 1 | plugins { 2 | id("my-java-base") 3 | id("java-library") 4 | } 5 | -------------------------------------------------------------------------------- /29_Classpath_Collisions/my-build-logic/settings.gradle.kts: -------------------------------------------------------------------------------- 1 | dependencyResolutionManagement { 2 | repositories.gradlePluginPortal() 3 | } 4 | 5 | include("java-plugins") -------------------------------------------------------------------------------- /29_Classpath_Collisions/my-project/app/build.gradle.kts: -------------------------------------------------------------------------------- 1 | plugins { 2 | id("my-java-application") 3 | } 4 | 5 | application { 6 | mainClass.set("mypackage.App") 7 | } 8 | 9 | dependencies { 10 | implementation("javax.activation:activation:1.1.1") 11 | implementation("javax.activation:activation:1.1") 12 | implementation("jakarta.activation:jakarta.activation-api:1.2.2") 13 | } 14 | -------------------------------------------------------------------------------- /29_Classpath_Collisions/my-project/app/src/main/java/mypackage/App.java: -------------------------------------------------------------------------------- 1 | package mypackage; 2 | 3 | import javax.activation.MimeType; 4 | 5 | public class App { 6 | 7 | public static void main(String[] args) { 8 | System.out.println(MimeType.class.getProtectionDomain().getCodeSource().getLocation()); 9 | } 10 | } 11 | -------------------------------------------------------------------------------- /29_Classpath_Collisions/my-project/libs/activation-1.1.1.jar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jjohannes/understanding-gradle/d3a158774e2f0eb7c007046955f858906c5b11c6/29_Classpath_Collisions/my-project/libs/activation-1.1.1.jar -------------------------------------------------------------------------------- /29_Classpath_Collisions/my-project/libs/activation-1.1.jar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jjohannes/understanding-gradle/d3a158774e2f0eb7c007046955f858906c5b11c6/29_Classpath_Collisions/my-project/libs/activation-1.1.jar -------------------------------------------------------------------------------- /29_Classpath_Collisions/my-project/libs/jakarta.activation-api-1.2.2.jar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jjohannes/understanding-gradle/d3a158774e2f0eb7c007046955f858906c5b11c6/29_Classpath_Collisions/my-project/libs/jakarta.activation-api-1.2.2.jar -------------------------------------------------------------------------------- /29_Classpath_Collisions/my-project/module/build.gradle.kts: -------------------------------------------------------------------------------- 1 | plugins { 2 | id("my-java-library") 3 | } 4 | 5 | dependencies { 6 | api("javax.activation:activation:1.1.1") 7 | implementation("commons-io:commons-io:2.6") 8 | } 9 | -------------------------------------------------------------------------------- /29_Classpath_Collisions/my-project/module/src/main/java/mypackage/modulea/ModuleA.java: -------------------------------------------------------------------------------- 1 | package mypackage.modulea; 2 | 3 | import org.apache.commons.io.FilenameUtils; 4 | import javax.activation.MimeType; 5 | 6 | public class ModuleA { 7 | 8 | public String doWork(MimeType mimeType) { 9 | return FilenameUtils.normalize("/a/../b"); 10 | } 11 | } 12 | -------------------------------------------------------------------------------- /29_Classpath_Collisions/my-project/settings.gradle.kts: -------------------------------------------------------------------------------- 1 | // Locations of Gradle plugins 2 | pluginManagement { 3 | repositories.gradlePluginPortal() 4 | includeBuild("../my-build-logic") 5 | } 6 | 7 | // Location of other components 8 | dependencyResolutionManagement { 9 | repositories.mavenCentral() 10 | } 11 | 12 | include("app") 13 | include("module") 14 | -------------------------------------------------------------------------------- /30_Security_Vulnerabilities/my-build-logic/java-plugins/build.gradle.kts: -------------------------------------------------------------------------------- 1 | plugins { 2 | `kotlin-dsl` 3 | } 4 | 5 | dependencies { 6 | implementation("org.owasp:dependency-check-gradle:11.1.0") 7 | } 8 | -------------------------------------------------------------------------------- /30_Security_Vulnerabilities/my-build-logic/java-plugins/src/main/kotlin/my-java-application.gradle.kts: -------------------------------------------------------------------------------- 1 | plugins { 2 | id("my-java-base") 3 | id("application") 4 | id("org.owasp.dependencycheck") 5 | } 6 | 7 | dependencyCheck { 8 | scanConfigurations = listOf(configurations.runtimeClasspath.get().name) 9 | autoUpdate = false 10 | // ... 11 | } 12 | -------------------------------------------------------------------------------- /30_Security_Vulnerabilities/my-build-logic/java-plugins/src/main/kotlin/my-java-library.gradle.kts: -------------------------------------------------------------------------------- 1 | plugins { 2 | id("my-java-base") 3 | id("java-library") 4 | } 5 | -------------------------------------------------------------------------------- /30_Security_Vulnerabilities/my-build-logic/settings.gradle.kts: -------------------------------------------------------------------------------- 1 | dependencyResolutionManagement { 2 | repositories.gradlePluginPortal() 3 | } 4 | 5 | include("java-plugins") -------------------------------------------------------------------------------- /30_Security_Vulnerabilities/my-project/app/build.gradle.kts: -------------------------------------------------------------------------------- 1 | plugins { 2 | id("my-java-application") 3 | } 4 | 5 | application { 6 | mainClass.set("mypackage.App") 7 | } 8 | 9 | dependencies { 10 | implementation(project(":module")) 11 | implementation("javax.activation:activation:1.1.1") 12 | implementation("org.slf4j:slf4j-api:2.0.3") 13 | runtimeOnly("org.slf4j:slf4j-simple:2.0.3") 14 | } 15 | 16 | // dependencies.constraints { 17 | // implementation("commons-io:commons-io:2.8" 18 | // } 19 | 20 | -------------------------------------------------------------------------------- /30_Security_Vulnerabilities/my-project/app/src/main/java/mypackage/App.java: -------------------------------------------------------------------------------- 1 | package mypackage; 2 | 3 | import mypackage.modulea.ModuleA; 4 | import org.slf4j.LoggerFactory; 5 | 6 | import javax.activation.MimeType; 7 | 8 | public class App extends ModuleA { 9 | 10 | public static void main(String[] args) { 11 | LoggerFactory.getLogger(App.class).info("running app"); 12 | new App().doWork(new MimeType()); 13 | } 14 | } 15 | -------------------------------------------------------------------------------- /30_Security_Vulnerabilities/my-project/module/build.gradle.kts: -------------------------------------------------------------------------------- 1 | plugins { 2 | id("my-java-library") 3 | } 4 | 5 | dependencies { 6 | api("javax.activation:activation:1.1.1") 7 | implementation("commons-io:commons-io:2.6") 8 | // implementation("commons-fileupload:commons-fileupload:1.4") 9 | } 10 | -------------------------------------------------------------------------------- /30_Security_Vulnerabilities/my-project/module/src/main/java/mypackage/modulea/ModuleA.java: -------------------------------------------------------------------------------- 1 | package mypackage.modulea; 2 | 3 | import org.apache.commons.io.FilenameUtils; 4 | import javax.activation.MimeType; 5 | 6 | public class ModuleA { 7 | 8 | public String doWork(MimeType mimeType) { 9 | return FilenameUtils.normalize("/a/../b"); 10 | } 11 | } 12 | -------------------------------------------------------------------------------- /30_Security_Vulnerabilities/my-project/settings.gradle.kts: -------------------------------------------------------------------------------- 1 | // Locations of Gradle plugins 2 | pluginManagement { 3 | repositories.gradlePluginPortal() 4 | includeBuild("../my-build-logic") 5 | } 6 | 7 | // Location of other components 8 | dependencyResolutionManagement { 9 | repositories.mavenCentral() 10 | } 11 | 12 | include("app") 13 | include("module") 14 | -------------------------------------------------------------------------------- /31_The_Module_Path/my-build-logic/java-plugins/build.gradle.kts: -------------------------------------------------------------------------------- 1 | plugins { 2 | `kotlin-dsl` 3 | } 4 | 5 | dependencies { 6 | implementation("org.gradlex:java-module-dependencies:1.8") 7 | } 8 | -------------------------------------------------------------------------------- /31_The_Module_Path/my-build-logic/java-plugins/src/main/kotlin/my-java-application.gradle.kts: -------------------------------------------------------------------------------- 1 | plugins { 2 | id("my-java-base") 3 | id("application") 4 | } 5 | 6 | -------------------------------------------------------------------------------- /31_The_Module_Path/my-build-logic/java-plugins/src/main/kotlin/my-java-library.gradle.kts: -------------------------------------------------------------------------------- 1 | plugins { 2 | id("my-java-base") 3 | id("java-library") 4 | } 5 | -------------------------------------------------------------------------------- /31_The_Module_Path/my-build-logic/settings.gradle.kts: -------------------------------------------------------------------------------- 1 | dependencyResolutionManagement { 2 | repositories.gradlePluginPortal() 3 | } 4 | 5 | include("java-plugins") -------------------------------------------------------------------------------- /31_The_Module_Path/my-project/app/build.gradle.kts: -------------------------------------------------------------------------------- 1 | plugins { 2 | id("my-java-application") 3 | } 4 | 5 | application { 6 | mainModule.set("org.example.app") 7 | mainClass.set("mypackage.App") 8 | } 9 | 10 | // dependencies { 11 | // implementation("jakarta.activation:jakarta.activation-api") 12 | // implementation(project(":modulea")) 13 | // } 14 | -------------------------------------------------------------------------------- /31_The_Module_Path/my-project/app/src/main/java/module-info.java: -------------------------------------------------------------------------------- 1 | module org.example.app { 2 | requires jakarta.activation; 3 | requires org.example.modulea; 4 | } 5 | -------------------------------------------------------------------------------- /31_The_Module_Path/my-project/app/src/main/java/mypackage/App.java: -------------------------------------------------------------------------------- 1 | package mypackage; 2 | 3 | import jakarta.activation.MimeType; 4 | import mypackage.modulea.ModuleA; 5 | 6 | public class App { 7 | 8 | public static void main(String[] args) { 9 | System.out.println(App.class.getModule().getName()); 10 | new MimeType(); 11 | new ModuleA(); 12 | } 13 | } 14 | -------------------------------------------------------------------------------- /31_The_Module_Path/my-project/modulea/build.gradle.kts: -------------------------------------------------------------------------------- 1 | plugins { 2 | id("my-java-library") 3 | } 4 | 5 | // dependencies { 6 | // implementation("jakarta.activation:jakarta.activation-api") 7 | // api("org.slf4j:slf4j-api") 8 | // compileOnly("jakarta.el:jakarta.el-api") 9 | // compileOnlyApi("jakarta.servlet:jakarta.servlet-api") 10 | // } 11 | -------------------------------------------------------------------------------- /31_The_Module_Path/my-project/modulea/src/main/java/module-info.java: -------------------------------------------------------------------------------- 1 | module org.example.modulea { 2 | requires jakarta.activation; 3 | requires transitive org.slf4j; 4 | requires static jakarta.el; 5 | requires static transitive jakarta.servlet; 6 | 7 | exports mypackage.modulea; 8 | } 9 | -------------------------------------------------------------------------------- /31_The_Module_Path/my-project/modulea/src/main/java/mypackage/modulea/ModuleA.java: -------------------------------------------------------------------------------- 1 | package mypackage.modulea; 2 | 3 | public class ModuleA { 4 | } 5 | -------------------------------------------------------------------------------- /31_The_Module_Path/my-project/settings.gradle.kts: -------------------------------------------------------------------------------- 1 | // Locations of Gradle plugins 2 | pluginManagement { 3 | repositories.gradlePluginPortal() 4 | includeBuild("../my-build-logic") 5 | } 6 | 7 | // Location of other components 8 | dependencyResolutionManagement { 9 | repositories.mavenCentral() 10 | } 11 | 12 | includeBuild(".") // https://github.com/gradle/gradle/issues/21490#issuecomment-1458887481 13 | 14 | include("app") 15 | include("modulea") 16 | -------------------------------------------------------------------------------- /32_Artifact_Transforms/my-build-logic/java-plugins/build.gradle.kts: -------------------------------------------------------------------------------- 1 | plugins { 2 | `kotlin-dsl` 3 | } 4 | 5 | dependencies { 6 | implementation("org.gradlex:extra-java-module-info:1.9") 7 | } -------------------------------------------------------------------------------- /32_Artifact_Transforms/my-build-logic/java-plugins/src/main/kotlin/my-java-application.gradle.kts: -------------------------------------------------------------------------------- 1 | plugins { 2 | id("my-java-base") 3 | id("application") 4 | } 5 | 6 | -------------------------------------------------------------------------------- /32_Artifact_Transforms/my-build-logic/java-plugins/src/main/kotlin/my-java-library.gradle.kts: -------------------------------------------------------------------------------- 1 | plugins { 2 | id("my-java-base") 3 | id("java-library") 4 | } 5 | -------------------------------------------------------------------------------- /32_Artifact_Transforms/my-build-logic/java-plugins/src/main/resources/org/example/commons-lang3-3.12.0/module-info.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jjohannes/understanding-gradle/d3a158774e2f0eb7c007046955f858906c5b11c6/32_Artifact_Transforms/my-build-logic/java-plugins/src/main/resources/org/example/commons-lang3-3.12.0/module-info.class -------------------------------------------------------------------------------- /32_Artifact_Transforms/my-build-logic/java-plugins/src/main/resources/org/example/commons-text-1.10.0/module-info.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/jjohannes/understanding-gradle/d3a158774e2f0eb7c007046955f858906c5b11c6/32_Artifact_Transforms/my-build-logic/java-plugins/src/main/resources/org/example/commons-text-1.10.0/module-info.class -------------------------------------------------------------------------------- /32_Artifact_Transforms/my-build-logic/settings.gradle.kts: -------------------------------------------------------------------------------- 1 | dependencyResolutionManagement { 2 | repositories.gradlePluginPortal() 3 | } 4 | 5 | include("java-plugins") -------------------------------------------------------------------------------- /32_Artifact_Transforms/my-project/app/build.gradle.kts: -------------------------------------------------------------------------------- 1 | plugins { 2 | id("my-java-application") 3 | } 4 | 5 | application { 6 | mainModule.set("org.example.app") 7 | mainClass.set("org.example.App") 8 | } 9 | 10 | dependencies { 11 | implementation("org.slf4j:slf4j-api") 12 | implementation("org.apache.commons:commons-text") 13 | implementation("org.apache.commons:commons-lang3") 14 | } 15 | -------------------------------------------------------------------------------- /32_Artifact_Transforms/my-project/app/src/main/java/module-info.java: -------------------------------------------------------------------------------- 1 | module org.example.app { 2 | requires org.slf4j; 3 | requires org.apache.commons.text; 4 | requires org.apache.commons.lang3; 5 | } 6 | -------------------------------------------------------------------------------- /32_Artifact_Transforms/my-project/settings.gradle.kts: -------------------------------------------------------------------------------- 1 | // Locations of Gradle plugins 2 | pluginManagement { 3 | repositories.gradlePluginPortal() 4 | includeBuild("../my-build-logic") 5 | } 6 | 7 | // Location of other components 8 | dependencyResolutionManagement { 9 | repositories.mavenCentral() 10 | } 11 | 12 | include("app") 13 | -------------------------------------------------------------------------------- /33_Classpath_and_Module_Path_in_Testing/my-build-logic/java-plugins/build.gradle.kts: -------------------------------------------------------------------------------- 1 | plugins { 2 | `kotlin-dsl` 3 | } 4 | 5 | dependencies { 6 | implementation("org.gradlex:java-module-testing:1.5") 7 | } 8 | -------------------------------------------------------------------------------- /33_Classpath_and_Module_Path_in_Testing/my-build-logic/java-plugins/src/main/kotlin/my-java-application.gradle.kts: -------------------------------------------------------------------------------- 1 | plugins { 2 | id("my-java-base") 3 | id("application") 4 | } 5 | 6 | -------------------------------------------------------------------------------- /33_Classpath_and_Module_Path_in_Testing/my-build-logic/java-plugins/src/main/kotlin/my-java-base.gradle.kts: -------------------------------------------------------------------------------- 1 | plugins { 2 | id("java") 3 | id("java-test-fixtures") 4 | id("org.gradlex.java-module-testing") 5 | } 6 | 7 | group = "org.example" 8 | 9 | java { 10 | toolchain.languageVersion.set(JavaLanguageVersion.of(17)) 11 | } 12 | 13 | javaModuleTesting.whitebox(testing.suites.getByName("test")) { 14 | requires.add("org.junit.jupiter.api") 15 | opensTo.add("org.junit.platform.commons") 16 | } 17 | 18 | tasks.test { 19 | useJUnitPlatform() // JUnit5 20 | } 21 | -------------------------------------------------------------------------------- /33_Classpath_and_Module_Path_in_Testing/my-build-logic/java-plugins/src/main/kotlin/my-java-library.gradle.kts: -------------------------------------------------------------------------------- 1 | plugins { 2 | id("my-java-base") 3 | id("java-library") 4 | } 5 | -------------------------------------------------------------------------------- /33_Classpath_and_Module_Path_in_Testing/my-build-logic/settings.gradle.kts: -------------------------------------------------------------------------------- 1 | dependencyResolutionManagement { 2 | repositories.gradlePluginPortal() 3 | } 4 | 5 | include("java-plugins") -------------------------------------------------------------------------------- /33_Classpath_and_Module_Path_in_Testing/my-project/app/build.gradle.kts: -------------------------------------------------------------------------------- 1 | plugins { 2 | id("my-java-application") 3 | } 4 | 5 | application { 6 | mainModule.set("org.example.app") 7 | mainClass.set("org.example.app.App") 8 | } 9 | 10 | dependencies { 11 | implementation("org.apache.commons:commons-lang3:3.6") 12 | 13 | testImplementation("org.apache.commons:commons-text:1.5") 14 | testImplementation("org.junit.jupiter:junit-jupiter-api:5.9.3") 15 | testRuntimeOnly("org.junit.jupiter:junit-jupiter-engine") 16 | testRuntimeOnly("org.junit.platform:junit-platform-launcher") 17 | } 18 | -------------------------------------------------------------------------------- /33_Classpath_and_Module_Path_in_Testing/my-project/app/src/main/java/module-info.java: -------------------------------------------------------------------------------- 1 | module org.example.app { 2 | requires org.apache.commons.lang3; 3 | 4 | exports org.example.app; 5 | } 6 | -------------------------------------------------------------------------------- /33_Classpath_and_Module_Path_in_Testing/my-project/app/src/main/java/org/example/app/App.java: -------------------------------------------------------------------------------- 1 | package org.example.app; 2 | 3 | public class App { 4 | 5 | public static void main(String[] args) { 6 | printModuleName(); 7 | } 8 | 9 | protected static void printModuleName() { 10 | System.out.println("Production Module: " + 11 | App.class.getModule().getName()); 12 | } 13 | } 14 | 15 | -------------------------------------------------------------------------------- /33_Classpath_and_Module_Path_in_Testing/my-project/app/src/test/java/org/example/app/AppTest.java: -------------------------------------------------------------------------------- 1 | package org.example.app; 2 | 3 | import org.junit.jupiter.api.Test; 4 | 5 | import java.io.IOException; 6 | 7 | import static java.nio.charset.StandardCharsets.UTF_8; 8 | 9 | class AppTest { 10 | 11 | @Test 12 | void testAppModule() throws IOException { 13 | App.printModuleName(); 14 | System.out.println("Test Module: " + 15 | AppTest.class.getModule().getName()); 16 | System.out.println( 17 | new String(AppTest.class.getResourceAsStream("/test-data.txt") 18 | .readAllBytes(), UTF_8)); 19 | } 20 | } 21 | -------------------------------------------------------------------------------- /33_Classpath_and_Module_Path_in_Testing/my-project/app/src/test/resources/test-data.txt: -------------------------------------------------------------------------------- 1 | __ __ __ __ ___ ______ ____ 2 | / / / /___ ____/ /__ __________/ /_____ _____ ____/ (_)___ ____ _ / ____/________ _____/ / /__ 3 | / / / / __ \/ __ / _ \/ ___/ ___/ __/ __ `/ __ \/ __ / / __ \/ __ `/ / / __/ ___/ __ `/ __ / / _ \ 4 | / /_/ / / / / /_/ / __/ / (__ ) /_/ /_/ / / / / /_/ / / / / / /_/ / / /_/ / / / /_/ / /_/ / / __/ 5 | \____/_/ /_/\__,_/\___/_/ /____/\__/\__,_/_/ /_/\__,_/_/_/ /_/\__, / \____/_/ \__,_/\__,_/_/\___/ 6 | /____/ -------------------------------------------------------------------------------- /33_Classpath_and_Module_Path_in_Testing/my-project/settings.gradle.kts: -------------------------------------------------------------------------------- 1 | // Locations of Gradle plugins 2 | pluginManagement { 3 | repositories.gradlePluginPortal() 4 | includeBuild("../my-build-logic") 5 | } 6 | 7 | // Location of other components 8 | dependencyResolutionManagement { 9 | repositories.mavenCentral() 10 | } 11 | 12 | include("app") 13 | -------------------------------------------------------------------------------- /34_Properties_and_Providers/my-build-logic/java-plugins/build.gradle.kts: -------------------------------------------------------------------------------- 1 | plugins { 2 | `kotlin-dsl` 3 | } 4 | -------------------------------------------------------------------------------- /34_Properties_and_Providers/my-build-logic/java-plugins/src/main/kotlin/org/example/MyEnum.kt: -------------------------------------------------------------------------------- 1 | package org.example 2 | 3 | enum class MyEnum { 4 | } -------------------------------------------------------------------------------- /34_Properties_and_Providers/my-build-logic/settings.gradle.kts: -------------------------------------------------------------------------------- 1 | dependencyResolutionManagement { 2 | repositories.gradlePluginPortal() 3 | } 4 | 5 | include("java-plugins") -------------------------------------------------------------------------------- /34_Properties_and_Providers/my-project/app/build.gradle.kts: -------------------------------------------------------------------------------- 1 | plugins { 2 | id("my-java-application") 3 | } 4 | 5 | application { 6 | // mainClassName = "org.example.app.App" 7 | mainClass.set("org.example.app.App") 8 | } -------------------------------------------------------------------------------- /34_Properties_and_Providers/my-project/app/src/main/java/org/example/app/App.java: -------------------------------------------------------------------------------- 1 | package org.example.app; 2 | 3 | public class App { 4 | 5 | public static void main(String[] args) { 6 | PrintUtil.print(); 7 | } 8 | } 9 | 10 | -------------------------------------------------------------------------------- /34_Properties_and_Providers/my-project/app/src/main/java/org/example/app/PrintUtil.java: -------------------------------------------------------------------------------- 1 | package org.example.app; 2 | 3 | public class PrintUtil { 4 | public static void print() { 5 | System.out.println("\uD83E\uDDA5"); 6 | } 7 | } 8 | -------------------------------------------------------------------------------- /34_Properties_and_Providers/my-project/app/version.txt: -------------------------------------------------------------------------------- 1 | 1.34 -------------------------------------------------------------------------------- /34_Properties_and_Providers/my-project/settings.gradle.kts: -------------------------------------------------------------------------------- 1 | // Locations of Gradle plugins 2 | pluginManagement { 3 | repositories.gradlePluginPortal() 4 | includeBuild("../my-build-logic") 5 | } 6 | 7 | // Location of other components 8 | dependencyResolutionManagement { 9 | repositories.mavenCentral() 10 | } 11 | 12 | include("app") 13 | -------------------------------------------------------------------------------- /35_Working_with_Files/my-build-logic/java-plugins/build.gradle.kts: -------------------------------------------------------------------------------- 1 | plugins { 2 | `kotlin-dsl` 3 | } 4 | -------------------------------------------------------------------------------- /35_Working_with_Files/my-build-logic/settings.gradle.kts: -------------------------------------------------------------------------------- 1 | dependencyResolutionManagement { 2 | repositories.gradlePluginPortal() 3 | } 4 | 5 | include("java-plugins") -------------------------------------------------------------------------------- /35_Working_with_Files/my-project/app/build.gradle.kts: -------------------------------------------------------------------------------- 1 | plugins { 2 | id("my-java-application") 3 | } 4 | 5 | dependencies { 6 | implementation("org.apache.commons:commons-text:1.11.0") 7 | } 8 | -------------------------------------------------------------------------------- /35_Working_with_Files/my-project/app/src/main/java/org/example/app/App.java: -------------------------------------------------------------------------------- 1 | package org.example.app; 2 | 3 | import org.apache.commons.text.CaseUtils; 4 | 5 | public class App { 6 | 7 | public static void main(String[] args) { 8 | System.out.println(CaseUtils.toCamelCase("hello world \uD83D\uDE80", true)); 9 | } 10 | } 11 | -------------------------------------------------------------------------------- /35_Working_with_Files/my-project/app/version.txt: -------------------------------------------------------------------------------- 1 | 1.34 -------------------------------------------------------------------------------- /35_Working_with_Files/my-project/settings.gradle.kts: -------------------------------------------------------------------------------- 1 | // Locations of Gradle plugins 2 | pluginManagement { 3 | repositories.gradlePluginPortal() 4 | includeBuild("../my-build-logic") 5 | } 6 | 7 | // Location of other components 8 | dependencyResolutionManagement { 9 | repositories.mavenCentral() 10 | } 11 | 12 | include("app") 13 | -------------------------------------------------------------------------------- /36_Task_Actions/my-build-logic/java-plugins/build.gradle.kts: -------------------------------------------------------------------------------- 1 | plugins { 2 | `kotlin-dsl` 3 | } 4 | -------------------------------------------------------------------------------- /36_Task_Actions/my-build-logic/java-plugins/src/main/kotlin/PrintVersion.kt: -------------------------------------------------------------------------------- 1 | import org.gradle.api.DefaultTask 2 | import org.gradle.api.provider.Property 3 | import org.gradle.api.tasks.Input 4 | import org.gradle.api.tasks.TaskAction 5 | 6 | abstract class PrintVersion : DefaultTask() { 7 | 8 | @get:Input 9 | abstract val version: Property 10 | 11 | @TaskAction 12 | fun print() { 13 | println("Version: ${version.get()}") 14 | } 15 | } 16 | -------------------------------------------------------------------------------- /36_Task_Actions/my-build-logic/settings.gradle.kts: -------------------------------------------------------------------------------- 1 | dependencyResolutionManagement { 2 | repositories.gradlePluginPortal() 3 | } 4 | 5 | include("java-plugins") -------------------------------------------------------------------------------- /36_Task_Actions/my-project/app/build.gradle.kts: -------------------------------------------------------------------------------- 1 | plugins { 2 | id("my-java-application") 3 | } 4 | 5 | version = "1.0" 6 | 7 | application { 8 | mainClass = "org.example.app.App" 9 | } -------------------------------------------------------------------------------- /36_Task_Actions/my-project/app/src/main/java/org/example/app/App.java: -------------------------------------------------------------------------------- 1 | package org.example.app; 2 | 3 | public class App { 4 | 5 | public static void main(String[] args) { 6 | System.out.println("Hello World \uD83D\uDE80"); 7 | } 8 | } 9 | -------------------------------------------------------------------------------- /36_Task_Actions/my-project/gradle.properties: -------------------------------------------------------------------------------- 1 | org.gradle.configuration-cache=true -------------------------------------------------------------------------------- /36_Task_Actions/my-project/settings.gradle.kts: -------------------------------------------------------------------------------- 1 | // Locations of Gradle plugins 2 | pluginManagement { 3 | repositories.gradlePluginPortal() 4 | includeBuild("../my-build-logic") 5 | } 6 | 7 | // Location of other components 8 | dependencyResolutionManagement { 9 | repositories.mavenCentral() 10 | } 11 | 12 | include("app") 13 | --------------------------------------------------------------------------------