01: /*
02: * Licensed to the Apache Software Foundation (ASF) under one or more
03: * contributor license agreements. See the NOTICE file distributed with
04: * this work for additional information regarding copyright ownership.
05: * The ASF licenses this file to You under the Apache License, Version 2.0
06: * (the "License"); you may not use this file except in compliance with
07: * the License. You may obtain a copy of the License at
08: *
09: * http://www.apache.org/licenses/LICENSE-2.0
10: *
11: * Unless required by applicable law or agreed to in writing, software
12: * distributed under the License is distributed on an "AS IS" BASIS,
13: * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14: * See the License for the specific language governing permissions and
15: * limitations under the License.
16: *
17: */
18: package org.apache.ivy.ant;
19:
20: import java.util.Iterator;
21:
22: import org.apache.ivy.core.report.ArtifactDownloadReport;
23: import org.apache.tools.ant.BuildException;
24: import org.apache.tools.ant.Project;
25: import org.apache.tools.ant.types.Path;
26:
27: /**
28: * Creates an ant path consisting in all artifacts found during a resolve.
29: */
30: public class IvyCachePath extends IvyCacheTask {
31: private String pathid;
32:
33: private String id;
34:
35: public String getPathid() {
36: return pathid;
37: }
38:
39: public void setPathid(String id) {
40: pathid = id;
41: }
42:
43: /**
44: * @deprecated use setPathid instead
45: * @param id
46: */
47: public void setId(String id) {
48: this .id = id;
49: }
50:
51: public void doExecute() throws BuildException {
52: prepareAndCheck();
53: if (pathid == null) {
54: if (id != null) {
55: pathid = id;
56: log("ID IS DEPRECATED, PLEASE USE PATHID INSTEAD",
57: Project.MSG_WARN);
58: } else {
59: throw new BuildException(
60: "pathid is required in ivy classpath");
61: }
62: }
63: try {
64: Path path = new Path(getProject());
65: getProject().addReference(pathid, path);
66: for (Iterator iter = getArtifactReports().iterator(); iter
67: .hasNext();) {
68: ArtifactDownloadReport a = (ArtifactDownloadReport) iter
69: .next();
70: path.createPathElement().setLocation(a.getLocalFile());
71: }
72: } catch (Exception ex) {
73: throw new BuildException("impossible to build ivy path: "
74: + ex, ex);
75: }
76:
77: }
78:
79: }
|