summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorHenrik Lynggaard Hansen2012-07-10 15:58:40 (EDT)
committer Henrik Lynggaard Hansen2012-07-10 15:58:40 (EDT)
commit5edebed43e29f9e00272d11dc847f4a05a77dba6 (patch)
treef2300080e1e203f5b88330fc133b431e3cab89c6
parent6b2a021db07f935226235132973fb64223c07d91 (diff)
downloadorg.eclipse.hudson.core-5edebed43e29f9e00272d11dc847f4a05a77dba6.zip
org.eclipse.hudson.core-5edebed43e29f9e00272d11dc847f4a05a77dba6.tar.gz
org.eclipse.hudson.core-5edebed43e29f9e00272d11dc847f4a05a77dba6.tar.bz2
reformat matrixrefs/changes/04/6704/1
Change-Id: I95f93af294906959a50b53bd5a58ec91084ef76e Signed-off-by: Henrik Lynggaard Hansen <henrik@hlyh.dk>
-rw-r--r--hudson-core/src/main/java/hudson/matrix/Axis.java114
-rw-r--r--hudson-core/src/main/java/hudson/matrix/AxisDescriptor.java13
-rw-r--r--hudson-core/src/main/java/hudson/matrix/AxisList.java36
-rw-r--r--hudson-core/src/main/java/hudson/matrix/Combination.java143
-rw-r--r--hudson-core/src/main/java/hudson/matrix/DefaultAxisDescriptor.java9
-rw-r--r--hudson-core/src/main/java/hudson/matrix/JDKAxis.java12
-rw-r--r--hudson-core/src/main/java/hudson/matrix/LabelAxis.java11
-rw-r--r--hudson-core/src/main/java/hudson/matrix/Layouter.java117
-rw-r--r--hudson-core/src/main/java/hudson/matrix/LinkedLogRotator.java26
-rw-r--r--hudson-core/src/main/java/hudson/matrix/MatrixAggregatable.java41
-rw-r--r--hudson-core/src/main/java/hudson/matrix/MatrixAggregator.java49
-rw-r--r--hudson-core/src/main/java/hudson/matrix/MatrixBuild.java24
-rw-r--r--hudson-core/src/main/java/hudson/matrix/MatrixConfiguration.java113
-rw-r--r--hudson-core/src/main/java/hudson/matrix/MatrixProject.java198
-rw-r--r--hudson-core/src/main/java/hudson/matrix/MatrixRun.java68
-rw-r--r--hudson-core/src/main/java/hudson/matrix/TextAxis.java6
-rw-r--r--hudson-core/src/main/java/hudson/matrix/package.html4
17 files changed, 518 insertions, 466 deletions
diff --git a/hudson-core/src/main/java/hudson/matrix/Axis.java b/hudson-core/src/main/java/hudson/matrix/Axis.java
index 4f46026..3cdb1b0 100644
--- a/hudson-core/src/main/java/hudson/matrix/Axis.java
+++ b/hudson-core/src/main/java/hudson/matrix/Axis.java
@@ -7,10 +7,10 @@
* which accompanies this distribution, and is available at
* http://www.eclipse.org/legal/epl-v10.html
*
- * Contributors:
-*
-* Kohsuke Kawaguchi
- *
+ * Contributors:
+ *
+ * Kohsuke Kawaguchi
+ *
*
*******************************************************************************/
@@ -37,29 +37,25 @@ import java.util.Map;
/**
* Configuration axis.
*
- * <p>
- * This class represents a single dimension of the configuration matrix.
- * For example, the JAX-WS RI test configuration might include
- * one axis "container={glassfish,tomcat,jetty}" and another axis
+ * <p> This class represents a single dimension of the configuration matrix. For
+ * example, the JAX-WS RI test configuration might include one axis
+ * "container={glassfish,tomcat,jetty}" and another axis
* "stax={sjsxp,woodstox}", and so on.
*
* @author Kohsuke Kawaguchi
*/
public class Axis extends AbstractDescribableImpl<Axis> implements Comparable<Axis>, Iterable<String>, ExtensionPoint {
+
/**
- * Name of this axis.
- * Used as a variable name.
+ * Name of this axis. Used as a variable name.
*
- * @deprecated as of 1.373
- * Use {@link #getName()}
+ * @deprecated as of 1.373 Use {@link #getName()}
*/
public final String name;
-
/**
* Possible values for this axis.
*
- * @deprecated as of 1.373
- * Use {@link #getValues()}
+ * @deprecated as of 1.373 Use {@link #getValues()}
*/
//TODO: review and check whether we can do it private
public final List<String> values;
@@ -67,12 +63,13 @@ public class Axis extends AbstractDescribableImpl<Axis> implements Comparable<Ax
public Axis(String name, List<String> values) {
this.name = name;
this.values = new ArrayList<String>(values);
- if(values.isEmpty())
+ if (values.isEmpty()) {
throw new IllegalArgumentException(); // bug in the code
+ }
}
public Axis(String name, String... values) {
- this(name,Arrays.asList(values));
+ this(name, Arrays.asList(values));
}
/**
@@ -87,11 +84,11 @@ public class Axis extends AbstractDescribableImpl<Axis> implements Comparable<Ax
}
/**
- * Returns true if this axis is a system-reserved axis
- * that <strike>has</strike> used to have af special treatment.
+ * Returns true if this axis is a system-reserved axis that
+ * <strike>has</strike> used to have af special treatment.
*
- * @deprecated as of 1.373
- * System vs user difference are generalized into extension point.
+ * @deprecated as of 1.373 System vs user difference are generalized into
+ * extension point.
*/
public boolean isSystem() {
return false;
@@ -117,16 +114,15 @@ public class Axis extends AbstractDescribableImpl<Axis> implements Comparable<Ax
}
/**
- * Axis is fully ordered so that we can convert between a list of axis
- * and a string unambiguously.
+ * Axis is fully ordered so that we can convert between a list of axis and a
+ * string unambiguously.
*/
public int compareTo(Axis that) {
return this.name.compareTo(that.name);
}
/**
- * Name of this axis.
- * Used as a variable name.
+ * Name of this axis. Used as a variable name.
*/
public String getName() {
return name;
@@ -141,77 +137,84 @@ public class Axis extends AbstractDescribableImpl<Axis> implements Comparable<Ax
@Override
public AxisDescriptor getDescriptor() {
- return (AxisDescriptor)super.getDescriptor();
+ return (AxisDescriptor) super.getDescriptor();
}
@Override
public String toString() {
- return new StringBuilder().append(name).append("={").append(Util.join(values,",")).append('}').toString();
+ return new StringBuilder().append(name).append("={").append(Util.join(values, ",")).append('}').toString();
}
/**
- * Used for generating the config UI.
- * If the axis is big and occupies a lot of space, use newline for separator
- * to display multi-line text.
+ * Used for generating the config UI. If the axis is big and occupies a lot
+ * of space, use newline for separator to display multi-line text.
*/
public String getValueString() {
- int len=0;
- for (String value : values)
+ int len = 0;
+ for (String value : values) {
len += value.length();
- char delim = len>30 ? '\n' : ' ';
+ }
+ char delim = len > 30 ? '\n' : ' ';
// Build string connected with delimiter, quoting as needed
- StringBuilder buf = new StringBuilder(len+values.size()*3);
- for (String value : values)
- buf.append(delim).append(QuotedStringTokenizer.quote(value,""));
+ StringBuilder buf = new StringBuilder(len + values.size() * 3);
+ for (String value : values) {
+ buf.append(delim).append(QuotedStringTokenizer.quote(value, ""));
+ }
return buf.substring(1);
}
/**
- * Parses the submitted form (where possible values are
- * presented as a list of checkboxes) and creates an axis
+ * Parses the submitted form (where possible values are presented as a list
+ * of checkboxes) and creates an axis
*/
public static Axis parsePrefixed(StaplerRequest req, String name) {
List<String> values = new ArrayList<String>();
- String prefix = name+'.';
+ String prefix = name + '.';
Enumeration e = req.getParameterNames();
while (e.hasMoreElements()) {
String paramName = (String) e.nextElement();
- if(paramName.startsWith(prefix))
+ if (paramName.startsWith(prefix)) {
values.add(paramName.substring(prefix.length()));
+ }
}
- if(values.isEmpty())
+ if (values.isEmpty()) {
return null;
- return new Axis(name,values);
+ }
+ return new Axis(name, values);
}
/**
- * Previously we used to persist {@link Axis}, but now those are divided into subtypes.
- * So upon deserialization, resolve to the proper type.
+ * Previously we used to persist {@link Axis}, but now those are divided
+ * into subtypes. So upon deserialization, resolve to the proper type.
*/
public Object readResolve() {
- if (getClass()!=Axis.class) return this;
+ if (getClass() != Axis.class) {
+ return this;
+ }
- if (getName().equals("jdk"))
+ if (getName().equals("jdk")) {
return new JDKAxis(getValues());
- if (getName().equals("label"))
- return new LabelAxis(getName(),getValues());
- return new TextAxis(getName(),getValues());
+ }
+ if (getName().equals("label")) {
+ return new LabelAxis(getName(), getValues());
+ }
+ return new TextAxis(getName(), getValues());
}
/**
* Returns all the registered {@link AxisDescriptor}s.
*/
- public static DescriptorExtensionList<Axis,AxisDescriptor> all() {
- return Hudson.getInstance().<Axis,AxisDescriptor>getDescriptorList(Axis.class);
+ public static DescriptorExtensionList<Axis, AxisDescriptor> all() {
+ return Hudson.getInstance().<Axis, AxisDescriptor>getDescriptorList(Axis.class);
}
/**
- * Converts the selected value (which is among {@link #values}) and adds that to the given map,
- * which serves as the build variables.
+ * Converts the selected value (which is among {@link #values}) and adds
+ * that to the given map, which serves as the build variables.
*/
- public void addBuildVariable(String value, Map<String,String> map) {
- map.put(name,value);
+ public void addBuildVariable(String value, Map<String, String> map) {
+ map.put(name, value);
}
@Override
@@ -243,4 +246,3 @@ public class Axis extends AbstractDescribableImpl<Axis> implements Comparable<Ax
return result;
}
}
-
diff --git a/hudson-core/src/main/java/hudson/matrix/AxisDescriptor.java b/hudson-core/src/main/java/hudson/matrix/AxisDescriptor.java
index 203bac9..52dd34a 100644
--- a/hudson-core/src/main/java/hudson/matrix/AxisDescriptor.java
+++ b/hudson-core/src/main/java/hudson/matrix/AxisDescriptor.java
@@ -7,10 +7,10 @@
* which accompanies this distribution, and is available at
* http://www.eclipse.org/legal/epl-v10.html
*
- * Contributors:
+ * Contributors:
+ *
+ *
*
- *
- *
*
*******************************************************************************/
@@ -29,6 +29,7 @@ import org.kohsuke.stapler.QueryParameter;
* @author Kohsuke Kawaguchi
*/
public abstract class AxisDescriptor extends Descriptor<Axis> {
+
protected AxisDescriptor(Class<? extends Axis> clazz) {
super(clazz);
}
@@ -37,7 +38,8 @@ public abstract class AxisDescriptor extends Descriptor<Axis> {
}
/**
- * Return false if the user shouldn't be able to create thie axis from the UI.
+ * Return false if the user shouldn't be able to create thie axis from the
+ * UI.
*/
public boolean isInstantiable() {
return true;
@@ -47,8 +49,9 @@ public abstract class AxisDescriptor extends Descriptor<Axis> {
* Makes sure that the given name is good as a axis name.
*/
public FormValidation doCheckName(@QueryParameter String value) {
- if(Util.fixEmpty(value)==null)
+ if (Util.fixEmpty(value) == null) {
return FormValidation.ok();
+ }
try {
Hudson.checkGoodName(value);
diff --git a/hudson-core/src/main/java/hudson/matrix/AxisList.java b/hudson-core/src/main/java/hudson/matrix/AxisList.java
index f0f4305..735111f 100644
--- a/hudson-core/src/main/java/hudson/matrix/AxisList.java
+++ b/hudson-core/src/main/java/hudson/matrix/AxisList.java
@@ -7,10 +7,10 @@
* which accompanies this distribution, and is available at
* http://www.eclipse.org/legal/epl-v10.html
*
- * Contributors:
+ * Contributors:
*
* Kohsuke Kawaguchi, Anton Kozak
- *
+ *
*
*******************************************************************************/
@@ -30,10 +30,11 @@ import org.apache.commons.collections.ListUtils;
/**
* List of {@link Axis}.
- *
+ *
* @author Kohsuke Kawaguchi
*/
public class AxisList extends ArrayList<Axis> {
+
public AxisList() {
}
@@ -47,22 +48,24 @@ public class AxisList extends ArrayList<Axis> {
public Axis find(String name) {
for (Axis a : this) {
- if(a.name.equals(name))
+ if (a.name.equals(name)) {
return a;
+ }
}
return null;
}
/**
- * Creates a subset of the list that only contains the type assignable to the specified type.
+ * Creates a subset of the list that only contains the type assignable to
+ * the specified type.
*/
public AxisList subList(Class<? extends Axis> subType) {
- return new AxisList(Util.filter(this,subType));
+ return new AxisList(Util.filter(this, subType));
}
@Override
public boolean add(Axis axis) {
- return axis!=null && super.add(axis);
+ return axis != null && super.add(axis);
}
@Override
@@ -91,10 +94,12 @@ public class AxisList extends ArrayList<Axis> {
*/
public Iterable<Combination> list() {
final int[] base = new int[size()];
- if (base.length==0) return Collections.<Combination>emptyList();
+ if (base.length == 0) {
+ return Collections.<Combination>emptyList();
+ }
int b = 1;
- for( int i=size()-1; i>=0; i-- ) {
+ for (int i = size() - 1; i >= 0; i--) {
base[i] = b;
b *= get(i).size();
}
@@ -107,18 +112,18 @@ public class AxisList extends ArrayList<Axis> {
private int counter = 0;
public boolean hasNext() {
- return counter<total;
+ return counter < total;
}
public Combination next() {
String[] data = new String[size()];
int x = counter++;
- for( int i=0; i<data.length; i++) {
- data[i] = get(i).value(x/base[i]);
+ for (int i = 0; i < data.length; i++) {
+ data[i] = get(i).value(x / base[i]);
x %= base[i];
}
- assert x==0;
- return new Combination(AxisList.this,data);
+ assert x == 0;
+ return new Combination(AxisList.this, data);
}
public void remove() {
@@ -133,13 +138,14 @@ public class AxisList extends ArrayList<Axis> {
* {@link Converter} implementation for XStream.
*/
public static final class ConverterImpl extends RobustCollectionConverter {
+
public ConverterImpl(XStream xs) {
super(xs);
}
@Override
public boolean canConvert(Class type) {
- return type==AxisList.class;
+ return type == AxisList.class;
}
@Override
diff --git a/hudson-core/src/main/java/hudson/matrix/Combination.java b/hudson-core/src/main/java/hudson/matrix/Combination.java
index 685ca0c..bad88df 100644
--- a/hudson-core/src/main/java/hudson/matrix/Combination.java
+++ b/hudson-core/src/main/java/hudson/matrix/Combination.java
@@ -7,10 +7,10 @@
* which accompanies this distribution, and is available at
* http://www.eclipse.org/legal/epl-v10.html
*
- * Contributors:
+ * Contributors:
*
* Kohsuke Kawaguchi, Winston Prakash
- *
+ *
*******************************************************************************/
package hudson.matrix;
@@ -32,31 +32,32 @@ import java.util.StringTokenizer;
import java.util.TreeMap;
import static java.lang.Boolean.TRUE;
-
/**
* A particular combination of {@link Axis} values.
*
- * For example, when axes are "x={1,2},y={3,4}", then
- * [x=1,y=3] is a combination (out of 4 possible combinations)
+ * For example, when axes are "x={1,2},y={3,4}", then [x=1,y=3] is a combination
+ * (out of 4 possible combinations)
*
* @author Kohsuke Kawaguchi
*/
-public final class Combination extends TreeMap<String,String> implements Comparable<Combination> {
+public final class Combination extends TreeMap<String, String> implements Comparable<Combination> {
protected static final String DELIM = ",";
public Combination(AxisList axisList, List<String> values) {
- for(int i=0; i<axisList.size(); i++)
- super.put(axisList.get(i).getName(),values.get(i));
+ for (int i = 0; i < axisList.size(); i++) {
+ super.put(axisList.get(i).getName(), values.get(i));
+ }
}
- public Combination(AxisList axisList,String... values) {
- this(axisList,Arrays.asList(values));
+ public Combination(AxisList axisList, String... values) {
+ this(axisList, Arrays.asList(values));
}
- public Combination(Map<String,String> keyValuePairs) {
- for (Map.Entry<String, String> e : keyValuePairs.entrySet())
- super.put(e.getKey(),e.getValue());
+ public Combination(Map<String, String> keyValuePairs) {
+ for (Map.Entry<String, String> e : keyValuePairs.entrySet()) {
+ super.put(e.getKey(), e.getValue());
+ }
}
public String get(Axis a) {
@@ -64,8 +65,8 @@ public final class Combination extends TreeMap<String,String> implements Compara
}
/**
- * Obtains the continuous unique index number of this {@link Combination}
- * in the given {@link AxisList}.
+ * Obtains the continuous unique index number of this {@link Combination} in
+ * the given {@link AxisList}.
*/
public int toIndex(AxisList axis) {
int r = 0;
@@ -77,15 +78,14 @@ public final class Combination extends TreeMap<String,String> implements Compara
}
/**
- * Obtains a number N such that "N%M==0" would create
- * a reasonable sparse matrix for integer M.
+ * Obtains a number N such that "N%M==0" would create a reasonable sparse
+ * matrix for integer M.
*
- * <p>
- * This is bit like {@link #toIndex(AxisList)}, but instead
- * of creating a continuous number (which often maps different
- * values of the same axis to the same index in modulo N residue ring,
- * we use a prime number P as the base. I think this guarantees the uniform
- * distribution in any N smaller than 2P (but proof, anyone?)
+ * <p> This is bit like {@link #toIndex(AxisList)}, but instead of creating
+ * a continuous number (which often maps different values of the same axis
+ * to the same index in modulo N residue ring, we use a prime number P as
+ * the base. I think this guarantees the uniform distribution in any N
+ * smaller than 2P (but proof, anyone?)
*/
private long toModuloIndex(AxisList axis) {
long r = 0;
@@ -95,16 +95,16 @@ public final class Combination extends TreeMap<String,String> implements Compara
}
return r;
}
-
+
/**
- * Evaluates the given Dynamic Language Script Expression with values bound from this combination.
- * <p>
- * For example, if this combination is a=X,b=Y, then expressions like <tt>a=="X"</tt> would evaluate to
- * true.
+ * Evaluates the given Dynamic Language Script Expression with values bound
+ * from this combination. <p> For example, if this combination is a=X,b=Y,
+ * then expressions like <tt>a=="X"</tt> would evaluate to true.
+ *
* @param axes
* @param expression
* @param scriptType
- * @return
+ * @return
*/
public boolean evalScriptExpression(AxisList axes, String expression) {
if (Util.fixEmptyAndTrim(expression) == null) {
@@ -132,19 +132,25 @@ public final class Combination extends TreeMap<String,String> implements Compara
}
public int compareTo(Combination that) {
- int d = this.size()-that.size();
- if(d!=0) return d;
+ int d = this.size() - that.size();
+ if (d != 0) {
+ return d;
+ }
- Iterator<Map.Entry<String,String>> itr = this.entrySet().iterator();
- Iterator<Map.Entry<String,String>> jtr = that.entrySet().iterator();
- while(itr.hasNext()) {
- Map.Entry<String,String> i = itr.next();
- Map.Entry<String,String> j = jtr.next();
+ Iterator<Map.Entry<String, String>> itr = this.entrySet().iterator();
+ Iterator<Map.Entry<String, String>> jtr = that.entrySet().iterator();
+ while (itr.hasNext()) {
+ Map.Entry<String, String> i = itr.next();
+ Map.Entry<String, String> j = jtr.next();
d = i.getKey().compareTo(j.getKey());
- if(d!=0) return d;
+ if (d != 0) {
+ return d;
+ }
d = i.getValue().compareTo(j.getValue());
- if(d!=0) return d;
+ if (d != 0) {
+ return d;
+ }
}
return 0;
}
@@ -153,15 +159,20 @@ public final class Combination extends TreeMap<String,String> implements Compara
* Works like {@link #toString()} but only include the given axes.
*/
public String toString(Collection<Axis> subset) {
- if(size()==1 && subset.size()==1)
+ if (size() == 1 && subset.size() == 1) {
return values().iterator().next();
+ }
StringBuilder buf = new StringBuilder();
for (Axis a : subset) {
- if(buf.length()>0) buf.append(',');
+ if (buf.length() > 0) {
+ buf.append(',');
+ }
buf.append(a.getName()).append('=').append(get(a));
}
- if(buf.length()==0) buf.append("default"); // special case to avoid 0-length name.
+ if (buf.length() == 0) {
+ buf.append("default"); // special case to avoid 0-length name.
+ }
return buf.toString();
}
@@ -170,8 +181,9 @@ public final class Combination extends TreeMap<String,String> implements Compara
*/
public List<String> values(Collection<? extends Axis> axes) {
List<String> r = new ArrayList<String>(axes.size());
- for (Axis a : axes)
+ for (Axis a : axes) {
r.add(get(a));
+ }
return r;
}
@@ -179,10 +191,8 @@ public final class Combination extends TreeMap<String,String> implements Compara
* Converts to the ID string representation:
* <tt>axisName=value,axisName=value,...</tt>
*
- * @param sep1
- * The separator between multiple axes.
- * @param sep2
- * The separator between axis name and value.
+ * @param sep1 The separator between multiple axes.
+ * @param sep2 The separator between axis name and value.
*/
public String toString(char sep1, char sep2) {
return toString(sep1, sep2, false);
@@ -222,7 +232,7 @@ public final class Combination extends TreeMap<String,String> implements Compara
@Override
public String toString() {
- return toString(',','=');
+ return toString(',', '=');
}
/**
@@ -236,17 +246,19 @@ public final class Combination extends TreeMap<String,String> implements Compara
* Reverse operation of {@link #toString()}.
*/
public static Combination fromString(String id) {
- if(id.equals("default"))
- return new Combination(Collections.<String,String>emptyMap());
+ if (id.equals("default")) {
+ return new Combination(Collections.<String, String>emptyMap());
+ }
- Map<String,String> m = new HashMap<String,String>();
+ Map<String, String> m = new HashMap<String, String>();
StringTokenizer tokens = new StringTokenizer(id, DELIM);
- while(tokens.hasMoreTokens()) {
+ while (tokens.hasMoreTokens()) {
String token = tokens.nextToken();
int idx = token.indexOf('=');
- if(idx<0)
- throw new IllegalArgumentException("Can't parse "+id);
- m.put(token.substring(0,idx),token.substring(idx+1));
+ if (idx < 0) {
+ throw new IllegalArgumentException("Can't parse " + id);
+ }
+ m.put(token.substring(0, idx), token.substring(idx + 1));
}
return new Combination(m);
}
@@ -254,18 +266,17 @@ public final class Combination extends TreeMap<String,String> implements Compara
/**
* Creates compact string representataion suitable for display purpose.
*
- * <p>
- * The string is made compact by looking for {@link Axis} whose values
+ * <p> The string is made compact by looking for {@link Axis} whose values
* are unique, and omit the axis name.
*/
public String toCompactString(AxisList axes) {
Set<String> nonUniqueAxes = new HashSet<String>();
- Map<String,Axis> axisByValue = new HashMap<String,Axis>();
+ Map<String, Axis> axisByValue = new HashMap<String, Axis>();
for (Axis a : axes) {
for (String v : a.getValues()) {
- Axis old = axisByValue.put(v,a);
- if(old!=null) {
+ Axis old = axisByValue.put(v, a);
+ if (old != null) {
// these two axes have colliding values
nonUniqueAxes.add(old.getName());
nonUniqueAxes.add(a.getName());
@@ -274,13 +285,18 @@ public final class Combination extends TreeMap<String,String> implements Compara
}
StringBuilder buf = new StringBuilder();
- for (Map.Entry<String,String> e : entrySet()) {
- if(buf.length()>0) buf.append(',');
- if(nonUniqueAxes.contains(e.getKey()))
+ for (Map.Entry<String, String> e : entrySet()) {
+ if (buf.length() > 0) {
+ buf.append(',');
+ }
+ if (nonUniqueAxes.contains(e.getKey())) {
buf.append(e.getKey()).append('=');
+ }
buf.append(e.getValue());
}
- if(buf.length()==0) buf.append("default"); // special case to avoid 0-length name.
+ if (buf.length() == 0) {
+ buf.append("default"); // special case to avoid 0-length name.
+ }
return buf.toString();
}
@@ -311,6 +327,7 @@ public final class Combination extends TreeMap<String,String> implements Compara
* @see Combination#evalScriptExpression(AxisList,String)
*/
public static final class BooleanCategory {
+
/**
* x -> y
*/
diff --git a/hudson-core/src/main/java/hudson/matrix/DefaultAxisDescriptor.java b/hudson-core/src/main/java/hudson/matrix/DefaultAxisDescriptor.java
index ae35b6f..85b73c3 100644
--- a/hudson-core/src/main/java/hudson/matrix/DefaultAxisDescriptor.java
+++ b/hudson-core/src/main/java/hudson/matrix/DefaultAxisDescriptor.java
@@ -7,10 +7,10 @@
* which accompanies this distribution, and is available at
* http://www.eclipse.org/legal/epl-v10.html
*
- * Contributors:
+ * Contributors:
+ *
+ *
*
- *
- *
*
*******************************************************************************/
@@ -25,6 +25,7 @@ import hudson.Extension;
*/
@Extension
public class DefaultAxisDescriptor extends AxisDescriptor {
+
public DefaultAxisDescriptor() {
super(Axis.class);
}
@@ -37,5 +38,5 @@ public class DefaultAxisDescriptor extends AxisDescriptor {
@Override
public boolean isInstantiable() {
return false;
- }
+ }
}
diff --git a/hudson-core/src/main/java/hudson/matrix/JDKAxis.java b/hudson-core/src/main/java/hudson/matrix/JDKAxis.java
index 066e77e..5c599bc 100644
--- a/hudson-core/src/main/java/hudson/matrix/JDKAxis.java
+++ b/hudson-core/src/main/java/hudson/matrix/JDKAxis.java
@@ -7,10 +7,10 @@
* which accompanies this distribution, and is available at
* http://www.eclipse.org/legal/epl-v10.html
*
- * Contributors:
+ * Contributors:
+ *
+ *
*
- *
- *
*
*******************************************************************************/
@@ -29,9 +29,10 @@ import java.util.List;
* @author Kohsuke Kawaguchi
*/
public class JDKAxis extends Axis {
+
/**
- * JDK axis was used to be stored as a plain "Axis" with the name "jdk",
- * so it cannot be configured by any other name.
+ * JDK axis was used to be stored as a plain "Axis" with the name "jdk", so
+ * it cannot be configured by any other name.
*/
public JDKAxis(List<String> values) {
super("jdk", values);
@@ -49,6 +50,7 @@ public class JDKAxis extends Axis {
@Extension
public static class DescriptorImpl extends AxisDescriptor {
+
@Override
public String getDisplayName() {
return Messages.JDKAxis_DisplayName();
diff --git a/hudson-core/src/main/java/hudson/matrix/LabelAxis.java b/hudson-core/src/main/java/hudson/matrix/LabelAxis.java
index 820c486..bd70e14 100644
--- a/hudson-core/src/main/java/hudson/matrix/LabelAxis.java
+++ b/hudson-core/src/main/java/hudson/matrix/LabelAxis.java
@@ -7,10 +7,10 @@
* which accompanies this distribution, and is available at
* http://www.eclipse.org/legal/epl-v10.html
*
- * Contributors:
+ * Contributors:
+ *
+ *
*
- *
- *
*
*******************************************************************************/
@@ -28,6 +28,7 @@ import java.util.List;
* @author Kohsuke Kawaguchi
*/
public class LabelAxis extends Axis {
+
@DataBoundConstructor
public LabelAxis(String name, List<String> values) {
super(name, values);
@@ -40,13 +41,15 @@ public class LabelAxis extends Axis {
@Extension
public static class DescriptorImpl extends AxisDescriptor {
+
@Override
public String getDisplayName() {
return Messages.LabelAxis_DisplayName();
}
/**
- * If there's no distributed build set up, it's pointless to provide this axis.
+ * If there's no distributed build set up, it's pointless to provide
+ * this axis.
*/
@Override
public boolean isInstantiable() {
diff --git a/hudson-core/src/main/java/hudson/matrix/Layouter.java b/hudson-core/src/main/java/hudson/matrix/Layouter.java
index 88b3433..f349c84 100644
--- a/hudson-core/src/main/java/hudson/matrix/Layouter.java
+++ b/hudson-core/src/main/java/hudson/matrix/Layouter.java
@@ -7,10 +7,10 @@
* which accompanies this distribution, and is available at
* http://www.eclipse.org/legal/epl-v10.html
*
- * Contributors:
-*
-* Kohsuke Kawaguchi
- *
+ * Contributors:
+ *
+ * Kohsuke Kawaguchi
+ *
*
*******************************************************************************/
@@ -25,21 +25,19 @@ import java.util.HashMap;
/**
* Used to assist thegeneration of config table.
*
- * <p>
- * {@link Axis Axes} are split into four groups.
- * {@link #x Ones that are displayed as columns},
+ * <p> {@link Axis Axes} are split into four groups. {@link #x Ones that are displayed as columns},
* {@link #y Ones that are displayed as rows},
- * {@link #z Ones that are listed as bullet items inside table cell},
- * and those which only have one value, and therefore doesn't show up
- * in the table.
+ * {@link #z Ones that are listed as bullet items inside table cell}, and those
+ * which only have one value, and therefore doesn't show up in the table.
*
- * <p>
- * Because of object reuse inside {@link Layouter}, this class is not thread-safe.
+ * <p> Because of object reuse inside {@link Layouter}, this class is not
+ * thread-safe.
*
* @author Kohsuke Kawaguchi
*/
public abstract class Layouter<T> {
- public final List<Axis> x,y,z;
+
+ public final List<Axis> x, y, z;
/**
* Axes that only have one value.
*/
@@ -49,7 +47,6 @@ public abstract class Layouter<T> {
*/
private int xSize, ySize, zSize;
-
public Layouter(List<Axis> x, List<Axis> y, List<Axis> z) {
this.x = x;
this.y = y;
@@ -67,44 +64,46 @@ public abstract class Layouter<T> {
List<Axis> nonTrivialAxes = new ArrayList<Axis>();
for (Axis a : axisList) {
- if(a.size()>1)
+ if (a.size() > 1) {
nonTrivialAxes.add(a);
- else
+ } else {
trivial.add(a);
+ }
}
- switch(nonTrivialAxes.size()) {
- case 0:
- break;
- case 1:
- z.add(nonTrivialAxes.get(0));
- break;
- case 2:
- // use the longer axis in Y
- Axis a = nonTrivialAxes.get(0);
- Axis b = nonTrivialAxes.get(1);
- x.add(a.size() > b.size() ? b : a);
- y.add(a.size() > b.size() ? a : b);
- break;
- default:
- // for size > 3, use x and y, and try to pack y more
- for( int i=0; i<nonTrivialAxes.size(); i++ )
- (i%3==1?x:y).add(nonTrivialAxes.get(i));
+ switch (nonTrivialAxes.size()) {
+ case 0:
+ break;
+ case 1:
+ z.add(nonTrivialAxes.get(0));
+ break;
+ case 2:
+ // use the longer axis in Y
+ Axis a = nonTrivialAxes.get(0);
+ Axis b = nonTrivialAxes.get(1);
+ x.add(a.size() > b.size() ? b : a);
+ y.add(a.size() > b.size() ? a : b);
+ break;
+ default:
+ // for size > 3, use x and y, and try to pack y more
+ for (int i = 0; i < nonTrivialAxes.size(); i++) {
+ (i % 3 == 1 ? x : y).add(nonTrivialAxes.get(i));
+ }
}
init();
}
private void init() {
- xSize = calc(x,-1);
- ySize = calc(y,-1);
- zSize = calc(z,-1);
+ xSize = calc(x, -1);
+ ySize = calc(y, -1);
+ zSize = calc(z, -1);
}
/**
* Computes the width of n-th X-axis.
*/
public int width(int n) {
- return calc(x,n);
+ return calc(x, n);
}
/**
@@ -112,8 +111,9 @@ public abstract class Layouter<T> {
*/
public int repeatX(int n) {
int w = 1;
- for( n--; n>=0; n-- )
+ for (n--; n >= 0; n--) {
w *= x.get(n).size();
+ }
return w;
}
@@ -121,25 +121,27 @@ public abstract class Layouter<T> {
* Computes the width of n-th Y-axis.
*/
public int height(int n) {
- return calc(y,n);
+ return calc(y, n);
}
private int calc(List<Axis> l, int n) {
int w = 1;
- for( n++ ; n<l.size(); n++ )
+ for (n++; n < l.size(); n++) {
w *= l.get(n).size();
+ }
return w;
}
/**
* Gets list of {@link Row}s to be displayed.
*
- * The {@link Row} object is reused, so every value
- * in collection returns the same object (but with different values.)
+ * The {@link Row} object is reused, so every value in collection returns
+ * the same object (but with different values.)
*/
public List<Row> getRows() {
return new AbstractList<Row>() {
final Row row = new Row();
+
public Row get(int index) {
row.index = index;
return row;
@@ -155,6 +157,7 @@ public abstract class Layouter<T> {
* Represents a row, which is a collection of {@link Column}s.
*/
public final class Row extends AbstractList<Column> {
+
private int index;
final Column col = new Column();
@@ -171,39 +174,41 @@ public abstract class Layouter<T> {
}
public String drawYHeader(int n) {
- int base = calc(y,n);
- if(index/base==(index-1)/base && index!=0) return null; // no need to draw a new value
-
+ int base = calc(y, n);
+ if (index / base == (index - 1) / base && index != 0) {
+ return null; // no need to draw a new value
+ }
Axis axis = y.get(n);
- return axis.value((index/base)%axis.values.size());
+ return axis.value((index / base) % axis.values.size());
}
}
protected abstract T getT(Combination c);
public final class Column extends AbstractList<T> {
+
/**
* Cell position.
*/
- private int xp,yp;
-
- private final Map<String,String> m = new HashMap<String,String>();
+ private int xp, yp;
+ private final Map<String, String> m = new HashMap<String, String>();
public T get(int zp) {
m.clear();
- buildMap(xp,x);
- buildMap(yp,y);
- buildMap(zp,z);
- for (Axis a : trivial)
- m.put(a.name,a.value(0));
+ buildMap(xp, x);
+ buildMap(yp, y);
+ buildMap(zp, z);
+ for (Axis a : trivial) {
+ m.put(a.name, a.value(0));
+ }
return getT(new Combination(m));
}
private void buildMap(int p, List<Axis> axes) {
int n = p;
- for( int i= axes.size()-1; i>=0; i-- ) {
+ for (int i = axes.size() - 1; i >= 0; i--) {
Axis a = axes.get(i);
- m.put(a.name, a.value(n%a.size()));
+ m.put(a.name, a.value(n % a.size()));
n /= a.size();
}
}
diff --git a/hudson-core/src/main/java/hudson/matrix/LinkedLogRotator.java b/hudson-core/src/main/java/hudson/matrix/LinkedLogRotator.java
index 812e1d7..74ec6bb 100644
--- a/hudson-core/src/main/java/hudson/matrix/LinkedLogRotator.java
+++ b/hudson-core/src/main/java/hudson/matrix/LinkedLogRotator.java
@@ -7,10 +7,10 @@
* which accompanies this distribution, and is available at
* http://www.eclipse.org/legal/epl-v10.html
*
- * Contributors:
+ * Contributors:
*
* Kohsuke Kawaguchi
- *
+ *
*
*******************************************************************************/
@@ -23,24 +23,22 @@ import hudson.util.RunList;
import java.io.IOException;
/**
- * {@link LogRotator} for {@link MatrixConfiguration},
- * which discards the builds if and only if it's discarded
- * in the parent.
+ * {@link LogRotator} for {@link MatrixConfiguration}, which discards the builds
+ * if and only if it's discarded in the parent.
*
- * <p>
- * Because of the serialization compatibility, we can't easily
- * refactor {@link LogRotator} into a contract and an implementation.
+ * <p> Because of the serialization compatibility, we can't easily refactor
+ * {@link LogRotator} into a contract and an implementation.
*
* @author Kohsuke Kawaguchi
*/
final class LinkedLogRotator extends LogRotator {
+
LinkedLogRotator(int artifactDaysToKeep, int artifactNumToKeep) {
super(-1, -1, artifactDaysToKeep, artifactNumToKeep);
}
/**
- * @deprecated since 1.369
- * Use {@link #LinkedLogRotator(int, int)}
+ * @deprecated since 1.369 Use {@link #LinkedLogRotator(int, int)}
*/
LinkedLogRotator() {
super(-1, -1, -1, -1);
@@ -53,12 +51,14 @@ final class LinkedLogRotator extends LogRotator {
MatrixConfiguration job = (MatrixConfiguration) _job;
// copy it to the array because we'll be deleting builds as we go.
RunList<MatrixRun> builds = job.getBuilds();
- for( MatrixRun r : builds.toArray(new MatrixRun[builds.size()]) ) {
- if(job.getParent().getBuildByNumber(r.getNumber())==null)
+ for (MatrixRun r : builds.toArray(new MatrixRun[builds.size()])) {
+ if (job.getParent().getBuildByNumber(r.getNumber()) == null) {
r.delete();
+ }
}
- if(!job.isActiveConfiguration() && job.getLastBuild()==null)
+ if (!job.isActiveConfiguration() && job.getLastBuild() == null) {
job.delete();
+ }
}
}
diff --git a/hudson-core/src/main/java/hudson/matrix/MatrixAggregatable.java b/hudson-core/src/main/java/hudson/matrix/MatrixAggregatable.java
index 9874f2b..71947cb 100644
--- a/hudson-core/src/main/java/hudson/matrix/MatrixAggregatable.java
+++ b/hudson-core/src/main/java/hudson/matrix/MatrixAggregatable.java
@@ -7,10 +7,10 @@
* which accompanies this distribution, and is available at
* http://www.eclipse.org/legal/epl-v10.html
*
- * Contributors:
-*
-* Kohsuke Kawaguchi
- *
+ * Contributors:
+ *
+ * Kohsuke Kawaguchi
+ *
*
*******************************************************************************/
@@ -22,36 +22,31 @@ import hudson.Launcher;
import hudson.model.BuildListener;
/**
- * {@link Publisher} can optionally implement this interface
- * to perform result aggregation across {@link MatrixRun}.
+ * {@link Publisher} can optionally implement this interface to perform result
+ * aggregation across {@link MatrixRun}.
*
- * <p>
- * This is useful for example to aggregate all the test results
- * in {@link MatrixRun} into a single table/graph.
+ * <p> This is useful for example to aggregate all the test results in
+ * {@link MatrixRun} into a single table/graph.
*
* @author Kohsuke Kawaguchi
* @since 1.115
*/
public interface MatrixAggregatable extends ExtensionPoint {
+
/**
* Creates a new instance of the aggregator.
*
- * <p>
- * This method is called during the build of
- * {@link MatrixBuild} and the created aggregator
- * will perform the aggregation.
+ * <p> This method is called during the build of {@link MatrixBuild} and the
+ * created aggregator will perform the aggregation.
*
- * @param build
- * The build for which the aggregation shall happen. Never null.
- * @param launcher
- * Can be used to launch processes during the build.
- * @param listener
- * Progress report and errors during the aggregation should
- * be sent to this object. Never null.
+ * @param build The build for which the aggregation shall happen. Never
+ * null.
+ * @param launcher Can be used to launch processes during the build.
+ * @param listener Progress report and errors during the aggregation should
+ * be sent to this object. Never null.
*
- * @return
- * null if the implementation is not willing to contribute
- * an aggregator.
+ * @return null if the implementation is not willing to contribute an
+ * aggregator.
*
* @see MatrixAggregator#build
* @see MatrixAggregator#listener
diff --git a/hudson-core/src/main/java/hudson/matrix/MatrixAggregator.java b/hudson-core/src/main/java/hudson/matrix/MatrixAggregator.java
index fe33755..e6c1956 100644
--- a/hudson-core/src/main/java/hudson/matrix/MatrixAggregator.java
+++ b/hudson-core/src/main/java/hudson/matrix/MatrixAggregator.java
@@ -7,10 +7,10 @@
* which accompanies this distribution, and is available at
* http://www.eclipse.org/legal/epl-v10.html
*
- * Contributors:
-*
-* Kohsuke Kawaguchi
- *
+ * Contributors:
+ *
+ * Kohsuke Kawaguchi
+ *
*
*******************************************************************************/
@@ -25,30 +25,27 @@ import hudson.tasks.Publisher;
import java.io.IOException;
/**
- * Performs the aggregation of {@link MatrixRun} results
- * into {@link MatrixBuild}.
+ * Performs the aggregation of {@link MatrixRun} results into
+ * {@link MatrixBuild}.
*
- * <p>
- * {@link MatrixAggregator} is a transitive stateful mutable object.
- * Unlike {@link Publisher}, it is not persisted. Instead, a fresh
- * instance is created for each {@link MatrixBuild}, and various
- * methods on this class are invoked in the event callback style
- * as the build progresses.
+ * <p> {@link MatrixAggregator} is a transitive stateful mutable object. Unlike
+ * {@link Publisher}, it is not persisted. Instead, a fresh instance is created
+ * for each {@link MatrixBuild}, and various methods on this class are invoked
+ * in the event callback style as the build progresses.
*
- * <p>
- * The end result of the aggregation should be
- * {@link MatrixBuild#addAction(Action) contributed as actions}.
+ * <p> The end result of the aggregation should be
+ * {@link MatrixBuild#addAction(Action) contributed as actions}.
*
* @author Kohsuke Kawaguchi
* @since 1.115
* @see MatrixAggregatable
*/
public abstract class MatrixAggregator implements ExtensionPoint {
+
/**
* The build in progress. Never null.
*/
protected final MatrixBuild build;
-
protected final Launcher launcher;
/**
* The listener to send the output to. Never null.
@@ -64,9 +61,8 @@ public abstract class MatrixAggregator implements ExtensionPoint {
/**
* Called before the build starts.
*
- * @return
- * true if the build can continue, false if there was an error
- * and the build needs to be aborted.
+ * @return true if the build can continue, false if there was an error and
+ * the build needs to be aborted.
* @see BuildStep#prebuild(Build,BuildListener)
*/
public boolean startBuild() throws InterruptedException, IOException {
@@ -76,21 +72,18 @@ public abstract class MatrixAggregator implements ExtensionPoint {
/**
* Called whenever one run is completed.
*
- * @param run
- * The completed {@link MatrixRun} object. Always non-null.
- * @return
- * See {@link #startBuild()} for the return value semantics.
+ * @param run The completed {@link MatrixRun} object. Always non-null.
+ * @return See {@link #startBuild()} for the return value semantics.
*/
public boolean endRun(MatrixRun run) throws InterruptedException, IOException {
return true;
}
/**
- * Called after all the {@link MatrixRun}s have been completed
- * to indicate that the build is about to finish.
- *
- * @return
- * See {@link #startBuild()} for the return value semantics.
+ * Called after all the {@link MatrixRun}s have been completed to indicate
+ * that the build is about to finish.
+ *
+ * @return See {@link #startBuild()} for the return value semantics.
*/
public boolean endBuild() throws InterruptedException, IOException {
return true;
diff --git a/hudson-core/src/main/java/hudson/matrix/MatrixBuild.java b/hudson-core/src/main/java/hudson/matrix/MatrixBuild.java
index e062aae..130cee1 100644
--- a/hudson-core/src/main/java/hudson/matrix/MatrixBuild.java
+++ b/hudson-core/src/main/java/hudson/matrix/MatrixBuild.java
@@ -7,10 +7,10 @@
* which accompanies this distribution, and is available at
* http://www.eclipse.org/legal/epl-v10.html
*
- * Contributors:
-*
-* Kohsuke Kawaguchi, Red Hat, Inc., Tom Huybrechts, Anton Kozak, Nikita Levyankov
- *
+ * Contributors:
+ *
+ * Kohsuke Kawaguchi, Red Hat, Inc., Tom Huybrechts, Anton Kozak, Nikita Levyankov
+ *
*
*******************************************************************************/
@@ -51,6 +51,7 @@ import org.kohsuke.stapler.StaplerResponse;
* @author Kohsuke Kawaguchi
*/
public class MatrixBuild extends AbstractBuild<MatrixProject, MatrixBuild> {
+
private AxisList axes;
public MatrixBuild(MatrixProject job) throws IOException {
@@ -78,6 +79,7 @@ public class MatrixBuild extends AbstractBuild<MatrixProject, MatrixBuild> {
*/
public final class RunPtr {
//TODO: review and check whether we can do it private
+
public final Combination combination;
private RunPtr(Combination c) {
@@ -119,8 +121,8 @@ public class MatrixBuild extends AbstractBuild<MatrixProject, MatrixBuild> {
}
/**
- * Gets the {@link MatrixRun} in this build that corresponds
- * to the given combination.
+ * Gets the {@link MatrixRun} in this build that corresponds to the given
+ * combination.
*/
public MatrixRun getRun(Combination c) {
MatrixConfiguration config = getParent().getItem(c);
@@ -172,6 +174,7 @@ public class MatrixBuild extends AbstractBuild<MatrixProject, MatrixBuild> {
}
private class RunnerImpl extends AbstractRunner {
+
private final List<MatrixAggregator> aggregators = new ArrayList<MatrixAggregator>();
protected Result doRun(BuildListener listener) throws Exception {
@@ -211,7 +214,7 @@ public class MatrixBuild extends AbstractBuild<MatrixProject, MatrixBuild> {
AxisList axes = p.getAxes();
String touchStoneCombinationFilter = p.getTouchStoneCombinationFilter();
if (touchStoneFilter != null && c.getCombination()
- .evalScriptExpression(axes, touchStoneCombinationFilter)) {
+ .evalScriptExpression(axes, touchStoneCombinationFilter)) {
touchStoneConfigurations.add(c);
} else {
delayedConfigurations.add(c);
@@ -287,7 +290,7 @@ public class MatrixBuild extends AbstractBuild<MatrixProject, MatrixBuild> {
}
private Result waitForCompletion(BuildListener listener, MatrixConfiguration c)
- throws InterruptedException, IOException, AggregatorFailureException {
+ throws InterruptedException, IOException, AggregatorFailureException {
String whyInQueue = "";
long startTime = System.currentTimeMillis();
@@ -363,13 +366,12 @@ public class MatrixBuild extends AbstractBuild<MatrixProject, MatrixBuild> {
}
return super.decideWorkspace(n, wsl);
}
-
}
/**
- * A private exception to help maintain the correct control flow after extracting the 'waitForCompletion' method
+ * A private exception to help maintain the correct control flow after
+ * extracting the 'waitForCompletion' method
*/
private static class AggregatorFailureException extends Exception {
}
-
}
diff --git a/hudson-core/src/main/java/hudson/matrix/MatrixConfiguration.java b/hudson-core/src/main/java/hudson/matrix/MatrixConfiguration.java
index b3f29d3..631f57f 100644
--- a/hudson-core/src/main/java/hudson/matrix/MatrixConfiguration.java
+++ b/hudson-core/src/main/java/hudson/matrix/MatrixConfiguration.java
@@ -7,10 +7,10 @@
* which accompanies this distribution, and is available at
* http://www.eclipse.org/legal/epl-v10.html
*
- * Contributors:
+ * Contributors:
*
* Kohsuke Kawaguchi, Tom Huybrechts
- *
+ *
*
*******************************************************************************/
@@ -49,19 +49,19 @@ import java.util.Map;
*
* @author Kohsuke Kawaguchi
*/
-public class MatrixConfiguration extends Project<MatrixConfiguration,MatrixRun> implements SCMedItem, NonBlockingTask {
+public class MatrixConfiguration extends Project<MatrixConfiguration, MatrixRun> implements SCMedItem, NonBlockingTask {
+
/**
* The actual value combination.
*/
private transient /*final*/ Combination combination;
-
/**
* Hash value of {@link #combination}. Cached for efficiency.
*/
private transient String digestName;
public MatrixConfiguration(MatrixProject parent, Combination c) {
- super(parent,c.toString());
+ super(parent, c.toString());
setCombination(c);
updateTransientActions();
}
@@ -77,38 +77,40 @@ public class MatrixConfiguration extends Project<MatrixConfiguration,MatrixRun>
*/
/*package*/ void setCombination(Combination c) {
this.combination = c;
- this.digestName = c.digest().substring(0,8);
+ this.digestName = c.digest().substring(0, 8);
}
/**
* Build numbers are always synchronized with the parent.
*
- * <p>
- * Computing this is bit tricky. Several considerations:
+ * <p> Computing this is bit tricky. Several considerations:
*
- * <ol>
- * <li>A new configuration build #N is started while the parent build #N is building,
- * and when that happens we want to return N.
- * <li>But the configuration build #N is done before the parent build #N finishes,
- * and when that happens we want to return N+1 because that's going to be the next one.
- * <li>Configuration builds might skip some numbers if the parent build is aborted
- * before this configuration is built.
- * <li>If nothing is building right now and the last build of the parent is #N,
- * then we want to return N+1.
- * </ol>
+ * <ol> <li>A new configuration build #N is started while the parent build
+ * #N is building, and when that happens we want to return N. <li>But the
+ * configuration build #N is done before the parent build #N finishes, and
+ * when that happens we want to return N+1 because that's going to be the
+ * next one. <li>Configuration builds might skip some numbers if the parent
+ * build is aborted before this configuration is built. <li>If nothing is
+ * building right now and the last build of the parent is #N, then we want
+ * to return N+1. </ol>
*/
@Override
public int getNextBuildNumber() {
AbstractBuild lb = getParent().getLastBuild();
- if(lb==null) return 0;
-
+ if (lb == null) {
+ return 0;
+ }
+
- int n=lb.getNumber();
- if(!lb.isBuilding()) n++;
+ int n = lb.getNumber();
+ if (!lb.isBuilding()) {
+ n++;
+ }
lb = getLastBuild();
- if(lb!=null)
- n = Math.max(n,lb.getNumber()+1);
+ if (lb != null) {
+ n = Math.max(n, lb.getNumber() + 1);
+ }
return n;
}
@@ -117,8 +119,10 @@ public class MatrixConfiguration extends Project<MatrixConfiguration,MatrixRun>
public int assignBuildNumber() throws IOException {
int nb = getNextBuildNumber();
MatrixRun r = getLastBuild();
- if(r!=null && r.getNumber()>=nb) // make sure we don't schedule the same build twice
- throw new IllegalStateException("Build #"+nb+" is already completed");
+ if (r != null && r.getNumber() >= nb) // make sure we don't schedule the same build twice
+ {
+ throw new IllegalStateException("Build #" + nb + " is already completed");
+ }
return nb;
}
@@ -129,19 +133,21 @@ public class MatrixConfiguration extends Project<MatrixConfiguration,MatrixRun>
@Override
public MatrixProject getParent() {
- return (MatrixProject)super.getParent();
+ return (MatrixProject) super.getParent();
}
/**
- * Get the actual combination of the axes values for this {@link MatrixConfiguration}
+ * Get the actual combination of the axes values for this
+ * {@link MatrixConfiguration}
*/
public Combination getCombination() {
return combination;
}
/**
- * Since {@link MatrixConfiguration} is always invoked from {@link MatrixRun}
- * once and just once, there's no point in having a quiet period.
+ * Since {@link MatrixConfiguration} is always invoked from
+ * {@link MatrixRun} once and just once, there's no point in having a quiet
+ * period.
*/
@Override
public int getQuietPeriod() {
@@ -248,7 +254,7 @@ public class MatrixConfiguration extends Project<MatrixConfiguration,MatrixRun>
public LogRotator getLogRotator() {
LogRotator lr = getParent().getLogRotator();
return new LinkedLogRotator(lr != null ? lr.getArtifactDaysToKeep() : -1,
- lr != null ? lr.getArtifactNumToKeep() : -1);
+ lr != null ? lr.getArtifactNumToKeep() : -1);
}
@Override
@@ -261,10 +267,10 @@ public class MatrixConfiguration extends Project<MatrixConfiguration,MatrixRun>
}
/**
- * JDK cannot be set on {@link MatrixConfiguration} because
- * it's controlled by {@link MatrixProject}.
- * @deprecated
- * Not supported.
+ * JDK cannot be set on {@link MatrixConfiguration} because it's controlled
+ * by {@link MatrixProject}.
+ *
+ * @deprecated Not supported.
*/
@Override
public void setJDK(JDK jdk) throws IOException {
@@ -272,8 +278,7 @@ public class MatrixConfiguration extends Project<MatrixConfiguration,MatrixRun>
}
/**
- * @deprecated
- * Value is controlled by {@link MatrixProject}.
+ * @deprecated Value is controlled by {@link MatrixProject}.
*/
@Override
public void setLogRotator(LogRotator logRotator) {
@@ -282,9 +287,9 @@ public class MatrixConfiguration extends Project<MatrixConfiguration,MatrixRun>
}
/**
- * Returns true if this configuration is a configuration
- * currently in use today (as opposed to the ones that are
- * there only to keep the past record.)
+ * Returns true if this configuration is a configuration currently in use
+ * today (as opposed to the ones that are there only to keep the past
+ * record.)
*
* @see MatrixProject#getActiveConfigurations()
*/
@@ -299,31 +304,29 @@ public class MatrixConfiguration extends Project<MatrixConfiguration,MatrixRun>
public ACL getACL() {
return getParent().getACL();
}
-
/**
- * On Cygwin, path names cannot be longer than 256 chars.
- * See http://cygwin.com/ml/cygwin/2005-04/msg00395.html and
+ * On Cygwin, path names cannot be longer than 256 chars. See
+ * http://cygwin.com/ml/cygwin/2005-04/msg00395.html and
* http://www.nabble.com/Windows-Filename-too-long-errors-t3161089.html for
- * the background of this issue. Setting this flag to true would
- * cause Hudson to use cryptic but short path name, giving more room for
- * jobs to use longer path names.
+ * the background of this issue. Setting this flag to true would cause
+ * Hudson to use cryptic but short path name, giving more room for jobs to
+ * use longer path names.
*/
- public static boolean useShortWorkspaceName = Boolean.getBoolean(MatrixConfiguration.class.getName()+".useShortWorkspaceName");
+ public static boolean useShortWorkspaceName = Boolean.getBoolean(MatrixConfiguration.class.getName() + ".useShortWorkspaceName");
- /**
- * @deprecated
- * Use {@link #scheduleBuild(ParametersAction, Cause)}. Since 1.283
- */
+ /**
+ * @deprecated Use {@link #scheduleBuild(ParametersAction, Cause)}. Since
+ * 1.283
+ */
public boolean scheduleBuild(ParametersAction parameters) {
- return scheduleBuild(parameters, new LegacyCodeCause());
+ return scheduleBuild(parameters, new LegacyCodeCause());
}
/**
*
- * @param parameters
- * Can be null.
+ * @param parameters Can be null.
*/
public boolean scheduleBuild(ParametersAction parameters, Cause c) {
- return Hudson.getInstance().getQueue().schedule(this, getQuietPeriod(), parameters, new CauseAction(c))!=null;
+ return Hudson.getInstance().getQueue().schedule(this, getQuietPeriod(), parameters, new CauseAction(c)) != null;
}
}
diff --git a/hudson-core/src/main/java/hudson/matrix/MatrixProject.java b/hudson-core/src/main/java/hudson/matrix/MatrixProject.java
index e220bc0..11cfc23 100644
--- a/hudson-core/src/main/java/hudson/matrix/MatrixProject.java
+++ b/hudson-core/src/main/java/hudson/matrix/MatrixProject.java
@@ -7,10 +7,10 @@
* which accompanies this distribution, and is available at
* http://www.eclipse.org/legal/epl-v10.html
*
- * Contributors:
-*
-* Kohsuke Kawaguchi, Jorg Heymans, Red Hat, Inc., id:cactusman, Anton Kozak, Nikita Levyankov
- *
+ * Contributors:
+ *
+ * Kohsuke Kawaguchi, Jorg Heymans, Red Hat, Inc., id:cactusman, Anton Kozak, Nikita Levyankov
+ *
*
*******************************************************************************/
@@ -69,13 +69,13 @@ import java.util.logging.Level;
import java.util.logging.Logger;
/**
- * {@link Job} that allows you to run multiple different configurations
- * from a single setting.
+ * {@link Job} that allows you to run multiple different configurations from a
+ * single setting.
*
* @author Kohsuke Kawaguchi
*/
public class MatrixProject extends BaseBuildableProject<MatrixProject, MatrixBuild> implements IMatrixProject, TopLevelItem,
- SCMedItem, ItemGroup<MatrixConfiguration>, Saveable, FlyweightTask, BuildableItemWithBuildWrappers {
+ SCMedItem, ItemGroup<MatrixConfiguration>, Saveable, FlyweightTask, BuildableItemWithBuildWrappers {
public static final String HAS_COMBINATION_FILTER_PARAM = "hasCombinationFilter";
public static final String HAS_TOUCH_STONE_COMBINATION_FILTER_PARAM = "hasTouchStoneCombinationFilter";
@@ -89,60 +89,59 @@ public class MatrixProject extends BaseBuildableProject<MatrixProject, MatrixBui
public static final String TOUCH_STONE_RESULT_CONDITION_PROPERTY_NAME = "touchStoneResultCondition";
public static final String AXES_PROPERTY_NAME = "axes";
protected static final String AXIS_CONFIGURATIONS_DIR = "configurations";
-
/**
* Configuration axes.
+ *
* @deprecated as of 2.2.0, use #getAxes() and #setAxes() instead
*/
@Deprecated
private volatile AxisList axes = new AxisList();
-
/**
- * The filter that is applied to combinations. It is a Dynamic Language Script if condition.
- * This can be null, which means "true".
- * Package visible for the tests only.
+ * The filter that is applied to combinations. It is a Dynamic Language
+ * Script if condition. This can be null, which means "true". Package
+ * visible for the tests only.
*
- * @deprecated as of 2.2.0, use #getCombinationFilter() and #setCombinationFilter() instead
+ * @deprecated as of 2.2.0, use #getCombinationFilter() and
+ * #setCombinationFilter() instead
*/
@Deprecated
private volatile String combinationFilter;
-
/**
- * All {@link MatrixConfiguration}s, keyed by their {@link MatrixConfiguration#getName() names}.
+ * All {@link MatrixConfiguration}s, keyed by their
+ * {@link MatrixConfiguration#getName() names}.
*/
- private transient /*final*/ Map<Combination,MatrixConfiguration> configurations = new CopyOnWriteMap.Tree<Combination,MatrixConfiguration>();
-
+ private transient /*final*/ Map<Combination, MatrixConfiguration> configurations = new CopyOnWriteMap.Tree<Combination, MatrixConfiguration>();
/**
* @see #getActiveConfigurations()
*/
@CopyOnWrite
private transient /*final*/ Set<MatrixConfiguration> activeConfigurations = new LinkedHashSet<MatrixConfiguration>();
-
/**
- * @deprecated as of 2.2.0, use #isRunSequentially() and #setRunSequentially() instead
+ * @deprecated as of 2.2.0, use #isRunSequentially() and
+ * #setRunSequentially() instead
*/
@Deprecated
private boolean runSequentially;
-
/**
* Filter to select a number of combinations to build first
*
- * @deprecated as of 2.2.0, use #getTouchStoneCombinationFilter() and #setTouchStoneCombinationFilter() instead
+ * @deprecated as of 2.2.0, use #getTouchStoneCombinationFilter() and
+ * #setTouchStoneCombinationFilter() instead
*/
@Deprecated
private String touchStoneCombinationFilter;
-
/**
- * Required result on the touchstone combinations, in order to
- * continue with the rest
+ * Required result on the touchstone combinations, in order to continue with
+ * the rest
*
- * @deprecated as of 2.2.0, use #getTouchStoneResultCondition() and #setTouchStoneResultCondition() instead
+ * @deprecated as of 2.2.0, use #getTouchStoneResultCondition() and
+ * #setTouchStoneResultCondition() instead
*/
@Deprecated
private Result touchStoneResultCondition;
-
/**
- * @deprecated as of 2.2.0, use #getCustomWorkspace() and #setCustomWorkspace() instead
+ * @deprecated as of 2.2.0, use #getCustomWorkspace() and
+ * #setCustomWorkspace() instead
*/
@Deprecated
private String customWorkspace;
@@ -214,7 +213,7 @@ public class MatrixProject extends BaseBuildableProject<MatrixProject, MatrixBui
*/
public void setTouchStoneCombinationFilter(String touchStoneCombinationFilter) {
CascadingUtil.getStringProjectProperty(this, TOUCH_STONE_COMBINATION_FILTER_PROPERTY_NAME)
- .setValue(touchStoneCombinationFilter);
+ .setValue(touchStoneCombinationFilter);
}
/**
@@ -229,7 +228,7 @@ public class MatrixProject extends BaseBuildableProject<MatrixProject, MatrixBui
*/
public void setTouchStoneResultCondition(Result touchStoneResultCondition) {
CascadingUtil.getResultProjectProperty(this,
- TOUCH_STONE_RESULT_CONDITION_PROPERTY_NAME).setValue(touchStoneResultCondition);
+ TOUCH_STONE_RESULT_CONDITION_PROPERTY_NAME).setValue(touchStoneResultCondition);
}
/**
@@ -258,7 +257,7 @@ public class MatrixProject extends BaseBuildableProject<MatrixProject, MatrixBui
setCombinationFilter(combinationFilter);
combinationFilter = null;//Reset to null. No longer needed.
}
- if ( null == getProperty(RUN_SEQUENTIALLY_PROPERTY_NAME)) {
+ if (null == getProperty(RUN_SEQUENTIALLY_PROPERTY_NAME)) {
setRunSequentially(runSequentially);
runSequentially = false;
}
@@ -281,14 +280,16 @@ public class MatrixProject extends BaseBuildableProject<MatrixProject, MatrixBui
/**
* Gets the subset of {@link AxisList} that are not system axes.
*
- * @deprecated as of 1.373
- * System vs user difference are generalized into extension point.
+ * @deprecated as of 1.373 System vs user difference are generalized into
+ * extension point.
*/
public List<Axis> getUserAxes() {
List<Axis> r = new ArrayList<Axis>();
- for (Axis a : getAxes())
- if(!a.isSystem())
+ for (Axis a : getAxes()) {
+ if (!a.isSystem()) {
r.add(a);
+ }
+ }
return r;
}
@@ -317,35 +318,34 @@ public class MatrixProject extends BaseBuildableProject<MatrixProject, MatrixBui
// perform the log rotation of inactive configurations to make sure
// their logs get eventually discarded
for (MatrixConfiguration config : configurations.values()) {
- if(!config.isActiveConfiguration())
+ if (!config.isActiveConfiguration()) {
config.logRotate();
+ }
}
}
/**
* Recursively search for configuration and put them to the map
*
- * <p>
- * The directory structure would be <tt>axis-a/b/axis-c/d/axis-e/f</tt> for
- * combination [a=b,c=d,e=f]. Note that two combinations [a=b,c=d] and [a=b,c=d,e=f]
- * can both co-exist (where one is an archived record and the other is live, for example)
- * so search needs to be thorough.
+ * <p> The directory structure would be <tt>axis-a/b/axis-c/d/axis-e/f</tt>
+ * for combination [a=b,c=d,e=f]. Note that two combinations [a=b,c=d] and
+ * [a=b,c=d,e=f] can both co-exist (where one is an archived record and the
+ * other is live, for example) so search needs to be thorough.
*
- * @param dir
- * Directory to be searched.
- * @param result
- * Receives the loaded {@link MatrixConfiguration}s.
- * @param combination
- * Combination of key/values discovered so far while traversing the directories.
- * Read-only.
+ * @param dir Directory to be searched.
+ * @param result Receives the loaded {@link MatrixConfiguration}s.
+ * @param combination Combination of key/values discovered so far while
+ * traversing the directories. Read-only.
*/
- private void loadConfigurations( File dir, CopyOnWriteMap.Tree<Combination,MatrixConfiguration> result, Map<String,String> combination ) {
+ private void loadConfigurations(File dir, CopyOnWriteMap.Tree<Combination, MatrixConfiguration> result, Map<String, String> combination) {
File[] axisDirs = dir.listFiles(new FileFilter() {
public boolean accept(File child) {
return child.isDirectory() && child.getName().startsWith("axis-");
}
});
- if(axisDirs==null) return;
+ if (axisDirs == null) {
+ return;
+ }
for (File subdir : axisDirs) {
String axis = subdir.getName().substring(5); // axis name
@@ -355,22 +355,24 @@ public class MatrixProject extends BaseBuildableProject<MatrixProject, MatrixBui
return child.isDirectory();
}
});
- if(valuesDir==null) continue; // no values here
-
+ if (valuesDir == null) {
+ continue; // no values here
+ }
for (File v : valuesDir) {
- Map<String,String> c = new HashMap<String, String>(combination);
- c.put(axis,TokenList.decode(v.getName()));
+ Map<String, String> c = new HashMap<String, String>(combination);
+ c.put(axis, TokenList.decode(v.getName()));
try {
XmlFile config = Items.getConfigFile(v);
- if(config.exists()) {
+ if (config.exists()) {
Combination comb = new Combination(c);
// if we already have this in memory, just use it.
// otherwise load it
- MatrixConfiguration item=null;
- if(this.configurations!=null)
+ MatrixConfiguration item = null;
+ if (this.configurations != null) {
item = this.configurations.get(comb);
- if(item==null) {
+ }
+ if (item == null) {
item = (MatrixConfiguration) config.read();
item.setCombination(comb);
item.onLoad(this, v.getName());
@@ -378,15 +380,16 @@ public class MatrixProject extends BaseBuildableProject<MatrixProject, MatrixBui
result.put(item.getCombination(), item);
}
} catch (IOException e) {
- LOGGER.log(Level.WARNING, "Failed to load matrix configuration "+v,e);
+ LOGGER.log(Level.WARNING, "Failed to load matrix configuration " + v, e);
}
- loadConfigurations(v,result,c);
+ loadConfigurations(v, result, c);
}
}
}
/**
- * Rebuilds the {@link #configurations} list and {@link #activeConfigurations}.
+ * Rebuilds the {@link #configurations} list and
+ * {@link #activeConfigurations}.
*/
void rebuildConfigurations() throws IOException {
// backward compatibility check to see if there's any data in the old structure
@@ -409,9 +412,9 @@ public class MatrixProject extends BaseBuildableProject<MatrixProject, MatrixBui
}
}
- CopyOnWriteMap.Tree<Combination,MatrixConfiguration> configurations =
- new CopyOnWriteMap.Tree<Combination,MatrixConfiguration>();
- loadConfigurations(getConfigurationsDir(),configurations,Collections.<String,String>emptyMap());
+ CopyOnWriteMap.Tree<Combination, MatrixConfiguration> configurations =
+ new CopyOnWriteMap.Tree<Combination, MatrixConfiguration>();
+ loadConfigurations(getConfigurationsDir(), configurations, Collections.<String, String>emptyMap());
this.configurations = configurations;
// find all active configurations
@@ -440,10 +443,9 @@ public class MatrixProject extends BaseBuildableProject<MatrixProject, MatrixBui
}
/**
- * Gets all active configurations.
- * <p>
- * In contract, inactive configurations are those that are left for archival purpose
- * and no longer built when a new {@link MatrixBuild} is executed.
+ * Gets all active configurations. <p> In contract, inactive configurations
+ * are those that are left for archival purpose and no longer built when a
+ * new {@link MatrixBuild} is executed.
*/
public Collection<MatrixConfiguration> getActiveConfigurations() {
return activeConfigurations;
@@ -486,8 +488,9 @@ public class MatrixProject extends BaseBuildableProject<MatrixProject, MatrixBui
public File getRootDirFor(Combination combination) {
File f = getConfigurationsDir();
- for (Entry<String, String> e : combination.entrySet())
- f = new File(f,"axis-"+e.getKey()+'/'+Util.rawEncode(e.getValue()));
+ for (Entry<String, String> e : combination.entrySet()) {
+ f = new File(f, "axis-" + e.getKey() + '/' + Util.rawEncode(e.getValue()));
+ }
f.getParentFile().mkdirs();
return f;
}
@@ -495,42 +498,50 @@ public class MatrixProject extends BaseBuildableProject<MatrixProject, MatrixBui
/**
* @see #getJDKs()
*/
- @Override @Deprecated
+ @Override
+ @Deprecated
public JDK getJDK() {
return super.getJDK();
}
/**
* Gets the {@link JDK}s where the builds will be run.
+ *
* @return never null but can be empty
*/
public Set<JDK> getJDKs() {
Axis a = getAxes().find("jdk");
- if(a==null) return Collections.emptySet();
+ if (a == null) {
+ return Collections.emptySet();
+ }
Set<JDK> r = new HashSet<JDK>();
for (String j : a) {
JDK jdk = Hudson.getInstance().getJDK(j);
- if(jdk!=null)
+ if (jdk != null) {
r.add(jdk);
+ }
}
return r;
}
/**
* Gets the {@link Label}s where the builds will be run.
+ *
* @return never null
*/
public Set<Label> getLabels() {
Set<Label> r = new HashSet<Label>();
- for (Combination c : getAxes().subList(LabelAxis.class).list())
- r.add(Hudson.getInstance().getLabel(Util.join(c.values(),"&&")));
+ for (Combination c : getAxes().subList(LabelAxis.class).list()) {
+ r.add(Hudson.getInstance().getLabel(Util.join(c.values(), "&&")));
+ }
return r;
}
public Publisher getPublisher(Descriptor<Publisher> descriptor) {
for (Publisher p : getPublishersList()) {
- if(p.getDescriptor()==descriptor)
+ if (p.getDescriptor() == descriptor) {
return p;
+ }
}
return null;
}
@@ -551,12 +562,13 @@ public class MatrixProject extends BaseBuildableProject<MatrixProject, MatrixBui
public Object getDynamic(String token, StaplerRequest req, StaplerResponse rsp) {
try {
MatrixConfiguration item = getItem(token);
- if(item!=null)
- return item;
+ if (item != null) {
+ return item;
+ }
} catch (IllegalArgumentException _) {
// failed to parse the token as Combination. Must be something else
}
- return super.getDynamic(token,req,rsp);
+ return super.getDynamic(token, req, rsp);
}
@Override
@@ -566,10 +578,10 @@ public class MatrixProject extends BaseBuildableProject<MatrixProject, MatrixBui
JSONObject json = req.getSubmittedForm();
setCombinationFilter(
- req.getParameter(HAS_COMBINATION_FILTER_PARAM) != null ? Util.nullify(req.getParameter(
+ req.getParameter(HAS_COMBINATION_FILTER_PARAM) != null ? Util.nullify(req.getParameter(
COMBINATION_FILTER_PROPERTY_NAME)) : null);
- if (req.getParameter(HAS_TOUCH_STONE_COMBINATION_FILTER_PARAM)!=null) {
+ if (req.getParameter(HAS_TOUCH_STONE_COMBINATION_FILTER_PARAM) != null) {
setTouchStoneCombinationFilter(Util.nullify(req.getParameter(TOUCH_STONE_COMBINATION_FILTER_PARAM)));
setTouchStoneResultCondition(Result.fromString(req.getParameter(TOUCH_STONE_RESULT_CONDITION_PARAM)));
} else {
@@ -577,11 +589,11 @@ public class MatrixProject extends BaseBuildableProject<MatrixProject, MatrixBui
}
setCustomWorkspace(
- req.hasParameter(CUSTOM_WORKSPACE_PARAM) ? req.getParameter(CUSTOM_WORKSPACE_DIRECTORY_PARAM) : null);
+ req.hasParameter(CUSTOM_WORKSPACE_PARAM) ? req.getParameter(CUSTOM_WORKSPACE_DIRECTORY_PARAM) : null);
// parse system axes
DescribableList<Axis, AxisDescriptor> newAxes = DescribableListUtil.buildFromHetero(this, req, json, "axis",
- Axis.all());
+ Axis.all());
checkAxisNames(newAxes);
setAxes(new AxisList(newAxes.toList()));
@@ -597,11 +609,13 @@ public class MatrixProject extends BaseBuildableProject<MatrixProject, MatrixBui
HashSet<String> axisNames = new HashSet<String>();
for (Axis a : newAxes) {
FormValidation fv = a.getDescriptor().doCheckName(a.getName());
- if (fv.kind!=Kind.OK)
- throw new FormException(Messages.MatrixProject_DuplicateAxisName(),fv,"axis.name");
+ if (fv.kind != Kind.OK) {
+ throw new FormException(Messages.MatrixProject_DuplicateAxisName(), fv, "axis.name");
+ }
- if (axisNames.contains(a.getName()))
- throw new FormException(Messages.MatrixProject_DuplicateAxisName(),"axis.name");
+ if (axisNames.contains(a.getName())) {
+ throw new FormException(Messages.MatrixProject_DuplicateAxisName(), "axis.name");
+ }
axisNames.add(a.getName());
}
}
@@ -612,26 +626,26 @@ public class MatrixProject extends BaseBuildableProject<MatrixProject, MatrixBui
@Override
public HttpResponse doDoWipeOutWorkspace() throws IOException, ServletException, InterruptedException {
HttpResponse rsp = super.doDoWipeOutWorkspace();
- for (MatrixConfiguration c : configurations.values())
+ for (MatrixConfiguration c : configurations.values()) {
c.doDoWipeOutWorkspace();
+ }
return rsp;
}
-
public DescriptorImpl getDescriptor() {
return DESCRIPTOR;
}
-
@Extension
public static final DescriptorImpl DESCRIPTOR = new DescriptorImpl();
public static final class DescriptorImpl extends AbstractProjectDescriptor {
+
public String getDisplayName() {
return Messages.MatrixProject_DisplayName();
}
public MatrixProject newInstance(ItemGroup parent, String name) {
- return new MatrixProject(parent,name);
+ return new MatrixProject(parent, name);
}
/**
@@ -640,8 +654,9 @@ public class MatrixProject extends BaseBuildableProject<MatrixProject, MatrixBui
public List<AxisDescriptor> getAxisDescriptors() {
List<AxisDescriptor> r = new ArrayList<AxisDescriptor>();
for (AxisDescriptor d : Axis.all()) {
- if (d.isInstantiable())
+ if (d.isInstantiable()) {
r.add(d);
+ }
}
return r;
}
@@ -665,6 +680,5 @@ public class MatrixProject extends BaseBuildableProject<MatrixProject, MatrixBui
LOGGER.log(Level.WARNING, "Failed to rebuild matrix configuration", e);
}
}
-
private static final Logger LOGGER = Logger.getLogger(MatrixProject.class.getName());
}
diff --git a/hudson-core/src/main/java/hudson/matrix/MatrixRun.java b/hudson-core/src/main/java/hudson/matrix/MatrixRun.java
index 42ef5b0..3a08997 100644
--- a/hudson-core/src/main/java/hudson/matrix/MatrixRun.java
+++ b/hudson-core/src/main/java/hudson/matrix/MatrixRun.java
@@ -7,10 +7,10 @@
* which accompanies this distribution, and is available at
* http://www.eclipse.org/legal/epl-v10.html
*
- * Contributors:
-*
-* Kohsuke Kawaguchi
- *
+ * Contributors:
+ *
+ * Kohsuke Kawaguchi
+ *
*
*******************************************************************************/
@@ -37,7 +37,8 @@ import java.util.Map;
*
* @author Kohsuke Kawaguchi
*/
-public class MatrixRun extends Build<MatrixConfiguration,MatrixRun> {
+public class MatrixRun extends Build<MatrixConfiguration, MatrixRun> {
+
public MatrixRun(MatrixConfiguration job) throws IOException {
super(job);
}
@@ -53,13 +54,13 @@ public class MatrixRun extends Build<MatrixConfiguration,MatrixRun> {
@Override
public String getUpUrl() {
StaplerRequest req = Stapler.getCurrentRequest();
- if(req!=null) {
+ if (req != null) {
List<Ancestor> ancs = req.getAncestors();
- for( int i=1; i<ancs.size(); i++) {
- if(ancs.get(i).getObject()==this) {
- Object parentObj = ancs.get(i-1).getObject();
- if(parentObj instanceof MatrixBuild || parentObj instanceof MatrixConfiguration) {
- return ancs.get(i-1).getUrl()+'/';
+ for (int i = 1; i < ancs.size(); i++) {
+ if (ancs.get(i).getObject() == this) {
+ Object parentObj = ancs.get(i - 1).getObject();
+ if (parentObj instanceof MatrixBuild || parentObj instanceof MatrixConfiguration) {
+ return ancs.get(i - 1).getUrl() + '/';
}
}
}
@@ -70,30 +71,31 @@ public class MatrixRun extends Build<MatrixConfiguration,MatrixRun> {
/**
* Gets the {@link MatrixBuild} that has the same build number.
*
- * @return
- * null if no such build exists, which happens when the module build
- * is manually triggered.
+ * @return null if no such build exists, which happens when the module build
+ * is manually triggered.
*/
public MatrixBuild getParentBuild() {
return getParent().getParent().getBuildByNumber(getNumber());
}
-
+
@Override
public void checkPermission(hudson.security.Permission p) {
MatrixBuild parentBuild = getParentBuild();
- if(parentBuild != null) {
+ if (parentBuild != null) {
parentBuild.checkPermission(p);
}
- };
+ }
+
+ ;
@Override
public String getDisplayName() {
StaplerRequest req = Stapler.getCurrentRequest();
- if(req!=null) {
+ if (req != null) {
List<Ancestor> ancs = req.getAncestors();
- for( int i=1; i<ancs.size(); i++) {
- if(ancs.get(i).getObject()==this) {
- if(ancs.get(i-1).getObject() instanceof MatrixBuild) {
+ for (int i = 1; i < ancs.size(); i++) {
+ if (ancs.get(i).getObject() == this) {
+ if (ancs.get(i - 1).getObject() instanceof MatrixBuild) {
return getParent().getCombination().toCompactString(getParent().getParent().getAxes());
}
}
@@ -108,11 +110,11 @@ public class MatrixRun extends Build<MatrixConfiguration,MatrixRun> {
@Override
protected void customizeBuildVariables(final Map<String, String> vars) {
AxisList axes = getParent().getParent().getAxes();
- for (Map.Entry<String,String> e : getParent().getCombination().entrySet()) {
+ for (Map.Entry<String, String> e : getParent().getCombination().entrySet()) {
Axis a = axes.find(e.getKey());
- if (a!=null) {
- a.addBuildVariable(e.getValue(),vars);
- }else {
+ if (a != null) {
+ a.addBuildVariable(e.getValue(), vars);
+ } else {
vars.put(e.getKey(), e.getValue());
}
}
@@ -124,8 +126,9 @@ public class MatrixRun extends Build<MatrixConfiguration,MatrixRun> {
@Override
public String getWhyKeepLog() {
MatrixBuild pb = getParentBuild();
- if(pb!=null && pb.getWhyKeepLog()!=null)
+ if (pb != null && pb.getWhyKeepLog() != null) {
return Messages.MatrixRun_KeptBecauseOfParent(pb);
+ }
return super.getWhyKeepLog();
}
@@ -139,24 +142,25 @@ public class MatrixRun extends Build<MatrixConfiguration,MatrixRun> {
run(new RunnerImpl());
}
- protected class RunnerImpl extends Build<MatrixConfiguration,MatrixRun>.RunnerImpl {
+ protected class RunnerImpl extends Build<MatrixConfiguration, MatrixRun>.RunnerImpl {
+
@Override
protected Lease decideWorkspace(Node n, WorkspaceList wsl) throws InterruptedException, IOException {
// Map current combination to a directory subtree, e.g. 'axis1=a,axis2=b' to 'axis1/a/axis2/b'.
String subtree;
- if(useShortWorkspaceName) {
- subtree = getParent().getDigestName();
+ if (useShortWorkspaceName) {
+ subtree = getParent().getDigestName();
} else {
- subtree = getParent().getCombination().toString('/','/', true);
+ subtree = getParent().getCombination().toString('/', '/', true);
}
-
+
String customWorkspace = getParent().getParent().getCustomWorkspace();
if (customWorkspace != null) {
// Use custom workspace as defined in the matrix project settings.
FilePath ws = n.getRootPath().child(getEnvironment(listener).expand(customWorkspace));
// We allow custom workspaces to be used concurrently between jobs.
return Lease.createDummyLease(ws.child(subtree));
- } else {
+ } else {
// Use default workspace as assigned by Hudson.
Node node = getBuiltOn();
FilePath ws = node.getWorkspaceFor(getParent().getParent());
diff --git a/hudson-core/src/main/java/hudson/matrix/TextAxis.java b/hudson-core/src/main/java/hudson/matrix/TextAxis.java
index 0b7467e..8b38654 100644
--- a/hudson-core/src/main/java/hudson/matrix/TextAxis.java
+++ b/hudson-core/src/main/java/hudson/matrix/TextAxis.java
@@ -8,7 +8,7 @@
* http://www.eclipse.org/legal/epl-v10.html
*
* Contributors:
- *
+ *
*
*******************************************************************************/
@@ -21,10 +21,11 @@ import java.util.List;
/**
* User-defined plain text axis.
- *
+ *
* @author Kohsuke Kawaguchi
*/
public class TextAxis extends Axis {
+
public TextAxis(String name, List<String> values) {
super(name, values);
}
@@ -40,6 +41,7 @@ public class TextAxis extends Axis {
@Extension
public static class DescriptorImpl extends AxisDescriptor {
+
@Override
public String getDisplayName() {
return Messages.TextArea_DisplayName();
diff --git a/hudson-core/src/main/java/hudson/matrix/package.html b/hudson-core/src/main/java/hudson/matrix/package.html
index 7f3d75f..989c574 100644
--- a/hudson-core/src/main/java/hudson/matrix/package.html
+++ b/hudson-core/src/main/java/hudson/matrix/package.html
@@ -17,5 +17,5 @@
-->
<html><head/><body>
-Matrix project
-</body></html> \ No newline at end of file
+ Matrix project
+ </body></html> \ No newline at end of file