提交 2f7dae63 编写于 作者: O Olivier Lamy

fix link to javadoc in maven modules, archiving test javadoc test too , still...

fix link to javadoc in maven modules, archiving test javadoc test too , still need to display link to test javadoc
上级 f5fbc56b
...@@ -6,6 +6,7 @@ work ...@@ -6,6 +6,7 @@ work
*.iws *.iws
*.ipr *.ipr
.idea .idea
out
# eclipse project file # eclipse project file
.settings .settings
......
...@@ -133,14 +133,16 @@ public class JavadocArchiver extends Recorder { ...@@ -133,14 +133,16 @@ public class JavadocArchiver extends Recorder {
} }
public String getDisplayName() { public String getDisplayName() {
if (new File(dir(), "help-doc.html").exists()) File dir = dir();
if (dir != null && new File(dir, "help-doc.html").exists())
return Messages.JavadocArchiver_DisplayName_Javadoc(); return Messages.JavadocArchiver_DisplayName_Javadoc();
else else
return Messages.JavadocArchiver_DisplayName_Generic(); return Messages.JavadocArchiver_DisplayName_Generic();
} }
public String getIconFileName() { public String getIconFileName() {
if(dir().exists()) File dir = dir();
if(dir != null && dir.exists())
return "help.gif"; return "help.gif";
else else
// hide it since we don't have javadoc yet. // hide it since we don't have javadoc yet.
......
...@@ -437,4 +437,5 @@ public class RedeployPublisher extends Recorder { ...@@ -437,4 +437,5 @@ public class RedeployPublisher extends Recorder {
// noop // noop
} }
} }
} }
...@@ -33,17 +33,17 @@ import hudson.maven.MavenReporterDescriptor; ...@@ -33,17 +33,17 @@ import hudson.maven.MavenReporterDescriptor;
import hudson.maven.MojoInfo; import hudson.maven.MojoInfo;
import hudson.maven.MavenModuleSet; import hudson.maven.MavenModuleSet;
import hudson.maven.MavenReportInfo; import hudson.maven.MavenReportInfo;
import hudson.model.Action; import hudson.model.*;
import hudson.model.BuildListener;
import hudson.model.Result;
import hudson.tasks.JavadocArchiver.JavadocAction; import hudson.tasks.JavadocArchiver.JavadocAction;
import org.apache.maven.project.MavenProject; import org.apache.maven.project.MavenProject;
import org.codehaus.plexus.component.configurator.ComponentConfigurationException; import org.codehaus.plexus.component.configurator.ComponentConfigurationException;
import java.io.File; import java.io.File;
import java.io.IOException; import java.io.IOException;
import java.util.ArrayList;
import java.util.Collection; import java.util.Collection;
import java.util.Collections; import java.util.Collections;
import java.util.List;
/** /**
* Records the javadoc and archives it. * Records the javadoc and archives it.
...@@ -51,13 +51,24 @@ import java.util.Collections; ...@@ -51,13 +51,24 @@ import java.util.Collections;
* @author Kohsuke Kawaguchi * @author Kohsuke Kawaguchi
*/ */
public class MavenJavadocArchiver extends MavenReporter { public class MavenJavadocArchiver extends MavenReporter {
private boolean aggregated = false;
private boolean testJavadoc = false;
private FilePath target;
private FilePath targetTestJavadoc;
public boolean postExecute(MavenBuildProxy build, MavenProject pom, MojoInfo mojo, BuildListener listener, Throwable error) throws InterruptedException, IOException { public boolean postExecute(MavenBuildProxy build, MavenProject pom, MojoInfo mojo, BuildListener listener, Throwable error) throws InterruptedException, IOException {
if(!mojo.is("org.apache.maven.plugins","maven-javadoc-plugin","javadoc") if(!mojo.is("org.apache.maven.plugins","maven-javadoc-plugin","javadoc")
&& !mojo.is("org.apache.maven.plugins","maven-javadoc-plugin","aggregate")) && !mojo.is("org.apache.maven.plugins","maven-javadoc-plugin","aggregate")
&& !mojo.is("org.apache.maven.plugins","maven-javadoc-plugin","test-javadoc")
&& !mojo.is("org.apache.maven.plugins","maven-javadoc-plugin","test-aggregate"))
return true; return true;
File destDir; File destDir;
boolean aggregated;
try { try {
aggregated = mojo.getConfigurationValue("aggregate",Boolean.class) || mojo.getGoal().equals("aggregate"); aggregated = mojo.getConfigurationValue("aggregate",Boolean.class) || mojo.getGoal().equals("aggregate");
if(aggregated && !pom.isExecutionRoot()) if(aggregated && !pom.isExecutionRoot())
...@@ -73,21 +84,25 @@ public class MavenJavadocArchiver extends MavenReporter { ...@@ -73,21 +84,25 @@ public class MavenJavadocArchiver extends MavenReporter {
} }
if(destDir.exists()) { if(destDir.exists()) {
testJavadoc = "test-javadoc".equals(mojo.getGoal());
// javadoc:javadoc just skips itself when the current project is not a java project // javadoc:javadoc just skips itself when the current project is not a java project
FilePath target; ;
if(aggregated) { if(aggregated) {
// store at MavenModuleSet level. // store at MavenModuleSet level.
listener.getLogger().println("[JENKINS] Archiving aggregated javadoc"); listener.getLogger().println("[JENKINS] Archiving aggregated javadoc");
target = build.getModuleSetRootDir(); target = build.getModuleSetRootDir();
} else { } else {
listener.getLogger().println("[JENKINS] Archiving javadoc");
listener.getLogger().println("[JENKINS] Archiving "
+ (!testJavadoc? "javadoc" : "test-javadoc"));
target = build.getProjectRootDir(); target = build.getProjectRootDir();
} }
target = target.child("javadoc"); target = target.child("javadoc");
if (testJavadoc) targetTestJavadoc = target.child("test-javadoc");
try { try {
new FilePath(destDir).copyRecursiveTo("**/*",target); new FilePath(destDir).copyRecursiveTo("**/*",testJavadoc ? targetTestJavadoc : target);
} catch (IOException e) { } catch (IOException e) {
Util.displayIOException(e,listener); Util.displayIOException(e,listener);
e.printStackTrace(listener.fatalError(Messages.MavenJavadocArchiver_FailedToCopy(destDir,target))); e.printStackTrace(listener.fatalError(Messages.MavenJavadocArchiver_FailedToCopy(destDir,target)));
...@@ -110,11 +125,49 @@ public class MavenJavadocArchiver extends MavenReporter { ...@@ -110,11 +125,49 @@ public class MavenJavadocArchiver extends MavenReporter {
} }
public Collection<? extends Action> getProjectActions(MavenModule project) { public Collection<? extends Action> getProjectActions(MavenModule project) {
return Collections.singleton(new JavadocAction(project)); // TODO test javadoc too
List actions = new ArrayList();
actions.add((new MavenJavadocAction(project,this.testJavadoc,this.target,this.targetTestJavadoc)));
// adding action for test javadoc link display
if (testJavadoc) actions.add((new MavenJavadocAction(project,this.testJavadoc,this.target,this.targetTestJavadoc)));
return actions;
} }
public Action getAggregatedProjectAction(MavenModuleSet project) { public Action getAggregatedProjectAction(MavenModuleSet project) {
return new JavadocAction(project); // TODO javadoc test too
return new MavenJavadocAction(project,this.testJavadoc,this.target,this.targetTestJavadoc);
}
public static class MavenJavadocAction extends JavadocAction {
private final AbstractItem abstractItem;
private final boolean testJavadoc;
private final FilePath target;
private final FilePath targetTestJavadoc;
public MavenJavadocAction(AbstractItem project, boolean testJavadoc,FilePath target, FilePath targetTestJavadoc) {
super(project);
this.abstractItem = project;
this.testJavadoc = testJavadoc;
this.target = target;
this.targetTestJavadoc = targetTestJavadoc;
}
protected String getTitle() {
return abstractItem.getDisplayName()+ (!testJavadoc ? " javadoc": "test javadoc");
}
public String getUrlName() {
return !testJavadoc ? " javadoc": "test javadoc";
}
protected File dir() {
if (testJavadoc) {
return targetTestJavadoc == null ? null : new File(target.getRemote());
}
return target == null ? null : new File(target.getRemote());
}
} }
@Extension @Extension
......
...@@ -31,6 +31,7 @@ MavenArtifactArchiver.FailedToInstallToMaster=Failed to install artifact to the ...@@ -31,6 +31,7 @@ MavenArtifactArchiver.FailedToInstallToMaster=Failed to install artifact to the
MavenFingerprinter.DisplayName=Record fingerprints MavenFingerprinter.DisplayName=Record fingerprints
MavenJavadocArchiver.DisplayName=Publish javadoc MavenJavadocArchiver.DisplayName=Publish javadoc
MavenTestJavadocArchiver.DisplayName=Publish Test javadoc
MavenJavadocArchiver.FailedToCopy=Unable to copy Javadoc from {0} to {1} MavenJavadocArchiver.FailedToCopy=Unable to copy Javadoc from {0} to {1}
MavenJavadocArchiver.NoDestDir=Unable to obtain the destDir from javadoc mojo MavenJavadocArchiver.NoDestDir=Unable to obtain the destDir from javadoc mojo
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册