Java源码示例:org.apache.tools.ant.ProjectComponent

示例1
/**
 * Returns the default ivy settings of this classloader. If it doesn't exist yet, a new one is
 * created using the given project to back the VariableContainer.
 *
 * @param task
 *            TODO add text.
 * @return An IvySetting instance.
 */
public static IvyAntSettings getDefaultInstance(ProjectComponent task) {
    Project project = task.getProject();
    Object defaultInstanceObj = project.getReference("ivy.instance");
    if (defaultInstanceObj != null
            && defaultInstanceObj.getClass().getClassLoader() != IvyAntSettings.class
                    .getClassLoader()) {
        task.log("ivy.instance reference an ivy:settings defined in an other classloader.  "
                + "An new default one will be used in this project.", Project.MSG_WARN);
        defaultInstanceObj = null;
    }
    if (defaultInstanceObj != null && !(defaultInstanceObj instanceof IvyAntSettings)) {
        throw new BuildException("ivy.instance reference a "
                + defaultInstanceObj.getClass().getName()
                + " an not an IvyAntSettings.  Please don't use this reference id ()");
    }
    if (defaultInstanceObj == null) {
        task.log("No ivy:settings found for the default reference 'ivy.instance'.  "
                + "A default instance will be used", Project.MSG_VERBOSE);

        IvyAntSettings settings = new IvyAntSettings();
        settings.setProject(project);
        project.addReference("ivy.instance", settings);
        settings.createIvyEngine(task);
        return settings;
    } else {
        return (IvyAntSettings) defaultInstanceObj;
    }
}
 
示例2
/**
 * Return the configured Ivy instance.
 *
 * @param task ProjectComponent
 * @return Returns the configured Ivy instance.
 */
public Ivy getConfiguredIvyInstance(ProjectComponent task) {
    if (ivyEngine == null) {
        createIvyEngine(task);
    }
    return ivyEngine;
}
 
示例3
protected Properties getDefaultProperties(ProjectComponent task) {
    URL url = IvySettings.getDefaultPropertiesURL();
    // this is copy of loadURL code from ant Property task (not available in 1.5.1)
    Properties props = new Properties();
    task.log("Loading " + url, Project.MSG_VERBOSE);
    try (InputStream is = url.openStream()) {
        props.load(is);
    } catch (IOException ex) {
        throw new BuildException(ex);
    }
    return props;
}
 
示例4
private <T extends ProjectComponent & ResourceCollection> T addSignaturesResource(T res) {
  res.setProject(getProject());
  apiSignatures.add(res);
  return res;
}
 
示例5
public static IvyAntSettings getDefaultInstance(Task task) {
    return getDefaultInstance((ProjectComponent) task);
}
 
示例6
public Ivy getConfiguredIvyInstance(Task task) {
    return getConfiguredIvyInstance((ProjectComponent) task);
}
 
示例7
void createIvyEngine(final ProjectComponent task) {
    Project project = task.getProject();
    Property prop = new Property() {
        public void execute() throws BuildException {
            addProperties(getDefaultProperties(task));
        }
    };
    prop.setProject(project);
    prop.init();
    prop.execute();

    IvyAntVariableContainer ivyAntVariableContainer = new IvyAntVariableContainer(project);
    IvySettings settings = new IvySettings(ivyAntVariableContainer);
    settings.setBaseDir(project.getBaseDir());

    if (file == null && url == null) {
        defineDefaultSettingFile(ivyAntVariableContainer, task);
    }

    if (antWorkspaceResolver != null) {
        settings.addConfigured(antWorkspaceResolver.getResolver());
    }

    Ivy ivy = Ivy.newInstance(settings);
    try {
        ivy.pushContext();
        AntMessageLogger.register(task, ivy);

        Message.showInfo();
        configureURLHandler();
        if (file != null) {
            if (!file.exists()) {
                throw new BuildException("settings file does not exist: " + file);
            }
            ivy.configure(file);
        } else {
            if (url == null) {
                throw new AssertionError(
                        "ivy setting should have either a file, either an url,"
                                + " and if not defineDefaultSettingFile must set it.");
            }
            ivy.configure(url);
        }
        ivyAntVariableContainer.updateProject(id);
        ivyEngine = ivy;
    } catch (ParseException | IOException e) {
        throw new BuildException("impossible to configure ivy:settings with given "
                + (file != null ? "file: " + file : "url: " + url) + " : " + e, e);
    } finally {
        ivy.popContext();
    }
}
 
示例8
@Override
public void initialize(@Nonnull AnalysisContext analysisContext) {
    this.logger = (ProjectComponent) analysisContext.getData(ANT_REPORTER_LOGGER_KEY);
    this.minSeverity = (DifferenceSeverity) analysisContext.getData(MIN_SEVERITY_KEY);
    this.errorsReported = false;
}
 
示例9
/**
 * Constructs a new AntMessageImpl instance.
 *
 * @param task
 *            the ant project component this message implementation should use for logging. Must
 *            not be <code>null</code>.
 */
protected AntMessageLogger(ProjectComponent task) {
    Checks.checkNotNull(task, "task");
    this.task = task;
}