001: /*
002: * Licensed to the Apache Software Foundation (ASF) under one or more
003: * contributor license agreements. See the NOTICE file distributed with
004: * this work for additional information regarding copyright ownership.
005: * The ASF licenses this file to You under the Apache License, Version 2.0
006: * (the "License"); you may not use this file except in compliance with
007: * the License. You may obtain a copy of the License at
008: *
009: * http://www.apache.org/licenses/LICENSE-2.0
010: *
011: * Unless required by applicable law or agreed to in writing, software
012: * distributed under the License is distributed on an "AS IS" BASIS,
013: * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
014: * See the License for the specific language governing permissions and
015: * limitations under the License.
016: *
017: */
018: package org.apache.ivy.core.deliver;
019:
020: import java.util.Date;
021:
022: import org.apache.ivy.core.settings.IvySettings;
023:
024: /**
025: * A set of options used to do a deliver.
026: */
027: public class DeliverOptions {
028: private String status;
029:
030: private Date pubdate;
031:
032: private PublishingDependencyRevisionResolver pdrResolver = new DefaultPublishingDRResolver();
033:
034: private boolean validate = true;
035:
036: private boolean resolveDynamicRevisions = true;
037:
038: private String resolveId;
039:
040: private String[] confs;
041:
042: /**
043: * Returns an instance of DeliverOptions with options corresponding to default values taken from
044: * the given settings.
045: *
046: * @param settings
047: * The settings to use to get default option values
048: * @return a DeliverOptions instance ready to be used or customized
049: */
050: public static DeliverOptions newInstance(IvySettings settings) {
051: return new DeliverOptions(null, new Date(),
052: new DefaultPublishingDRResolver(), settings
053: .doValidate(), true, null);
054: }
055:
056: /**
057: * Creates an instance of DeliverOptions which require to be configured using the appropriate
058: * setters.
059: */
060: public DeliverOptions() {
061: }
062:
063: /**
064: * Creates an instance of DeliverOptions with all options explicitly set.
065: */
066: public DeliverOptions(String status, Date pubDate,
067: PublishingDependencyRevisionResolver pdrResolver,
068: boolean validate, boolean resolveDynamicRevisions,
069: String[] confs) {
070: this .status = status;
071: this .pubdate = pubDate;
072: this .pdrResolver = pdrResolver;
073: this .validate = validate;
074: this .resolveDynamicRevisions = resolveDynamicRevisions;
075: this .confs = confs;
076: }
077:
078: /**
079: * Return the pdrResolver that will be used during deliver for each dependency to get its
080: * published information. This can particularly useful when the deliver is made for a release,
081: * and when we wish to deliver each dependency which is still in integration. The
082: * PublishingDependencyRevisionResolver can then do the delivering work for the dependency and
083: * return the new (delivered) dependency info (with the delivered revision). Note that
084: * PublishingDependencyRevisionResolver is only called for each <b>direct</b> dependency.
085: *
086: * @return the pdrResolver that will be used during deliver
087: */
088: public PublishingDependencyRevisionResolver getPdrResolver() {
089: return pdrResolver;
090: }
091:
092: /**
093: * Sets the pdrResolver that will be used during deliver for each dependency to get its
094: * published information. This can particularly useful when the deliver is made for a release,
095: * and when we wish to deliver each dependency which is still in integration. The
096: * PublishingDependencyRevisionResolver can then do the delivering work for the dependency and
097: * return the new (delivered) dependency info (with the delivered revision). Note that
098: * PublishingDependencyRevisionResolver is only called for each <b>direct</b> dependency.
099: *
100: * @return the instance of DeliverOptions on which the method has been called, for easy method
101: * chaining
102: */
103: public DeliverOptions setPdrResolver(
104: PublishingDependencyRevisionResolver pdrResolver) {
105: this .pdrResolver = pdrResolver;
106: return this ;
107: }
108:
109: public boolean isResolveDynamicRevisions() {
110: return resolveDynamicRevisions;
111: }
112:
113: public DeliverOptions setResolveDynamicRevisions(
114: boolean resolveDynamicRevisions) {
115: this .resolveDynamicRevisions = resolveDynamicRevisions;
116: return this ;
117: }
118:
119: public boolean isValidate() {
120: return validate;
121: }
122:
123: public DeliverOptions setValidate(boolean validate) {
124: this .validate = validate;
125: return this ;
126: }
127:
128: public Date getPubdate() {
129: return pubdate;
130: }
131:
132: public DeliverOptions setPubdate(Date pubdate) {
133: this .pubdate = pubdate;
134: return this ;
135: }
136:
137: /**
138: * Returns the status to which the module should be delivered, or null if the current status
139: * should be kept.
140: *
141: * @return the status to which the module should be delivered
142: */
143: public String getStatus() {
144: return status;
145: }
146:
147: /**
148: * Sets the status to which the module should be delivered, use null if the current status
149: * should be kept.
150: *
151: * @return the instance of DeliverOptions on which the method has been called, for easy method
152: * chaining
153: */
154: public DeliverOptions setStatus(String status) {
155: this .status = status;
156: return this ;
157: }
158:
159: /**
160: * Returns the id of a previous resolve to use for delivering.
161: *
162: * @return the id of a previous resolve
163: */
164: public String getResolveId() {
165: return resolveId;
166: }
167:
168: /**
169: * Sets the id of a previous resolve to use for delivering.
170: *
171: * @param resolveId
172: * the id of a previous resolve
173: * @return the instance of DeliverOptions on which the method has been called, for easy method
174: * chaining
175: */
176: public DeliverOptions setResolveId(String resolveId) {
177: this .resolveId = resolveId;
178: return this ;
179: }
180:
181: /**
182: * Return the configurations which must be deliverd. Returns <tt>null</tt> if all
183: * configurations has to be deliverd. Attention: the returned array can contain wildcards!
184: *
185: * @return the configurations to deliver
186: */
187: public String[] getConfs() {
188: return confs;
189: }
190:
191: /**
192: * Sets the configurations to deliver.
193: *
194: * @param confs
195: * the configurations to deliver
196: * @return the instance of DeliverOptions on which the method has been called, for easy method
197: * chaining
198: */
199: public DeliverOptions setConfs(String[] confs) {
200: this .confs = confs;
201: return this ;
202: }
203:
204: public String toString() {
205: return "status=" + status + " pubdate=" + pubdate
206: + " validate=" + validate + " resolveDynamicRevisions="
207: + resolveDynamicRevisions + " resolveId=" + resolveId;
208:
209: }
210:
211: }
|