Permalink
Browse files

Merge pull request #2 from oleg-nenashev/JENKINS-49586

[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 afcf6bfd27770e813c279927c6020c1fc8f1e071
@@ -0,0 +1,2 @@
// Build the plugin using https://github.com/jenkins-infra/pipeline-library
buildPlugin(jenkinsVersions: [null, '2.104'])
41 pom.xml
@@ -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>
@@ -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>
@@ -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>
@@ -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>
@@ -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>

@@ -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 {
@@ -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
@@ -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;
}
}
@@ -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()
@@ -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;
}

@@ -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
@@ -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>
@@ -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.
@@ -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.