Skip to content

Commit

Permalink
Merge pull request #88 from jglick/RunMojo.minimumJavaVersion
Browse files Browse the repository at this point in the history
Pass minimumJavaVersion to RunMojo so that hpi:run works again
  • Loading branch information
jglick authored Dec 14, 2018
2 parents 875bf53 + 831f36e commit c7ac262
Show file tree
Hide file tree
Showing 6 changed files with 45 additions and 6 deletions.
4 changes: 3 additions & 1 deletion pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -360,7 +360,9 @@
</goals>
<configuration>
<streamLogs>false</streamLogs>
<debug>true</debug>
<environmentVariables>
<JENKINS_HOME/> <!-- block anything set by a CI environment -->
</environmentVariables>
</configuration>
</execution>
</executions>
Expand Down
2 changes: 1 addition & 1 deletion src/it/parent-3x/invoker.properties
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
# install, not verify, because we want to check the artifact as we would be about to deploy it
# release.skipTests normally set in jenkins-release profile since release:perform would do the tests
invoker.goals=-Pjenkins-release -Drelease.skipTests=false clean install
invoker.goals=-Pjenkins-release -Drelease.skipTests=false clean install hpi:run
24 changes: 24 additions & 0 deletions src/it/parent-3x/src/main/java/test/JustTesting.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
package test;

import hudson.Main;
import hudson.init.Initializer;
import java.util.concurrent.TimeUnit;
import jenkins.model.Jenkins;
import jenkins.util.Timer;

public class JustTesting {

private JustTesting() {}

@Initializer
public static void shutDown() {
if (Main.isUnitTest) {
return;
}
Timer.get().schedule(() -> {
Jenkins.getInstance().doSafeExit(null);
return null;
}, 15, TimeUnit.SECONDS);
}

}
7 changes: 6 additions & 1 deletion src/it/parent-3x/verify.groovy
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,12 @@ checkArtifact(installed, 'parent-3x-1.0-SNAPSHOT-test-sources.jar',
['InjectedTest.java'],
[:])

// TODO try mvn hpi:run (how do we find the right version of mvn to run?) and check that we can access http://localhost:8080/jenkins/sample/
// TODO check that we can access http://localhost:8080/jenkins/sample/ during hpi:run
// (tricky since this script is called only once mvn is done)
def text = new File(basedir, 'build.log').text
assert text.contains('INFO: Jenkins is fully up and running') && text.contains('INFO: Jenkins stopped')
assert new File(basedir, 'work/plugins/parent-3x.hpl').file
assert new File(basedir, 'work/plugins/structs.jpi').file

// TODO run a copy of jenkins.war with the installed *.hpi predeployed and do a similar check

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ public abstract class AbstractJenkinsManifestMojo extends AbstractHpiMojo {
* Specify the minimum version of Java that this plugin requires.
*/
@Parameter(required = true)
private String minimumJavaVersion;
protected String minimumJavaVersion;

/**
* Generates a manifest file to be included in the .hpi file
Expand Down
12 changes: 10 additions & 2 deletions src/main/java/org/jenkinsci/maven/plugins/hpi/RunMojo.java
Original file line number Diff line number Diff line change
Expand Up @@ -213,6 +213,12 @@ public class RunMojo extends AbstractJettyMojo {

private Collection<Logger> loggerReferences; // just to prevent GC

/**
* Specify the minimum version of Java that this plugin requires.
*/
@Parameter(required = true)
private String minimumJavaVersion;

/**
* The context path for the webapp. Defaults to the
* name of the webapp's artifact.
Expand Down Expand Up @@ -254,10 +260,11 @@ public void execute() throws MojoExecutionException, MojoFailureException {
if (h == null) {
h = System.getenv("HUDSON_HOME");
}
if(h!=null)
if (h != null && !h.isEmpty() && /* see pom.xml override */!h.equals("null")) {
jenkinsHome = new File(h);
else
} else {
jenkinsHome = new File(basedir, "work");
}
}

// auto-enable stapler trace, unless otherwise configured already.
Expand Down Expand Up @@ -465,6 +472,7 @@ private void generateHpl() throws MojoExecutionException, MojoFailureException {
hpl.pluginFirstClassLoader = this.pluginFirstClassLoader;
hpl.maskClasses = this.maskClasses;
hpl.remoteRepos = this.remoteRepos;
hpl.minimumJavaVersion = this.minimumJavaVersion;
/* As needed:
hpl.artifactFactory = this.artifactFactory;
hpl.artifactResolver = this.artifactResolver;
Expand Down

0 comments on commit c7ac262

Please sign in to comment.