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

[JENKINS-58113] - Remove the Internal Maven Mode from PCT + Use maven from PATH when "-mvn" is not specified #194

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
6 changes: 3 additions & 3 deletions plugins-compat-tester-cli/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,11 @@
<parent>
<groupId>org.jenkins-ci.tests</groupId>
<artifactId>plugins-compat-tester-aggregator</artifactId>
<version>0.2.1-SNAPSHOT</version>
<version>0.4.0-SNAPSHOT</version>
</parent>

<artifactId>plugins-compat-tester-cli</artifactId>
<version>0.2.1-SNAPSHOT</version>
<version>0.4.0-SNAPSHOT</version>
<name>Plugins compatibility tester CLI</name>
<description>Jenkins Plugin Compatibility Tester (PCT) against latest released version</description>

Expand Down Expand Up @@ -59,7 +59,7 @@
<dependency>
<groupId>org.jenkins-ci.tests</groupId>
<artifactId>plugins-compat-tester</artifactId>
<version>0.2.1-SNAPSHOT</version>
<version>0.4.0-SNAPSHOT</version>
</dependency>
<dependency>
<groupId>com.beust</groupId>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,8 @@ public class CliOptions {

@Parameter(names = "-mvn",
description = "External Maven executable")
private File externalMaven = null;
@CheckForNull
private File externalMaven;

@Parameter(names = "-skipTestCache",
description = "Allows to skip compatibility test cache (by default, to 100 days)\n" +
Expand Down
4 changes: 2 additions & 2 deletions plugins-compat-tester-model/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,11 @@
<parent>
<groupId>org.jenkins-ci.tests</groupId>
<artifactId>plugins-compat-tester-aggregator</artifactId>
<version>0.2.1-SNAPSHOT</version>
<version>0.4.0-SNAPSHOT</version>
</parent>

<artifactId>plugins-compat-tester-model</artifactId>
<version>0.2.1-SNAPSHOT</version>
<version>0.4.0-SNAPSHOT</version>
<name>Plugins compatibility tester model layer</name>
<description>Jenkins Plugin Compatibility Tester (PCT) model layer</description>

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -89,6 +89,7 @@ public class PluginCompatTesterConfig {
@CheckForNull
private String testJavaArgs = null;

@CheckForNull
private File externalMaven = null;

// List of plugin artifact ids on which tests will be performed
Expand Down Expand Up @@ -367,6 +368,7 @@ public void setWar(File war) {
this.war = war;
}

@CheckForNull
public File getExternalMaven() {
return externalMaven;
}
Expand Down
55 changes: 13 additions & 42 deletions plugins-compat-tester/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -4,16 +4,16 @@
<parent>
<groupId>org.jenkins-ci.tests</groupId>
<artifactId>plugins-compat-tester-aggregator</artifactId>
<version>0.2.1-SNAPSHOT</version>
<version>0.4.0-SNAPSHOT</version>
</parent>

<artifactId>plugins-compat-tester</artifactId>
<version>0.2.1-SNAPSHOT</version>
<version>0.4.0-SNAPSHOT</version>
<name>Plugins compatibility tester</name>
<description>Jenkins Plugin Compatibility Tester (PCT) against latest released version</description>

<properties>
<maven.scm.providers.version>1.5</maven.scm.providers.version>
<maven.scm.providers.version>1.5</maven.scm.providers.version>
</properties>

<dependencies>
Expand All @@ -24,65 +24,42 @@
<dependency>
<groupId>org.jenkins-ci.tests</groupId>
<artifactId>plugins-compat-tester-model</artifactId>
<version>0.2.1-SNAPSHOT</version>
<version>0.4.0-SNAPSHOT</version>
</dependency>
<dependency>
<groupId>org.jenkins-ci.main</groupId>
<artifactId>jenkins-core</artifactId>
</dependency>

<!-- Upper bounds between core and Maven Embedder -->
<!-- TODO: All of that stuff happens due to Maven detaching. Would it be sane to include Maven Plugin 3.0 as a JAR instead? -->

<dependency>
<groupId>antlr</groupId>
<artifactId>antlr</artifactId>
<version>2.7.7</version>
</dependency>
<dependency>
<groupId>commons-logging</groupId>
<artifactId>commons-logging</artifactId>
<version>1.2</version>
</dependency>
<dependency>
<groupId>commons-codec</groupId>
<artifactId>commons-codec</artifactId>
<version>1.13</version>
</dependency>
<dependency>
<groupId>org.apache.ant</groupId>
<artifactId>ant</artifactId>
<version>1.10.7</version>
</dependency>

<!-- Upper bounds in Embedder -->
<dependency>
<groupId>org.codehaus.plexus</groupId>
<artifactId>plexus-utils</artifactId>
<version>3.3.0</version>
</dependency>
<dependency>
<groupId>org.codehaus.plexus</groupId>
<artifactId>plexus-container-default</artifactId>
Copy link
Member Author

Choose a reason for hiding this comment

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

We can use it since we do not longer bundle Maven libs.
http://olamy.blogspot.com/2010/09/use-maven-3-apis-in-hudson-plugin.html from @olamy

<version>2.0.0</version>
</dependency>
<dependency>
<groupId>org.codehaus.plexus</groupId>
<artifactId>plexus-classworlds</artifactId>
<version>2.5.2</version>
<version>2.6.0</version>
</dependency>

<dependency>
<groupId>org.apache.maven.scm</groupId>
<artifactId>maven-scm-manager-plexus</artifactId>
<version>1.5</version>
<exclusions>
<exclusion>
<groupId>org.codehaus.plexus</groupId>
<artifactId>plexus-container-default</artifactId>
</exclusion>
</exclusions>
</dependency>
<dependency>
<groupId>org.jenkins-ci.lib</groupId>
<artifactId>lib-jenkins-maven-embedder</artifactId>
Copy link
Member

Choose a reason for hiding this comment

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

oh yes

<version>3.12.1</version>
</dependency>

<!--TODO(oleg_nenashev): Remove all providers except Git? -->
<!-- scm providers declaration -->
<dependency>
<groupId>org.apache.maven.scm</groupId>
Expand Down Expand Up @@ -165,12 +142,6 @@
<groupId>org.codehaus.plexus</groupId>
<artifactId>plexus-slf4j-logging</artifactId>
<version>1.1</version>
<exclusions>
<exclusion>
<groupId>org.codehaus.plexus</groupId>
<artifactId>plexus-container-default</artifactId>
</exclusion>
</exclusions>
</dependency>

<dependency>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,6 @@
import org.jenkins.tools.test.exception.PluginSourcesUnavailableException;
import org.jenkins.tools.test.exception.PomExecutionException;
import org.jenkins.tools.test.maven.ExternalMavenRunner;
import org.jenkins.tools.test.maven.InternalMavenRunner;
import org.jenkins.tools.test.maven.MavenRunner;
import org.jenkins.tools.test.model.MavenCoordinates;
import org.jenkins.tools.test.model.MavenPom;
Expand Down Expand Up @@ -124,7 +123,7 @@ public class PluginCompatTester {

public PluginCompatTester(PluginCompatTesterConfig config){
this.config = config;
runner = config.getExternalMaven() == null ? new InternalMavenRunner() : new ExternalMavenRunner(config.getExternalMaven());
runner = new ExternalMavenRunner(config.getExternalMaven());
}

private SortedSet<MavenCoordinates> generateCoreCoordinatesToTest(UpdateSite.Data data, PluginCompatReport previousReport){
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@
import org.apache.commons.io.FileUtils;
import org.jenkins.tools.test.exception.PomExecutionException;
import org.jenkins.tools.test.maven.ExternalMavenRunner;
import org.jenkins.tools.test.maven.InternalMavenRunner;
import org.jenkins.tools.test.maven.MavenRunner;
import org.jenkins.tools.test.model.PluginCompatTesterConfig;
import org.jenkins.tools.test.model.hook.PluginCompatTesterHookBeforeCompile;
Expand All @@ -35,7 +34,7 @@ public Map<String, Object> action(Map<String, Object> moreInfo) throws Exception
System.out.println("Executing multi-parent compile hook");
PluginCompatTesterConfig config = (PluginCompatTesterConfig) moreInfo.get("config");

runner = config.getExternalMaven() == null ? new InternalMavenRunner() : new ExternalMavenRunner(config.getExternalMaven());
runner = new ExternalMavenRunner(config.getExternalMaven());
mavenConfig = getMavenConfig(config);

File pluginDir = (File) moreInfo.get("pluginDir");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,18 +17,29 @@
import java.util.regex.Pattern;
import org.jenkins.tools.test.exception.PomExecutionException;

import javax.annotation.CheckForNull;

/**
* Runs external Maven executable.
*/
public class ExternalMavenRunner implements MavenRunner {


@CheckForNull
private File mvn;

public ExternalMavenRunner(File mvn) {

/**
* Constructor.
* @param mvn Path to Maven.
* If {@code null}, a default Maven executable from {@code PATH} will be used
*/
public ExternalMavenRunner(@CheckForNull File mvn) {
this.mvn = mvn;
}

@Override
public void run(Config config, File baseDirectory, File buildLogFile, String... goals) throws PomExecutionException {
List<String> cmd = new ArrayList<>();
cmd.add(mvn.getAbsolutePath());
cmd.add(mvn != null ? mvn.getAbsolutePath() : "mvn");
cmd.add("--show-version");
cmd.add("--batch-mode");
if (config.userSettingsFile != null) {
Expand Down

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@

import com.google.common.collect.ImmutableList;
import java.io.File;
import java.io.IOException;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
import org.jenkins.tools.test.model.PluginCompatTesterConfig;
Expand Down Expand Up @@ -73,7 +74,7 @@ public void testWithUrl() throws Throwable {

PluginCompatTesterConfig config = new PluginCompatTesterConfig(testFolder.getRoot(),
new File("../reports/PluginCompatReport.xml"),
new ClassPathResource("m2-settings.xml").getFile());
getSettingsFile());

config.setIncludePlugins(includedPlugins);
config.setSkipTestCache(true);
Expand Down Expand Up @@ -197,4 +198,16 @@ public void testCustomWarPackagerVersions() {
assertTrue("No matches",m.matches());
}

private static File getSettingsFile() throws IOException {
// Check whether we run in ci.jenkins.io with Azure settings
File ciJenkinsIOSettings = new File(new File("settings-azure.xml").getAbsolutePath().replace("/plugins-compat-tester/settings-azure.xml", "@tmp/settings-azure.xml"));
System.out.println("Will check Maven settings from " + ciJenkinsIOSettings.getAbsolutePath());
if (ciJenkinsIOSettings.exists()) {
System.out.println("Will use the ci.jenkins.io Azure settings file for testing: " + ciJenkinsIOSettings.getAbsolutePath());
return ciJenkinsIOSettings;
}
// Default fallback for local runs
return new ClassPathResource("m2-settings.xml").getFile();
}

}
Loading