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
99 *
1010 * Contributors:
1111 * Microsoft Corporation - initial API and implementation
12+ * Bayerische Motoren Werke Aktiengesellschaft (BMW AG)
1213 *
1314 */
1415
2122import org .gradle .api .Project ;
2223import org .gradle .api .artifacts .ConfigurablePublishArtifact ;
2324import org .gradle .api .publish .PublishingExtension ;
25+ import org .gradle .api .publish .maven .MavenPom ;
2426import org .gradle .api .publish .maven .MavenPublication ;
2527
2628import java .nio .file .Path ;
3537 * </ul>
3638 */
3739class 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
0 commit comments