- * If you don't want fields to be persisted, use transient.
- */
- public static String PARAMETERNAME_PATH_TO_MSBUILD = "pathToMsBuild";
- private static String DEFAULT_PATH_TO_MSBUILD = "msbuild.exe";
- private String pathToMsBuild;
-
+
+ @CopyOnWrite
+ private volatile MsBuildInstallation[] installations = new MsBuildInstallation[0];
+
DescriptorImpl() {
super(MsBuildBuilder.class);
- load();
- if(pathToMsBuild==null || pathToMsBuild.length()==0){
- pathToMsBuild = DEFAULT_PATH_TO_MSBUILD;
- save();
- }
+ load();
}
/**
@@ -160,33 +172,14 @@
@Override
public boolean configure(StaplerRequest req) throws FormException{
- // to persist global configuration information,
- // set that to properties and call save().
- pathToMsBuild = req.getParameter("descriptor."+PARAMETERNAME_PATH_TO_MSBUILD);
- if(pathToMsBuild == null || pathToMsBuild.length()==0){
- pathToMsBuild = DEFAULT_PATH_TO_MSBUILD;
- }
- save();
- return true;
+ installations = req.bindParametersToList(MsBuildInstallation.class,"msbuild.").toArray(new MsBuildInstallation[0]);
+ save();
+ return true;
}
- /**
- * This method returns the path to the msbuild.exe file for executing msbuild
- */
- public String getPathToMsBuild() {
- return pathToMsBuild;
- }
+ public MsBuildInstallation[] getInstallations() {
+ return installations;
+ }
-
-
- @Override
- public Builder newInstance(StaplerRequest arg0, JSONObject arg1) throws FormException {
- String buildFile= arg1.getString("msBuildFile");
- String cmdLineArg= arg1.getString("cmdLineArgs");
- MsBuildBuilder builder = new MsBuildBuilder(buildFile,cmdLineArg);
-
- return builder;
- }
-
}
}
Index: main/java/hudson/plugins/msbuild/MsBuildInstallation.java
===================================================================
--- main/java/hudson/plugins/msbuild/MsBuildInstallation.java (revision 0)
+++ main/java/hudson/plugins/msbuild/MsBuildInstallation.java (revision 0)
@@ -0,0 +1,46 @@
+package hudson.plugins.msbuild;
+
+import org.kohsuke.stapler.DataBoundConstructor;
+
+import java.io.File;
+
+/**
+ * MsBuild installation.
+ *
+ * @author Gregory Boissinot - Zenika
+*/
+public final class MsBuildInstallation {
+
+
+ private final String name;
+ private final String pathToMsBuild;
+
+ @DataBoundConstructor
+ public MsBuildInstallation(String name, String pathToMsBuild) {
+ this.name = name;
+ this.pathToMsBuild = pathToMsBuild;
+ }
+
+
+ public String getPathToMsBuild() {
+ return pathToMsBuild;
+ }
+
+ /**
+ * Human readable display name.
+ */
+ public String getName() {
+ return name;
+ }
+
+ public File getExecutable() {
+ return new File(pathToMsBuild);
+ }
+
+ /**
+ * Returns true if the executable exists.
+ */
+ public boolean getExists() {
+ return getExecutable().exists();
+ }
+}
Index: main/resources/hudson/plugins/msbuild/MsBuildBuilder/config.jelly
===================================================================
--- main/resources/hudson/plugins/msbuild/MsBuildBuilder/config.jelly (revision 15920)
+++ main/resources/hudson/plugins/msbuild/MsBuildBuilder/config.jelly (working copy)
@@ -2,6 +2,16 @@
+
+
+
+
+