Last active
February 14, 2022 09:37
-
-
Save aalmiray/037412256648f8711afa51a622e7f855 to your computer and use it in GitHub Desktop.
Example project showcasing the Gradle SuperPOM concept
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
plugins { | |
id 'java' | |
id 'com.acme.gradle.superpom' version '1.0.0' | |
} | |
group = 'com.acme.gradle' | |
version = '1.0.0-SNAPSHOT' | |
config { | |
info { | |
name = 'myproject' | |
description = 'My Project' | |
inceptionYear = '2018' | |
people { | |
person { | |
id = 'aalmiray' | |
name = 'Andres Almiray' | |
roles = ['developer'] | |
} | |
} | |
links { | |
scm = 'http://com.acme/git/myproject.git' | |
} | |
} | |
} |
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
<?xml version="1.0" encoding="UTF-8"?> | |
<project xmlns="http://maven.apache.org/POM/4.0.0" | |
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" | |
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> | |
<modelVersion>4.0.0</modelVersion> | |
<groupId>com.acme.gradle</groupId> | |
<artifactId>myproject</artifactId> | |
<version>1.0.0-SNAPSHOT</version> | |
<repositories> | |
<repository> | |
<snapshots> | |
<enabled>false</enabled> | |
</snapshots> | |
<id>central</id> | |
<name>Central Repository</name> | |
<url>https://repo.maven.apache.org/maven2</url> | |
</repository> | |
</repositories> | |
<pluginRepositories> | |
<pluginRepository> | |
<releases> | |
<updatePolicy>never</updatePolicy> | |
</releases> | |
<snapshots> | |
<enabled>false</enabled> | |
</snapshots> | |
<id>central</id> | |
<name>Central Repository</name> | |
<url>https://repo.maven.apache.org/maven2</url> | |
</pluginRepository> | |
</pluginRepositories> | |
<build> | |
<sourceDirectory>/tmp/myproject/src/main/java</sourceDirectory> | |
<scriptSourceDirectory>/tmp/myproject/src/main/scripts</scriptSourceDirectory> | |
<testSourceDirectory>/tmp/myproject/src/test/java</testSourceDirectory> | |
<outputDirectory>/tmp/myproject/target/classes</outputDirectory> | |
<testOutputDirectory>/tmp/myproject/target/test-classes</testOutputDirectory> | |
<resources> | |
<resource> | |
<directory>/tmp/myproject/src/main/resources</directory> | |
</resource> | |
</resources> | |
<testResources> | |
<testResource> | |
<directory>/tmp/myproject/src/test/resources</directory> | |
</testResource> | |
</testResources> | |
<directory>/tmp/myproject/target</directory> | |
<finalName>myproject-1.0.0-SNAPSHOT</finalName> | |
<pluginManagement> | |
<plugins> | |
<plugin> | |
<artifactId>maven-antrun-plugin</artifactId> | |
<version>1.3</version> | |
</plugin> | |
<plugin> | |
<artifactId>maven-assembly-plugin</artifactId> | |
<version>2.2-beta-5</version> | |
</plugin> | |
<plugin> | |
<artifactId>maven-dependency-plugin</artifactId> | |
<version>2.8</version> | |
</plugin> | |
<plugin> | |
<artifactId>maven-release-plugin</artifactId> | |
<version>2.5.3</version> | |
</plugin> | |
</plugins> | |
</pluginManagement> | |
<plugins> | |
<plugin> | |
<artifactId>maven-clean-plugin</artifactId> | |
<version>2.5</version> | |
<executions> | |
<execution> | |
<id>default-clean</id> | |
<phase>clean</phase> | |
<goals> | |
<goal>clean</goal> | |
</goals> | |
</execution> | |
</executions> | |
</plugin> | |
<plugin> | |
<artifactId>maven-resources-plugin</artifactId> | |
<version>2.6</version> | |
<executions> | |
<execution> | |
<id>default-testResources</id> | |
<phase>process-test-resources</phase> | |
<goals> | |
<goal>testResources</goal> | |
</goals> | |
</execution> | |
<execution> | |
<id>default-resources</id> | |
<phase>process-resources</phase> | |
<goals> | |
<goal>resources</goal> | |
</goals> | |
</execution> | |
</executions> | |
</plugin> | |
<plugin> | |
<artifactId>maven-jar-plugin</artifactId> | |
<version>2.4</version> | |
<executions> | |
<execution> | |
<id>default-jar</id> | |
<phase>package</phase> | |
<goals> | |
<goal>jar</goal> | |
</goals> | |
</execution> | |
</executions> | |
</plugin> | |
<plugin> | |
<artifactId>maven-compiler-plugin</artifactId> | |
<version>3.1</version> | |
<executions> | |
<execution> | |
<id>default-compile</id> | |
<phase>compile</phase> | |
<goals> | |
<goal>compile</goal> | |
</goals> | |
</execution> | |
<execution> | |
<id>default-testCompile</id> | |
<phase>test-compile</phase> | |
<goals> | |
<goal>testCompile</goal> | |
</goals> | |
</execution> | |
</executions> | |
</plugin> | |
<plugin> | |
<artifactId>maven-surefire-plugin</artifactId> | |
<version>2.12.4</version> | |
<executions> | |
<execution> | |
<id>default-test</id> | |
<phase>test</phase> | |
<goals> | |
<goal>test</goal> | |
</goals> | |
</execution> | |
</executions> | |
</plugin> | |
<plugin> | |
<artifactId>maven-install-plugin</artifactId> | |
<version>2.4</version> | |
<executions> | |
<execution> | |
<id>default-install</id> | |
<phase>install</phase> | |
<goals> | |
<goal>install</goal> | |
</goals> | |
</execution> | |
</executions> | |
</plugin> | |
<plugin> | |
<artifactId>maven-deploy-plugin</artifactId> | |
<version>2.7</version> | |
<executions> | |
<execution> | |
<id>default-deploy</id> | |
<phase>deploy</phase> | |
<goals> | |
<goal>deploy</goal> | |
</goals> | |
</execution> | |
</executions> | |
</plugin> | |
<plugin> | |
<artifactId>maven-site-plugin</artifactId> | |
<version>3.3</version> | |
<executions> | |
<execution> | |
<id>default-site</id> | |
<phase>site</phase> | |
<goals> | |
<goal>site</goal> | |
</goals> | |
<configuration> | |
<outputDirectory>/tmp/myproject/target/site</outputDirectory> | |
<reportPlugins> | |
<reportPlugin> | |
<groupId>org.apache.maven.plugins</groupId> | |
<artifactId>maven-project-info-reports-plugin</artifactId> | |
</reportPlugin> | |
</reportPlugins> | |
</configuration> | |
</execution> | |
<execution> | |
<id>default-deploy</id> | |
<phase>site-deploy</phase> | |
<goals> | |
<goal>deploy</goal> | |
</goals> | |
<configuration> | |
<outputDirectory>/tmp/myproject/target/site</outputDirectory> | |
<reportPlugins> | |
<reportPlugin> | |
<groupId>org.apache.maven.plugins</groupId> | |
<artifactId>maven-project-info-reports-plugin</artifactId> | |
</reportPlugin> | |
</reportPlugins> | |
</configuration> | |
</execution> | |
</executions> | |
<configuration> | |
<outputDirectory>/tmp/myproject/target/site</outputDirectory> | |
<reportPlugins> | |
<reportPlugin> | |
<groupId>org.apache.maven.plugins</groupId> | |
<artifactId>maven-project-info-reports-plugin</artifactId> | |
</reportPlugin> | |
</reportPlugins> | |
</configuration> | |
</plugin> | |
</plugins> | |
</build> | |
<reporting> | |
<outputDirectory>/tmp/myproject/target/site</outputDirectory> | |
</reporting> | |
</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
$ gradle effectiveSettings --sections=info,bintray | |
> Task :effectiveSettings | |
info: | |
name: myproject | |
description: My Project | |
url: http://acme.com | |
inceptionYear: 2018 | |
copyrightYear: 2018 | |
vendor: Acme | |
authors: | |
Keyser Soze | |
organization: | |
people: | |
admin: | |
id: admin | |
name: Keyser Soze | |
roles: | |
admin | |
aalmiray: | |
id: aalmiray | |
name: Andres Almiray | |
roles: | |
developer | |
links: | |
website: http://acme.com | |
issueTracker: http://acme.com/issues | |
scm: http://com.acme/git/myproject.git | |
specification: | |
enabled: false | |
title: myproject | |
version: 1.0.0-SNAPSHOT | |
vendor: Acme | |
implementation: | |
enabled: true | |
title: myproject | |
version: 1.0.0-SNAPSHOT | |
vendor: Acme | |
bintray: | |
enabled: false |
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
<?xml version="1.0" encoding="UTF-8"?> | |
<project xmlns='http://maven.apache.org/POM/4.0.0' | |
xsi:schemaLocation='http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd' | |
xmlns:xsi='http://www.w3.org/2001/XMLSchema-instance'> | |
<modelVersion>4.0.0</modelVersion> | |
<groupId>com.acme.gradle</groupId> | |
<artifactId>myproject</artifactId> | |
<version>1.0.0-SNAPSHOT</version> | |
</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
pluginManagement { | |
repositories { | |
jcenter() | |
maven { url 'https://plugins.gradle.org/m2/' } | |
mavenLocal() | |
} | |
} |
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
buildscript { | |
repositories { | |
jcenter() | |
maven { url 'https://plugins.gradle.org/m2/' } | |
} | |
dependencies { | |
classpath 'org.kordamp.gradle:project-gradle-plugin:0.8.0' | |
} | |
} | |
apply plugin: 'groovy' | |
apply plugin: 'java-gradle-plugin' | |
apply plugin: 'org.kordamp.gradle.project' | |
group = 'com.acme.gradle' | |
version = '1.0.0' | |
config { | |
release = (rootProject.findProperty('release') ?: false).toBoolean() | |
info { | |
name = 'superpom-plugin' | |
vendor = 'Acme' | |
description = 'Company wide super POM' | |
inceptionYear = '2018' | |
links { | |
website = 'http://acme.com' | |
} | |
specification { enabled = false } | |
implementation { enabled = false } | |
people { | |
person { | |
id = 'aalmiray' | |
name = 'Andres Almiray' | |
roles = ['developer'] | |
} | |
} | |
} | |
groovydoc { | |
replaceJavadoc = true | |
options { | |
link 'https://docs.gradle.org/4.0/javadoc/', 'org.gradle.' | |
} | |
} | |
license { | |
licenses { | |
license { | |
id = 'Apache-2.0' | |
} | |
} | |
} | |
bintray { enabled = false } | |
} | |
repositories { | |
jcenter() | |
maven { url 'https://plugins.gradle.org/m2/' } | |
} | |
dependencies { | |
compile gradleApi() | |
compile 'org.kordamp.gradle:project-gradle-plugin:0.8.0' | |
} | |
gradlePlugin { | |
plugins { | |
superpomPlugin { | |
id = 'com.acme.gradle.superpom' | |
implementationClass = 'com.acme.gradle.SuperpomPlugin' | |
} | |
} | |
} |
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
package com.acme.gradle | |
import org.gradle.api.Plugin | |
import org.gradle.api.Project | |
import org.kordamp.gradle.plugin.project.ProjectPlugin | |
import org.kordamp.gradle.plugin.base.ProjectConfigurationExtension | |
class SuperpomPlugin implements Plugin<Project> { | |
void apply(Project project) { | |
project.plugins.apply(ProjectPlugin) | |
project.extensions.findByType(ProjectConfigurationExtension).with { | |
release = (project.rootProject.findProperty('release') ?: false).toBoolean() | |
info { | |
vendor = 'Acme' | |
links { | |
website = 'http://acme.com' | |
issueTracker = 'http://acme.com/issues' | |
} | |
specification { enabled = false } | |
people { | |
person { | |
id = 'admin' | |
name = 'Keyser Soze' | |
roles = ['admin'] | |
} | |
} | |
} | |
license { | |
licenses { | |
license { | |
id = 'Apache-2.0' | |
} | |
} | |
} | |
bintray { | |
enabled = false | |
} | |
} | |
project.allprojects { | |
repositories { | |
mavenCentral() | |
mavenLocal() | |
} | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment