Skip to content

Commit

Permalink
switch maven project list to :artifactId from modulePath (#557)
Browse files Browse the repository at this point in the history
switch to `artifactId` so we do not need to rely on metadata in the pom that could be incorrect (jenkinsci/maven-hpi-plugin#497)

---------

Co-authored-by: James Nord <[email protected]>
  • Loading branch information
ampuscas and jtnord authored Jun 6, 2023
1 parent 9d7ff9c commit d185358
Show file tree
Hide file tree
Showing 9 changed files with 11 additions and 79 deletions.

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ public Plugin extractMetadata(String pluginId, Manifest manifest, Model model) t
.withGitHash(model.getScm().getTag())
.withTag(model.getScm().getTag())
// Any multi-module projects have already been handled by now or require new hooks
.withModule(null)
.withModule(":" + model.getArtifactId())
.withVersion(model.getVersion())
.build();
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@ private Plugin getPlugin(String module) throws PomExecutionException {
if ("hpi".equals(packaging)) {
String pluginId = expressionEvaluator.evaluateString("project.artifactId");
String version = expressionEvaluator.evaluateString("project.version");
return toPlugin(pluginId, version, localCheckoutDir, module);
return toPlugin(pluginId, version, localCheckoutDir, ":" + pluginId);
}
return null;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -45,14 +45,13 @@ public Plugin extractMetadata(String pluginId, Manifest manifest, Model model) t
if (gitHash == null) {
gitHash = mainAttributes.getValue(PLUGIN_GIT_HASH);
}

return new Plugin.Builder()
.withPluginId(mainAttributes.getValue(PLUGIN_ID))
.withName(mainAttributes.getValue(PLUGIN_NAME))
.withScmConnection(mainAttributes.getValue(PLUGIN_SCM_CONNECTION))
.withTag(mainAttributes.getValue(PLUGIN_SCM_TAG))
.withGitHash(gitHash)
.withModule(mainAttributes.getValue(PLUGIN_MODULE))
.withModule(":" + mainAttributes.getValue(PLUGIN_ID))
.withVersion(mainAttributes.getValue(PLUGIN_VERSION))
.build();
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ public class Plugin {
@CheckForNull
private final String tag;

@CheckForNull
@NonNull
private final String module;

@CheckForNull
Expand All @@ -35,7 +35,7 @@ private Plugin(Builder builder) {
this.version = Objects.requireNonNull(builder.version, "version may not be null");
this.gitUrl = Objects.requireNonNull(builder.gitUrl, "gitUrl may not be null");
this.tag = builder.tag;
this.module = builder.module;
this.module = Objects.requireNonNull(builder.module, "module may not be null");
this.gitHash = builder.gitHash;
this.name = builder.name;
}
Expand Down Expand Up @@ -82,9 +82,9 @@ public String getGitHash() {
}

/**
* The module name for this plugin; will be {@code null} if the plugin is not part of a multi-module build.
* The module name for this plugin; the module will always have a name, whether it is part of a multi-module build or not.
*/
@CheckForNull
@NonNull
public String getModule() {
return module;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ void testCheckMethod() {
.withGitUrl("ignored")
.withVersion("ignored")
.withPluginId("jacoco")
.withModule(":jacoco")
.build();

BeforeExecutionContext context = new BeforeExecutionContext(null, plugin, null, null, null);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ void testCheckMethod() {
.withGitUrl("ignored")
.withVersion("ignored")
.withPluginId("warnings-ng")
.withModule(":warnings-ng")
.build();

BeforeExecutionContext context = new BeforeExecutionContext(null, plugin, null, null, null);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ void extractModernMetadata() throws Exception {
allOf(
hasProperty("pluginId", is("aws-java-sdk-ec2")),
hasProperty("gitUrl", is("https://github.com/jenkinsci/aws-java-sdk-plugin.git")),
hasProperty("module", is("aws-java-sdk-ec2")),
hasProperty("module", is(":aws-java-sdk-ec2")),
hasProperty("gitHash", is("938ad577f750694635f3c0160ac2110db5d6eb98")),
hasProperty("name", is("Amazon Web Services SDK :: EC2")),
hasProperty("version", startsWith("1.12.406-373.v59d2b_d41281b_"))));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@
import static org.hamcrest.Matchers.hasProperty;
import static org.hamcrest.Matchers.hasSize;
import static org.hamcrest.Matchers.is;
import static org.hamcrest.Matchers.nullValue;
import static org.hamcrest.Matchers.startsWith;
import static org.junit.jupiter.api.Assertions.assertThrows;

Expand Down Expand Up @@ -38,7 +37,7 @@ void testExtractPlugins() throws Exception {
allOf(
hasProperty("pluginId", is("text-finder")),
hasProperty("gitUrl", is("https://github.com/jenkinsci/text-finder-plugin.git")),
hasProperty("module", nullValue()), // not a multi-module project
hasProperty("module", is(":text-finder")), // regardless if it is a multi-module or not
hasProperty("tag", startsWith("text-finder-1.")),
hasProperty("name", is("Text Finder")),
hasProperty("version", startsWith("1."))));
Expand Down

0 comments on commit d185358

Please sign in to comment.