Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Question about how to use a common versions object
- Loading branch information
1 parent
aa35e6a
commit 8177332
Showing
27 changed files
with
279 additions
and
729 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
# Set default behavior to automatically normalize line endings. | ||
* text=auto | ||
|
||
# Force batch scripts to always use CRLF line endings so that if a repo is accessed | ||
# in Windows via a file share from Linux, the scripts will work. | ||
*.{cmd,[cC][mM][dD]} text eol=crlf | ||
*.{bat,[bB][aA][tT]} text eol=crlf | ||
|
||
# Force bash scripts to always use LF line endings so that if a repo is accessed | ||
# in Unix via a file share from Windows, the scripts will work. | ||
*.sh text eol=lf |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,34 +1,5 @@ | ||
This is a simple project where I try to understand how to use gradle and `buildSrc` for dependency management. It is also used to ask the gradle folks for help. | ||
# Helpme | ||
|
||
All the "requests for help" in this project can be found by searching for "HELPME". | ||
How to use the object `buildSrc/src/main/kotlin/land/tbp/wwsc/Versions.kt` inside `buildSrc/build.gradle.kts`? | ||
|
||
The initial project sources taken from gradle documentation itself: https://docs.gradle.org/current/samples/sample_convention_plugins.html. Press the "Kotlin DSL" button at the top. | ||
|
||
Unfortunately those are rather lackluster as they don't help with setting up a proper application which uses multiple technologies. That's why I created this project which tries to set up a spring boot + kotlin project. | ||
|
||
|
||
# Problems (HELPME) | ||
|
||
This is a blocker for me right now, so it gets its own readme section. | ||
|
||
## How can i find the name of a "plugin dependency"? | ||
|
||
- `id("org.springframework.boot")` is found at https://plugins.gradle.org/plugin/org.springframework.boot and i assume the dependency is `implementation("org.springframework.boot:spring-boot-gradle-plugin:2.5.4")` | ||
- `kotlin("jvm")` is found at https://plugins.gradle.org/plugin/org.jetbrains.kotlin.jvm and i assume the dependency is `implementation("org.jetbrains.kotlin:kotlin-gradle-plugin:1.5.30")` | ||
- ❓ `kotlin("plugin.spring")` is found at https://plugins.gradle.org/plugin/org.jetbrains.kotlin.plugin.spring, however i have no idea what i should add as dependency. | ||
|
||
The problem here (imo) is that the website https://plugins.gradle.org/ does not show the "plugin dependency name" itself. | ||
It has 2 examples: | ||
|
||
- `Using the plugins DSL` | ||
- `Using legacy plugin application` | ||
|
||
However, there is no `Using buildSrc plugin dependency`. Can that be added as well? | ||
|
||
|
||
|
||
# How to run: | ||
|
||
``` | ||
gradle clean check jacocoTestReport bootJar | ||
``` | ||
I want to do this because I want to store the versions of my libraries and plugins in one central place. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,36 +1,41 @@ | ||
// HELPME: how can i not duplicate V? | ||
object V { | ||
const val springBootVersion = "2.5.3" | ||
const val kotlinVersion = "1.5.10" | ||
} | ||
|
||
|
||
// TODO: HELPME | ||
// How to use the versions from the central location `land.tbp.wwsc.Versions`? | ||
// Using the following imports does not work as the imports aren't found. | ||
//import land.tbp.wwsc.Versions.gradleTaskinfoVersion | ||
//import land.tbp.wwsc.Versions.kotlinLibraryVersion | ||
//import land.tbp.wwsc.Versions.ktlintGradleVersion | ||
//import land.tbp.wwsc.Versions.sonarqubeVersion | ||
//import land.tbp.wwsc.Versions.springBootVersion | ||
///////////////// | ||
|
||
// So, I have to duplicate the imports code, which is bad. | ||
val kotlinLibraryVersion = "1.5.10" | ||
val springBootVersion = "2.5.3" | ||
val ktlintGradleVersion = "10.1.0" | ||
val sonarqubeVersion = "3.3" | ||
val gradleTaskinfoVersion = "1.3.0" | ||
|
||
/* | ||
How to test? | ||
Comment the val calls above and uncomment the imports. gradle will complain that it doesn't know what to import. | ||
*/ | ||
plugins { | ||
`kotlin-dsl` | ||
} | ||
|
||
repositories { | ||
gradlePluginPortal() // so that external plugins can be resolved in dependencies section | ||
gradlePluginPortal() | ||
} | ||
|
||
dependencies { | ||
implementation("gradle.plugin.com.github.spotbugs.snom:spotbugs-gradle-plugin:4.6.2") | ||
testImplementation("junit:junit:4.13") | ||
|
||
// used for kotlin with spring project | ||
implementation("org.jetbrains.kotlin:kotlin-gradle-plugin:${V.kotlinVersion}") | ||
implementation("org.springframework.boot:spring-boot-gradle-plugin:${V.springBootVersion}") | ||
|
||
// HELPME: what is the name of the plugin containing kotlin spring ( kotlin("plugin.spring") )? | ||
// From https://plugins.gradle.org/plugin/org.jetbrains.kotlin.plugin.spring, i expect it to be | ||
// implementation("org.jetbrains.kotlin:kotlin-allopen:1.5.10") | ||
// but that makes no sense. | ||
// @gradle documentation folks: Where can i find the name of the plugins?? | ||
|
||
|
||
implementation("gradle.plugin.org.barfuin.gradle.taskinfo:gradle-taskinfo:1.3.0") | ||
implementation("org.jlleitschuh.gradle:ktlint-gradle:10.1.0") | ||
implementation("org.sonarsource.scanner.gradle:sonarqube-gradle-plugin:3.3") | ||
implementation("org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlinLibraryVersion") | ||
implementation("org.springframework.boot:spring-boot-gradle-plugin:$springBootVersion") | ||
|
||
implementation("org.jetbrains.kotlin:kotlin-allopen:$kotlinLibraryVersion") | ||
implementation("org.jetbrains.kotlin:kotlin-noarg:$kotlinLibraryVersion") | ||
|
||
implementation("gradle.plugin.org.barfuin.gradle.taskinfo:gradle-taskinfo:$gradleTaskinfoVersion") | ||
implementation("org.jlleitschuh.gradle:ktlint-gradle:$ktlintGradleVersion") | ||
implementation("org.sonarsource.scanner.gradle:sonarqube-gradle-plugin:$sonarqubeVersion") | ||
} |
This file was deleted.
Oops, something went wrong.
38 changes: 0 additions & 38 deletions
38
buildSrc/src/main/java/com/example/ReadmeVerificationTask.java
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
package land.tbp.wwsc | ||
|
||
import org.gradle.api.JavaVersion | ||
|
||
object Versions { | ||
val javaVersion = JavaVersion.VERSION_11 | ||
const val kotlinLanguageApiVersion = "1.5" | ||
|
||
const val kotlinLibraryVersion = "1.5.10" | ||
|
||
const val springBootVersion = "2.5.3" | ||
const val springCloudVersion = "2020.0.3" | ||
const val springCloudGcpPubsubVersion = "2.0.3" | ||
|
||
const val oracleJdbc = "19.3.0.0" | ||
|
||
const val jacksonVersion = "2.12.4" | ||
|
||
const val keycloakVersion = "13.0.1" | ||
const val openApiVersion = "1.5.10" | ||
const val logstashLogbackEncoderVersion = "6.6" | ||
|
||
const val h2Version = "1.4.200" | ||
const val prometheusVersion = "1.7.2" | ||
|
||
const val kittinunfResultVersion = "3.1.0" | ||
|
||
const val springMockkVersion = "3.0.1" | ||
const val mockKVersion = "1.12.0" | ||
const val assertJVersion = "3.20.2" | ||
const val awaitilityVersion = "4.1.0" | ||
const val mockitoCore = "2.8.9" | ||
|
||
const val ktlintGradleVersion = "10.1.0" | ||
const val sonarqubeVersion = "3.3" | ||
const val gradleTaskinfoVersion = "1.3.0" | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
28 changes: 0 additions & 28 deletions
28
buildSrc/src/main/kotlin/myproject.java-conventions.gradle.kts
This file was deleted.
Oops, something went wrong.
Oops, something went wrong.