summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorakozak2011-11-21 07:38:27 (EST)
committer Winston Prakash2011-12-01 20:46:49 (EST)
commit8ceb5834a99f34a1c60e560557681f6493238ed0 (patch)
tree3f7464701712d23dc4e95843af31eaf2688db20c
parentb96c8bf239394b707209fb8eefd93ad488d6da6d (diff)
downloadorg.eclipse.hudson.core-8ceb5834a99f34a1c60e560557681f6493238ed0.zip
org.eclipse.hudson.core-8ceb5834a99f34a1c60e560557681f6493238ed0.tar.gz
org.eclipse.hudson.core-8ceb5834a99f34a1c60e560557681f6493238ed0.tar.bz2
Added interface for Matrix Project, refactoring.
Signed-off-by: Winston Prakash <winston.prakash@gmail.com>
-rw-r--r--hudson-core/src/main/java/hudson/matrix/Axis.java29
-rw-r--r--hudson-core/src/main/java/hudson/matrix/IMatrixProject.java164
-rw-r--r--hudson-core/src/main/java/hudson/matrix/MatrixProject.java129
-rw-r--r--hudson-core/src/main/java/hudson/model/IFreeStyleProject.java2
-rw-r--r--hudson-core/src/main/java/hudson/model/IJob.java2
-rw-r--r--hudson-core/src/main/java/hudson/model/IProject.java2
-rw-r--r--hudson-core/src/main/java/hudson/model/Job.java5
-rw-r--r--hudson-core/src/test/java/hudson/model/FreeStyleProjectTest.java1
8 files changed, 268 insertions, 66 deletions
diff --git a/hudson-core/src/main/java/hudson/matrix/Axis.java b/hudson-core/src/main/java/hudson/matrix/Axis.java
index 7dd482b..0a4c4d9 100644
--- a/hudson-core/src/main/java/hudson/matrix/Axis.java
+++ b/hudson-core/src/main/java/hudson/matrix/Axis.java
@@ -213,4 +213,33 @@ public class Axis extends AbstractDescribableImpl<Axis> implements Comparable<Ax
public void addBuildVariable(String value, Map<String,String> map) {
map.put(name,value);
}
+
+ @Override
+ public boolean equals(Object o) {
+ if (this == o) {
+ return true;
+ }
+ if (o == null || getClass() != o.getClass()) {
+ return false;
+ }
+
+ Axis axis = (Axis) o;
+
+ if (name != null ? !name.equals(axis.name) : axis.name != null) {
+ return false;
+ }
+ if (values != null ? !values.equals(axis.values) : axis.values != null) {
+ return false;
+ }
+
+ return true;
+ }
+
+ @Override
+ public int hashCode() {
+ int result = name != null ? name.hashCode() : 0;
+ result = 31 * result + (values != null ? values.hashCode() : 0);
+ return result;
+ }
}
+
diff --git a/hudson-core/src/main/java/hudson/matrix/IMatrixProject.java b/hudson-core/src/main/java/hudson/matrix/IMatrixProject.java
new file mode 100644
index 0000000..c49fd02
--- /dev/null
+++ b/hudson-core/src/main/java/hudson/matrix/IMatrixProject.java
@@ -0,0 +1,164 @@
+/*******************************************************************************
+ *
+ * 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:
+ *
+ * Фтещт Лщяфл
+ *
+ *******************************************************************************/
+package hudson.matrix;
+
+import hudson.model.Descriptor;
+import hudson.model.IAbstractProject;
+import hudson.model.Result;
+import hudson.tasks.BuildWrapper;
+import hudson.tasks.Builder;
+import hudson.tasks.Publisher;
+import hudson.util.DescribableList;
+import java.io.IOException;
+import java.util.List;
+import java.util.Map;
+
+/**
+ * Matrix Project Interface.
+ *
+ * @author Anton Kozak
+ */
+public interface IMatrixProject extends IAbstractProject {
+
+ /**
+ * Returns {@link AxisList} of configured axes.
+ *
+ * @return {@link AxisList} of configured axes.
+ */
+ public AxisList getAxes();
+
+ /**
+ * Reconfigures axes.
+ *
+ * @param axes new {@link AxisList}.
+ * @throws java.io.IOException exception.
+ */
+ public void setAxes(AxisList axes) throws IOException;
+
+ /**
+ * Whether Hudson should run {@link hudson.matrix.MatrixRun}s are run sequentially.
+ *
+ * @return If true, {@link hudson.matrix.MatrixRun}s are run sequentially, instead of running in parallel.
+ */
+ boolean isRunSequentially();
+
+ /**
+ * Sets the mode of the running.
+ *
+ * @param runSequentially If true, {@link hudson.matrix.MatrixRun}s are run sequentially, instead of running in parallel.
+ * @throws IOException exception.
+ */
+ void setRunSequentially(boolean runSequentially) throws IOException;
+
+ /**
+ * Sets the combination filter.
+ *
+ * @param combinationFilter the combinationFilter to set
+ * @throws java.io.IOException exception.
+ */
+ void setCombinationFilter(String combinationFilter) throws IOException;
+
+ /**
+ * Obtains the combination filter, used to trim down the size of the matrix.
+ * <p/>
+ * <p/>
+ * By default, a {@link hudson.matrix.MatrixConfiguration} is created for every possible combination of axes exhaustively.
+ * But by specifying a Groovy expression as a combination filter, one can trim down the # of combinations built.
+ * <p/>
+ * <p/>
+ * Namely, this expression is evaluated for each axis value combination, and only when it evaluates to true,
+ * a corresponding {@link hudson.matrix.MatrixConfiguration} will be created and built.
+ *
+ * @return can be null.
+ * @since 1.279
+ */
+ String getCombinationFilter();
+
+ /**
+ * Returns touchstone combination filter.
+ *
+ * @return touchstone combination filter.
+ */
+ String getTouchStoneCombinationFilter();
+
+ /**
+ * Sets touchstone combination filter.
+ *
+ * @param touchStoneCombinationFilter touchstone combination filter.
+ */
+ void setTouchStoneCombinationFilter(String touchStoneCombinationFilter);
+
+ /**
+ * Returns touchstone combination result condition.
+ *
+ * @return touchstone combination result condition.
+ */
+ Result getTouchStoneResultCondition();
+
+ /**
+ * Sets touchstone combination result condition.
+ *
+ * @param touchStoneResultCondition touchstone combination result condition.
+ */
+ void setTouchStoneResultCondition(Result touchStoneResultCondition);
+
+ /**
+ * Returns custom workspace.
+ *
+ * @return custom workspace.
+ */
+ String getCustomWorkspace();
+
+ /**
+ * Sets User-specified workspace directory, or null if it's up to Hudson.
+ * <p/>
+ * <p/>
+ * Normally a matrix project uses the workspace location assigned by its parent container,
+ * but sometimes people have builds that have hard-coded paths.
+ * <p/>
+ * <p/>
+ * This is not {@link java.io.File} because it may have to hold a path representation on another OS.
+ * <p/>
+ * <p/>
+ * If this path is relative, it's resolved against {@link hudson.model.Node#getRootPath()} on the node where this workspace
+ * is prepared.
+ *
+ * @param customWorkspace custom workspace.
+ * @throws java.io.IOException exception.
+ */
+ void setCustomWorkspace(String customWorkspace) throws IOException;
+
+ /**
+ * Returns list of active {@link Builder}s configured for this project.
+ *
+ * @return listof active {@link Builder}s configured for this project.
+ */
+ List<Builder> getBuilders();
+
+ /**
+ * Returns map of active {@link Publisher} configured for this project.
+ *
+ * @return map of active {@link Publisher} configured for this project.
+ */
+ Map<Descriptor<Publisher>, Publisher> getPublishers();
+
+ /**
+ * Returns {@link DescribableList} of active {@link BuildWrapper} configured for this project.
+ *
+ * @return @link DescribableList} of active {@link BuildWrapper} configured for this project.
+ */
+ DescribableList<BuildWrapper, Descriptor<BuildWrapper>> getBuildWrappersList();
+
+}
diff --git a/hudson-core/src/main/java/hudson/matrix/MatrixProject.java b/hudson-core/src/main/java/hudson/matrix/MatrixProject.java
index 8ccecba..1da46f9 100644
--- a/hudson-core/src/main/java/hudson/matrix/MatrixProject.java
+++ b/hudson-core/src/main/java/hudson/matrix/MatrixProject.java
@@ -82,7 +82,8 @@ import static hudson.Util.*;
*
* @author Kohsuke Kawaguchi
*/
-public class MatrixProject extends AbstractProject<MatrixProject,MatrixBuild> implements TopLevelItem, SCMedItem, ItemGroup<MatrixConfiguration>, Saveable, FlyweightTask, BuildableItemWithBuildWrappers {
+public class MatrixProject extends AbstractProject<MatrixProject,MatrixBuild> implements IMatrixProject, TopLevelItem,
+ SCMedItem, ItemGroup<MatrixConfiguration>, Saveable, FlyweightTask, BuildableItemWithBuildWrappers {
/**
* Configuration axes.
*/
@@ -151,12 +152,15 @@ public class MatrixProject extends AbstractProject<MatrixProject,MatrixBuild> im
super(parent, name);
}
+ /**
+ * @inheritDoc
+ */
public AxisList getAxes() {
return axes;
}
/**
- * Reconfigures axes.
+ * @inheritDoc
*/
public void setAxes(AxisList axes) throws IOException {
this.axes = new AxisList(axes);
@@ -165,23 +169,22 @@ public class MatrixProject extends AbstractProject<MatrixProject,MatrixBuild> im
}
/**
- * If true, {@link MatrixRun}s are run sequentially, instead of running in parallel.
- *
- * TODO: this should be subsumed by {@link ResourceController}.
+ * @inheritDoc
*/
public boolean isRunSequentially() {
return runSequentially;
}
+ /**
+ * @inheritDoc
+ */
public void setRunSequentially(boolean runSequentially) throws IOException {
this.runSequentially = runSequentially;
save();
}
/**
- * Sets the combination filter.
- *
- * @param combinationFilter the combinationFilter to set
+ * @inheritDoc
*/
public void setCombinationFilter(String combinationFilter) throws IOException {
this.combinationFilter = combinationFilter;
@@ -190,73 +193,99 @@ public class MatrixProject extends AbstractProject<MatrixProject,MatrixBuild> im
}
/**
- * Obtains the combination filter, used to trim down the size of the matrix.
- *
- * <p>
- * By default, a {@link MatrixConfiguration} is created for every possible combination of axes exhaustively.
- * But by specifying a Groovy expression as a combination filter, one can trim down the # of combinations built.
- *
- * <p>
- * Namely, this expression is evaluated for each axis value combination, and only when it evaluates to true,
- * a corresponding {@link MatrixConfiguration} will be created and built.
- *
- * @return can be null.
- * @since 1.279
+ * @inheritDoc
*/
public String getCombinationFilter() {
return combinationFilter;
}
+ /**
+ * @inheritDoc
+ */
public String getTouchStoneCombinationFilter() {
return touchStoneCombinationFilter;
}
+ /**
+ * @inheritDoc
+ */
public void setTouchStoneCombinationFilter(
String touchStoneCombinationFilter) {
this.touchStoneCombinationFilter = touchStoneCombinationFilter;
}
+ /**
+ * @inheritDoc
+ */
public Result getTouchStoneResultCondition() {
return touchStoneResultCondition;
}
+ /**
+ * @inheritDoc
+ */
public void setTouchStoneResultCondition(Result touchStoneResultCondition) {
this.touchStoneResultCondition = touchStoneResultCondition;
}
+ /**
+ * @inheritDoc
+ */
public String getCustomWorkspace() {
return customWorkspace;
}
-
+
/**
- * User-specified workspace directory, or null if it's up to Hudson.
- *
- * <p>
- * Normally a matrix project uses the workspace location assigned by its parent container,
- * but sometimes people have builds that have hard-coded paths.
- *
- * <p>
- * This is not {@link File} because it may have to hold a path representation on another OS.
- *
- * <p>
- * If this path is relative, it's resolved against {@link Node#getRootPath()} on the node where this workspace
- * is prepared.
+ * @inheritDoc
*/
public void setCustomWorkspace(String customWorkspace) throws IOException {
this.customWorkspace= customWorkspace;
}
-
+
+ /**
+ * @inheritDoc
+ */
+ public List<Builder> getBuilders() {
+ return builders.toList();
+ }
+
+ public DescribableList<Builder,Descriptor<Builder>> getBuildersList() {
+ return builders;
+ }
+
+ /**
+ * @inheritDoc
+ */
+ public Map<Descriptor<Publisher>,Publisher> getPublishers() {
+ return publishers.toMap();
+ }
+
+ public DescribableList<Publisher,Descriptor<Publisher>> getPublishersList() {
+ return publishers;
+ }
+
+ public DescribableList<BuildWrapper, Descriptor<BuildWrapper>> getBuildWrappersList() {
+ return buildWrappers;
+ }
+
+ /**
+ * @inheritDoc
+ */
+ public Map<Descriptor<BuildWrapper>,BuildWrapper> getBuildWrappers() {
+ return buildWrappers.toMap();
+ }
+
@Override
protected List<Action> createTransientActions() {
List<Action> r = super.createTransientActions();
- for (BuildStep step : builders)
+ for (BuildStep step : getBuildersList())
r.addAll(step.getProjectActions(this));
- for (BuildStep step : publishers)
+ for (BuildStep step : getPublishersList())
r.addAll(step.getProjectActions(this));
- for (BuildWrapper step : buildWrappers)
+ for (BuildWrapper step : getBuildWrappersList())
r.addAll(step.getProjectActions(this));
- for (Trigger trigger : triggers)
+ for (Trigger trigger : getTriggersList())
r.addAll(trigger.getProjectActions());
return r;
@@ -507,30 +536,6 @@ public class MatrixProject extends AbstractProject<MatrixProject,MatrixBuild> im
return r;
}
- public List<Builder> getBuilders() {
- return builders.toList();
- }
-
- public DescribableList<Builder,Descriptor<Builder>> getBuildersList() {
- return builders;
- }
-
- public Map<Descriptor<Publisher>,Publisher> getPublishers() {
- return publishers.toMap();
- }
-
- public DescribableList<Publisher,Descriptor<Publisher>> getPublishersList() {
- return publishers;
- }
-
- public DescribableList<BuildWrapper, Descriptor<BuildWrapper>> getBuildWrappersList() {
- return buildWrappers;
- }
-
- public Map<Descriptor<BuildWrapper>,BuildWrapper> getBuildWrappers() {
- return buildWrappers.toMap();
- }
-
public Publisher getPublisher(Descriptor<Publisher> descriptor) {
for (Publisher p : publishers) {
if(p.getDescriptor()==descriptor)
diff --git a/hudson-core/src/main/java/hudson/model/IFreeStyleProject.java b/hudson-core/src/main/java/hudson/model/IFreeStyleProject.java
index a982527..fcf6dd0 100644
--- a/hudson-core/src/main/java/hudson/model/IFreeStyleProject.java
+++ b/hudson-core/src/main/java/hudson/model/IFreeStyleProject.java
@@ -1,6 +1,6 @@
/*******************************************************************************
*
- * Copyright (c) 20011 Oracle Corporation.
+ * 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
diff --git a/hudson-core/src/main/java/hudson/model/IJob.java b/hudson-core/src/main/java/hudson/model/IJob.java
index c7f4c49..1a4584d 100644
--- a/hudson-core/src/main/java/hudson/model/IJob.java
+++ b/hudson-core/src/main/java/hudson/model/IJob.java
@@ -1,6 +1,6 @@
/*******************************************************************************
*
- * Copyright (c) 20011 Oracle Corporation.
+ * 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
diff --git a/hudson-core/src/main/java/hudson/model/IProject.java b/hudson-core/src/main/java/hudson/model/IProject.java
index 4baf249..79f3f8b 100644
--- a/hudson-core/src/main/java/hudson/model/IProject.java
+++ b/hudson-core/src/main/java/hudson/model/IProject.java
@@ -1,6 +1,6 @@
/*******************************************************************************
*
- * Copyright (c) 20011 Oracle Corporation.
+ * 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
diff --git a/hudson-core/src/main/java/hudson/model/Job.java b/hudson-core/src/main/java/hudson/model/Job.java
index 6319946..4aea26d 100644
--- a/hudson-core/src/main/java/hudson/model/Job.java
+++ b/hudson-core/src/main/java/hudson/model/Job.java
@@ -460,7 +460,7 @@ public abstract class Job<JobT extends Job<JobT, RunT>, RunT extends Run<JobT, R
*/
@SuppressWarnings("unchecked")
public Map<JobPropertyDescriptor, JobProperty<? super JobT>> getProperties() {
- return Descriptor.toMap((Iterable) properties);
+ return Descriptor.toMap((Iterable) properties); //TODO should we analyze properties from super psroject?
}
/**
@@ -1245,6 +1245,9 @@ public abstract class Job<JobT extends Job<JobT, RunT>, RunT extends Run<JobT, R
*/
@SuppressWarnings({"unchecked"})
public JobT getTemplate() {
+ if (template == null) {
+ template = (JobT) Functions.getItemByName(Hudson.getInstance().getAllItems(this.getClass()), templateName);
+ }
return template;
}
diff --git a/hudson-core/src/test/java/hudson/model/FreeStyleProjectTest.java b/hudson-core/src/test/java/hudson/model/FreeStyleProjectTest.java
index bf75363..6017ba4 100644
--- a/hudson-core/src/test/java/hudson/model/FreeStyleProjectTest.java
+++ b/hudson-core/src/test/java/hudson/model/FreeStyleProjectTest.java
@@ -234,6 +234,7 @@ public class FreeStyleProjectTest {
FreeStyleProject childProject1 = new FreeStyleProjectMock("child1");
childProject1.setLogRotator(new LogRotator(10, 11, 12, 13));
assertNotNull(childProject1.getLogRotator());
+ assertEquals(childProject1.getLogRotator().getDaysToKeep(), 10);
}
@Test