-
Notifications
You must be signed in to change notification settings - Fork 40.6k
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
1 changed file
with
22 additions
and
7 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 |
---|---|---|
|
@@ -31,6 +31,11 @@ | |
import org.gradle.api.publish.maven.MavenPomScm; | ||
import org.gradle.api.publish.maven.MavenPublication; | ||
import org.gradle.api.publish.maven.plugins.MavenPublishPlugin; | ||
import org.slf4j.Logger; | ||
import org.slf4j.LoggerFactory; | ||
|
||
import org.springframework.boot.build.properties.BuildProperties; | ||
import org.springframework.boot.build.properties.BuildType; | ||
|
||
/** | ||
* Conventions that are applied in the presence of the {@link MavenPublishPlugin}. When | ||
|
@@ -56,6 +61,8 @@ | |
*/ | ||
class MavenPublishingConventions { | ||
|
||
private static final Logger logger = LoggerFactory.getLogger(MavenPublishingConventions.class); | ||
|
||
void apply(Project project) { | ||
project.getPlugins().withType(MavenPublishPlugin.class).all((mavenPublish) -> { | ||
PublishingExtension publishing = project.getExtensions().getByType(PublishingExtension.class); | ||
|
@@ -93,9 +100,7 @@ private void customizePom(MavenPom pom, Project project) { | |
pom.licenses(this::customizeLicences); | ||
pom.developers(this::customizeDevelopers); | ||
pom.scm((scm) -> customizeScm(scm, project)); | ||
if (!isUserInherited(project)) { | ||
pom.issueManagement(this::customizeIssueManagement); | ||
} | ||
pom.issueManagement((issueManagement) -> customizeIssueManagement(issueManagement, project)); | ||
} | ||
|
||
private void customizeJavaMavenPublication(MavenPublication publication, Project project) { | ||
|
@@ -127,16 +132,26 @@ private void customizeDevelopers(MavenPomDeveloperSpec developers) { | |
} | ||
|
||
private void customizeScm(MavenPomScm scm, Project project) { | ||
if (BuildProperties.get(project).buildType() != BuildType.OPEN_SOURCE) { | ||
logger.debug("Skipping Maven POM SCM for non open source build type"); | ||
return; | ||
} | ||
scm.getUrl().set("https://github.com/spring-projects/spring-boot"); | ||
if (!isUserInherited(project)) { | ||
scm.getConnection().set("scm:git:git://github.com/spring-projects/spring-boot.git"); | ||
scm.getDeveloperConnection().set("scm:git:ssh://[email protected]/spring-projects/spring-boot.git"); | ||
} | ||
scm.getUrl().set("https://github.com/spring-projects/spring-boot"); | ||
} | ||
|
||
private void customizeIssueManagement(MavenPomIssueManagement issueManagement) { | ||
issueManagement.getSystem().set("GitHub"); | ||
issueManagement.getUrl().set("https://github.com/spring-projects/spring-boot/issues"); | ||
private void customizeIssueManagement(MavenPomIssueManagement issueManagement, Project project) { | ||
if (BuildProperties.get(project).buildType() != BuildType.OPEN_SOURCE) { | ||
logger.debug("Skipping Maven POM SCM for non open source build type"); | ||
return; | ||
} | ||
if (!isUserInherited(project)) { | ||
issueManagement.getSystem().set("GitHub"); | ||
issueManagement.getUrl().set("https://github.com/spring-projects/spring-boot/issues"); | ||
} | ||
} | ||
|
||
private boolean isUserInherited(Project project) { | ||
|