Skip to content

Commit

Permalink
Merge pull request #2 from oleg-nenashev/JENKINS-49586
Browse files Browse the repository at this point in the history
[JENKINS-49586] - Stop Serializing JDependParser to the disk (JEP-200 in 2.102+)
  • Loading branch information
oleg-nenashev committed Feb 22, 2018
2 parents 0c8fbfa + a8c8e30 commit afcf6bf
Show file tree
Hide file tree
Showing 9 changed files with 90 additions and 20 deletions.
2 changes: 2 additions & 0 deletions Jenkinsfile
@@ -0,0 +1,2 @@
// Build the plugin using https://github.com/jenkins-infra/pipeline-library
buildPlugin(jenkinsVersions: [null, '2.104'])
41 changes: 36 additions & 5 deletions pom.xml
Expand Up @@ -3,7 +3,7 @@
<parent>
<groupId>org.jenkins-ci.plugins</groupId>
<artifactId>plugin</artifactId>
<version>1.532</version>
<version>3.4</version>
</parent>

<artifactId>jdepend</artifactId>
Expand All @@ -13,8 +13,15 @@
<name>Jenkins JDepend Plugin</name>
<description>A Jenkins plugin that uses JDepend to generate metrics.</description>
<inceptionYear>2009</inceptionYear>
<url>http://wiki.jenkins-ci.org/display/JENKINS/JDepend+Plugin</url>

<url>https://wiki.jenkins.io/display/JENKINS/JDepend+Plugin</url>

<properties>
<jenkins.version>1.625.3</jenkins.version>
<java.level>7</java.level>
<!-- TODO: Delete once FindBugs issues are fixed (4 issues) -->
<findbugs.failOnError>false</findbugs.failOnError>
</properties>

<licenses>
<license>
<name>BSD</name>
Expand Down Expand Up @@ -56,6 +63,13 @@
<groupId>org.codehaus.mojo</groupId>
<artifactId>jdepend-maven-plugin</artifactId>
<version>2.0-beta-2</version>
<exclusions>
<exclusion>
<!-- Newer version comes from Jenkins Core's Acegi Security. No comments... -->
<groupId>oro</groupId>
<artifactId>oro</artifactId>
</exclusion>
</exclusions>
</dependency>
<dependency>
<groupId>jdepend</groupId>
Expand All @@ -66,6 +80,23 @@
<groupId>org.apache.maven.doxia</groupId>
<artifactId>doxia-core</artifactId>
<version>1.1.1</version>
<exclusions>
<exclusion>
<!-- Newer version comes from Jenkins Core. -->
<groupId>commons-lang</groupId>
<artifactId>commons-lang</artifactId>
</exclusion>
<exclusion>
<!-- Newer Jenkins cores use a patched version -->
<groupId>commons-httpclient</groupId>
<artifactId>commons-httpclient</artifactId>
</exclusion>
</exclusions>
</dependency>
<dependency> <!-- Upper bounds conflict between Docix Core and JTH -->
<groupId>xerces</groupId>
<artifactId>xercesImpl</artifactId>
<version>2.11.0</version>
</dependency>
<dependency>
<groupId>org.apache.maven.doxia</groupId>
Expand All @@ -77,14 +108,14 @@
<repositories>
<repository>
<id>repo.jenkins-ci.org</id>
<url>http://repo.jenkins-ci.org/public/</url>
<url>https://repo.jenkins-ci.org/public/</url>
</repository>
</repositories>

<pluginRepositories>
<pluginRepository>
<id>repo.jenkins-ci.org</id>
<url>http://repo.jenkins-ci.org/public/</url>
<url>https://repo.jenkins-ci.org/public/</url>
</pluginRepository>
</pluginRepositories>

Expand Down
52 changes: 43 additions & 9 deletions src/main/java/hudson/plugins/jdepend/JDependBuildAction.java
Expand Up @@ -8,23 +8,35 @@

import hudson.model.AbstractBuild;
import hudson.model.Action;
import hudson.model.Run;
import jenkins.model.RunAction2;
import org.kohsuke.accmod.Restricted;
import org.kohsuke.accmod.restrictions.NoExternalUse;

import javax.annotation.CheckForNull;

/**
* A build action to generate JDepend HTML reports
* @author cflewis
*
*/
public class JDependBuildAction implements Action
public class JDependBuildAction implements RunAction2
{
public final AbstractBuild<?, ?> build;
private final JDependParser jDependParser;
private String htmlReport;

public JDependBuildAction(AbstractBuild<?, ?> build, JDependParser jDependParser)
private transient Run<?,?> owner;

public JDependBuildAction(JDependParser jDependParser) {
this(null, jDependParser);
}

/**
* @deprecated Use {@link #JDependBuildAction(JDependParser)}
*/
@Deprecated
public JDependBuildAction(@CheckForNull AbstractBuild<?, ?> build, JDependParser jDependParser)
{
super();
this.build = build;
this.jDependParser = jDependParser;
this.owner = build;
JDependReporter r = new JDependReporter(jDependParser);

try {
Expand Down Expand Up @@ -61,7 +73,7 @@ public String getUrlName() {

/**
* Get the HTML string of the JDepend report.
* This report is HTML tidied, and had the <html><body> tags
* This report is HTML tidied, and had the {@code <html><body>} tags
* and such cruft removed.
*
* @return JDepend HTML report
Expand All @@ -79,7 +91,29 @@ public String getJDependHtml() {
return htmlReport;
}

/**
* Gets current parser.
* Not persisted over the restart.
* @return Always {@code null}
*/
@Deprecated
@CheckForNull
public JDependParser getJDependParser() {
return jDependParser;
return null;
}

@Override
public void onAttached(Run<?, ?> r) {
this.owner = r;
}

@Override
public void onLoad(Run<?, ?> r) {
this.owner = r;
}

@Restricted(NoExternalUse.class)
public Run<?, ?> getOwner() {
return owner;
}
}
1 change: 0 additions & 1 deletion src/main/java/hudson/plugins/jdepend/JDependParser.java
Expand Up @@ -39,7 +39,6 @@ public JDependParser(File xmlFile) throws ParserConfigurationException,
*
* This would work better if it cached the result.
*
* @param packages
* @return The total number of classes parsed.
*/
protected String getTotalClasses()
Expand Down
4 changes: 2 additions & 2 deletions src/main/java/hudson/plugins/jdepend/JDependRecorder.java
Expand Up @@ -154,7 +154,7 @@ protected boolean generateJDependReport(AbstractBuild<?, ?> build,
!configuredJDependFile.matches("(\\s)?")) {
p = getConfiguredParser(build, configuredJDependFile);

build.getActions().add(new JDependBuildAction(build, p));
build.addAction(new JDependBuildAction(p));
return true;
}

Expand Down Expand Up @@ -194,7 +194,7 @@ protected boolean generateJDependReport(AbstractBuild<?, ?> build,
log("Couldn't generate JDepend file " + e);
}

build.getActions().add(new JDependBuildAction(build, p));
build.addAction(new JDependBuildAction(p));

/**
* Attempt to delete the temp files. If the source JDepend worked on
Expand Down
@@ -1,3 +1,4 @@
<?jelly escape-by-default='true'?>
<j:jelly xmlns:j="jelly:core" xmlns:st="jelly:stapler" xmlns:d="jelly:define" xmlns:l="/lib/layout" xmlns:t="/lib/hudson" xmlns:f="/lib/form" xmlns:i="jelly:fmt" xmlns:local="local">

<l:layout>
Expand Down Expand Up @@ -25,10 +26,10 @@
}
</style>
</l:header>
<st:include it="${it.build}" page="sidepanel.jelly" />
<st:include it="${it.owner}" page="sidepanel.jelly" />

<l:main-panel>
${it.getJDependHtml()}
<j:out value="${it.getJDependHtml()}"/>
</l:main-panel>
</l:layout>
</j:jelly>
@@ -1,9 +1,10 @@
<?jelly escape-by-default='true'?>
<j:jelly xmlns:j="jelly:core" xmlns:st="jelly:stapler" xmlns:d="jelly:define" xmlns:l="/lib/layout" xmlns:t="/lib/hudson" xmlns:f="/lib/form" xmlns:i="jelly:fmt" xmlns:local="local">
<l:layout>
<st:include it="${it.project}" page="sidepanel.jelly" />

<l:main-panel>
${it.getJDependHtml()}
<j:out value="${it.getJDependHtml()}"/>
</l:main-panel>
</l:layout>
</j:jelly>
@@ -1,3 +1,4 @@
<?jelly escape-by-default='true'?>
<j:jelly xmlns:j="jelly:core" xmlns:st="jelly:stapler" xmlns:d="jelly:define" xmlns:l="/lib/layout" xmlns:t="/lib/hudson" xmlns:f="/lib/form">
<!--
This jelly script is used for per-project configuration.
Expand Down
1 change: 1 addition & 0 deletions src/main/resources/index.jelly
@@ -1,3 +1,4 @@
<?jelly escape-by-default='true'?>
<div>
This is a plugin that runs JDepend reports on builds.
</div>

0 comments on commit afcf6bf

Please sign in to comment.