Skip to content

Commit 3a2dc40

Browse files
authored
Merge pull request #558 from jenkinsci/java11
Update version for Java 11
2 parents 449a9a3 + d969c34 commit 3a2dc40

File tree

15 files changed

+88
-59
lines changed

15 files changed

+88
-59
lines changed

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
[![Join the chat at https://gitter.im/jenkinsci/warnings-plugin](https://badges.gitter.im/jenkinsci/warnings-plugin.svg)](https://gitter.im/jenkinsci/warnings-plugin?utm_source=badge&utm_medium=badge&utm_campaign=pr-badge&utm_content=badge)
44
[![Jenkins](https://ci.jenkins.io/job/Plugins/job/git-forensics-plugin/job/master/badge/icon?subject=Jenkins%20CI)](https://ci.jenkins.io/job/Plugins/job/git-forensics-plugin/job/master/)
55
[![GitHub Actions](https://github.com/jenkinsci/git-forensics-plugin/workflows/GitHub%20CI/badge.svg?branch=master)](https://github.com/jenkinsci/git-forensics-plugin/actions)
6-
[![Codecov](https://codecov.io/gh/jenkinsci/git-forensics-plugin/branch/master/graph/badge.svg)](https://codecov.io/gh/jenkinsci/git-forensics-plugin)
6+
[![Codecov](https://app.codecov.io/gh/jenkinsci/git-forensics-plugin/branch/master/graph/badge.svg)](https://app.codecov.io/gh/jenkinsci/git-forensics-plugin)
77

88
This Git Forensics Jenkins plugin mines and analyzes data from a Git repository. It implements all extension points of
99
[Jenkins' Forensics API Plugin](https://github.com/jenkinsci/forensics-api-plugin) and provides the following services:

plugin/pom.xml

Lines changed: 42 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
<parent>
55
<groupId>org.jvnet.hudson.plugins</groupId>
66
<artifactId>analysis-pom</artifactId>
7-
<version>5.35.0</version>
7+
<version>6.2.0</version>
88
<relativePath />
99
</parent>
1010

@@ -18,7 +18,7 @@
1818
<url>https://github.com/jenkinsci/git-forensics-plugin</url>
1919

2020
<properties>
21-
<revision>1.12.0</revision>
21+
<revision>2.0.0</revision>
2222
<changelist>-SNAPSHOT</changelist>
2323

2424
<module.name>${project.groupId}.git.forensics</module.name>
@@ -29,6 +29,15 @@
2929

3030
<!-- Maven Surefire ArgLine -->
3131
<argLine>-Djava.awt.headless=true -Xmx1024m -Djenkins.test.timeout=1000 --add-opens java.base/java.lang=ALL-UNNAMED --add-opens java.base/java.io=ALL-UNNAMED --add-opens java.base/java.util=ALL-UNNAMED --add-opens java.base/java.util.concurrent=ALL-UNNAMED</argLine>
32+
33+
<forensics-api.version>2.0.0</forensics-api.version>
34+
<jquery3-api.version>3.6.3-1</jquery3-api.version>
35+
<plugin-util-api.version>3.1.0</plugin-util-api.version>
36+
<bootstrap5-api.version>5.2.2-1</bootstrap5-api.version>
37+
<font-awesome-api.version>6.3.0-1</font-awesome-api.version>
38+
<data-tables-api.version>1.13.3-1</data-tables-api.version>
39+
<echarts-api.version>5.4.0-2</echarts-api.version>
40+
3241
</properties>
3342

3443
<licenses>
@@ -46,6 +55,31 @@
4655
</developer>
4756
</developers>
4857

58+
<dependencyManagement>
59+
<dependencies>
60+
<dependency>
61+
<groupId>io.jenkins.plugins</groupId>
62+
<artifactId>echarts-api</artifactId>
63+
<version>${echarts-api.version}</version>
64+
</dependency>
65+
<dependency>
66+
<groupId>io.jenkins.plugins</groupId>
67+
<artifactId>bootstrap5-api</artifactId>
68+
<version>${bootstrap5-api.version}</version>
69+
</dependency>
70+
<dependency>
71+
<groupId>io.jenkins.plugins</groupId>
72+
<artifactId>jquery3-api</artifactId>
73+
<version>${jquery3-api.version}</version>
74+
</dependency>
75+
<dependency>
76+
<groupId>io.jenkins.plugins</groupId>
77+
<artifactId>data-tables-api</artifactId>
78+
<version>${data-tables-api.version}</version>
79+
</dependency>
80+
</dependencies>
81+
</dependencyManagement>
82+
4983
<dependencies>
5084
<!-- Project Dependencies -->
5185
<dependency>
@@ -67,15 +101,17 @@
67101
<dependency>
68102
<groupId>io.jenkins.plugins</groupId>
69103
<artifactId>forensics-api</artifactId>
104+
<version>${forensics-api.version}</version>
70105
</dependency>
71106
<dependency>
72107
<groupId>io.jenkins.plugins</groupId>
73108
<artifactId>font-awesome-api</artifactId>
74-
<version>6.2.0-3</version>
109+
<version>${font-awesome-api.version}</version>
75110
</dependency>
76111
<dependency>
77112
<groupId>io.jenkins.plugins</groupId>
78113
<artifactId>plugin-util-api</artifactId>
114+
<version>${plugin-util-api.version}</version>
79115
</dependency>
80116
<dependency>
81117
<groupId>org.jenkins-ci.plugins</groupId>
@@ -88,6 +124,7 @@
88124
<artifactId>forensics-api</artifactId>
89125
<scope>test</scope>
90126
<classifier>tests</classifier>
127+
<version>${forensics-api.version}</version>
91128
</dependency>
92129

93130
<!-- Custom for Integration Test-->
@@ -118,10 +155,12 @@
118155
<artifactId>plugin-util-api</artifactId>
119156
<scope>test</scope>
120157
<classifier>tests</classifier>
158+
<version>${plugin-util-api.version}</version>
121159
</dependency>
122160
<dependency>
123161
<groupId>io.jenkins.plugins</groupId>
124162
<artifactId>data-tables-api</artifactId>
163+
<version>${data-tables-api.version}</version>
125164
<scope>test</scope>
126165
<classifier>tests</classifier>
127166
</dependency>

plugin/src/main/java/io/jenkins/plugins/forensics/git/delta/DeltaRepositoryCallback.java

Lines changed: 14 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -24,12 +24,11 @@
2424

2525
import hudson.remoting.VirtualChannel;
2626

27-
import io.jenkins.plugins.forensics.delta.model.Change;
28-
import io.jenkins.plugins.forensics.delta.model.ChangeEditType;
29-
import io.jenkins.plugins.forensics.delta.model.Delta;
30-
import io.jenkins.plugins.forensics.delta.model.FileChanges;
31-
import io.jenkins.plugins.forensics.delta.model.FileEditType;
32-
import io.jenkins.plugins.forensics.git.delta.model.GitDelta;
27+
import io.jenkins.plugins.forensics.delta.Change;
28+
import io.jenkins.plugins.forensics.delta.ChangeEditType;
29+
import io.jenkins.plugins.forensics.delta.Delta;
30+
import io.jenkins.plugins.forensics.delta.FileChanges;
31+
import io.jenkins.plugins.forensics.delta.FileEditType;
3332
import io.jenkins.plugins.forensics.git.util.AbstractRepositoryCallback;
3433
import io.jenkins.plugins.forensics.git.util.RemoteResultWrapper;
3534

@@ -39,13 +38,12 @@
3938
* @author Florian Orendi
4039
*/
4140
public class DeltaRepositoryCallback extends AbstractRepositoryCallback<RemoteResultWrapper<Delta>> {
41+
private static final long serialVersionUID = -4561284338216569043L;
4242

4343
static final String ERROR_MESSAGE_UNKNOWN_FILE_EDIT_TYPE = "Detected unknown file edit type '%s'";
4444

4545
static final String ERROR_MESSAGE_UNKNOWN_CHANGE_TYPE = "Detected unknown change type '%s'";
4646

47-
private static final long serialVersionUID = -4561284338216569043L;
48-
4947
private final String currentCommitId;
5048

5149
private final String referenceCommitId;
@@ -60,6 +58,7 @@ public class DeltaRepositoryCallback extends AbstractRepositoryCallback<RemoteRe
6058
*/
6159
public DeltaRepositoryCallback(final String currentCommitId, final String referenceCommitId) {
6260
super();
61+
6362
this.currentCommitId = currentCommitId;
6463
this.referenceCommitId = referenceCommitId;
6564
}
@@ -111,13 +110,13 @@ private RemoteResultWrapper<Delta> calculateDelta(final Repository repository) t
111110
}
112111

113112
log.logInfo("-> Creating the Git diff file");
114-
String diffFile = new String(diffStream.toByteArray(), StandardCharsets.UTF_8);
113+
String diffFile = diffStream.toString(StandardCharsets.UTF_8);
115114

116115
GitDelta delta = new GitDelta(currentCommitId, referenceCommitId, fileChangesMap, diffFile);
117116
RemoteResultWrapper<Delta> wrapper = new RemoteResultWrapper<>(delta, "Errors from Git Delta:");
118-
wrapper.merge(log);
119117

120118
log.logInfo("-> Git code delta successfully calculated");
119+
wrapper.merge(log);
121120

122121
return wrapper;
123122
}
@@ -207,9 +206,11 @@ private FileChanges createFileChanges(final FileEditType fileEditType, final Dif
207206
* if reading failed
208207
*/
209208
private String getFileContent(final ObjectId fileId, final Repository repository) throws IOException {
210-
ObjectDatabase objectDatabase = repository.getObjectDatabase();
211-
ObjectLoader objectLoader = objectDatabase.open(fileId);
212-
return new String(objectLoader.getCachedBytes(), StandardCharsets.UTF_8);
209+
try (ObjectDatabase objectDatabase = repository.getObjectDatabase()) {
210+
ObjectLoader objectLoader = objectDatabase.open(fileId);
211+
212+
return new String(objectLoader.getCachedBytes(), StandardCharsets.UTF_8);
213+
}
213214
}
214215

215216
/**

plugin/src/main/java/io/jenkins/plugins/forensics/git/delta/model/GitDelta.java renamed to plugin/src/main/java/io/jenkins/plugins/forensics/git/delta/GitDelta.java

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,17 @@
1-
package io.jenkins.plugins.forensics.git.delta.model;
1+
package io.jenkins.plugins.forensics.git.delta;
22

33
import java.util.Map;
44
import java.util.Objects;
55

6-
import io.jenkins.plugins.forensics.delta.model.Delta;
7-
import io.jenkins.plugins.forensics.delta.model.FileChanges;
6+
import io.jenkins.plugins.forensics.delta.Delta;
7+
import io.jenkins.plugins.forensics.delta.FileChanges;
88

99
/**
1010
* A Git specific extension of {@link Delta}.
1111
*
1212
* @author Florian Orendi
1313
*/
1414
public class GitDelta extends Delta {
15-
1615
private static final long serialVersionUID = 4075956106966630282L;
1716

1817
/**
@@ -24,17 +23,18 @@ public class GitDelta extends Delta {
2423
* Constructor for a delta instance which wraps code changes between the two passed commits.
2524
*
2625
* @param currentCommit
27-
* The currently processed commit
26+
* the currently processed commit
2827
* @param referenceCommit
29-
* The reference commit
28+
* the reference commit
3029
* @param fileChanges
31-
* The map which contains the changes for modified files, mapped by the file ID.
30+
* the map which contains the changes for modified files, mapped by the file ID.
3231
* @param diffFile
33-
* The Diff-File which has been created by Git and wraps up all made changes between two commits.
32+
* the Diff-File which has been created by Git and wraps up all made changes between two commits.
3433
*/
3534
public GitDelta(final String currentCommit, final String referenceCommit,
3635
final Map<String, FileChanges> fileChanges, final String diffFile) {
3736
super(currentCommit, referenceCommit, fileChanges);
37+
3838
this.diffFile = diffFile;
3939
}
4040

plugin/src/main/java/io/jenkins/plugins/forensics/git/delta/GitDeltaCalculator.java

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -9,9 +9,10 @@
99
import org.jenkinsci.plugins.gitclient.GitClient;
1010
import hudson.model.Run;
1111

12+
import io.jenkins.plugins.forensics.delta.Delta;
1213
import io.jenkins.plugins.forensics.delta.DeltaCalculator;
13-
import io.jenkins.plugins.forensics.delta.model.Delta;
1414
import io.jenkins.plugins.forensics.git.reference.GitCommitsRecord;
15+
import io.jenkins.plugins.forensics.git.util.GitCommitTextDecorator;
1516
import io.jenkins.plugins.forensics.git.util.RemoteResultWrapper;
1617

1718
/**
@@ -21,12 +22,12 @@
2122
*/
2223
@SuppressFBWarnings(value = "SE", justification = "GitClient implementation is Serializable")
2324
public class GitDeltaCalculator extends DeltaCalculator {
25+
private static final long serialVersionUID = -7303579046266608368L;
26+
private static final GitCommitTextDecorator DECORATOR = new GitCommitTextDecorator();
2427

2528
static final String DELTA_ERROR = "Computing delta information failed with an exception:";
2629
static final String EMPTY_COMMIT_ERROR = "Calculating the Git code delta is not possible due to an unknown commit ID";
2730

28-
private static final long serialVersionUID = -7303579046266608368L;
29-
3031
private final GitClient git;
3132

3233
/**
@@ -37,6 +38,7 @@ public class GitDeltaCalculator extends DeltaCalculator {
3738
*/
3839
public GitDeltaCalculator(final GitClient git) {
3940
super();
41+
4042
this.git = git;
4143
}
4244

@@ -49,9 +51,8 @@ public Optional<Delta> calculateDelta(final Run<?, ?> build, final Run<?, ?> ref
4951
String currentCommit = getLatestCommit(build.getFullDisplayName(), buildCommits.get(), log);
5052
String referenceCommit = getLatestCommit(referenceBuild.getFullDisplayName(), referenceCommits.get(), log);
5153
if (!currentCommit.isEmpty() && !referenceCommit.isEmpty()) {
52-
log.logInfo(
53-
"-> Invoking Git delta calculator for determining the made changes between the commits with the IDs '%s' and '%s'",
54-
currentCommit, referenceCommit);
54+
log.logInfo("-> Invoking Git delta calculator for determining the changes between commits '%s' and '%s'",
55+
DECORATOR.asText(currentCommit), DECORATOR.asText(referenceCommit));
5556
try {
5657
RemoteResultWrapper<Delta> wrapped = git.withRepository(
5758
new DeltaRepositoryCallback(currentCommit, referenceCommit));
@@ -82,7 +83,7 @@ public Optional<Delta> calculateDelta(final Run<?, ?> build, final Run<?, ?> ref
8283
*/
8384
private String getLatestCommit(final String buildName, final GitCommitsRecord record, final FilteredLog log) {
8485
String latestCommitId = record.getLatestCommit();
85-
log.logInfo("-> Using commit '%s' as latest commit for build '%s'", latestCommitId, buildName);
86+
log.logInfo("-> Using commit '%s' as latest commit for build '%s'", DECORATOR.asText(latestCommitId), buildName);
8687
return latestCommitId;
8788
}
8889
}

plugin/src/main/java/io/jenkins/plugins/forensics/git/delta/GitDeltaCalculatorFactory.java

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,6 @@
2323
*/
2424
@Extension
2525
public class GitDeltaCalculatorFactory extends DeltaCalculatorFactory {
26-
2726
@Override
2827
public Optional<DeltaCalculator> createDeltaCalculator(final SCM scm, final Run<?, ?> run, final FilePath workspace,
2928
final TaskListener listener, final FilteredLog logger) {

plugin/src/main/java/io/jenkins/plugins/forensics/git/delta/model/package-info.java

Lines changed: 0 additions & 10 deletions
This file was deleted.

plugin/src/main/java/io/jenkins/plugins/forensics/git/util/GitCommitDecorator.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414
/**
1515
* A {@link RepositoryBrowser} for Git commits. Since a {@link RepositoryBrowser} has no API to generate links to simple
1616
* commits, this decorator adds such a functionality for Git. Basically, this implementation delegates to the {@link
17-
* GitRepositoryBrowser} implementation, if available. Otherwise a plain link will be rendered using a short
17+
* GitRepositoryBrowser} implementation, if available. Otherwise, a plain link will be rendered using a short
1818
* representation, see {@link #asText(String)}.
1919
*
2020
* @author Ullrich Hafner

plugin/src/main/resources/io/jenkins/plugins/forensics/git/reference/GitReferenceRecorder/config.jelly

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
<?jelly escape-by-default='true'?>
2-
<j:jelly xmlns:j="jelly:core" xmlns:f="/lib/form" xmlns:c="/controls">
2+
<j:jelly xmlns:j="jelly:core" xmlns:f="/lib/form">
33

44
<f:entry title="${%title.referenceJob}" field="referenceJob" description="${%description.referenceJob}">
5-
<c:safe-combobox />
5+
<f:combobox />
66
</f:entry>
77

88
<f:entry title="${%title.defaultBranch}" field="defaultBranch" description="${%description.defaultBranch}">

plugin/src/test/java/io/jenkins/plugins/forensics/git/PackageArchitectureTest.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,8 @@
88
import com.tngtech.archunit.lang.ArchRule;
99

1010
import static com.tngtech.archunit.lang.syntax.ArchRuleDefinition.*;
11-
import static com.tngtech.archunit.library.plantuml.PlantUmlArchCondition.Configurations.*;
12-
import static com.tngtech.archunit.library.plantuml.PlantUmlArchCondition.*;
11+
import static com.tngtech.archunit.library.plantuml.rules.PlantUmlArchCondition.Configuration.*;
12+
import static com.tngtech.archunit.library.plantuml.rules.PlantUmlArchCondition.*;
1313

1414
/**
1515
* Checks the package architecture of this plugin.

0 commit comments

Comments
 (0)