From 09c6316e75edea51bfdecd525afbf8d77be2fc16 Mon Sep 17 00:00:00 2001 From: kohsuke Date: Sun, 8 Apr 2007 02:10:13 +0000 Subject: [PATCH] added hyperlinking to plugin details. git-svn-id: https://hudson.dev.java.net/svn/hudson/trunk/hudson/main@2934 71c3de6d-444a-0410-be80-ed276b4c234a --- core/src/main/java/hudson/Functions.java | 5 +++ .../main/java/hudson/maven/ExecutedMojo.java | 42 +++++++++++++++++++ 2 files changed, 47 insertions(+) diff --git a/core/src/main/java/hudson/Functions.java b/core/src/main/java/hudson/Functions.java index ea96ae576d..30e9b075a2 100644 --- a/core/src/main/java/hudson/Functions.java +++ b/core/src/main/java/hudson/Functions.java @@ -9,6 +9,7 @@ import hudson.model.Items; import hudson.model.JobPropertyDescriptor; import hudson.model.Job; import hudson.model.Action; +import hudson.maven.ExecutedMojo; import org.kohsuke.stapler.Ancestor; import org.kohsuke.stapler.StaplerRequest; import org.kohsuke.stapler.StaplerResponse; @@ -375,4 +376,8 @@ public class Functions { if(o==null) return 0; return ASTSizeFunction.sizeOf(o); } + + public static ExecutedMojo.Cache createExecutedMojoCache() { + return new ExecutedMojo.Cache(); + } } diff --git a/core/src/main/java/hudson/maven/ExecutedMojo.java b/core/src/main/java/hudson/maven/ExecutedMojo.java index 00062d3759..ea941e1b64 100644 --- a/core/src/main/java/hudson/maven/ExecutedMojo.java +++ b/core/src/main/java/hudson/maven/ExecutedMojo.java @@ -1,13 +1,17 @@ package hudson.maven; import hudson.Util; +import hudson.model.Hudson; import hudson.remoting.Which; import org.apache.maven.plugin.descriptor.MojoDescriptor; import org.apache.maven.plugin.descriptor.PluginDescriptor; +import org.kohsuke.stapler.Stapler; import java.io.FileInputStream; import java.io.IOException; import java.io.Serializable; +import java.util.Map; +import java.util.HashMap; /** * Persisted record of mojo execution. @@ -80,4 +84,42 @@ public final class ExecutedMojo implements Serializable { if(executionId==null) return "-"; else return executionId; } + + /** + * Returns a hyperlink for the plugin name if there's one. + * Otherwise null. + */ + public String getPluginLink(Cache c) { + MavenModule m = c.get(this); + if(m!=null) + return Stapler.getCurrentRequest().getContextPath()+m.getUrl(); + if(groupId.equals("org.apache.maven.plugins")) + return "http://maven.apache.org/plugins/"+artifactId+'/'; + return null; + } + + public String getGoalLink(Cache c) { + if(groupId.equals("org.apache.maven.plugins")) + return "http://maven.apache.org/plugins/"+artifactId+'/'+goal+"-mojo.html"; + return null; + } + + /** + * Used during the HTML rendering to cache the index. + */ + public static final class Cache { + /** + * All maven modules in this Hudson by their names. + */ + public final Map modules = new HashMap(); + + public Cache() { + for( MavenModule m : Hudson.getInstance().getAllItems(MavenModule.class)) + modules.put(m.getModuleName(),m); + } + + public MavenModule get(ExecutedMojo mojo) { + return modules.get(new ModuleName(mojo.groupId,mojo.artifactId)); + } + } } -- GitLab