-
Notifications
You must be signed in to change notification settings - Fork 13
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
9 changed files
with
232 additions
and
0 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 |
---|---|---|
@@ -1,3 +1,10 @@ | ||
plugins { | ||
`kotlin-dsl` | ||
} | ||
|
||
dependencies { | ||
implementation(platform(project(":plugins-platform"))) | ||
|
||
implementation("dev.jacomet.gradle.plugins:logging-capabilities") | ||
implementation("org.gradlex:java-ecosystem-capabilities") | ||
} |
31 changes: 31 additions & 0 deletions
31
.../plugins/dependency-rules-plugins/src/main/kotlin/org.example.dependency-rules.gradle.kts
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,31 @@ | ||
import org.example.metadatarules.fixdependencies.TypesafeConfigGuiceRule | ||
import org.example.metadatarules.status.ComponentStatusRule | ||
import org.example.metadatarules.versionalignment.HttpComponentsPlatformRule | ||
import org.example.metadatarules.versionalignment.PoiPlatformRule | ||
import org.example.metadatarules.versionalignment.Slf4jPlatformRule | ||
import org.example.metadatarules.versionalignment.ParentPomAsPlatformRule | ||
|
||
plugins { | ||
id("dev.jacomet.logging-capabilities") | ||
id("org.gradlex.java-ecosystem-capabilities") | ||
} | ||
|
||
// Configure logging capabilities plugin to default to Slf4JSimple | ||
loggingCapabilities.enforceSlf4JSimple() | ||
|
||
dependencies.components { | ||
// Versions that are not final get the 'integration' status | ||
all<ComponentStatusRule>() | ||
|
||
// Fix dependencies | ||
withModule<TypesafeConfigGuiceRule>(TypesafeConfigGuiceRule.TYPESAFE_CONFIG_GUICE_MODULE) | ||
|
||
// Define 'Alignment Platforms' (platforms for multi-component libraries without published BOM) | ||
withModule<HttpComponentsPlatformRule>(HttpComponentsPlatformRule.HTTP_COMPONENTS_CLIENT) | ||
withModule<PoiPlatformRule>(PoiPlatformRule.POI_COMMON) | ||
withModule<Slf4jPlatformRule>(Slf4jPlatformRule.SLF4J_PARENT) | ||
|
||
// Make parents usable as pure 'Alignment Platforms' - remove all constraints that do not concern the alignment | ||
withModule<ParentPomAsPlatformRule>(HttpComponentsPlatformRule.HTTP_COMPONENTS_CLIENT) | ||
withModule<ParentPomAsPlatformRule>(Slf4jPlatformRule.SLF4J_PARENT) | ||
} |
25 changes: 25 additions & 0 deletions
25
...gins/src/main/kotlin/org/example/metadatarules/fixdependencies/TypesafeConfigGuiceRule.kt
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,25 @@ | ||
package org.example.metadatarules.fixdependencies | ||
|
||
import org.gradle.api.artifacts.CacheableRule | ||
import org.gradle.api.artifacts.ComponentMetadataContext | ||
import org.gradle.api.artifacts.ComponentMetadataRule | ||
|
||
/** | ||
* Removes the 'no_aop' classifier from the Guice dependency, because it | ||
* no longer exists with Guice 5.0 to which we upgrade the dependency. | ||
*/ | ||
@CacheableRule | ||
abstract class TypesafeConfigGuiceRule : ComponentMetadataRule { | ||
companion object { | ||
const val TYPESAFE_CONFIG_GUICE_MODULE = "com.github.racc:typesafeconfig-guice" | ||
} | ||
|
||
override fun execute(context: ComponentMetadataContext) { | ||
context.details.allVariants { | ||
withDependencies { | ||
removeIf { it.group == "com.google.inject" } | ||
add("com.google.inject:guice") | ||
} | ||
} | ||
} | ||
} |
29 changes: 29 additions & 0 deletions
29
...ncy-rules-plugins/src/main/kotlin/org/example/metadatarules/status/ComponentStatusRule.kt
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,29 @@ | ||
package org.example.metadatarules.status | ||
|
||
import org.gradle.api.artifacts.CacheableRule | ||
import org.gradle.api.artifacts.ComponentMetadataContext | ||
import org.gradle.api.artifacts.ComponentMetadataRule | ||
|
||
/** | ||
* Make sure versions that are not final released have a different status than 'release'. | ||
* Otherwise, they will be considered when asking for the 'latest.release' version. | ||
* | ||
* (POM metadata does not support the 'status' concept and thus Gradle assumes everything is a 'release' by default) | ||
*/ | ||
@CacheableRule | ||
abstract class ComponentStatusRule : ComponentMetadataRule { | ||
override fun execute(context: ComponentMetadataContext) { | ||
val version = context.details.id.version | ||
val lcVersion = version.lowercase() | ||
if (lcVersion.contains("alpha") | ||
|| lcVersion.contains("-b") | ||
|| lcVersion.contains("beta") | ||
|| lcVersion.contains("cr") | ||
|| lcVersion.contains("m") | ||
|| lcVersion.contains("rc") | ||
|| lcVersion.startsWith("200")) { | ||
|
||
context.details.status = "integration" | ||
} | ||
} | ||
} |
42 changes: 42 additions & 0 deletions
42
.../src/main/kotlin/org/example/metadatarules/versionalignment/HttpComponentsPlatformRule.kt
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,42 @@ | ||
package org.example.metadatarules.versionalignment | ||
|
||
import org.gradle.api.artifacts.CacheableRule | ||
import org.gradle.api.artifacts.ComponentMetadataContext | ||
import org.gradle.api.artifacts.ComponentMetadataRule | ||
|
||
/** | ||
* Extend the Parent POM 'httpcomponents-client' with constraints so that it can be used as platform | ||
* to align the versions of all 'org.apache.httpcomponents' components. | ||
* | ||
* See: | ||
* https://repo1.maven.org/maven2/org/apache/httpcomponents/httpcomponents-client/4.5.13/httpcomponents-client-4.5.13.pom | ||
* | ||
* <modules> | ||
* <module>httpclient</module> | ||
* <module>httpmime</module> | ||
* <module>fluent-hc</module> | ||
* <module>httpclient-cache</module> | ||
* <module>httpclient-win</module> | ||
* <module>httpclient-osgi</module> | ||
* </modules> | ||
*/ | ||
@CacheableRule | ||
abstract class HttpComponentsPlatformRule : ComponentMetadataRule { | ||
companion object { | ||
const val HTTP_COMPONENTS_CLIENT = "org.apache.httpcomponents:httpcomponents-client" | ||
} | ||
|
||
override fun execute(context: ComponentMetadataContext) { | ||
val version = context.details.id.version | ||
context.details.allVariants { | ||
withDependencyConstraints { | ||
add("org.apache.httpcomponents:httpclient:$version") | ||
add("org.apache.httpcomponents:httpmime:$version") | ||
add("org.apache.httpcomponents:fluent-hc:$version") | ||
add("org.apache.httpcomponents:httpclient-cache:$version") | ||
add("org.apache.httpcomponents:httpclient-win:$version") | ||
add("org.apache.httpcomponents:httpclient-osgi:$version") | ||
} | ||
} | ||
} | ||
} |
23 changes: 23 additions & 0 deletions
23
...ins/src/main/kotlin/org/example/metadatarules/versionalignment/ParentPomAsPlatformRule.kt
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,23 @@ | ||
package org.example.metadatarules.versionalignment | ||
|
||
import org.gradle.api.artifacts.CacheableRule | ||
import org.gradle.api.artifacts.ComponentMetadataContext | ||
import org.gradle.api.artifacts.ComponentMetadataRule | ||
|
||
/** | ||
* Sometime libraries consisting of multiple components do not offer a BOM but have | ||
* a 'Parent POM' that contains the information for alignment. | ||
* However, these often also contain constraints on other components that we do not | ||
* want to include. This Rule removes these additional constraints. | ||
*/ | ||
@CacheableRule | ||
abstract class ParentPomAsPlatformRule : ComponentMetadataRule { | ||
override fun execute(context: ComponentMetadataContext) { | ||
val group = context.details.id.group | ||
context.details.allVariants { | ||
withDependencyConstraints { | ||
removeAll { it.group != group } | ||
} | ||
} | ||
} | ||
} |
30 changes: 30 additions & 0 deletions
30
...les-plugins/src/main/kotlin/org/example/metadatarules/versionalignment/PoiPlatformRule.kt
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,30 @@ | ||
package org.example.metadatarules.versionalignment | ||
|
||
import org.gradle.api.artifacts.CacheableRule | ||
import org.gradle.api.artifacts.ComponentMetadataContext | ||
import org.gradle.api.artifacts.ComponentMetadataRule | ||
|
||
/** | ||
* Extend the central 'poi' component with constraints so that it can be used as platform | ||
* to align the versions of all 'org.apache.poi' components. | ||
* | ||
* See: | ||
* https://repo1.maven.org/maven2/org/apache/poi/poi/5.2.0/poi-5.2.0.pom | ||
*/ | ||
@CacheableRule | ||
abstract class PoiPlatformRule : ComponentMetadataRule { | ||
companion object { | ||
const val POI_COMMON = "org.apache.poi:poi" | ||
} | ||
|
||
override fun execute(context: ComponentMetadataContext) { | ||
val version = context.details.id.version | ||
context.details.allVariants { | ||
withDependencyConstraints { | ||
add("org.apache.poi:poi-excelant:$version") | ||
add("org.apache.poi:poi-ooxml:$version") | ||
add("org.apache.poi:poi-scratchpad:$version") | ||
} | ||
} | ||
} | ||
} |
40 changes: 40 additions & 0 deletions
40
...s-plugins/src/main/kotlin/org/example/metadatarules/versionalignment/Slf4jPlatformRule.kt
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,40 @@ | ||
package org.example.metadatarules.versionalignment | ||
|
||
import org.gradle.api.artifacts.CacheableRule | ||
import org.gradle.api.artifacts.ComponentMetadataContext | ||
import org.gradle.api.artifacts.ComponentMetadataRule | ||
|
||
/** | ||
* Extend the Parent POM 'slf4j-parent' with constraints so that it can be used as platform | ||
* to align the versions of all 'org.slf4j' components. | ||
* | ||
* See: | ||
* https://repo1.maven.org/maven2/org/slf4j/slf4j-parent/1.7.36/slf4j-parent-1.7.36.pom | ||
*/ | ||
@CacheableRule | ||
abstract class Slf4jPlatformRule : ComponentMetadataRule { | ||
companion object { | ||
const val SLF4J_PARENT = "org.slf4j:slf4j-parent" | ||
} | ||
|
||
override fun execute(context: ComponentMetadataContext) { | ||
val version = context.details.id.version | ||
context.details.allVariants { | ||
withDependencyConstraints { | ||
add("org.slf4j:slf4j-api:$version") | ||
add("org.slf4j:slf4j-simple:$version") | ||
add("org.slf4j:slf4j-nop:$version") | ||
add("org.slf4j:slf4j-jdk14:$version") | ||
add("org.slf4j:slf4j-log4j12:$version") | ||
add("org.slf4j:slf4j-reload4j:$version") | ||
add("org.slf4j:slf4j-jcl:$version") | ||
add("org.slf4j:slf4j-android:$version") | ||
add("org.slf4j:slf4j-ext:$version") | ||
add("org.slf4j:jcl-over-slf4j:$version") | ||
add("org.slf4j:log4j-over-slf4j:$version") | ||
add("org.slf4j:jul-to-slf4j:$version") | ||
add("org.slf4j:osgi-over-slf4j:$version") | ||
} | ||
} | ||
} | ||
} |
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,3 +1,8 @@ | ||
plugins { | ||
id("java-platform") | ||
} | ||
|
||
dependencies.constraints { | ||
api("dev.jacomet.gradle.plugins:logging-capabilities:0.11.1") | ||
api("org.gradlex:java-ecosystem-capabilities:1.3.1") | ||
} |