diff --git a/core/src/main/java/hudson/tools/ToolDescriptor.java b/core/src/main/java/hudson/tools/ToolDescriptor.java index 2ae35c9fb01e196f62b240f976a12680e8d19dbd..2c6c1fdc14e36f6c75a8fcf4498b436ec1210de4 100644 --- a/core/src/main/java/hudson/tools/ToolDescriptor.java +++ b/core/src/main/java/hudson/tools/ToolDescriptor.java @@ -29,11 +29,14 @@ import hudson.model.Describable; import hudson.tasks.BuildStep; /** + * {@link Descriptor} for {@link ToolInstallation}. + * * @author huybrechts + * @since 1.286 */ public abstract class ToolDescriptor extends Descriptor { - T[] installations; + private T[] installations; public T[] getInstallations() { return installations; @@ -42,6 +45,4 @@ public abstract class ToolDescriptor extends Descrip public void setInstallations(T[] installations) { this.installations = installations; } - - public abstract String getDisplayName(); } diff --git a/core/src/main/java/hudson/tools/ToolInstallation.java b/core/src/main/java/hudson/tools/ToolInstallation.java index 0ce2981e53919d827525db0d5a72b013bc63df8e..12df9783707d7b3a521a4ddfa24c96a08dfb384f 100644 --- a/core/src/main/java/hudson/tools/ToolInstallation.java +++ b/core/src/main/java/hudson/tools/ToolInstallation.java @@ -27,15 +27,38 @@ package hudson.tools; import hudson.model.Describable; import hudson.model.Descriptor; import hudson.model.Hudson; +import hudson.model.JDK; import hudson.DescriptorExtensionList; +import hudson.ExtensionPoint; +import hudson.Extension; import hudson.tasks.BuildWrapper; import java.io.Serializable; /** + * Formalization of a tool installed in nodes used for builds + * (examples include things like JDKs, Ants, Mavens, and Groovys) + * + *

+ * You can define such a concept in your plugin entirely on your own, without extending from + * this class, but choosing this class as a base class has several benefits: + * + *

    + *
  • Hudson allows admins to specify different locations for tools on some slaves. + * For example, JDK on the master might be on /usr/local/java but on a Windows slave + * it could be at c:\Program Files\Java + *
  • Hudson can verify the existence of tools and provide warnings and diagnostics for + * admins. (TBD) + *
  • Hudson can perform automatic installations for users. (TBD) + *
+ * + *

+ * To contribute an extension point, put {@link Extension} on your {@link ToolDescriptor} class. + * * @author huybrechts + * @since 1.286 */ -public abstract class ToolInstallation implements Serializable, Describable { +public abstract class ToolInstallation implements Serializable, Describable, ExtensionPoint { private final String name; private final String home; @@ -45,20 +68,34 @@ public abstract class ToolInstallation implements Serializable, Describable getDescriptor() { return (ToolDescriptor) Hudson.getInstance().getDescriptor(getClass()); } + /** + * Returns all the registered {@link ToolDescriptor}s. + */ public static DescriptorExtensionList> all() { // use getDescriptorList and not getExtensionList to pick up legacy instances return Hudson.getInstance().getDescriptorList(ToolInstallation.class); } + + private static final long serialVersionUID = 1L; } diff --git a/core/src/main/java/hudson/tools/ToolLocationNodeProperty.java b/core/src/main/java/hudson/tools/ToolLocationNodeProperty.java index 111860493c507f7b215394afe5c085f046cb98a2..fe374ed0006728f5c92588e5873d1c2beb813a53 100644 --- a/core/src/main/java/hudson/tools/ToolLocationNodeProperty.java +++ b/core/src/main/java/hudson/tools/ToolLocationNodeProperty.java @@ -24,25 +24,24 @@ package hudson.tools; -import hudson.model.Node; -import hudson.model.Hudson; +import hudson.DescriptorExtensionList; +import hudson.Extension; import hudson.model.Descriptor; +import hudson.model.Hudson; +import hudson.model.Node; import hudson.slaves.NodeProperty; import hudson.slaves.NodePropertyDescriptor; -import hudson.tasks.Ant; -import hudson.DescriptorExtensionList; -import hudson.Extension; - -import java.util.*; -import java.util.concurrent.ConcurrentHashMap; - import org.kohsuke.stapler.DataBoundConstructor; -import com.thoughtworks.xstream.converters.Converter; -import com.thoughtworks.xstream.converters.MarshallingContext; -import com.thoughtworks.xstream.converters.UnmarshallingContext; -import com.thoughtworks.xstream.io.HierarchicalStreamWriter; -import com.thoughtworks.xstream.io.HierarchicalStreamReader; +import java.util.Arrays; +import java.util.Collections; +import java.util.List; + +/** + * {@link NodeProperty} that allows users to specify different locations for {@link ToolInstallation}s. + * + * @since 1.286 + */ public class ToolLocationNodeProperty extends NodeProperty { private final List locations; @@ -85,7 +84,7 @@ public class ToolLocationNodeProperty extends NodeProperty { return "Tool Locations"; } - public synchronized DescriptorExtensionList> getToolDescriptors() { + public synchronized DescriptorExtensionList> getToolDescriptors() { return ToolInstallation.all(); }