Java Code Examples for org.apache.tools.ant.Target#setName()
The following examples show how to use
org.apache.tools.ant.Target#setName() .
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: AntBuilder.java From groovy with Apache License 2.0 | 6 votes |
public AntBuilder(final Project project, final Target owningTarget) { this.project = project; /* * GROOVY-4524: The following is not needed anymore as an ant Project already by default has inputhandler * set to DefaultInputHandler. And if it is again set here, it mistakenly overrides the custom input handler * if set using -inputhandler switch. */ //this.project.setInputHandler(new DefaultInputHandler()); collectorTarget = owningTarget; antXmlContext = new AntXMLContext(project); collectorTarget.setProject(project); antXmlContext.setCurrentTarget(collectorTarget); antXmlContext.setLocator(new AntBuilderLocator()); antXmlContext.setCurrentTargets(new HashMap<String, Target>()); implicitTarget = new Target(); implicitTarget.setProject(project); implicitTarget.setName(""); antXmlContext.setImplicitTarget(implicitTarget); // FileScanner is a Groovy utility project.addDataTypeDefinition("fileScanner", FileScanner.class); }
Example 2
Source File: NbMerge.java From netbeans with Apache License 2.0 | 4 votes |
/** Execute targets which cannot fail and though throw BuildException */ private void fixedModulesBuild() throws BuildException { // Somewhat convoluted code because Project.executeTargets does not // eliminate duplicates when analyzing dependencies! Ecch. // build fixed modules first dummy = new Target (); dummyName = "nbmerge-" + getOwningTarget().getName(); targets = getProject().getTargets(); while (targets.contains (dummyName)) dummyName += "-x"; dummy.setName (dummyName); for (String fixedmodule : buildfixedmodules) { dummy.addDependency (targetprefix + fixedmodule); } getProject().addTarget(dummy); getProject().setProperty("fixedmodules-built", "1" ); @SuppressWarnings("unchecked") Vector<Target> fullList = getProject().topoSort(dummyName, targets); // Now remove earlier ones: already done. Vector<Target> doneList = getProject().topoSort(getOwningTarget().getName(), targets); List<Target> todo = new ArrayList<>(fullList.subList(0, fullList.indexOf(dummy))); todo.removeAll(doneList.subList(0, doneList.indexOf(getOwningTarget()))); log("Going to execute targets " + todo); for (Target nexttargit: todo) { String targetname = nexttargit.getName(); if ( builttargets.indexOf(targetname) < 0 ) { // XXX poor replacement for Project.fireTargetStarted etc. System.out.println(""); System.out.println(targetname + ":"); try { nexttargit.execute(); } catch (BuildException ex) { log("Failed to build target: " + targetname, Project.MSG_ERR); throw ex; } builttargets.addElement(targetname); } } builtmodules.addAll(buildfixedmodules); // add already built fixed modules to the list log("fixedmodules=" + buildfixedmodules, Project.MSG_DEBUG); log("builtmodules=" + builtmodules, Project.MSG_VERBOSE); }
Example 3
Source File: NbMerge.java From netbeans with Apache License 2.0 | 4 votes |
/** Execute targets which can fail _without_ throwing BuildException */ private void modulesBuild() throws BuildException { if ( ! failonerror ) { // build the rest of modules for (String module : buildmodules) { dummy = new Target (); dummyName = "nbmerge-" + getOwningTarget().getName() + "-" + module; while (targets.contains (dummyName)) dummyName += "-x"; dummy.setName (dummyName); dummy.addDependency (targetprefix + module); getProject().addTarget(dummy); @SuppressWarnings("unchecked") Vector<Target> fullList = getProject().topoSort(dummyName, targets); // Now remove earlier ones: already done. @SuppressWarnings("unchecked") Vector<Target> doneList = getProject().topoSort(getOwningTarget().getName(), targets); List<Target> todo = new ArrayList<>(fullList.subList(0, fullList.indexOf(dummy))); todo.removeAll(doneList.subList(0, doneList.indexOf(getOwningTarget()))); Iterator<Target> targit = todo.iterator(); try { while (targit.hasNext()) { Target nexttargit = targit.next(); String targetname = nexttargit.getName(); if ( builttargets.indexOf(targetname) < 0 ) { System.out.println(); System.out.println(targetname + ":"); nexttargit.execute(); builttargets.addElement(targetname); } } builtmodules.addElement(module); } catch (BuildException BE) { log(BE.toString(), Project.MSG_WARN); BE.printStackTrace(); failedmodules.addElement(module); } } log("builtmodules=" + builtmodules, Project.MSG_VERBOSE); log("failedmodules=" + failedmodules, Project.MSG_VERBOSE); } }
Example 4
Source File: Main.java From scava with Eclipse Public License 2.0 | 4 votes |
public static void main(String[] args) { Vector<Target> targets = new Vector<Target>(); Target m2mTarget = new Target(); m2mTarget.setName(M2M); Target m2tTarget = new Target(); m2tTarget.setName(M2T); Target setupTarget = new Target(); setupTarget.setName(SETUP); File buildFile = new File(BUILD_XML); Project p = new Project(); p.setUserProperty(ANT_FILE, buildFile.getAbsolutePath()); p.init(); ProjectHelper helper = ProjectHelper.getProjectHelper(); p.addReference(ANT_PROJECT_HELPER, helper); helper.parse(p, buildFile); Scanner scanner = new Scanner(System.in); while (true){ System.out.println("Which transformation would you like to start? (M2M / M2T) : "); String target = scanner.next(); if (target.equals(M2M)){ System.out.println("Select the OpenAPI JSON schema to transform."); try { TimeUnit.MILLISECONDS.sleep(500); } catch (InterruptedException e) { e.printStackTrace(); } JFileChooser chooser = new JFileChooser(); chooser.setFileSelectionMode(JFileChooser.FILES_ONLY); chooser.setCurrentDirectory(new File(SCHEMAS_DIR)); chooser.showOpenDialog(null); File selectedFile = chooser.getSelectedFile(); if (selectedFile.isFile() && selectedFile.getName().endsWith(".json")){ System.out.println(selectedFile.getName()); targets.add(m2mTarget); break; } else { chooser = null; System.out.println("Something went wrong"); } //p.executeSortedTargets(targets); } else if (target.equals(M2M)){ //p.executeTarget(p.getDefaultTarget()); break; } else { System.out.println("Invalid"); } } scanner.close(); }