aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorakozak2011-11-23 03:37:34 (EST)
committerWinston Prakash2011-12-01 20:47:07 (EST)
commitb007562fbee09f45a624393aa879f7fe273d15e5 (patch)
tree4f8e92606c08cf0649c5c3f339ac757cc6f63eb9
parent14ab5577ec76c95ad976a03766323424ca9549d0 (diff)
downloadorg.eclipse.hudson.core-b007562fbee09f45a624393aa879f7fe273d15e5.zip
org.eclipse.hudson.core-b007562fbee09f45a624393aa879f7fe273d15e5.tar.gz
org.eclipse.hudson.core-b007562fbee09f45a624393aa879f7fe273d15e5.tar.bz2
Migrate builders section to IProjectProperty usage
Signed-off-by: Winston Prakash <winston.prakash@gmail.com>
-rw-r--r--hudson-core/src/main/java/hudson/model/Job.java5
-rw-r--r--hudson-core/src/main/java/hudson/model/Project.java33
-rw-r--r--hudson-core/src/main/java/org/eclipse/hudson/api/model/project/property/BaseProjectProperty.java2
-rw-r--r--hudson-core/src/main/resources/hudson/model/AbstractItem/configure-common.jelly1
-rw-r--r--hudson-core/src/main/resources/hudson/model/Project/configure-entries.jelly5
-rw-r--r--hudson-core/src/main/resources/lib/hudson/project/config-builders.jelly15
6 files changed, 43 insertions, 18 deletions
diff --git a/hudson-core/src/main/java/hudson/model/Job.java b/hudson-core/src/main/java/hudson/model/Job.java
index 519518d..6ac14ab 100644
--- a/hudson-core/src/main/java/hudson/model/Job.java
+++ b/hudson-core/src/main/java/hudson/model/Job.java
@@ -20,6 +20,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.DescribableListProjectProperty;
import org.eclipse.hudson.api.model.project.property.IntegerProjectProperty;
import org.eclipse.hudson.api.model.project.property.LogRotatorProjectProperty;
import org.eclipse.hudson.api.model.project.property.ResultProjectProperty;
@@ -269,6 +270,10 @@ public abstract class Job<JobT extends Job<JobT, RunT>, RunT extends Run<JobT, R
return (AxisListProjectProperty) getProperty(key, AxisListProjectProperty.class);
}
+ public DescribableListProjectProperty getDescribableListProjectProperty(String key) {
+ return (DescribableListProjectProperty) getProperty(key, DescribableListProjectProperty.class);
+ }
+
@Override
public synchronized void save() throws IOException {
if (null == allowSave) {
diff --git a/hudson-core/src/main/java/hudson/model/Project.java b/hudson-core/src/main/java/hudson/model/Project.java
index 171ff2b..004c003 100644
--- a/hudson-core/src/main/java/hudson/model/Project.java
+++ b/hudson-core/src/main/java/hudson/model/Project.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
@@ -52,8 +52,13 @@ public abstract class Project<P extends Project<P,B>,B extends Build<P,B>>
extends AbstractProject<P,B> implements SCMedItem, Saveable, ProjectWithMaven, BuildableItemWithBuildWrappers,
IProject {
+ public static final String BUILDERS_PROPERTY_NAME = "builders";
+
/**
* List of active {@link Builder}s configured for this project.
+ * @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.
*/
private DescribableList<Builder,Descriptor<Builder>> builders =
new DescribableList<Builder,Descriptor<Builder>>(this);
@@ -86,25 +91,38 @@ public abstract class Project<P extends Project<P,B>,B extends Build<P,B>>
buildWrappers = new DescribableList<BuildWrapper, Descriptor<BuildWrapper>>(this);
OldDataMonitor.report(this, "1.64");
}
- builders.setOwner(this);
+ getBuildersList().setOwner(this);
publishers.setOwner(this);
buildWrappers.setOwner(this);
}
+ @Override
+ protected void buildProjectProperties() throws IOException {
+ super.buildProjectProperties();
+ if (null == getProperty(BUILDERS_PROPERTY_NAME)) {
+ setBuilders(builders);
+ builders = null;
+ }
+ }
+
public AbstractProject<?, ?> asProject() {
return this;
}
public List<Builder> getBuilders() {
- return builders.toList();
+ return getBuildersList().toList();
}
public Map<Descriptor<Publisher>,Publisher> getPublishers() {
return publishers.toMap();
}
+ public void setBuilders(DescribableList<Builder,Descriptor<Builder>> builders) {
+ getDescribableListProjectProperty(BUILDERS_PROPERTY_NAME).setValue(builders);
+ }
+
public DescribableList<Builder,Descriptor<Builder>> getBuildersList() {
- return builders;
+ return getDescribableListProjectProperty(BUILDERS_PROPERTY_NAME).getValue();
}
public DescribableList<Publisher,Descriptor<Publisher>> getPublishersList() {
@@ -187,8 +205,11 @@ public abstract class Project<P extends Project<P,B>,B extends Build<P,B>>
JSONObject json = req.getSubmittedForm();
- buildWrappers.rebuild(req,json, BuildWrappers.getFor(this));
- builders.rebuildHetero(req,json, Builder.all(), "builder");
+ buildWrappers.rebuild(req, json, BuildWrappers.getFor(this));
+ DescribableList<Builder, Descriptor<Builder>> buildersCandidates
+ = new DescribableList<Builder, Descriptor<Builder>>(this);
+ buildersCandidates.replaceBy(Descriptor.newInstancesFromHeteroList(req, json, "builder", Builder.all()));
+ setBuilders(buildersCandidates);
publishers.rebuild(req, json, BuildStepDescriptor.filter(Publisher.all(), this.getClass()));
}
diff --git a/hudson-core/src/main/java/org/eclipse/hudson/api/model/project/property/BaseProjectProperty.java b/hudson-core/src/main/java/org/eclipse/hudson/api/model/project/property/BaseProjectProperty.java
index 1ee8a9f..042db2c 100644
--- a/hudson-core/src/main/java/org/eclipse/hudson/api/model/project/property/BaseProjectProperty.java
+++ b/hudson-core/src/main/java/org/eclipse/hudson/api/model/project/property/BaseProjectProperty.java
@@ -150,7 +150,7 @@ public class BaseProjectProperty<T> implements IProjectProperty<T> {
* @return true if cascading value should be replaced by candidate value.
*/
protected boolean allowOverrideValue(T cascadingValue, T candidateValue) {
- return !ObjectUtils.equals(cascadingValue, candidateValue);
+ return ObjectUtils.notEqual(cascadingValue, candidateValue);
}
/**
diff --git a/hudson-core/src/main/resources/hudson/model/AbstractItem/configure-common.jelly b/hudson-core/src/main/resources/hudson/model/AbstractItem/configure-common.jelly
index b35898a..9589132 100644
--- a/hudson-core/src/main/resources/hudson/model/AbstractItem/configure-common.jelly
+++ b/hudson-core/src/main/resources/hudson/model/AbstractItem/configure-common.jelly
@@ -24,7 +24,6 @@
<j:if test="${app.CONCURRENT_BUILD}">
<f:optionalBlock field="concurrentBuild" title="${%title.concurrentbuilds}"/>
</j:if>
- <j:set var="jobUrl" value="${h.getNearestAncestorUrl(request,it)}"/>
<j:set var="jdks" value="${app.JDKs}"/>
<j:if test="${jdks.size() gt 1}">
<!-- if there's only one JDK configured, always use that. -->
diff --git a/hudson-core/src/main/resources/hudson/model/Project/configure-entries.jelly b/hudson-core/src/main/resources/hudson/model/Project/configure-entries.jelly
index b39a3f1..60b0ea2 100644
--- a/hudson-core/src/main/resources/hudson/model/Project/configure-entries.jelly
+++ b/hudson-core/src/main/resources/hudson/model/Project/configure-entries.jelly
@@ -1,6 +1,6 @@
<!-- **************************************************************************
#
-# Copyright (c) 2004-2009 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, Nikita Levyankov
#
#
#************************************************************************** -->
@@ -19,6 +19,7 @@
Config page
-->
<j:jelly xmlns:j="jelly:core" xmlns:st="jelly:stapler" xmlns:d="jelly:define" xmlns:l="/lib/layout" xmlns:t="/lib/hudson" xmlns:f="/lib/form" xmlns:p="/lib/hudson/project">
+ <j:set var="jobUrl" value="${h.getNearestAncestorUrl(request,it)}"/>
<st:include page="configure-common.jelly" />
<p:config-trigger>
diff --git a/hudson-core/src/main/resources/lib/hudson/project/config-builders.jelly b/hudson-core/src/main/resources/lib/hudson/project/config-builders.jelly
index 95050d5..ea32b4c 100644
--- a/hudson-core/src/main/resources/lib/hudson/project/config-builders.jelly
+++ b/hudson-core/src/main/resources/lib/hudson/project/config-builders.jelly
@@ -1,6 +1,6 @@
<!-- **************************************************************************
#
-# Copyright (c) 2004-2009 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, Nikita Levyankov
#
#
#************************************************************************** -->
@@ -19,17 +19,16 @@
Builder config pane
-->
<j:jelly xmlns:j="jelly:core" xmlns:st="jelly:stapler" xmlns:d="jelly:define" xmlns:l="/lib/layout" xmlns:t="/lib/hudson" xmlns:f="/lib/form" xmlns:p="/lib/hudson/project">
+ <j:set var="buildersProperty" value="${it.getDescribableListProjectProperty(it.BUILDERS_PROPERTY_NAME)}"/>
+ <j:set var="builders" value="${buildersProperty.getValue()}"/>
<!-- build config pane -->
- <!--f:descriptorList title="${%Build}"
- descriptors="${h.getBuilderDescriptors(it)}"
- instances="${it.builders}"
- varName="builder" /-->
-
<f:section title="${%Build}">
<f:block>
<f:hetero-list name="builder" hasHeader="true"
descriptors="${h.getBuilderDescriptors(it)}"
- items="${it.builders}"
+ items="${builders}"
+ isPropertyOverridden="${buildersProperty.isOverridden()}"
+ resetUrl="${jobUrl}/resetProjectProperty?propertyName=${it.BUILDERS_PROPERTY_NAME}"
addCaption="${%Add build step}"/>
</f:block>
</f:section>