Skip to content

Commit

Permalink
Better support for JDK 11
Browse files Browse the repository at this point in the history
  • Loading branch information
damianszczepanik committed Dec 30, 2023
1 parent e14c2aa commit 91ae607
Show file tree
Hide file tree
Showing 5 changed files with 23 additions and 20 deletions.
3 changes: 2 additions & 1 deletion .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ jobs:
build:
strategy:
matrix:
java: [ '11' ]
os: [ 'ubuntu-latest', 'windows-latest', 'macos-latest' ]

runs-on: ${{ matrix.os }}
Expand All @@ -23,7 +24,7 @@ jobs:

- uses: actions/setup-java@v3
with:
java-version: 11
java-version: ${{ matrix.java }}
distribution: adopt

- run: mvn --batch-mode verify
9 changes: 5 additions & 4 deletions Jenkinsfile
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
// `buildPlugin` step provided by: https://github.com/jenkins-infra/pipeline-library

buildPlugin(
useContainerAgent: true,
failFast: false,
configurations: [
[platform: 'linux', jdk: 11],
[platform: 'windows', jdk: 11],
])
platforms: ['linux', 'windows'],
jdkVersions: [11]
)
23 changes: 12 additions & 11 deletions pom.xml
Original file line number Diff line number Diff line change
@@ -1,16 +1,19 @@
<?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">
<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.75</version>
<relativePath/>
</parent>

<groupId>pl.damianszczepanik</groupId>
<artifactId>build-history-manager</artifactId>
<version>1.7.2-SNAPSHOT</version>
<packaging>hpi</packaging>

<dependencyManagement>
<dependencies>
<dependency>
Expand All @@ -23,6 +26,7 @@
</dependencies>
</dependencyManagement>

<!-- This name and URL are added by the Jenkins when displaying help.html file -->
<name>Build History Manager</name>
<description>
Jenkins plugin that allows to build complex rules to decide when and which builds should be removed from the
Expand All @@ -33,17 +37,13 @@
<properties>
<jenkins.version>2.387.3</jenkins.version>

<slf4jVersion>1.7.30</slf4jVersion>
<asm.version>9.4</asm.version>
<powermock.version>2.0.9</powermock.version>
<!-- releases newer than this do not have Deencapsulation class-->
<jmockit.version>1.34</jmockit.version>

<test.integration.pattern>**/*IT.java</test.integration.pattern>

<sonar.projectKey>damianszczepanik_build-history-manager-plugin</sonar.projectKey>
<sonar.organization>damianszczepanik</sonar.organization>
<sonar.host.url>https://sonarcloud.io</sonar.host.url>
</properties>

<scm>
Expand All @@ -53,7 +53,7 @@
<tag>HEAD</tag>
</scm>
<ciManagement>
<system>jenkins</system>
<system>Jenkins</system>
<url>https://ci.jenkins.io/job/Plugins/job/build-history-manager-plugin/</url>
</ciManagement>

Expand Down Expand Up @@ -93,8 +93,8 @@
<artifactId>maven-compiler-plugin</artifactId>
<version>3.8.1</version>
<configuration>
<source>1.8</source>
<target>1.8</target>
<source>11</source>
<target>11</target>
<encoding>UTF-8</encoding>
</configuration>
</plugin>
Expand Down Expand Up @@ -167,17 +167,18 @@
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-release-plugin</artifactId>
<version>2.5.3</version>
<version>3.0.1</version>
</plugin>
</plugins>
</pluginManagement>
</build>

<dependencies>
<dependency>
<dependencies>
<dependency>
<groupId>org.jenkins-ci.plugins</groupId>
<artifactId>token-macro</artifactId>
</dependency>

<dependency>
<groupId>org.jenkins-ci.plugins</groupId>
<artifactId>structs</artifactId>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
import org.powermock.core.classloader.annotations.PowerMockIgnore;
import org.powermock.core.classloader.annotations.PrepareForTest;
import org.powermock.modules.junit4.PowerMockRunner;
import pl.damianszczepanik.jenkins.buildhistorymanager.model.ConditionBuilder;
import pl.damianszczepanik.jenkins.buildhistorymanager.model.ConditionBuilder.NegativeCondition;
import pl.damianszczepanik.jenkins.buildhistorymanager.model.Rule;
import pl.damianszczepanik.jenkins.buildhistorymanager.model.RuleBuilder;
import pl.damianszczepanik.jenkins.buildhistorymanager.model.RuleConfiguration;
Expand Down Expand Up @@ -72,9 +72,9 @@ public void getRules_ReturnsRules() {
public void perform_InitializesRule() throws IOException, InterruptedException {

// given
Rule rule = new Rule(Arrays.asList(new ConditionBuilder.NegativeCondition()), null);
Rule rule = new Rule(List.of(new NegativeCondition()), null);
Deencapsulation.setField(rule, "matchedTimes", 1);
BuildHistoryManager discarder = new BuildHistoryManager(Arrays.asList(rule));
BuildHistoryManager discarder = new BuildHistoryManager(List.of(rule));
Job<?, ?> job = JobBuilder.buildSampleJob();

// when
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ public DescriptorMocker(Descriptor descriptor) {
mockStatic(Jenkins.class);
Jenkins jenkins = mock(Jenkins.class);
when(Jenkins.get()).thenReturn(jenkins); // for new Jenkins
when(Jenkins.getInstance()).thenReturn(jenkins); // for old Jenkins
when(Jenkins.getInstanceOrNull()).thenReturn(jenkins); // for old Jenkins
when(jenkins.getDescriptorOrDie(ArgumentMatchers.any())).thenReturn(descriptor);
}
}

0 comments on commit 91ae607

Please sign in to comment.