Skip to content

Commit

Permalink
Revert JENKINS-20679 (#341)
Browse files Browse the repository at this point in the history
  • Loading branch information
basil authored May 11, 2022
1 parent dff451c commit 533f4d2
Show file tree
Hide file tree
Showing 9 changed files with 70 additions and 19 deletions.
1 change: 1 addition & 0 deletions src/it/minimum-java-version/invoker.properties
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
invoker.goals=-ntp clean verify
30 changes: 30 additions & 0 deletions src/it/minimum-java-version/pom.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
<modelVersion>4.0.0</modelVersion>
<parent>
<groupId>org.jenkins-ci.plugins</groupId>
<artifactId>plugin</artifactId>
<version>4.40</version>
<relativePath />
</parent>
<groupId>org.jenkins-ci.tools.hpi.its</groupId>
<artifactId>minimum-java-version</artifactId>
<version>1.0-SNAPSHOT</version>
<packaging>hpi</packaging>
<name>MyNewPlugin</name>
<properties>
<jenkins.version>2.249.1</jenkins.version>
<hpi-plugin.version>@project.version@</hpi-plugin.version>
</properties>
<build>
<plugins>
<plugin>
<groupId>org.jenkins-ci.tools</groupId>
<artifactId>maven-hpi-plugin</artifactId>
<configuration>
<minimumJavaVersion>8</minimumJavaVersion>
</configuration>
</plugin>
</plugins>
</build>
</project>
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
package org.jenkinsci.tools.hpi.its;
public class X {}
2 changes: 2 additions & 0 deletions src/it/minimum-java-version/src/main/resources/index.jelly
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
<?jelly escape-by-default='true'?>
<div/>
22 changes: 22 additions & 0 deletions src/it/minimum-java-version/verify.groovy
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
/*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. The ASF licenses this file
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
*/

assert new File(basedir, 'build.log').getText('UTF-8').contains("Ignoring deprecated minimumJavaVersion parameter. This property should be removed from your plugin's POM. In the future this warning will be changed to an error and will break the build.")

return true
1 change: 0 additions & 1 deletion src/it/process-jar/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,6 @@
</executions>
<configuration>
<jarClassifier>shaded</jarClassifier>
<minimumJavaVersion>8</minimumJavaVersion>
</configuration>
</plugin>
<!-- TODO the shade plugin doesn't like shading the non-main attached artifacts yet -->
Expand Down
1 change: 0 additions & 1 deletion src/it/verify-it/verify.groovy
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,6 @@ Files.newInputStream(new File(basedir, 'target/verify-it/META-INF/MANIFEST.MF').
assert manifest.getMainAttributes().getValue('Jenkins-Version').equals('2.249.1')
assert manifest.getMainAttributes().getValue('Long-Name').equals('MyNewPlugin')
assert manifest.getMainAttributes().getValue('Manifest-Version').equals('1.0')
assert manifest.getMainAttributes().getValue('Minimum-Java-Version').equals('1.8')
assert manifest.getMainAttributes().getValue('Plugin-Developers').equals('Noam Chomsky:nchomsky:[email protected]')
assert manifest.getMainAttributes().getValue('Plugin-License-Name').equals('MIT License')
assert manifest.getMainAttributes().getValue('Plugin-License-Url').equals('https://opensource.org/licenses/MIT')
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -74,8 +74,11 @@ public abstract class AbstractJenkinsManifestMojo extends AbstractHpiMojo {

/**
* Specify the minimum version of Java that this plugin requires.
*
* @deprecated removed without replacement
*/
@Parameter(required = true)
@Deprecated
@Parameter
protected String minimumJavaVersion;

/**
Expand Down Expand Up @@ -130,20 +133,11 @@ protected void setAttributes(Manifest.ExistingSection mainSection) throws MojoEx
if (compatibleSinceVersion!=null)
mainSection.addAttributeAndCheck(new Manifest.Attribute("Compatible-Since-Version", compatibleSinceVersion));

if (this.minimumJavaVersion == null) {
throw new MojoExecutionException("minimumJavaVersion attribute must be set starting from version 2.8");
}
try {
int res = Integer.parseInt(this.minimumJavaVersion);
LOGGER.log(Level.INFO, "Minimum Java version for the plugin: {0}", this.minimumJavaVersion);
} catch(NumberFormatException ex) {
if (this.minimumJavaVersion.equals("1.6") || this.minimumJavaVersion.equals("1.7") || this.minimumJavaVersion.equals("1.8")) {
// okay
} else {
throw new MojoExecutionException("Unsupported Java version string: `" + this.minimumJavaVersion + "`. If you use Java 9 or above, see https://openjdk.java.net/jeps/223");
}
if (this.minimumJavaVersion != null && !this.minimumJavaVersion.isEmpty()) {
getLog().warn("Ignoring deprecated minimumJavaVersion parameter."
+ " This property should be removed from your plugin's POM."
+ " In the future this warning will be changed to an error and will break the build.");
}
mainSection.addAttributeAndCheck(new Manifest.Attribute("Minimum-Java-Version", this.minimumJavaVersion));

if (sandboxStatus!=null)
mainSection.addAttributeAndCheck(new Manifest.Attribute("Sandbox-Status", sandboxStatus));
Expand Down
8 changes: 5 additions & 3 deletions src/main/java/org/jenkinsci/maven/plugins/hpi/RunMojo.java
Original file line number Diff line number Diff line change
Expand Up @@ -245,8 +245,11 @@ public class RunMojo extends AbstractJettyMojo {

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

/**
Expand Down Expand Up @@ -497,8 +500,7 @@ private void generateHpl() throws MojoExecutionException {
MojoExecutor.element(MojoExecutor.name("warSourceDirectory"), warSourceDirectory.toString()),
MojoExecutor.element(MojoExecutor.name("jenkinsCoreId"), jenkinsCoreId),
MojoExecutor.element(MojoExecutor.name("pluginFirstClassLoader"), Boolean.toString(pluginFirstClassLoader)),
MojoExecutor.element(MojoExecutor.name("maskClasses"), maskClasses),
MojoExecutor.element(MojoExecutor.name("minimumJavaVersion"), minimumJavaVersion)),
MojoExecutor.element(MojoExecutor.name("maskClasses"), maskClasses)),
MojoExecutor.executionEnvironment(project, session, pluginManager));
}

Expand Down

0 comments on commit 533f4d2

Please sign in to comment.