2
* Licensed to the Apache Software Foundation (ASF) under one or more
3
* contributor license agreements. See the NOTICE file distributed with
4
* this work for additional information regarding copyright ownership.
5
* The ASF licenses this file to You under the Apache License, Version 2.0
6
* (the "License"); you may not use this file except in compliance with
7
* the License. You may obtain a copy of the License at
9
* http://www.apache.org/licenses/LICENSE-2.0
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.
18
package org.apache.ivy.ant;
21
import java.net.MalformedURLException;
22
import java.util.ArrayList;
23
import java.util.List;
25
import org.apache.ivy.Ivy;
26
import org.apache.ivy.util.Message;
27
import org.apache.tools.ant.BuildException;
28
import org.apache.tools.ant.DirectoryScanner;
29
import org.apache.tools.ant.types.FileSet;
32
* Checks the given ivy file using current configuration to see if all dependencies are available,
33
* with good confs. If a resolver name is given, it also checks that the declared publications are
34
* available in the corresponding resolver. Note that the check is not performed recursively, i.e.
35
* if a dependency has itself dependencies badly described or not available, this check will not
38
public class IvyCheck extends IvyTask {
39
private File file = null;
41
private List filesets = new ArrayList();
43
private String resolvername;
45
public File getFile() {
49
public void setFile(File file) {
54
* Adds a set of files to check.
57
* a set of files to check
59
public void addFileset(FileSet set) {
63
public String getResolvername() {
67
public void setResolvername(String resolverName) {
68
resolvername = resolverName;
71
public void doExecute() throws BuildException {
73
Ivy ivy = getIvyInstance();
75
if (ivy.check(file.toURI().toURL(), resolvername)) {
76
Message.verbose("checked " + file + ": OK");
79
for (int i = 0; i < filesets.size(); i++) {
80
FileSet fs = (FileSet) filesets.get(i);
81
DirectoryScanner ds = fs.getDirectoryScanner(getProject());
83
File fromDir = fs.getDir(getProject());
85
String[] srcFiles = ds.getIncludedFiles();
86
for (int j = 0; j < srcFiles.length; j++) {
87
File file = new File(fromDir, srcFiles[j]);
88
if (ivy.check(file.toURI().toURL(), resolvername)) {
89
Message.verbose("checked " + file + ": OK");
93
} catch (MalformedURLException e) {
94
throw new BuildException("impossible to convert a file to an url! " + e, e);