-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
16 changed files
with
183 additions
and
50 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 |
---|---|---|
|
@@ -14,19 +14,18 @@ | |
* contact D4L by email to [email protected]. | ||
*/ | ||
plugins { | ||
id("care.data4life.fhir.dependency") | ||
id("care.data4life.gradle.fhir.dependency") | ||
|
||
id("care.data4life.fhir.dependency-updates") | ||
id("care.data4life.fhir.download-scripts") | ||
id("care.data4life.fhir.publishing") | ||
id("care.data4life.fhir.versioning") | ||
id("care.data4life.gradle.fhir.script.dependency-updates") | ||
id("care.data4life.gradle.fhir.script.download-scripts") | ||
id("care.data4life.gradle.fhir.script.publishing") | ||
id("care.data4life.gradle.fhir.script.versioning") | ||
} | ||
|
||
allprojects { | ||
repositories { | ||
google() | ||
mavenCentral() | ||
jcenter() | ||
} | ||
} | ||
|
||
|
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 |
---|---|---|
|
@@ -13,10 +13,13 @@ | |
* applications and/or if you’d like to contribute to the development of the SDK, please | ||
* contact D4L by email to [email protected]. | ||
*/ | ||
|
||
import care.data4life.gradle.fhir.dependency.d4l | ||
|
||
plugins { | ||
`kotlin-dsl` | ||
|
||
id("care.data4life.fhir.dependency") | ||
id("care.data4life.gradle.fhir.dependency") | ||
} | ||
|
||
|
||
|
@@ -25,20 +28,21 @@ repositories { | |
gradlePluginPortal() | ||
mavenCentral() | ||
google() | ||
d4l() | ||
} | ||
|
||
dependencies { | ||
implementation(care.data4life.fhir.dependency.GradlePlugin.kotlin) | ||
implementation(care.data4life.fhir.dependency.GradlePlugin.android) | ||
implementation(care.data4life.gradle.fhir.dependency.GradlePlugin.kotlin) | ||
implementation(care.data4life.gradle.fhir.dependency.GradlePlugin.android) | ||
|
||
// dependency check | ||
// dependency-updates.gradle.kts | ||
implementation("com.github.ben-manes:gradle-versions-plugin:0.38.0") | ||
// download scripts | ||
// download-scripts.gradle.kts | ||
implementation("de.undercouch:gradle-download-task:4.1.1") | ||
// publishing.gradle.kts | ||
implementation("org.eclipse.jgit:org.eclipse.jgit:5.11.0.202103091610-r") | ||
// versioning.gradle.kts | ||
implementation("com.palantir.gradle.gitversion:gradle-git-version:0.12.3") | ||
implementation("care.data4life.gradle.gitversion:gradle-git-version:0.12.4-d4l") | ||
} | ||
|
||
kotlinDslPluginOptions { | ||
|
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 |
---|---|---|
|
@@ -13,7 +13,7 @@ | |
* applications and/or if you’d like to contribute to the development of the SDK, please | ||
* contact D4L by email to [email protected]. | ||
*/ | ||
package care.data4life.fhir | ||
package care.data4life.gradle.fhir.config | ||
|
||
object LibraryConfig { | ||
const val group = "care.data4life.fhir" | ||
|
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 |
---|---|---|
|
@@ -14,15 +14,27 @@ | |
* contact D4L by email to [email protected]. | ||
*/ | ||
|
||
package care.data4life.fhir | ||
package care.data4life.gradle.fhir.script | ||
|
||
/** | ||
* [DependencyUpdates](https://github.com/ben-manes/gradle-versions-plugin) | ||
* Dependency update check task using [DependencyUpdates](https://github.com/ben-manes/gradle-versions-plugin) | ||
* | ||
* Install: | ||
* | ||
* You need to add following dependencies to the buildSrc/build.gradle.kts | ||
* | ||
* - implementation("com.github.ben-manes:gradle-versions-plugin:0.38.0") | ||
* dependencies { | ||
* implementation("com.github.ben-manes:gradle-versions-plugin:0.38.0") | ||
* } | ||
* | ||
* Now just add id("care.data4life.gradle.fhir.script.dependency-updates") to your project module build.gradle.kts plugins section | ||
* | ||
* plugins { | ||
* id("care.data4life.gradle.fhir.script.dependency-updates") | ||
* } | ||
* | ||
* Usage: | ||
* - ./gradlew dependencyUpdates | ||
*/ | ||
plugins { | ||
id("com.github.ben-manes.versions") | ||
|
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 |
---|---|---|
|
@@ -14,20 +14,41 @@ | |
* contact D4L by email to [email protected]. | ||
*/ | ||
|
||
package care.data4life.fhir | ||
package care.data4life.gradle.fhir.script | ||
|
||
import de.undercouch.gradle.tasks.download.Download | ||
|
||
/** | ||
* [Gradle Download Task](https://github.com/michel-kraemer/gradle-download-task) | ||
* | ||
* Download task to retrieve the latest gradle scripts using [Gradle Download Task](https://github.com/michel-kraemer/gradle-download-task) | ||
* | ||
* Install: | ||
* | ||
* You need to add following dependencies to the buildSrc/build.gradle.kts | ||
* | ||
* - implementation("de.undercouch:gradle-download-task:4.1.1") | ||
* dependencies { | ||
* implementation("de.undercouch:gradle-download-task:4.1.1") | ||
* } | ||
* | ||
* and ensure that the gradlePluginPortal is available | ||
* | ||
* repositories { | ||
* gradlePluginPortal() | ||
* } | ||
* | ||
* It requires a Environment variable set for GITHUB_USERNAME and GITHUB_REPO_TOKEN, the token should have repo:read scope | ||
* | ||
* Now just add id("care.data4life.gradle.fhir.script.download-scripts") to your project module build.gradle.kts plugins section | ||
* | ||
* plugins { | ||
* id("care.data4life.gradle.fhir.script.download-scripts") | ||
* } | ||
* | ||
* Usage: | ||
* - downloadAll will download all available configuration and scripts | ||
* - downloadDanger | ||
* - downloadDangerWorkflow | ||
* - downloadGradleScripts | ||
*/ | ||
plugins { | ||
id("de.undercouch.download") | ||
|
@@ -36,8 +57,9 @@ plugins { | |
private val repository = "https://raw.githubusercontent.com/d4l-data4life/hc-gradle-scripts" | ||
private val branch = "main" | ||
val baseLink = "$repository/$branch" | ||
val scriptPath = "buildSrc/src/main/kotlin/scripts" | ||
val scriptLink = "$baseLink/$scriptPath" | ||
val scriptPathSource = "buildSrc/src/main/kotlin/care/data4life/sdk/script" | ||
val scriptPathTarget = "buildSrc/src/main/kotlin/care/data4life/gradle/datadonation/script" | ||
val scriptLink = "$baseLink/$scriptPathSource" | ||
val workflowPath = ".github/workflows" | ||
val workflowLink = "$baseLink/$workflowPath" | ||
|
||
|
@@ -46,6 +68,7 @@ val scriptFiles = listOf( | |
"$scriptLink/download-scripts.gradle.kts", | ||
"$scriptLink/publishing.gradle.kts", | ||
"$scriptLink/publishing-config.gradle.kts", | ||
"$scriptLink/quality-spotless.gradle.kts", | ||
"$scriptLink/versioning.gradle.kts" | ||
) | ||
|
||
|
@@ -57,7 +80,7 @@ val downloadGradleScripts by tasks.creating(Download::class) { | |
password(System.getenv("GITHUB_REPO_TOKEN")) | ||
|
||
src(scriptFiles) | ||
dest("${rootProject.rootDir}/$scriptPath/") | ||
dest("${rootProject.rootDir}/$scriptPathTarget/") | ||
|
||
overwrite(true) | ||
} | ||
|
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 |
---|---|---|
|
@@ -14,8 +14,9 @@ | |
* contact D4L by email to [email protected]. | ||
*/ | ||
|
||
package care.data4life.fhir | ||
package care.data4life.gradle.fhir.script | ||
|
||
import care.data4life.gradle.fhir.config.LibraryConfig | ||
import org.gradle.api.publish.maven.MavenPublication | ||
|
||
/** | ||
|
@@ -69,9 +70,9 @@ publishing { | |
url = uri("https://maven.pkg.github.com/d4l-data4life/hc-fhir-sdk-java") | ||
credentials { | ||
username = (project.findProperty("gpr.user") | ||
?: System.getenv("PACKAGE_REGISTRY_UPLOAD_USERNAME")).toString() | ||
?: System.getenv("PACKAGE_REGISTRY_UPLOAD_USERNAME")).toString() | ||
password = (project.findProperty("gpr.key") | ||
?: System.getenv("PACKAGE_REGISTRY_UPLOAD_TOKEN")).toString() | ||
?: System.getenv("PACKAGE_REGISTRY_UPLOAD_TOKEN")).toString() | ||
} | ||
} | ||
|
||
|
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 |
---|---|---|
|
@@ -14,8 +14,9 @@ | |
* contact D4L by email to [email protected]. | ||
*/ | ||
|
||
package care.data4life.fhir | ||
package care.data4life.gradle.fhir.script | ||
|
||
import care.data4life.gradle.fhir.config.LibraryConfig | ||
import org.eclipse.jgit.api.Git | ||
import org.eclipse.jgit.api.ResetCommand | ||
import org.eclipse.jgit.transport.PushResult | ||
|
@@ -39,10 +40,10 @@ import org.eclipse.jgit.transport.UsernamePasswordCredentialsProvider | |
* mavenCentral() | ||
* } | ||
* | ||
* Now just add id("care.data4life.fhir.publishing") to your rootProject build.gradle.kts plugins | ||
* Now just add id("care.data4life.gradle.fhir.script.publishing") to your rootProject build.gradle.kts plugins | ||
* | ||
* plugins { | ||
* id("care.data4life.fhir.publishing") | ||
* id("care.data4life.gradle.fhir.script.publishing") | ||
* } | ||
* | ||
* Usage: | ||
|
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 |
---|---|---|
|
@@ -13,15 +13,20 @@ | |
* applications and/or if you’d like to contribute to the development of the SDK, please | ||
* contact D4L by email to [email protected]. | ||
*/ | ||
package care.data4life.fhir | ||
|
||
package care.data4life.gradle.fhir.script | ||
|
||
import care.data4life.gradle.gitversion.VersionDetails | ||
|
||
/** | ||
* Usage: | ||
* Versioning task to calculate the version based on git tags and branch names using [Gradle Git Version](https://github.com/d4l-data4life/gradle-git-version) | ||
* | ||
* Install: | ||
* | ||
* You need to add following dependencies to the buildSrc/build.gradle.kts | ||
* | ||
* dependencies { | ||
* implementation("com.palantir.gradle.gitversion:gradle-git-version:0.12.3") | ||
* implementation("care.data4life.gradle.gitversion:gradle-git-version:0.12.4-d4l") | ||
* } | ||
* | ||
* and ensure that the gradlePluginPortal is available | ||
|
@@ -30,12 +35,14 @@ package care.data4life.fhir | |
* gradlePluginPortal() | ||
* } | ||
* | ||
* Now just add id("scripts.versioning") to your rootProject build.gradle.kts plugins | ||
* Now just add id("care.data4life.gradle.fhir.script.versioning") to your rootProject build.gradle.kts plugins | ||
* | ||
* plugins { | ||
* id("scripts.versioning") | ||
* id("care.data4life.gradle.fhir.script.versioning") | ||
* } | ||
* | ||
* Usage: | ||
* | ||
* Versions will be calculated based on the latest git tag v* and branch name. if no tag is present a git hash will be used instead | ||
* | ||
* Branch == main == tag (v0.1.0) -> uses latest tag -> v0.1.0 | ||
|
@@ -45,15 +52,15 @@ package care.data4life.fhir | |
* | ||
* Review the generated version: | ||
* - ./gradlew versionInfo | ||
* | ||
*/ | ||
plugins { | ||
id("com.palantir.git-version") | ||
id("care.data4life.git-version") | ||
} | ||
|
||
val versionDetails: groovy.lang.Closure<com.palantir.gradle.gitversion.VersionDetails> by extra | ||
val versionDetails: groovy.lang.Closure<VersionDetails> by extra | ||
val patternNoQualifierBranch = "main|release/.*".toRegex() | ||
val patternFeatureBranch = "feature/(.*)".toRegex() | ||
val patternDependabotBranch = "dependabot/(.*)".toRegex() | ||
val patternTicketNumber = "[A-Z]{2,8}-.*/(.*)".toRegex() | ||
|
||
fun versionName(): String { | ||
|
@@ -63,11 +70,12 @@ fun versionName(): String { | |
details.branchName == null -> versionNameWithQualifier(details) | ||
patternNoQualifierBranch.matches(details.branchName) -> versionNameWithQualifier(details) | ||
patternFeatureBranch.matches(details.branchName) -> versionNameFeature(details) | ||
patternDependabotBranch.matches(details.branchName) -> versionNameDependabot(details) | ||
else -> throw UnsupportedOperationException("branch name not supported: ${details.branchName}") | ||
} | ||
} | ||
|
||
fun versionNameFeature(details: com.palantir.gradle.gitversion.VersionDetails): String { | ||
fun versionNameFeature(details: VersionDetails): String { | ||
var featureName = patternFeatureBranch.matchEntire(details.branchName)!!.groups[1]!!.value | ||
|
||
if (patternTicketNumber.matches(featureName)) { | ||
|
@@ -77,8 +85,18 @@ fun versionNameFeature(details: com.palantir.gradle.gitversion.VersionDetails): | |
return versionNameWithQualifier(details, featureName) | ||
} | ||
|
||
fun versionNameDependabot(details: VersionDetails): String { | ||
var dependabotName = patternDependabotBranch.matchEntire(details.branchName)!!.groups[1]!!.value | ||
|
||
dependabotName = dependabotName | ||
.replace("_", "-") | ||
.replace("/", "-") | ||
|
||
return versionNameWithQualifier(details, "bump-$dependabotName") | ||
} | ||
|
||
fun versionNameWithQualifier( | ||
details: com.palantir.gradle.gitversion.VersionDetails, | ||
details: VersionDetails, | ||
name: String = "" | ||
): String { | ||
val version = if (!details.isCleanTag) { | ||
|
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 |
---|---|---|
|
@@ -13,7 +13,7 @@ | |
* applications and/or if you’d like to contribute to the development of the SDK, please | ||
* contact D4L by email to [email protected]. | ||
*/ | ||
import care.data4life.fhir.LibraryConfig | ||
import care.data4life.gradle.fhir.config.LibraryConfig | ||
|
||
plugins { | ||
id 'org.asciidoctor.convert' version '1.5.9.1' | ||
|
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 |
---|---|---|
|
@@ -13,15 +13,16 @@ | |
* applications and/or if you’d like to contribute to the development of the SDK, please | ||
* contact D4L by email to [email protected]. | ||
*/ | ||
import care.data4life.fhir.dependency.Dependency | ||
import care.data4life.fhir.LibraryConfig | ||
|
||
import care.data4life.gradle.fhir.dependency.Dependency | ||
import care.data4life.gradle.fhir.config.LibraryConfig | ||
|
||
plugins { | ||
`java-library` | ||
jacoco | ||
|
||
// Publish | ||
id("care.data4life.fhir.publishing-config") | ||
id("care.data4life.gradle.fhir.script.publishing-config") | ||
} | ||
|
||
group = LibraryConfig.group | ||
|
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
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 |
---|---|---|
|
@@ -13,7 +13,7 @@ | |
* applications and/or if you’d like to contribute to the development of the SDK, please | ||
* contact D4L by email to [email protected]. | ||
*/ | ||
package care.data4life.fhir.dependency | ||
package care.data4life.gradle.fhir.dependency | ||
|
||
object Dependency { | ||
val jvm = Java | ||
|
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 |
---|---|---|
|
@@ -14,7 +14,7 @@ | |
* contact D4L by email to [email protected]. | ||
*/ | ||
|
||
package care.data4life.fhir.dependency | ||
package care.data4life.gradle.fhir.dependency | ||
|
||
import org.gradle.api.Plugin | ||
import org.gradle.api.Project | ||
|
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 |
---|---|---|
|
@@ -13,7 +13,7 @@ | |
* applications and/or if you’d like to contribute to the development of the SDK, please | ||
* contact D4L by email to [email protected]. | ||
*/ | ||
package care.data4life.fhir.dependency | ||
package care.data4life.gradle.fhir.dependency | ||
|
||
object GradlePlugin { | ||
const val android = "com.android.tools.build:gradle:${Version.GradlePlugin.android}" | ||
|
Oops, something went wrong.