org.apache.tools.ant.ProjectComponent Java Examples
The following examples show how to use
org.apache.tools.ant.ProjectComponent.
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: IvyAntSettings.java From ant-ivy with Apache License 2.0 | 5 votes |
/** * 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; } }
Example #2
Source File: IvyAntSettings.java From ant-ivy with Apache License 2.0 | 5 votes |
/** * 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; }
Example #3
Source File: IvyAntSettings.java From ant-ivy with Apache License 2.0 | 5 votes |
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; }
Example #4
Source File: AntTask.java From forbidden-apis with Apache License 2.0 | 4 votes |
private <T extends ProjectComponent & ResourceCollection> T addSignaturesResource(T res) { res.setProject(getProject()); apiSignatures.add(res); return res; }
Example #5
Source File: IvyAntSettings.java From ant-ivy with Apache License 2.0 | 4 votes |
public static IvyAntSettings getDefaultInstance(Task task) { return getDefaultInstance((ProjectComponent) task); }
Example #6
Source File: IvyAntSettings.java From ant-ivy with Apache License 2.0 | 4 votes |
public Ivy getConfiguredIvyInstance(Task task) { return getConfiguredIvyInstance((ProjectComponent) task); }
Example #7
Source File: IvyAntSettings.java From ant-ivy with Apache License 2.0 | 4 votes |
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(); } }
Example #8
Source File: AntReporter.java From revapi with Apache License 2.0 | 4 votes |
@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; }
Example #9
Source File: AntMessageLogger.java From ant-ivy with Apache License 2.0 | 2 votes |
/** * 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; }