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

Pass minimumJavaVersion to RunMojo so that hpi:run works again #88

Merged
merged 2 commits into from
Dec 14, 2018
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
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