Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Native support for multi-module Maven projects #510

Merged
merged 89 commits into from
Apr 17, 2023
Merged
Show file tree
Hide file tree
Changes from 16 commits
Commits
Show all changes
89 commits
Select commit Hold shift + click to select a range
c799373
checkpoint - working list
jtnord Mar 24, 2023
6ca3dcc
move hooks package
jtnord Mar 24, 2023
c62874d
adding legacy metadata provider
jtnord Mar 27, 2023
80f93e6
lets start testing
jtnord Mar 31, 2023
b5e2bc0
incremental support
jtnord Mar 31, 2023
1b86c04
cloneUrl can not be null here
jtnord Mar 31, 2023
b1428fc
clenup and unit tests
jtnord Mar 31, 2023
8e534d1
introduce metadata extrator exception, use Sets not lists
jtnord Apr 3, 2023
7bf5887
fix filtering
jtnord Apr 3, 2023
0069388
we need to filter local sources too
jtnord Apr 4, 2023
770f356
remove leftover from previous work
jtnord Apr 4, 2023
c804b50
apply new formating styles
jtnord Apr 4, 2023
7efa72a
Merge commit '88778f2117cfaaa2c7b148763e6350e465d56887' into multimodule
jtnord Apr 4, 2023
12da61c
Merge remote-tracking branch 'origin/master' into multimodule
jtnord Apr 4, 2023
41fc368
restore some logging
jtnord Apr 4, 2023
fca517f
missed test in refactor
jtnord Apr 4, 2023
d4a1e74
fix comment typo
jtnord Apr 4, 2023
30a9905
attempt to fix javadoc errors on CI build
jtnord Apr 4, 2023
31a1199
whatever
jtnord Apr 6, 2023
b94c09d
Merge branch 'master' into whacha
basil Apr 11, 2023
cff94f0
Merge branch 'master' into whacha
basil Apr 11, 2023
91561a0
Merge branch 'master' into whacha
basil Apr 11, 2023
03d6fcf
Merge branch 'master' into whacha
basil Apr 11, 2023
74a1123
Fix merge
basil Apr 11, 2023
c7c77c3
Fix merge
basil Apr 11, 2023
3c52e7c
Merge branch 'master' into whacha
basil Apr 11, 2023
67e9ea6
Don't be like XMLHTTPRequest. Be like XmlHttpRequest.
basil Apr 11, 2023
cc6e194
War is defined as "a state of usually open and declared armed hostile
basil Apr 11, 2023
20193d3
Fix merge
basil Apr 11, 2023
9c49750
Fix spelling and capitalization
basil Apr 11, 2023
0512be9
Fix bug
basil Apr 11, 2023
ba6520b
Remove unnecessary options
basil Apr 11, 2023
b6a7a95
Don't be like XMLHTTPRequest. Be like XmlHttpRequest.
basil Apr 11, 2023
a88253b
Fix spelling
basil Apr 11, 2023
d9fc196
Merge branch 'master' into whacha
basil Apr 11, 2023
fd67010
Don't be like XMLHTTPRequest. Be like XmlHttpRequest.
basil Apr 11, 2023
23883fc
Spelling
basil Apr 11, 2023
3fda563
Capitalization of proper nouns
basil Apr 11, 2023
447a475
Typos
basil Apr 11, 2023
4cc5213
Fix spelling
basil Apr 11, 2023
a80c22c
Metadata is one word
basil Apr 11, 2023
6402c15
Multi-module is hyphenated
basil Apr 11, 2023
41750de
Spelling
basil Apr 11, 2023
12f1038
Spelling
basil Apr 11, 2023
bb9f8fa
Merge remote-tracking branch 'origin/master' into whacha
basil Apr 11, 2023
ed481bc
Spelling
basil Apr 11, 2023
bedc8e7
Merge remote-tracking branch 'origin/master' into whacha
basil Apr 11, 2023
68ccd99
Capitalization
basil Apr 11, 2023
1cc72c3
Capitalization
basil Apr 11, 2023
1e9bf5a
Copyediting
basil Apr 11, 2023
27f6525
Singular
basil Apr 11, 2023
57949fb
Simplify ModelReader
basil Apr 11, 2023
21bce62
Update src/main/java/org/jenkins/tools/test/PluginCompatTester.java
basil Apr 12, 2023
2576d23
Spotless
basil Apr 12, 2023
e66b2c1
Final version of https://github.com/jenkinsci/maven-hpi-plugin/pull/436
basil Apr 12, 2023
016bdd1
https://github.com/jenkinsci/maven-hpi-plugin/releases/tag/maven-hpi-…
basil Apr 12, 2023
8fad523
change output format for list plugins and add integration test
jtnord Apr 12, 2023
e7a9896
Simplify exception handling
basil Apr 12, 2023
150ae35
Cleanup
basil Apr 12, 2023
d3d93de
Better error handling
basil Apr 12, 2023
4e505fa
Remove unrelated changes
basil Apr 12, 2023
c87189c
Cleanup
basil Apr 12, 2023
1416900
minor
basil Apr 12, 2023
20bbac4
Cleanup
basil Apr 12, 2023
c56d074
Cleaner semantics
basil Apr 12, 2023
b723439
dedupe
basil Apr 12, 2023
2910e45
cleanup
basil Apr 12, 2023
e3fae9e
cleanup
basil Apr 12, 2023
5fc1454
Consistent naming
basil Apr 12, 2023
392efa8
Simplify/clean up
basil Apr 12, 2023
a15efcc
No more classes full of static methods
basil Apr 12, 2023
789d988
More cleanup
basil Apr 13, 2023
0f51458
cleanup
basil Apr 13, 2023
e310871
Rewrite local checkout plugin metadata extractor
basil Apr 13, 2023
5a770fe
Fix Javadoc
basil Apr 13, 2023
01632f2
Fix bug
basil Apr 13, 2023
74034dc
Merge remote-tracking branch 'origin/master' into whacha
basil Apr 13, 2023
7aaea9e
Merge branch 'master' into whacha
basil Apr 13, 2023
bc03821
Remove unnecessary differences from trunk
basil Apr 13, 2023
bc8839e
extract service loader to single class
jtnord Apr 13, 2023
4cb71e3
Pass around a shared service locator
jtnord Apr 13, 2023
ba5b973
Merge remote-tracking branch 'origin/master' into multimodule
jtnord Apr 13, 2023
cb6d308
Merge remote-tracking branch 'origin/master' into multimodule
jtnord Apr 13, 2023
61ac4d3
remove unused logger
jtnord Apr 13, 2023
17173a8
fix build
basil Apr 13, 2023
505510c
fix build
basil Apr 13, 2023
0328c2a
Support local checkout of plugin not in WAR
basil Apr 14, 2023
6378120
Fix another bug
basil Apr 14, 2023
63af22a
Clarify comment
basil Apr 14, 2023
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
37 changes: 35 additions & 2 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -256,14 +256,47 @@
<delete dir="${project.build.directory}/megawar/WEB-INF/detached-plugins" />
<delete file="${project.build.directory}/megawar/META-INF/JENKINS.RSA" />
<delete file="${project.build.directory}/megawar/META-INF/JENKINS.SF" />
<war destfile="${project.build.directory}/megawar.war">
<war destfile="${project.build.directory}/megawar.war" manifest="${project.build.directory}/megawar/META-INF/MANIFEST.MF">
basil marked this conversation as resolved.
Show resolved Hide resolved
<fileset dir="${project.build.directory}/megawar" />
</war>
</target>
</configuration>
</execution>
</executions>
</plugin>
<plugin>
basil marked this conversation as resolved.
Show resolved Hide resolved
<artifactId>maven-jar-plugin</artifactId>
<configuration>
<archive>
<manifest>
<addDefaultImplementationEntries>true</addDefaultImplementationEntries>
</manifest>
<manifestEntries>
<scmRevision>${buildNumber} ${buildIsTainted}</scmRevision>
</manifestEntries>
</archive>
</configuration>
</plugin>
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>buildnumber-maven-plugin</artifactId>
<version>3.0.0</version>
<configuration>
<doCheck>true</doCheck>
<doUpdate>false</doUpdate>
<failTheBuild>false</failTheBuild>
<getRevisionOnlyOnce>true</getRevisionOnlyOnce>
<shortRevisionLength>7</shortRevisionLength>
</configuration>
<executions>
<execution>
<goals>
<goal>create</goal>
</goals>
<phase>validate</phase>
</execution>
</executions>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-shade-plugin</artifactId>
Expand All @@ -278,7 +311,7 @@
<createDependencyReducedPom>false</createDependencyReducedPom>
<transformers>
<transformer implementation="org.apache.maven.plugins.shade.resource.ManifestResourceTransformer">
<mainClass>org.jenkins.tools.test.PluginCompatTesterCli</mainClass>
<mainClass>org.jenkins.tools.test.CLI</mainClass>
</transformer>
<transformer implementation="org.apache.maven.plugins.shade.resource.ComponentsXmlResourceTransformer" />
<transformer implementation="org.apache.maven.plugins.shade.resource.ServicesResourceTransformer" />
Expand Down
16 changes: 16 additions & 0 deletions src/main/java/org/jenkins/tools/test/CLI.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
package org.jenkins.tools.test;

import picocli.CommandLine;

@CommandLine.Command(
name = "pct",
mixinStandardHelpOptions = true,
subcommands = {PluginCompatTesterCli.class, PluginListerCLI.class},
versionProvider = VersionProvider.class)
public class CLI {

public static void main(String... args) {
int exitCode = new CommandLine(new CLI()).execute(args);
System.exit(exitCode);
}
}
835 changes: 336 additions & 499 deletions src/main/java/org/jenkins/tools/test/PluginCompatTester.java

Large diffs are not rendered by default.

17 changes: 7 additions & 10 deletions src/main/java/org/jenkins/tools/test/PluginCompatTesterCli.java
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@
import java.nio.file.Files;
import java.util.List;
import java.util.Map;
import java.util.Set;
import java.util.concurrent.Callable;
import org.jenkins.tools.test.exception.PluginCompatibilityTesterException;
import org.jenkins.tools.test.logging.LoggingConfiguration;
Expand All @@ -41,9 +42,10 @@
import picocli.CommandLine;

@CommandLine.Command(
name = "pct",
name = "test-plugins",
mixinStandardHelpOptions = true,
description = "Perform a compatibility test for plugins against Jenkins core and other plugins.")
description = "Perform a compatibility test for plugins against Jenkins core and other plugins.",
versionProvider = VersionProvider.class)
public class PluginCompatTesterCli implements Callable<Integer> {

static {
Expand Down Expand Up @@ -75,7 +77,7 @@ public class PluginCompatTesterCli implements Callable<Integer> {
paramLabel = "plugin",
description =
"Comma-separated list of plugin artifact IDs to test. If not set, every plugin in the WAR will be tested.")
private List<String> includePlugins;
private Set<String> includePlugins;

@CheckForNull
@CommandLine.Option(
Expand All @@ -85,7 +87,7 @@ public class PluginCompatTesterCli implements Callable<Integer> {
paramLabel = "plugin",
description =
"Comma-separated list of plugin artifact IDs to skip. If not set, only the plugins specified by --plugins will be tested (or all plugins otherwise).")
private List<String> excludePlugins;
private Set<String> excludePlugins;

@CheckForNull
@CommandLine.Option(
Expand Down Expand Up @@ -194,11 +196,6 @@ public Integer call() throws PluginCompatibilityTesterException {

PluginCompatTester tester = new PluginCompatTester(config);
tester.testPlugins();
return 0;
}

public static void main(String... args) {
int exitCode = new CommandLine(new PluginCompatTesterCli()).execute(args);
System.exit(exitCode);
return Integer.valueOf(0);
}
}
123 changes: 123 additions & 0 deletions src/main/java/org/jenkins/tools/test/PluginListerCLI.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,123 @@
package org.jenkins.tools.test;

import edu.umd.cs.findbugs.annotations.CheckForNull;
import java.io.BufferedWriter;
import java.io.File;
import java.io.IOException;
import java.io.UncheckedIOException;
import java.nio.file.Files;
import java.nio.file.StandardOpenOption;
import java.util.Collections;
import java.util.List;
import java.util.Map;
import java.util.Map.Entry;
import java.util.Set;
import java.util.concurrent.Callable;
import java.util.logging.Level;
import java.util.logging.Logger;
import java.util.stream.Collectors;
import org.jenkins.tools.test.exception.PluginCompatibilityTesterException;
import org.jenkins.tools.test.model.plugin_metadata.PluginMetadata;
import org.jenkins.tools.test.model.plugin_metadata.PluginMetadataExtractor;
import org.jenkins.tools.test.model.plugin_metadata.PluginMetadataHooks;
import org.jenkins.tools.test.picocli.ExistingFileTypeConverter;
import org.jenkins.tools.test.util.WarUtils;
import picocli.CommandLine;

@CommandLine.Command(
name = "list-plugins",
mixinStandardHelpOptions = true,
description = "List (non-detached) plugins and their associated repositories that the bundled in the war.",
versionProvider = VersionProvider.class)
public class PluginListerCLI implements Callable<Integer> {

private static final Logger LOGGER = Logger.getLogger(PluginListerCLI.class.getName());

@CommandLine.Option(
names = {"-w", "--war"},
required = true,
description = "Path to the WAR file to be examined.",
converter = ExistingFileTypeConverter.class)
private File warFile;

@CommandLine.Option(
names = "--external-hooks-jars",
split = ",",
arity = "1",
paramLabel = "jar",
description = "Comma-separated list of paths to external hooks JARs.",
converter = ExistingFileTypeConverter.class)
private List<File> externalHooksJars = Collections.emptyList();

@CheckForNull
@CommandLine.Option(
names = {"-o", "--output"},
required = false,
description = "location of the file to write containing the plugin and reposiries.")
private File output;

@CheckForNull
@CommandLine.Option(
names = "--include-plugins",
split = ",",
arity = "1",
paramLabel = "plugin",
description =
"Comma-separated list of plugin artifact IDs to test. If not set, every plugin in the WAR will be listed.")
private Set<String> includePlugins;

@CheckForNull
@CommandLine.Option(
names = "--exclude-plugins",
split = ",",
arity = "1",
paramLabel = "plugin",
description =
"Comma-separated list of plugin artifact IDs to skip. If not set, only the plugins specified by --plugins will be listed (or all plugins otherwise).")
private Set<String> excludePlugins;

@Override
public Integer call() throws PluginCompatibilityTesterException {
List<PluginMetadataExtractor> metadataExtractors = PluginMetadataHooks.loadExtractors(externalHooksJars);

List<PluginMetadata> pluginMetadataList =
WarUtils.extractPluginMetadataFromWar(warFile, metadataExtractors, includePlugins, excludePlugins);

// group the plugins into their actual repositories.
Map<String, List<PluginMetadata>> metaDataByRepoMap =
pluginMetadataList.stream().collect(Collectors.groupingBy(PluginMetadata::getGitURL));

if (metaDataByRepoMap.isEmpty()) {
LOGGER.log(Level.WARNING, "found no plugins in ", warFile);
return Integer.valueOf(5);
}

if (output != null) {
try (BufferedWriter writer = Files.newBufferedWriter(
output.toPath(),
StandardOpenOption.CREATE,
StandardOpenOption.TRUNCATE_EXISTING,
StandardOpenOption.WRITE)) {
for (Map.Entry<String, List<PluginMetadata>> entry : metaDataByRepoMap.entrySet()) {
writer.write(formatEntry(entry));
writer.write("\\n");
basil marked this conversation as resolved.
Show resolved Hide resolved
}
} catch (IOException e) {
throw new UncheckedIOException(e);
}
} else {
for (Map.Entry<String, List<PluginMetadata>> entry : metaDataByRepoMap.entrySet()) {
System.out.println(formatEntry(entry));
}
}
return Integer.valueOf(0);
}

private static String formatEntry(Entry<String, List<PluginMetadata>> entry) {
StringBuilder sb = new StringBuilder(entry.getKey());
for (PluginMetadata pm : entry.getValue()) {
sb.append("\t").append(pm.getPluginId());
}
return sb.toString();
}
}
41 changes: 41 additions & 0 deletions src/main/java/org/jenkins/tools/test/VersionProvider.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
package org.jenkins.tools.test;

import edu.umd.cs.findbugs.annotations.SuppressFBWarnings;
import java.io.IOException;
import java.io.InputStream;
import java.util.jar.Attributes;
import java.util.jar.Manifest;
import picocli.CommandLine;

public class VersionProvider implements CommandLine.IVersionProvider {

@Override
public String[] getVersion() throws Exception {
return new String[] {getPCTVersionString(), getJavaVersionString()};
}

@SuppressFBWarnings(
value = {"NP_LOAD_OF_KNOWN_NULL_VALUE", "RCN_REDUNDANT_NULLCHECK_OF_NULL_VALUE"},
justification =
"spotbugs false poisitive due to try-with-resources / https://github.com/spotbugs/spotbugs/issues/2191")
private static String getPCTVersionString() {
try (InputStream manifestStream = VersionProvider.class.getResourceAsStream("/META-INF/MANIFEST.MF")) {
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

uses the metadata we now build into the jar. unrelated to the multi-module work - but was here as it was in all the builds I had for various testing. Should have been puled out earlier.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should have been puled out earlier.

Why wasn't it?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I was juggling with too many workspaces, no real reason - I Can still extract it.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

OK, that places a large burden on others who are trying to make sense of such a large change. As a courtesy I already extracted this, so there is nothing left to be done.

if (manifestStream != null) {
Manifest mf = new Manifest(manifestStream);
System.out.println(mf);
Attributes mainAttributes = mf.getMainAttributes();
return "PCT : "
+ mainAttributes.getValue("Implementation-Version")
+ " "
+ mainAttributes.getValue("scmRevision");
}
} catch (IOException e) {
// ignored
}
return "PCT : SNAPSHOT build";
}

private static String getJavaVersionString() {
return "Java : " + System.getProperty("java.version");
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
package org.jenkins.tools.test.exception;

/**
* Exception used when extracting metadata from the war fails, e.g. the list of plugins or Jenkins
* version could not be obtained.
*/
public class MetadataExtractionException extends PluginCompatibilityTesterException {

private static final long serialVersionUID = 1L;

public MetadataExtractionException(String message, Throwable cause) {
super(message, cause);
}

public MetadataExtractionException(String message) {
super(message);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@
*/
public class PluginCompatibilityTesterException extends Exception {

private static final long serialVersionUID = 1L;

public PluginCompatibilityTesterException(String message) {
super(message);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,9 @@
* @author Frederic Camblor
*/
public class PluginSourcesUnavailableException extends PluginCompatibilityTesterException {

private static final long serialVersionUID = 1L;

public PluginSourcesUnavailableException(String message) {
super(message);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,8 @@
*/
public class PomExecutionException extends PluginCompatibilityTesterException {

private static final long serialVersionUID = 1L;

public PomExecutionException(String message) {
super(message);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,9 @@
* @author Frederic Camblor
*/
public class PomTransformationException extends PluginCompatibilityTesterException {

private static final long serialVersionUID = 1L;

public PomTransformationException(String message) {
super(message);
}
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
package org.jenkins.tools.test.exception;

/** A {@ code RuntimeException} that wraps a wraps a PluginCompatibilityTesterException. */
public class WrappedPluginCompatabilityException extends RuntimeException {

private static final long serialVersionUID = 1L;

public WrappedPluginCompatabilityException(PluginCompatibilityTesterException wrapped) {
super(wrapped);
}

@SuppressWarnings("sync-override")
@Override
public PluginCompatibilityTesterException getCause() {
return (PluginCompatibilityTesterException) super.getCause();
}
}
Loading