Source Code Cross Referenced for IvyPublish.java in  » Code-Analyzer » apache-ivy » org » apache » ivy » ant » Java Source Code / Java DocumentationJava Source Code and Java Documentation

Java Source Code / Java Documentation
1. 6.0 JDK Core
2. 6.0 JDK Modules
3. 6.0 JDK Modules com.sun
4. 6.0 JDK Modules com.sun.java
5. 6.0 JDK Modules sun
6. 6.0 JDK Platform
7. Ajax
8. Apache Harmony Java SE
9. Aspect oriented
10. Authentication Authorization
11. Blogger System
12. Build
13. Byte Code
14. Cache
15. Chart
16. Chat
17. Code Analyzer
18. Collaboration
19. Content Management System
20. Database Client
21. Database DBMS
22. Database JDBC Connection Pool
23. Database ORM
24. Development
25. EJB Server geronimo
26. EJB Server GlassFish
27. EJB Server JBoss 4.2.1
28. EJB Server resin 3.1.5
29. ERP CRM Financial
30. ESB
31. Forum
32. GIS
33. Graphic Library
34. Groupware
35. HTML Parser
36. IDE
37. IDE Eclipse
38. IDE Netbeans
39. Installer
40. Internationalization Localization
41. Inversion of Control
42. Issue Tracking
43. J2EE
44. JBoss
45. JMS
46. JMX
47. Library
48. Mail Clients
49. Net
50. Parser
51. PDF
52. Portal
53. Profiler
54. Project Management
55. Report
56. RSS RDF
57. Rule Engine
58. Science
59. Scripting
60. Search Engine
61. Security
62. Sevlet Container
63. Source Control
64. Swing Library
65. Template Engine
66. Test Coverage
67. Testing
68. UML
69. Web Crawler
70. Web Framework
71. Web Mail
72. Web Server
73. Web Services
74. Web Services apache cxf 2.0.1
75. Web Services AXIS2
76. Wiki Engine
77. Workflow Engines
78. XML
79. XML UI
Java
Java Tutorial
Java Open Source
Jar File Download
Java Articles
Java Products
Java by API
Photoshop Tutorials
Maya Tutorials
Flash Tutorials
3ds-Max Tutorials
Illustrator Tutorials
GIMP Tutorials
C# / C Sharp
C# / CSharp Tutorial
C# / CSharp Open Source
ASP.Net
ASP.NET Tutorial
JavaScript DHTML
JavaScript Tutorial
JavaScript Reference
HTML / CSS
HTML CSS Reference
C / ANSI-C
C Tutorial
C++
C++ Tutorial
Ruby
PHP
Python
Python Tutorial
Python Open Source
SQL Server / T-SQL
SQL Server / T-SQL Tutorial
Oracle PL / SQL
Oracle PL/SQL Tutorial
PostgreSQL
SQL / MySQL
MySQL Tutorial
VB.Net
VB.Net Tutorial
Flash / Flex / ActionScript
VBA / Excel / Access / Word
XML
XML Tutorial
Microsoft Office PowerPoint 2007 Tutorial
Microsoft Office Excel 2007 Tutorial
Microsoft Office Word 2007 Tutorial
Java Source Code / Java Documentation » Code Analyzer » apache ivy » org.apache.ivy.ant 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


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.ant;
019:
020:        import java.io.File;
021:        import java.net.URL;
022:        import java.util.ArrayList;
023:        import java.util.Collection;
024:        import java.util.Date;
025:        import java.util.HashMap;
026:        import java.util.Iterator;
027:        import java.util.List;
028:        import java.util.Map;
029:
030:        import org.apache.ivy.Ivy;
031:        import org.apache.ivy.core.IvyPatternHelper;
032:        import org.apache.ivy.core.module.descriptor.Artifact;
033:        import org.apache.ivy.core.module.id.ArtifactRevisionId;
034:        import org.apache.ivy.core.module.id.ModuleRevisionId;
035:        import org.apache.ivy.core.publish.PublishOptions;
036:        import org.apache.ivy.core.settings.IvySettings;
037:        import org.apache.ivy.util.Message;
038:        import org.apache.tools.ant.BuildException;
039:
040:        /**
041:         * This task allow to publish a module revision to an Ivy repository.
042:         */
043:        public class IvyPublish extends IvyTask {
044:            private String organisation;
045:
046:            private String module;
047:
048:            private String revision;
049:
050:            private String pubRevision;
051:
052:            private String srcivypattern;
053:
054:            private String status;
055:
056:            private String conf = null;
057:
058:            private String pubdate;
059:
060:            private String deliverTarget;
061:
062:            private String publishResolverName = null;
063:
064:            private List artifactspattern = new ArrayList();
065:
066:            private File deliveryList;
067:
068:            private boolean publishivy = true;
069:
070:            private boolean warnonmissing = true;
071:
072:            private boolean haltonmissing = true;
073:
074:            private boolean overwrite = false;
075:
076:            private boolean update = false;
077:
078:            private boolean replacedynamicrev = true;
079:
080:            private boolean forcedeliver;
081:
082:            private Collection artifacts = new ArrayList();
083:
084:            public void setCache(File cache) {
085:                cacheAttributeNotSupported();
086:            }
087:
088:            public String getSrcivypattern() {
089:                return srcivypattern;
090:            }
091:
092:            public void setSrcivypattern(String destivypattern) {
093:                srcivypattern = destivypattern;
094:            }
095:
096:            /**
097:             * @deprecated use {@link #getSrcivypattern()} instead.
098:             */
099:            public String getDeliverivypattern() {
100:                return srcivypattern;
101:            }
102:
103:            /**
104:             * @deprecated use {@link #setSrcivypattern(String)} instead.
105:             */
106:            public void setDeliverivypattern(String destivypattern) {
107:                srcivypattern = destivypattern;
108:            }
109:
110:            public String getModule() {
111:                return module;
112:            }
113:
114:            public void setModule(String module) {
115:                this .module = module;
116:            }
117:
118:            public String getOrganisation() {
119:                return organisation;
120:            }
121:
122:            public void setOrganisation(String organisation) {
123:                this .organisation = organisation;
124:            }
125:
126:            public String getPubdate() {
127:                return pubdate;
128:            }
129:
130:            public void setPubdate(String pubdate) {
131:                this .pubdate = pubdate;
132:            }
133:
134:            public String getPubrevision() {
135:                return pubRevision;
136:            }
137:
138:            public void setPubrevision(String pubRevision) {
139:                this .pubRevision = pubRevision;
140:            }
141:
142:            public String getRevision() {
143:                return revision;
144:            }
145:
146:            public void setRevision(String revision) {
147:                this .revision = revision;
148:            }
149:
150:            public String getStatus() {
151:                return status;
152:            }
153:
154:            public void setStatus(String status) {
155:                this .status = status;
156:            }
157:
158:            public void setConf(String conf) {
159:                this .conf = conf;
160:            }
161:
162:            public void setDelivertarget(String deliverTarget) {
163:                this .deliverTarget = deliverTarget;
164:            }
165:
166:            public void setDeliveryList(File deliveryList) {
167:                this .deliveryList = deliveryList;
168:            }
169:
170:            public String getResolver() {
171:                return publishResolverName;
172:            }
173:
174:            public void setResolver(String publishResolverName) {
175:                this .publishResolverName = publishResolverName;
176:            }
177:
178:            public String getArtifactspattern() {
179:                return (String) (artifactspattern.isEmpty() ? null
180:                        : artifactspattern.get(0));
181:            }
182:
183:            public void setArtifactspattern(String artifactsPattern) {
184:                artifactspattern.clear();
185:                artifactspattern.add(artifactsPattern);
186:            }
187:
188:            public void addArtifactspattern(String artifactsPattern) {
189:                artifactspattern.add(artifactsPattern);
190:            }
191:
192:            public void addConfiguredArtifacts(ArtifactsPattern p) {
193:                artifactspattern.add(p.getPattern());
194:            }
195:
196:            public boolean isReplacedynamicrev() {
197:                return replacedynamicrev;
198:            }
199:
200:            public void setReplacedynamicrev(boolean replacedynamicrev) {
201:                this .replacedynamicrev = replacedynamicrev;
202:            }
203:
204:            public void doExecute() throws BuildException {
205:                Ivy ivy = getIvyInstance();
206:                IvySettings settings = ivy.getSettings();
207:
208:                organisation = getProperty(organisation, settings,
209:                        "ivy.organisation");
210:                module = getProperty(module, settings, "ivy.module");
211:                revision = getProperty(revision, settings, "ivy.revision");
212:                pubRevision = getProperty(pubRevision, settings,
213:                        "ivy.deliver.revision");
214:                if (artifactspattern.isEmpty()) {
215:                    String p = getProperty(null, settings,
216:                            "ivy.publish.src.artifacts.pattern");
217:                    if (p != null) {
218:                        artifactspattern.add(p);
219:                    }
220:                }
221:                if (srcivypattern == null) {
222:                    srcivypattern = getArtifactspattern();
223:                }
224:                status = getProperty(status, settings, "ivy.status");
225:                if (organisation == null) {
226:                    throw new BuildException(
227:                            "no organisation provided for ivy publish task: "
228:                                    + "It can either be set explicitely via the attribute 'organisation' "
229:                                    + "or via 'ivy.organisation' property or a prior call to <resolve/>");
230:                }
231:                if (module == null) {
232:                    throw new BuildException(
233:                            "no module name provided for ivy publish task: "
234:                                    + "It can either be set explicitely via the attribute 'module' "
235:                                    + "or via 'ivy.module' property or a prior call to <resolve/>");
236:                }
237:                if (revision == null) {
238:                    throw new BuildException(
239:                            "no module revision provided for ivy publish task: "
240:                                    + "It can either be set explicitely via the attribute 'revision' "
241:                                    + "or via 'ivy.revision' property or a prior call to <resolve/>");
242:                }
243:                if (artifactspattern.isEmpty()) {
244:                    throw new BuildException(
245:                            "no artifacts pattern: either provide it through parameter or "
246:                                    + "through ivy.publish.src.artifacts.pattern property");
247:                }
248:                if (publishResolverName == null) {
249:                    throw new BuildException(
250:                            "no publish deliver name: please provide it through parameter 'resolver'");
251:                }
252:                if ("working".equals(revision)) {
253:                    revision = Ivy.getWorkingRevision();
254:                }
255:                Date pubdate = getPubDate(this .pubdate, new Date());
256:                if (pubRevision == null) {
257:                    if (revision.startsWith("working@")) {
258:                        pubRevision = Ivy.DATE_FORMAT.format(pubdate);
259:                    } else {
260:                        pubRevision = revision;
261:                    }
262:                }
263:                if (status == null) {
264:                    throw new BuildException(
265:                            "no status provided: either provide it as parameter "
266:                                    + "or through the ivy.status.default property");
267:                }
268:                ModuleRevisionId mrid = ModuleRevisionId.newInstance(
269:                        organisation, module, revision);
270:                try {
271:                    File ivyFile = new File(IvyPatternHelper.substitute(
272:                            srcivypattern, organisation, module, pubRevision,
273:                            "ivy", "ivy", "xml"));
274:                    if (publishivy && (!ivyFile.exists() || forcedeliver)) {
275:                        IvyDeliver deliver = new IvyDeliver();
276:                        deliver.setSettingsRef(getSettingsRef());
277:                        deliver.setTaskName(getTaskName());
278:                        deliver.setProject(getProject());
279:                        deliver.setDeliverpattern(getSrcivypattern());
280:                        deliver.setDelivertarget(deliverTarget);
281:                        deliver.setDeliveryList(deliveryList);
282:                        deliver.setModule(getModule());
283:                        deliver.setOrganisation(getOrganisation());
284:                        deliver.setPubdate(Ivy.DATE_FORMAT.format(pubdate));
285:                        deliver.setPubrevision(getPubrevision());
286:                        deliver.setRevision(getRevision());
287:                        deliver.setStatus(getStatus());
288:                        deliver.setValidate(doValidate(settings));
289:                        deliver.setReplacedynamicrev(isReplacedynamicrev());
290:                        deliver.setConf(conf);
291:
292:                        deliver.execute();
293:                    }
294:
295:                    Collection missing = ivy
296:                            .publish(
297:                                    mrid,
298:                                    artifactspattern,
299:                                    publishResolverName,
300:                                    new PublishOptions()
301:                                            .setPubrevision(getPubrevision())
302:                                            .setSrcIvyPattern(
303:                                                    publishivy ? srcivypattern
304:                                                            : null)
305:                                            .setStatus(getStatus())
306:                                            .setPubdate(pubdate)
307:                                            .setExtraArtifacts(
308:                                                    (Artifact[]) artifacts
309:                                                            .toArray(new Artifact[artifacts
310:                                                                    .size()]))
311:                                            .setValidate(doValidate(settings))
312:                                            .setOverwrite(overwrite).setUpdate(
313:                                                    update).setConfs(
314:                                                    splitConfs(conf)));
315:                    if (warnonmissing) {
316:                        for (Iterator iter = missing.iterator(); iter.hasNext();) {
317:                            Artifact artifact = (Artifact) iter.next();
318:                            Message.warn("missing artifact: " + artifact);
319:                        }
320:                    }
321:                    if (haltonmissing && !missing.isEmpty()) {
322:                        throw new BuildException(
323:                                "missing published artifacts for " + mrid
324:                                        + ": " + missing);
325:                    }
326:
327:                } catch (Exception e) {
328:                    throw new BuildException(
329:                            "impossible to publish artifacts for " + mrid
330:                                    + ": " + e, e);
331:                }
332:            }
333:
334:            public PublishArtifact createArtifact() {
335:                PublishArtifact art = new PublishArtifact();
336:                artifacts.add(art);
337:                return art;
338:            }
339:
340:            public boolean isPublishivy() {
341:                return publishivy;
342:            }
343:
344:            public void setPublishivy(boolean publishivy) {
345:                this .publishivy = publishivy;
346:            }
347:
348:            public boolean isWarnonmissing() {
349:                return warnonmissing;
350:            }
351:
352:            public void setWarnonmissing(boolean warnonmissing) {
353:                this .warnonmissing = warnonmissing;
354:            }
355:
356:            public boolean isHaltonmissing() {
357:                return haltonmissing;
358:            }
359:
360:            public void setHaltonmissing(boolean haltonmissing) {
361:                this .haltonmissing = haltonmissing;
362:            }
363:
364:            public boolean isOverwrite() {
365:                return overwrite;
366:            }
367:
368:            public void setOverwrite(boolean overwrite) {
369:                this .overwrite = overwrite;
370:            }
371:
372:            public void setForcedeliver(boolean b) {
373:                forcedeliver = b;
374:            }
375:
376:            public boolean isForcedeliver() {
377:                return forcedeliver;
378:            }
379:
380:            public boolean isUpdate() {
381:                return update;
382:            }
383:
384:            public void setUpdate(boolean update) {
385:                this .update = update;
386:            }
387:
388:            public class PublishArtifact implements  Artifact {
389:                private String ext;
390:
391:                private String name;
392:
393:                private String type;
394:
395:                public String[] getConfigurations() {
396:                    return null;
397:                }
398:
399:                public String getExt() {
400:                    return ext == null ? type : ext;
401:                }
402:
403:                public ArtifactRevisionId getId() {
404:                    return null;
405:                }
406:
407:                public ModuleRevisionId getModuleRevisionId() {
408:                    return null;
409:                }
410:
411:                public String getName() {
412:                    return name;
413:                }
414:
415:                public Date getPublicationDate() {
416:                    return null;
417:                }
418:
419:                public String getType() {
420:                    return type;
421:                }
422:
423:                public URL getUrl() {
424:                    return null;
425:                }
426:
427:                public void setExt(String ext) {
428:                    this .ext = ext;
429:                }
430:
431:                public void setName(String name) {
432:                    this .name = name;
433:                }
434:
435:                public void setType(String type) {
436:                    this .type = type;
437:                }
438:
439:                public String getAttribute(String attName) {
440:                    return null;
441:                }
442:
443:                public Map getAttributes() {
444:                    return new HashMap();
445:                }
446:
447:                public String getExtraAttribute(String attName) {
448:                    return null;
449:                }
450:
451:                public Map getExtraAttributes() {
452:                    return new HashMap();
453:                }
454:
455:                public Map getQualifiedExtraAttributes() {
456:                    return getExtraAttributes();
457:                }
458:
459:                public String getStandardAttribute(String attName) {
460:                    return null;
461:                }
462:
463:                public Map getStandardAttributes() {
464:                    return new HashMap();
465:                }
466:
467:                public boolean isMetadata() {
468:                    return false;
469:                }
470:            }
471:
472:            public static class ArtifactsPattern {
473:                private String pattern;
474:
475:                public String getPattern() {
476:                    return pattern;
477:                }
478:
479:                public void setPattern(String pattern) {
480:                    this.pattern = pattern;
481:                }
482:            }
483:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.