| author | akozak | 2011-11-23 02:52:44 (EST) |
|---|---|---|
| committer | Winston Prakash | 2011-12-01 20:47:05 (EST) |
| commit | b98c4dc5259469f15143fb0c6733e8e67687e67d (patch) (side-by-side diff) | |
| tree | 4b58d24b51c20a6900762f9daf8a268586c91b13 | |
| parent | c49257f048f6ffd05f87d9a4f0cbab9915e02a92 (diff) | |
| download | org.eclipse.hudson.core-b98c4dc5259469f15143fb0c6733e8e67687e67d.zip org.eclipse.hudson.core-b98c4dc5259469f15143fb0c6733e8e67687e67d.tar.gz org.eclipse.hudson.core-b98c4dc5259469f15143fb0c6733e8e67687e67d.tar.bz2 | |
Added cascading for Axes on Matrix Configuration Page.
Signed-off-by: Winston Prakash <winston.prakash@gmail.com>
9 files changed, 140 insertions, 23 deletions
diff --git a/hudson-core/src/main/java/hudson/matrix/AxisList.java b/hudson-core/src/main/java/hudson/matrix/AxisList.java index c2a025f..483cfe9 100644 --- a/hudson-core/src/main/java/hudson/matrix/AxisList.java +++ b/hudson-core/src/main/java/hudson/matrix/AxisList.java @@ -1,6 +1,6 @@ /******************************************************************************* * - * Copyright (c) 2004-2010 Oracle Corporation. + * Copyright (c) 2004-2011 Oracle Corporation. * * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 @@ -9,7 +9,7 @@ * * Contributors: * - * Kohsuke Kawaguchi + * Kohsuke Kawaguchi, Anton Kozak * * *******************************************************************************/ @@ -28,6 +28,8 @@ import java.util.HashSet; import java.util.Iterator; import java.util.Arrays; import java.util.Set; +import org.apache.commons.collections.CollectionUtils; +import org.apache.commons.collections.ListUtils; /** * List of {@link Axis}. @@ -66,6 +68,27 @@ public class AxisList extends ArrayList<Axis> { return axis!=null && super.add(axis); } + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + if (!super.equals(o)) { + return false; + } + AxisList axisList = (AxisList) o; + + return CollectionUtils.isEqualCollection(this, axisList); + } + + @Override + public int hashCode() { + return ListUtils.hashCodeForList(this); + } + /** * List up all the possible combinations of this list. */ diff --git a/hudson-core/src/main/java/hudson/matrix/Combination.java b/hudson-core/src/main/java/hudson/matrix/Combination.java index bc39bb5..61ad1f3 100644 --- a/hudson-core/src/main/java/hudson/matrix/Combination.java +++ b/hudson-core/src/main/java/hudson/matrix/Combination.java @@ -45,6 +45,8 @@ import groovy.lang.GroovyShell; */ 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)); @@ -203,7 +205,7 @@ public final class Combination extends TreeMap<String,String> implements Compara return new Combination(Collections.<String,String>emptyMap()); Map<String,String> m = new HashMap<String,String>(); - StringTokenizer tokens = new StringTokenizer(id, ","); + StringTokenizer tokens = new StringTokenizer(id, DELIM); while(tokens.hasMoreTokens()) { String token = tokens.nextToken(); int idx = token.indexOf('='); diff --git a/hudson-core/src/main/java/hudson/matrix/MatrixBuild.java b/hudson-core/src/main/java/hudson/matrix/MatrixBuild.java index abe14d5..a41aa13 100644 --- a/hudson-core/src/main/java/hudson/matrix/MatrixBuild.java +++ b/hudson-core/src/main/java/hudson/matrix/MatrixBuild.java @@ -193,7 +193,9 @@ public class MatrixBuild extends AbstractBuild<MatrixProject,MatrixBuild> { Collection<MatrixConfiguration> touchStoneConfigurations = new HashSet<MatrixConfiguration>(); Collection<MatrixConfiguration> delayedConfigurations = new HashSet<MatrixConfiguration>(); for (MatrixConfiguration c: activeConfigurations) { - if (touchStoneFilter != null && c.getCombination().evalGroovyExpression(p.getAxes(), p.getTouchStoneCombinationFilter())) { + AxisList axes = p.getAxes(); + String touchStoneCombinationFilter = p.getTouchStoneCombinationFilter(); + if (touchStoneFilter != null && c.getCombination().evalGroovyExpression(axes, touchStoneCombinationFilter)) { touchStoneConfigurations.add(c); } else { delayedConfigurations.add(c); diff --git a/hudson-core/src/main/java/hudson/matrix/MatrixProject.java b/hudson-core/src/main/java/hudson/matrix/MatrixProject.java index 3911421..0c5427d 100644 --- a/hudson-core/src/main/java/hudson/matrix/MatrixProject.java +++ b/hudson-core/src/main/java/hudson/matrix/MatrixProject.java @@ -93,18 +93,23 @@ public class MatrixProject extends AbstractProject<MatrixProject, MatrixBuild> i public static final String COMBINATION_FILTER_PROPERTY_NAME = "combinationFilter"; public static final String TOUCH_STONE_COMBINATION_FILTER_PROPERTY_NAME = "touchStoneCombinationFilter"; public static final String TOUCH_STONE_RESULT_CONDITION_PROPERTY_NAME = "touchStoneResultCondition"; + public static final String AXES_PROPERTY_NAME = "axes"; /** * Configuration axes. + * @deprecated as of 2.1.2, use #getAxes() and #setAxes() instead */ + @Deprecated private volatile AxisList axes = new AxisList(); /** * The filter that is applied to combinations. It is a Groovy 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.1.2, use #getCombinationFilter() and #setCombinationFilter() instead */ + @Deprecated private volatile String combinationFilter; /** @@ -139,6 +144,7 @@ public class MatrixProject extends AbstractProject<MatrixProject, MatrixBuild> i /** * @deprecated as of 2.2.0, use #isRunSequentially() and #setRunSequentially() instead */ + @Deprecated private boolean runSequentially; /** @@ -146,6 +152,7 @@ public class MatrixProject extends AbstractProject<MatrixProject, MatrixBuild> i * * @deprecated as of 2.2.0, use #getTouchStoneCombinationFilter() and #setTouchStoneCombinationFilter() instead */ + @Deprecated private String touchStoneCombinationFilter; /** @@ -153,11 +160,13 @@ public class MatrixProject extends AbstractProject<MatrixProject, MatrixBuild> i * continue with the rest. * @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 private String customWorkspace; public MatrixProject(String name) { @@ -172,18 +181,14 @@ public class MatrixProject extends AbstractProject<MatrixProject, MatrixBuild> i * @inheritDoc */ public AxisList getAxes() { - return axes!= null ? axes : (hasCascadingProject()? getCascadingProject().getAxes() : null); + return getAxesListProjectProperty(AXES_PROPERTY_NAME).getValue(); } /** * @inheritDoc */ public void setAxes(AxisList axes) throws IOException { - if (!(hasCascadingProject() && ObjectUtils.equals(getCascadingProject().getAxes(), axes))) { - this.axes = new AxisList(axes); - } else { - this.axes = null; - } + getAxesListProjectProperty(AXES_PROPERTY_NAME).setValue(axes); // TODO verify me rebuildConfigurations(); save(); @@ -311,6 +316,36 @@ public class MatrixProject extends AbstractProject<MatrixProject, MatrixBuild> i } @Override + protected void buildProjectProperties() throws IOException { + super.buildProjectProperties(); + //Convert legacy properties to IProjectProperty logic + if (null != axes && null == getProperty(AXES_PROPERTY_NAME)) { + setAxes(axes); + axes = null;//Reset to null. No longer needed. + } + if (null != combinationFilter && null == getProperty(COMBINATION_FILTER_PROPERTY_NAME)) { + setCombinationFilter(combinationFilter); + combinationFilter = null;//Reset to null. No longer needed. + } + if ( null == getProperty(RUN_SEQUENTIALLY_PROPERTY_NAME)) { + setRunSequentially(runSequentially); + runSequentially = false; + } + if (null != touchStoneCombinationFilter && null == getProperty(TOUCH_STONE_COMBINATION_FILTER_PROPERTY_NAME)) { + setTouchStoneCombinationFilter(touchStoneCombinationFilter); + touchStoneCombinationFilter = null;//Reset to null. No longer needed. + } + if (null != touchStoneResultCondition && null == getProperty(TOUCH_STONE_RESULT_CONDITION_PROPERTY_NAME)) { + setTouchStoneResultCondition(touchStoneResultCondition); + touchStoneResultCondition = null;//Reset to null. No longer needed. + } + if (null != customWorkspace && null == getProperty(CUSTOM_WORKSPACE_PROPERTY_NAME)) { + setCustomWorkspace(customWorkspace); + customWorkspace = null;//Reset to null. No longer needed. + } + } + + @Override protected List<Action> createTransientActions() { List<Action> r = super.createTransientActions(); @@ -334,14 +369,14 @@ public class MatrixProject extends AbstractProject<MatrixProject, MatrixBuild> i */ public List<Axis> getUserAxes() { List<Axis> r = new ArrayList<Axis>(); - for (Axis a : axes) + for (Axis a : getAxes()) if(!a.isSystem()) r.add(a); return r; } public Layouter<MatrixConfiguration> getLayouter() { - return new Layouter<MatrixConfiguration>(axes) { + return new Layouter<MatrixConfiguration>(getAxes()) { protected MatrixConfiguration getT(Combination c) { return getItem(c); } @@ -350,8 +385,8 @@ public class MatrixProject extends AbstractProject<MatrixProject, MatrixBuild> i @Override public void onLoad(ItemGroup<? extends Item> parent, String name) throws IOException { - super.onLoad(parent, name); - Collections.sort(axes); // perhaps the file was edited on disk and the sort order might have been broken + super.onLoad(parent,name); + Collections.sort(getAxes()); // perhaps the file was edited on disk and the sort order might have been broken getBuildersList().setOwner(this); getPublishersList().setOwner(this); getBuildWrappersList().setOwner(this); @@ -464,7 +499,9 @@ public class MatrixProject extends AbstractProject<MatrixProject, MatrixBuild> i // find all active configurations Set<MatrixConfiguration> active = new LinkedHashSet<MatrixConfiguration>(); - for (Combination c : axes.list()) { + for (Combination c : getAxes().list()) { + AxisList axes = getAxes(); + String combinationFilter = getCombinationFilter(); if(c.evalGroovyExpression(axes,combinationFilter)) { LOGGER.fine("Adding configuration: " + c); MatrixConfiguration config = configurations.get(c); @@ -549,7 +586,7 @@ public class MatrixProject extends AbstractProject<MatrixProject, MatrixBuild> i * @return never null but can be empty */ public Set<JDK> getJDKs() { - Axis a = axes.find("jdk"); + Axis a = getAxes().find("jdk"); if(a==null) return Collections.emptySet(); Set<JDK> r = new HashSet<JDK>(); for (String j : a) { @@ -566,7 +603,7 @@ public class MatrixProject extends AbstractProject<MatrixProject, MatrixBuild> i */ public Set<Label> getLabels() { Set<Label> r = new HashSet<Label>(); - for (Combination c : axes.subList(LabelAxis.class).list()) + for (Combination c : getAxes().subList(LabelAxis.class).list()) r.add(Hudson.getInstance().getLabel(Util.join(c.values(),"&&"))); return r; } @@ -633,7 +670,7 @@ public class MatrixProject extends AbstractProject<MatrixProject, MatrixBuild> i DescribableList<Axis,AxisDescriptor> newAxes = new DescribableList<Axis,AxisDescriptor>(this); newAxes.rebuildHetero(req, json, Axis.all(),"axis"); checkAxisNames(newAxes); - this.axes = new AxisList(newAxes.toList()); + setAxes(new AxisList(newAxes.toList())); setRunSequentially(json.has(RUN_SEQUENTIALLY_PROPERTY_NAME)); diff --git a/hudson-core/src/main/java/hudson/model/AbstractProject.java b/hudson-core/src/main/java/hudson/model/AbstractProject.java index e6b14b7..fd8d47f 100644 --- a/hudson-core/src/main/java/hudson/model/AbstractProject.java +++ b/hudson-core/src/main/java/hudson/model/AbstractProject.java @@ -154,6 +154,7 @@ public abstract class AbstractProject<P extends AbstractProject<P,R>,R extends A * Use getter/setter for accessing to this field. * */ + @Deprecated private volatile Integer quietPeriod = null; /** @@ -162,6 +163,7 @@ public abstract class AbstractProject<P extends AbstractProject<P,R>,R extends A * don't use this field directly, logic was moved to {@link org.eclipse.hudson.api.model.IProjectProperty}. * Use getter/setter for accessing to this field. */ + @Deprecated private volatile Integer scmCheckoutRetryCount = null; /** @@ -201,6 +203,7 @@ public abstract class AbstractProject<P extends AbstractProject<P,R>,R extends A * @deprecated as of 2.2.0. Don't use this field directly, logic was moved to {@link org.eclipse.hudson.api.model.IProjectProperty}. * Use getter/setter for accessing to this field. */ + @Deprecated protected volatile boolean blockBuildWhenDownstreamBuilding; /** @@ -209,6 +212,7 @@ public abstract class AbstractProject<P extends AbstractProject<P,R>,R extends A * @deprecated as of 2.2.0. Don't use this field directly, logic was moved to {@link org.eclipse.hudson.api.model.IProjectProperty}. * Use getter/setter for accessing to this field. */ + @Deprecated protected volatile boolean blockBuildWhenUpstreamBuilding; /** @@ -224,11 +228,13 @@ public abstract class AbstractProject<P extends AbstractProject<P,R>,R extends A * don't use this field directly, logic was moved to {@link org.eclipse.hudson.api.model.IProjectProperty}. * Use getter/setter for accessing to this field. */ + @Deprecated private volatile String jdk; /** * @deprecated since 2007-01-29. */ + @Deprecated private transient boolean enableRemoteTrigger; private volatile BuildAuthorizationToken authToken = null; @@ -252,6 +258,7 @@ public abstract class AbstractProject<P extends AbstractProject<P,R>,R extends A * @deprecated as of 2.2.0 Don't use this field directly, logic was moved to {@link org.eclipse.hudson.api.model.IProjectProperty}. * Use getter/setter for accessing to this field. */ + @Deprecated private boolean concurrentBuild; /** @@ -260,6 +267,7 @@ public abstract class AbstractProject<P extends AbstractProject<P,R>,R extends A * @deprecated as of 2.2.0 don't use this field directly, logic was moved to {@link org.eclipse.hudson.api.model.IProjectProperty}. * Use getter/setter for accessing to this field. */ + @Deprecated private volatile boolean cleanWorkspaceRequired; protected AbstractProject(ItemGroup parent, String name) { diff --git a/hudson-core/src/main/java/hudson/model/FreeStyleProject.java b/hudson-core/src/main/java/hudson/model/FreeStyleProject.java index dd6a067..65d4196 100644 --- a/hudson-core/src/main/java/hudson/model/FreeStyleProject.java +++ b/hudson-core/src/main/java/hudson/model/FreeStyleProject.java @@ -40,9 +40,11 @@ public class FreeStyleProject extends Project<FreeStyleProject,FreeStyleBuild> i * See {@link #setCustomWorkspace(String)}. * * @since 1.216 - * @deprecated left for backward compatibility - * @since 2.2.0 + * @deprecated as of 2.2.0 + * don't use this field directly, logic was moved to {@link org.eclipse.hudson.api.model.IProjectProperty}. + * Use getter/setter for accessing to this field. */ + @Deprecated private String customWorkspace; /** diff --git a/hudson-core/src/main/java/hudson/model/Job.java b/hudson-core/src/main/java/hudson/model/Job.java index ab9de57..519518d 100644 --- a/hudson-core/src/main/java/hudson/model/Job.java +++ b/hudson-core/src/main/java/hudson/model/Job.java @@ -18,6 +18,7 @@ package hudson.model; import hudson.Functions; +import org.eclipse.hudson.api.model.project.property.AxisListProjectProperty; import org.eclipse.hudson.api.model.project.property.BooleanProjectProperty; import org.eclipse.hudson.api.model.project.property.IntegerProjectProperty; import org.eclipse.hudson.api.model.project.property.LogRotatorProjectProperty; @@ -264,6 +265,10 @@ public abstract class Job<JobT extends Job<JobT, RunT>, RunT extends Run<JobT, R return (LogRotatorProjectProperty) getProperty(key, LogRotatorProjectProperty.class); } + public AxisListProjectProperty getAxesListProjectProperty(String key) { + return (AxisListProjectProperty) getProperty(key, AxisListProjectProperty.class); + } + @Override public synchronized void save() throws IOException { if (null == allowSave) { diff --git a/hudson-core/src/main/java/org/eclipse/hudson/api/model/project/property/AxisListProjectProperty.java b/hudson-core/src/main/java/org/eclipse/hudson/api/model/project/property/AxisListProjectProperty.java new file mode 100644 index 0000000..b5fc6c5 --- a/dev/null +++ b/hudson-core/src/main/java/org/eclipse/hudson/api/model/project/property/AxisListProjectProperty.java @@ -0,0 +1,33 @@ +/******************************************************************************* + * + * Copyright (c) 2011 Oracle Corporation. + * + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * + * Anton Kozak + * + *******************************************************************************/ + +package org.eclipse.hudson.api.model.project.property; + +import hudson.matrix.AxisList; +import org.eclipse.hudson.api.model.IJob; + +/** + * Represents {@link hudson.matrix.AxisList} property. + * <p/> + * Date: 10/5/11 + * + * @author Anton Kozak + */ +public class AxisListProjectProperty extends BaseProjectProperty<AxisList> { + + public AxisListProjectProperty(IJob job) { + super(job); + } +}
\ No newline at end of file diff --git a/hudson-core/src/main/resources/hudson/matrix/MatrixProject/configure-entries.jelly b/hudson-core/src/main/resources/hudson/matrix/MatrixProject/configure-entries.jelly index cf45716..24938ae 100644 --- a/hudson-core/src/main/resources/hudson/matrix/MatrixProject/configure-entries.jelly +++ b/hudson-core/src/main/resources/hudson/matrix/MatrixProject/configure-entries.jelly @@ -46,10 +46,15 @@ href="${rootURL}/scripts/yui/treeview/assets/skins/sam/treeview.css" /> <f:block> + <j:set var="axesProperty" value="${it.getAxesListProjectProperty(it.AXES_PROPERTY_NAME)}"/> + <j:set var="axes" value="${axesProperty.getValue()}"/> + <f:hetero-list name="axis" hasHeader="true" descriptors="${descriptor.axisDescriptors}" - items="${it.axes}" - addCaption="${%Add axis}"/> + items="${axes}" + addCaption="${%Add axis}" + resetUrl="${jobUrl}/resetProjectProperty?propertyName=${it.AXES_PROPERTY_NAME}" + isPropertyOverridden="${axesProperty.isOverridden()}"/> </f:block> <j:set var="runSequentiallyProperty" value="${it.getBooleanProperty(it.RUN_SEQUENTIALLY_PROPERTY_NAME)}"/> |

