Skip to content

Commit 0f14879

Browse files
authored
feat: set pom information defaults (#151)
* feat: centralize pom information * PR remarks
1 parent 83ad790 commit 0f14879

File tree

4 files changed

+41
-27
lines changed

4 files changed

+41
-27
lines changed

build.gradle.kts

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,8 @@ plugins {
1010

1111
val group: String by project
1212
val annotationProcessorVersion: String by project
13+
val edcScmUrl: String by project
14+
val edcScmConnection: String by project
1315

1416
allprojects {
1517
apply(plugin = "${group}.edc-build")
@@ -24,6 +26,13 @@ allprojects {
2426
apply(plugin = "com.gradle.plugin-publish")
2527
}
2628

29+
configure<org.eclipse.edc.plugins.edcbuild.extensions.BuildExtension> {
30+
pom {
31+
scmUrl.set(edcScmUrl)
32+
scmConnection.set(edcScmConnection)
33+
}
34+
}
35+
2736
tasks.withType<Test> {
2837
useJUnitPlatform()
2938
testLogging {

gradle.properties

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,7 @@
11
group=org.eclipse.edc
22
version=0.0.1-SNAPSHOT
33

4+
edcScmUrl=https://github.com/eclipse-edc/GradlePlugins
5+
edcScmConnection=scm:git:[email protected]:eclipse-edc/GradlePlugins.git
6+
47
annotationProcessorVersion=0.0.1-SNAPSHOT

plugins/edc-build/src/main/java/org/eclipse/edc/plugins/edcbuild/conventions/MavenArtifactConvention.java

Lines changed: 28 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright (c) 2022 Microsoft Corporation
2+
* Copyright (c) 2022 - 2023 Microsoft Corporation
33
*
44
* This program and the accompanying materials are made available under the
55
* terms of the Apache License, Version 2.0 which is available at
@@ -9,6 +9,7 @@
99
*
1010
* Contributors:
1111
* Microsoft Corporation - initial API and implementation
12+
* Bayerische Motoren Werke Aktiengesellschaft (BMW AG)
1213
*
1314
*/
1415

@@ -21,6 +22,7 @@
2122
import org.gradle.api.Project;
2223
import org.gradle.api.artifacts.ConfigurablePublishArtifact;
2324
import org.gradle.api.publish.PublishingExtension;
25+
import org.gradle.api.publish.maven.MavenPom;
2426
import org.gradle.api.publish.maven.MavenPublication;
2527

2628
import java.nio.file.Path;
@@ -35,6 +37,9 @@
3537
* </ul>
3638
*/
3739
class MavenArtifactConvention implements EdcConvention {
40+
41+
private static final String PROJECT_URL = "https://projects.eclipse.org/projects/technology.edc";
42+
3843
@Override
3944
public void apply(Project target) {
4045
target.afterEvaluate(project -> {
@@ -44,7 +49,7 @@ public void apply(Project target) {
4449
pubExt.getPublications().stream()
4550
.filter(p -> p instanceof MavenPublication)
4651
.map(p -> (MavenPublication) p)
47-
.peek(mavenPub -> addPomInformation(pomExt, mavenPub))
52+
.peek(mavenPub -> mavenPub.pom(pom -> setPomInformation(pomExt, target, pom)))
4853
.forEach(mavenPub -> addManifestArtifact(target, mavenPub));
4954
});
5055
}
@@ -68,29 +73,30 @@ private void addManifestArtifact(Project target, MavenPublication mavenPub) {
6873
}
6974
}
7075

71-
private void addPomInformation(MavenPomExtension pomExt, MavenPublication mavenPub) {
72-
mavenPub.pom(pom -> {
73-
// these properties are mandatory!
74-
pom.getName().set(pomExt.getProjectName());
75-
pom.getDescription().set(pomExt.getDescription());
76-
pom.getUrl().set(pomExt.getProjectUrl());
76+
private static void setPomInformation(MavenPomExtension pomExt, Project project, MavenPom pom) {
77+
// these properties are mandatory!
78+
var projectName = pomExt.getProjectName().getOrElse(project.getName());
79+
var description = pomExt.getDescription().getOrElse("edc :: " + project.getName());
80+
var projectUrl = pomExt.getProjectUrl().getOrElse(PROJECT_URL);
81+
pom.getName().set(projectName);
82+
pom.getDescription().set(description);
83+
pom.getUrl().set(projectUrl);
7784

78-
// we'll provide a sane default for these properties
79-
pom.licenses(l -> l.license(pl -> {
80-
pl.getName().set(pomExt.getLicenseName().getOrElse("The Apache License, Version 2.0"));
81-
pl.getUrl().set(pomExt.getLicenseUrl().getOrElse("http://www.apache.org/licenses/LICENSE-2.0.txt"));
82-
}));
85+
// we'll provide a sane default for these properties
86+
pom.licenses(l -> l.license(pl -> {
87+
pl.getName().set(pomExt.getLicenseName().getOrElse("The Apache License, Version 2.0"));
88+
pl.getUrl().set(pomExt.getLicenseUrl().getOrElse("http://www.apache.org/licenses/LICENSE-2.0.txt"));
89+
}));
8390

84-
pom.developers(d -> d.developer(md -> {
85-
md.getId().set(pomExt.getDeveloperId().getOrElse("mspiekermann"));
86-
md.getName().set(pomExt.getDeveloperName().getOrElse("Markus Spiekermann"));
87-
md.getEmail().set(pomExt.getDeveloperEmail().getOrElse("[email protected]"));
88-
}));
91+
pom.developers(d -> d.developer(md -> {
92+
md.getId().set(pomExt.getDeveloperId().getOrElse("mspiekermann"));
93+
md.getName().set(pomExt.getDeveloperName().getOrElse("Markus Spiekermann"));
94+
md.getEmail().set(pomExt.getDeveloperEmail().getOrElse("[email protected]"));
95+
}));
8996

90-
pom.scm(scm -> {
91-
scm.getUrl().set(pomExt.getScmUrl());
92-
scm.getConnection().set(pomExt.getScmConnection());
93-
});
97+
pom.scm(scm -> {
98+
scm.getUrl().set(pomExt.getScmUrl());
99+
scm.getConnection().set(pomExt.getScmConnection());
94100
});
95101
}
96102

plugins/edc-build/src/main/java/org/eclipse/edc/plugins/edcbuild/extensions/MavenPomExtension.java

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@
1717
import org.gradle.api.provider.Property;
1818

1919
public abstract class MavenPomExtension {
20-
private String groupId = "org.eclipse.edc";
20+
private final String groupId = "org.eclipse.edc";
2121

2222
public abstract Property<String> getProjectName();
2323

@@ -43,8 +43,4 @@ public String getGroupId() {
4343
return groupId;
4444
}
4545

46-
public void setGroupId(String groupId) {
47-
this.groupId = groupId;
48-
}
49-
5046
}

0 commit comments

Comments
 (0)