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
8 changed files
with
91 additions
and
2 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 | Original file line | Diff line number | Diff line change |
---|---|---|---|
@@ -0,0 +1,8 @@ | |||
apply plugin: 'maven-bom' | |||
apply from: "$rootDir/gradle/maven-deployment.gradle" | |||
|
|||
generatePom.enabled = false | |||
|
|||
mavenBom { | |||
projects = coreModuleProjects | |||
} |
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 | Original file line | Diff line number | Diff line change |
---|---|---|---|
@@ -0,0 +1,19 @@ | |||
import org.gradle.api.DefaultTask | |||
import org.gradle.api.GradleException | |||
import org.gradle.api.Plugin | |||
import org.gradle.api.Project | |||
import org.gradle.api.Task | |||
import org.gradle.api.plugins.* | |||
import org.gradle.api.tasks.* | |||
import org.gradle.api.tasks.TaskAction | |||
|
|||
public class MavenBomPlugin implements Plugin<Project> { | |||
static String MAVEN_BOM_TASK_NAME = "mavenBom" | |||
|
|||
public void apply(Project project) { | |||
project.plugins.apply(JavaPlugin) | |||
project.plugins.apply(MavenPlugin) | |||
project.task(MAVEN_BOM_TASK_NAME, type: MavenBomTask, group: 'Generate', description: 'Configures the pom as a Maven Build of Materials (BOM)') | |||
project.install.dependsOn project.mavenBom | |||
} | |||
} |
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 | Original file line | Diff line number | Diff line change |
---|---|---|---|
@@ -0,0 +1,55 @@ | |||
import groovy.xml.MarkupBuilder | |||
|
|||
import org.gradle.api.DefaultTask | |||
import org.gradle.api.Project | |||
import org.gradle.api.tasks.* | |||
|
|||
public class MavenBomTask extends DefaultTask { | |||
|
|||
Set<Project> projects | |||
|
|||
File bomFile | |||
|
|||
|
|||
public MavenBomTask() { | |||
this.group = "Generate" | |||
this.description = "Generates a Maven Build of Materials (BOM). See http://maven.apache.org/guides/introduction/introduction-to-dependency-mechanism.html#Importing_Dependencies" | |||
this.projects = project.subprojects | |||
this.bomFile = project.file("${->project.buildDir}/maven-bom/${->project.name}-${->project.version}.txt") | |||
} | |||
|
|||
@TaskAction | |||
public void configureBom() { | |||
project.configurations.archives.artifacts.clear() | |||
|
|||
bomFile.parentFile.mkdirs() | |||
bomFile.write("Maven Build of Materials (BOM). See http://maven.apache.org/guides/introduction/introduction-to-dependency-mechanism.html#Importing_Dependencies") | |||
project.artifacts { | |||
// work around GRADLE-2406 by attaching text artifact | |||
archives(bomFile) | |||
} | |||
project.install { | |||
repositories.mavenInstaller { | |||
pom.whenConfigured { | |||
packaging = "pom" | |||
withXml { | |||
asNode().children().last() + { | |||
delegate.dependencyManagement { | |||
delegate.dependencies { | |||
projects.sort { dep -> "$dep.group:$dep.name" }.each { p -> | |||
|
|||
delegate.dependency { | |||
delegate.groupId(p.group) | |||
delegate.artifactId(p.name) | |||
delegate.version(p.version) | |||
} | |||
} | |||
} | |||
} | |||
} | |||
} | |||
} | |||
} | |||
} | |||
} | |||
} |
1 change: 1 addition & 0 deletions
1
buildSrc/src/main/resources/META-INF/gradle-plugins/maven-bom.properties
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 | Original file line | Diff line number | Diff line change |
---|---|---|---|
@@ -0,0 +1 @@ | |||
implementation-class=MavenBomPlugin |
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
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