org.apache.tools.ant.Project Java Examples
The following examples show how to use
org.apache.tools.ant.Project.
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: LocFilesTest.java From netbeans with Apache License 2.0 | 6 votes |
@Override protected void setUp() throws Exception { clearWorkDir(); dist = new File(getWorkDir(), "dist"); dist.mkdirs(); src = new File(getWorkDir(), "src"); src.mkdirs(); Project p = new Project(); task = new LocFiles(); task.setProject(p); task.setCluster("platform"); task.setLocales("cs"); task.setPatternSet("pattern.set"); task.setSrc(src); task.setDestDir(dist); }
Example #2
Source File: CheckHelpSetsBin.java From netbeans with Apache License 2.0 | 6 votes |
private Map<String,URLClassLoader> createClassLoaderMap(File dir, String[] files) throws IOException { Map<String,URLClassLoader> m = new TreeMap<>(); for (int i = 0; i < files.length; i++) { File moduleJar = new File(dir, files[i]); Manifest manifest; try (JarFile jar = new JarFile(moduleJar)) { manifest = jar.getManifest(); } if (manifest == null) { log(moduleJar + " has no manifest", Project.MSG_WARN); continue; } String codename = JarWithModuleAttributes.extractCodeName(manifest.getMainAttributes()); if (codename == null) { log(moduleJar + " is not a module", Project.MSG_WARN); continue; } m.put(codename.replaceFirst("/[0-9]+$", ""), new URLClassLoader(new URL[] {moduleJar.toURI().toURL()}, ClassLoader.getSystemClassLoader().getParent(), new NbDocsStreamHandler.Factory())); } return m; }
Example #3
Source File: AutoUpdate.java From visualvm with GNU General Public License v2.0 | 6 votes |
private Map<String,List<String>> findExistingModules(File... clusters) { Map<String,List<String>> all = new HashMap<String, List<String>>(); for (File c : clusters) { File mc = new File(c, "update_tracking"); final File[] arr = mc.listFiles(); if (arr == null) { continue; } for (File m : arr) { try { parseVersion(m, all); } catch (Exception ex) { log("Cannot parse " + m, ex, Project.MSG_WARN); } } } return all; }
Example #4
Source File: IvyExtractFromSources.java From ant-ivy with Apache License 2.0 | 6 votes |
/** * @param pack String * @return ModuleRevisionId */ private ModuleRevisionId getMapping(String pack) { String askedPack = pack; ModuleRevisionId ret = null; while (ret == null && !pack.isEmpty()) { if (ignoredPackaged.contains(pack)) { return null; } ret = mapping.get(pack); int lastDotIndex = pack.lastIndexOf('.'); if (lastDotIndex != -1) { pack = pack.substring(0, lastDotIndex); } else { break; } } if (ret == null) { log("no mapping found for " + askedPack, Project.MSG_VERBOSE); } return ret; }
Example #5
Source File: DeliverTest.java From ant-ivy with Apache License 2.0 | 6 votes |
@Before public void setUp() { cache = new File("build/cache"); System.setProperty("ivy.cache.dir", cache.getAbsolutePath()); createCache(); deliverDir = new File("build/test/deliver"); deliverDir.mkdirs(); Project project = TestHelper.newProject(); project.init(); ivyDeliver = new IvyDeliver(); ivyDeliver.setProject(project); ivyDeliver.setDeliverpattern(deliverDir.getAbsolutePath() + "/[type]s/[artifact]-[revision](-[classifier]).[ext]"); }
Example #6
Source File: IvyDependencyUpdateCheckerTest.java From ant-ivy with Apache License 2.0 | 6 votes |
@Test public void testExcludedConf() { dependencyUpdateChecker.setFile(new File("test/java/org/apache/ivy/ant/ivy-multiconf.xml")); dependencyUpdateChecker.setConf("*,!default"); dependencyUpdateChecker.execute(); // assertTrue(getIvyFileInCache(ModuleRevisionId.newInstance("org1", "mod1.1", "2.0")) // .exists()); // assertFalse(getIvyFileInCache(ModuleRevisionId.newInstance("org1", "mod1.2", "2.0")) // .exists()); assertLogContaining("Dependencies updates available :"); assertLogContaining("All dependencies are up to date"); // test the properties Project project = dependencyUpdateChecker.getProject(); assertFalse(project.getProperty("ivy.resolved.configurations").contains("default")); }
Example #7
Source File: IvyCachePathTest.java From ant-ivy with Apache License 2.0 | 6 votes |
@Test public void testWithResolveIdAndMissingConfs() { Project otherProject = TestHelper.newProject(); otherProject.setProperty("ivy.settings.file", "test/repositories/ivysettings.xml"); IvyResolve resolve = new IvyResolve(); resolve.setProject(otherProject); resolve.setFile(new File("test/java/org/apache/ivy/ant/ivy-multiconf.xml")); resolve.setResolveId("testWithResolveIdAndMissingConfs"); resolve.setConf("default"); resolve.execute(); // resolve another ivy file resolve = new IvyResolve(); resolve.setProject(project); resolve.setFile(new File("test/java/org/apache/ivy/ant/ivy-latest.xml")); resolve.execute(); project.setProperty("ivy.dep.file", "test/java/org/apache/ivy/ant/ivy-multiconf.xml"); path.setResolveId("testWithResolveIdAndMissingConfs"); path.setPathid("withresolveid-pathid"); path.setConf("default,compile"); path.setFile(new File("test/java/org/apache/ivy/ant/ivy-multiconf.xml")); path.execute(); }
Example #8
Source File: NbBuildLogger.java From netbeans with Apache License 2.0 | 6 votes |
public @Override String getProperty(String name) { verifyRunning(); Project project = getProjectIfPropertiesDefined(); if (project != null) { String v = project.getProperty(name); if (v != null) { return v; } else { Object o = project.getReference(name); if (o != null) { return o.toString(); } else { return null; } } } else { return null; } }
Example #9
Source File: AntHarnessTest.java From ExpectIt with Apache License 2.0 | 6 votes |
private static Project newProject() throws IOException { setupBuildFile(); Project project = new Project(); project.setUserProperty("ant.file", buildFile.getAbsolutePath()); project.init(); DefaultLogger listener = new DefaultLogger(); listener.setErrorPrintStream(System.err); listener.setOutputPrintStream(System.out); listener.setMessageOutputLevel(Project.MSG_INFO); ProjectHelper helper = ProjectHelper.getProjectHelper(); project.addReference("ant.projectHelper", helper); project.setProperty("ftp.port", String.valueOf(ftpPort)); project.setProperty("ssh.port", String.valueOf(sshPort)); helper.parse(project, buildFile); project.addBuildListener(listener); return project; }
Example #10
Source File: 387581_IndexTaskTest_0_t.java From coming with MIT License | 6 votes |
/** * The JUnit setup method * *@exception IOException Description of Exception */ public void setUp() throws Exception { Project project = new Project(); IndexTask task = new IndexTask(); FileSet fs = new FileSet(); fs.setDir(new File(docsDir)); task.addFileset(fs); task.setOverwrite(true); task.setDocumentHandler(docHandler); task.setIndex(new File(indexDir)); task.setProject(project); task.execute(); searcher = new IndexSearcher(indexDir); analyzer = new StopAnalyzer(); }
Example #11
Source File: TestDistFilterTest.java From netbeans with Apache License 2.0 | 6 votes |
private void assertProperty(Project prj, String propName, String modules[]) throws IOException { String listModules = prj.getProperty(propName); assertNotNull("prop " + propName + " was not defined",listModules); log(" listModules " + listModules); String arrayModules[] = (listModules.length() == 0) ? new String[0] :listModules.split(":"); Set<File> set1 = new HashSet<>(); for (int i = 0 ; i < arrayModules.length ; i++) { String module = arrayModules[i]; if (module.length() == 1 && i < arrayModules.length + 1) { // module is e:/dd/dd/ on windows module = module + ":" + arrayModules[++i]; } log(i + " = " + module ); set1.add(new File(module)); } Set<File> set2 = new HashSet<>(); for (int i = 0 ; i < modules.length ; i++) { set2.add(new File(getWorkDir(),modules[i])); } assertEquals("paths length",set2.size(),set1.size()); assertEquals("Different paths: ", set2,set1); }
Example #12
Source File: UploadFileSetToS3TaskTests.java From aws-ant-tasks with Apache License 2.0 | 6 votes |
@Test public void testExecuteMultipleFiles() throws IOException { UploadFileSetToS3Task task = new UploadFileSetToS3Task(); task.setProject(new Project()); FileSet fileset = new FileSet(); fileset.setDir(testFile1.getParentFile()); fileset.setIncludes("*.txt"); task.addFileset(fileset); task.setBucketName(BUCKET_NAME); task.setKeyPrefix(KEY_PREFIX); task.execute(); resFile1 = File.createTempFile(RES_FILE_1, TESTFILE_SUFFIX); resFile2 = File.createTempFile(RES_FILE_2, TESTFILE_SUFFIX); resFile3 = File.createTempFile(RES_FILE_3, TESTFILE_SUFFIX); client.getObject(new GetObjectRequest(BUCKET_NAME, KEY_PREFIX + fileName1), resFile1); client.getObject(new GetObjectRequest(BUCKET_NAME, KEY_PREFIX + fileName2), resFile2); client.getObject(new GetObjectRequest(BUCKET_NAME, KEY_PREFIX + fileName3), resFile3); assertTrue(FileUtils.contentEquals(testFile1, resFile1)); assertTrue(FileUtils.contentEquals(testFile1, resFile1)); assertTrue(FileUtils.contentEquals(testFile1, resFile1)); }
Example #13
Source File: JPDAStart.java From netbeans with Apache License 2.0 | 6 votes |
static ClassPath createJDKSourcePath ( Project project, Path bootclasspath ) { if (bootclasspath == null) { // if current platform is default one, bootclasspath is set to null JavaPlatform jp = JavaPlatform.getDefault(); if (jp != null) { return jp.getSourceFolders (); } else { return ClassPathSupport.createClassPath(java.util.Collections.EMPTY_LIST); } } else { return convertToSourcePath (project, bootclasspath, false); } }
Example #14
Source File: SelectToolTask.java From openjdk-jdk9 with GNU General Public License v2.0 | 6 votes |
@Override public void execute() { Project p = getProject(); Properties props = readProperties(propertyFile); toolName = props.getProperty("tool.name"); if (toolName != null) { toolArgs = props.getProperty(toolName + ".args", ""); } if (toolProperty == null || askIfUnset && (toolName == null || (argsProperty != null && toolArgs == null))) { showGUI(props); } // finally, return required values, if any if (toolProperty != null && !(toolName == null || toolName.equals(""))) { p.setProperty(toolProperty, toolName); if (argsProperty != null && toolArgs != null) p.setProperty(argsProperty, toolArgs); } }
Example #15
Source File: SelectToolTask.java From hottub with GNU General Public License v2.0 | 5 votes |
@Override public void execute() { Project p = getProject(); Properties props = readProperties(propertyFile); toolName = props.getProperty("tool.name"); toolBootstrap = props.getProperty("tool.bootstrap") != null; if (toolName != null) { toolArgs = props.getProperty(toolName + ".args", ""); } if (toolProperty == null || askIfUnset && (toolName == null || (argsProperty != null && toolArgs == null))) { showGUI(props); } // finally, return required values, if any if (toolProperty != null && !(toolName == null || toolName.equals(""))) { p.setProperty(toolProperty, toolName); if (toolBootstrap) p.setProperty(bootstrapProperty, "true"); if (argsProperty != null && toolArgs != null) p.setProperty(argsProperty, toolArgs); } }
Example #16
Source File: ExportedAPICondition.java From netbeans with Apache License 2.0 | 5 votes |
public boolean eval() throws BuildException { Hashtable<String,Object> props = getProject().getProperties(); if (props.get("public.packages").equals("-")) { log("No exported packages", Project.MSG_VERBOSE); return false; } String friends = (String) props.get("friends"); if (friends == null) { log("Public API", Project.MSG_VERBOSE); return true; } /* Disabled to avoid spamming [email protected]. ModuleListParser mlp; try { mlp = new ModuleListParser(props, ModuleType.NB_ORG, getProject()); } catch (IOException x) { throw new BuildException(x, getLocation()); } String mycluster = mlp.findByCodeNameBase(props.get("code.name.base.dashes").replace('-', '.')).getClusterName(); for (String friend : friends.split(", ")) { ModuleListParser.Entry entry = mlp.findByCodeNameBase(friend); if (entry == null) { log("External friend " + friend, Project.MSG_VERBOSE); return true; } String cluster = entry.getClusterName(); if (!mycluster.equals(cluster)) { log("Friend " + friend + " is in cluster " + cluster + " rather than " + mycluster, Project.MSG_VERBOSE); return true; } } log("No friends outside cluster", Project.MSG_VERBOSE); */ return false; }
Example #17
Source File: BundleLocator.java From knopflerfish.org with BSD 3-Clause "New" or "Revised" License | 5 votes |
private void processBundlePath() { if (null!=bundlePath && 0<bundlePath.length()) { final URL baseUrl = getBaseURL(); // Create a file set for each entry in the bundle path. final String[] urls = Util.splitwords(this.bundlePath, ";", '"'); for (final String url2 : urls) { log("Processing URL '" + url2 + "' from bundlePath '" + this.bundlePath + "'.", Project.MSG_DEBUG); try { final URL url = new URL(baseUrl, url2.trim()); if ("file".equals(url.getProtocol())) { final String path = url.getPath(); final File dir = new File(path.replace('/', File.separatorChar)); log("Adding file set with dir '" + dir + "' for bundlePath file URL with path '" + path + "'.", Project.MSG_VERBOSE); final FileSet fs = new FileSet(); fs.setDir(dir); fs.setExcludes("**/*-source.jar,**/*-javadoc.jar"); fs.setIncludes("**/*.jar"); fs.setProject(getProject()); filesets.add(fs); } } catch (final MalformedURLException e) { throw new BuildException("Invalid URL, '" + url2 + "' found in bundlePath: '" + bundlePath + "'.", e); } } } }
Example #18
Source File: LibVersionsCheckTask.java From lucene-solr with Apache License 2.0 | 5 votes |
/** * Returns true if the "/org/name" coordinate keys in the given * properties file are lexically sorted and are not duplicates. */ private boolean verifySortedCoordinatesPropertiesFile(File coordinatePropertiesFile) { log("Checking for lexically sorted non-duplicated '/org/name' keys in: " + coordinatePropertiesFile, verboseLevel); boolean success = true; String line = null; String currentKey = null; String previousKey = null; try (InputStream stream = new FileInputStream(coordinatePropertiesFile); Reader reader = new InputStreamReader(stream, StandardCharsets.ISO_8859_1); BufferedReader bufferedReader = new BufferedReader(reader)) { while (null != (line = readLogicalPropertiesLine(bufferedReader))) { final Matcher keyMatcher = COORDINATE_KEY_PATTERN.matcher(line); if ( ! keyMatcher.lookingAt()) { continue; // Ignore keys that don't look like "/org/name" } currentKey = keyMatcher.group(1); if (null != previousKey) { int comparison = currentKey.compareTo(previousKey); if (0 == comparison) { log("DUPLICATE coordinate key '" + currentKey + "' in " + coordinatePropertiesFile.getName(), Project.MSG_ERR); success = false; } else if (comparison < 0) { log("OUT-OF-ORDER coordinate key '" + currentKey + "' in " + coordinatePropertiesFile.getName(), Project.MSG_ERR); success = false; } } previousKey = currentKey; } } catch (IOException e) { throw new BuildException("Exception reading " + coordinatePropertiesFile.getPath() + ": " + e.toString(), e); } return success; }
Example #19
Source File: TranslateClassPath.java From netbeans with Apache License 2.0 | 5 votes |
@Override public void execute() throws BuildException { if (classpath == null) { throw new BuildException("Classpath must be set."); } if (targetProperty == null) { throw new BuildException("Target property must be set."); } Project p = getProject(); String translated = translate(classpath); p.setProperty(targetProperty, translated); }
Example #20
Source File: ParseProjectXml.java From netbeans with Apache License 2.0 | 5 votes |
private void define(String prop, String val) { log("Setting " + prop + "=" + val, Project.MSG_VERBOSE); String old = getProject().getProperty(prop); if (old != null && !old.equals(val)) { getProject().log("Warning: " + prop + " was already set to " + old, Project.MSG_WARN); } getProject().setNewProperty(prop, val); }
Example #21
Source File: ChangesFileGenerator.java From gemfirexd-oss with Apache License 2.0 | 5 votes |
private void println( String text ) { if ( _invokedByAnt ) { log( text, Project.MSG_WARN ); } else { System.out.println( text ); } }
Example #22
Source File: LowercaseTableNames.java From unitime with Apache License 2.0 | 5 votes |
public void warn(String message) { try { log(message, Project.MSG_WARN); } catch (Exception e) { System.out.println(message); } }
Example #23
Source File: TaskBuildOptions.java From webdsl with Apache License 2.0 | 5 votes |
public void execute() { Project project = getProject(); String buildoptions = project.getProperty("buildoptions"); Pattern p = Pattern.compile("\\s"); String[] commands = p.split(buildoptions); for(int i=0; i<commands.length; i++){ project.setProperty("command"+i,commands[i]); Echo echo = (Echo) project.createTask("echo"); echo.setMessage("command"+i+": "+commands[i]); echo.perform(); } project.setProperty("numberofcommands",""+commands.length); }
Example #24
Source File: AutoUpdate.java From netbeans with Apache License 2.0 | 5 votes |
private String readVersion(File nbm) { String infoXml = "jar:" + nbm.toURI() + "!/Info/info.xml"; try { XPathFactory f = XPathFactory.newInstance(); Document doc = XMLUtil.parse(new InputSource(infoXml), false, false, XMLUtil.rethrowHandler(), XMLUtil.nullResolver()); String res = f.newXPath().evaluate("module/manifest/@OpenIDE-Module-Specification-Version", doc); if (res.length() == 0) { throw new IOException("Not found tag OpenIDE-Module-Specification-Version!"); } return res; } catch (Exception ex) { log("Cannot parse " + infoXml + ": " + ex, ex, Project.MSG_WARN); return null; } }
Example #25
Source File: AbstractProcessTask.java From astor with GNU General Public License v2.0 | 5 votes |
protected Collection getFiles() { Map fileMap = new HashMap(); Project p = getProject(); for (int i = 0; i < filesets.size(); i++) { FileSet fs = (FileSet)filesets.elementAt(i); DirectoryScanner ds = fs.getDirectoryScanner(p); String[] srcFiles = ds.getIncludedFiles(); File dir = fs.getDir(p); for (int j = 0; j < srcFiles.length; j++) { File src = new File(dir, srcFiles[j]); fileMap.put(src.getAbsolutePath(), src); } } return fileMap.values(); }
Example #26
Source File: AntUtil.java From pushfish-android with BSD 2-Clause "Simplified" License | 5 votes |
/** * @return Factory method to create new Project instances */ public static Project createProject() { final Project project = new Project(); final ProjectHelper helper = ProjectHelper.getProjectHelper(); project.addReference(ProjectHelper.PROJECTHELPER_REFERENCE, helper); helper.getImportStack().addElement("AntBuilder"); // import checks that stack is not empty project.addBuildListener(new AntLoggingAdapter()); project.init(); project.getBaseDir(); return project; }
Example #27
Source File: BasicAntBuilder.java From Pushjet-Android with BSD 2-Clause "Simplified" License | 5 votes |
@Override protected void nodeCompleted(Object parent, Object node) { ClassLoader original = Thread.currentThread().getContextClassLoader(); Thread.currentThread().setContextClassLoader(Project.class.getClassLoader()); try { super.nodeCompleted(parent, node); } finally { Thread.currentThread().setContextClassLoader(original); } }
Example #28
Source File: MithraObjectXmlGenerator.java From reladomo with Apache License 2.0 | 5 votes |
private Connection getConnection() { this.log("establishing connection", Project.MSG_DEBUG); Connection connection = this.establishConnection(getDriver(), getUrl(), getUserName(), getPassword()); if (connection == null) { throw new BuildException("Connection is null"); } return connection; }
Example #29
Source File: JarExpander.java From PoseidonX with Apache License 2.0 | 5 votes |
private Expand createExpand(File jarFile) { String outputDir = expandDir + File.separator + jarFile.getName(); Project prj = new Project(); FileSet fileSet = createFileSetForJarFile(jarFile, prj); PatternSet patternSet = createPatternSet(prj); Expand expand = new Expand(); expand.setProject(prj); expand.setOverwrite(true); expand.setDest(new File(outputDir)); expand.addFileset(fileSet); expand.addPatternset(patternSet); return expand; }
Example #30
Source File: IvyDeliverTest.java From ant-ivy with Apache License 2.0 | 5 votes |
@Test public void testWithResolveIdInAnotherBuild() throws Exception { // create a new build Project other = TestHelper.newProject(); other.setProperty("ivy.settings.file", "test/repositories/ivysettings.xml"); other.setProperty("build", "build/test/deliver"); // do a resolve in the new build IvyResolve resolve = new IvyResolve(); resolve.setProject(other); resolve.setFile(new File("test/java/org/apache/ivy/ant/ivy-simple.xml")); resolve.setResolveId("withResolveId"); resolve.execute(); // resolve another ivy file resolve = new IvyResolve(); resolve.setProject(project); resolve.setFile(new File("test/java/org/apache/ivy/ant/ivy-latest.xml")); resolve.execute(); deliver.setResolveId("withResolveId"); deliver.setPubrevision("1.2"); deliver.setDeliverpattern("build/test/deliver/ivy-[revision].xml"); deliver.execute(); // should have done the ivy delivering File deliveredIvyFile = new File("build/test/deliver/ivy-1.2.xml"); assertTrue(deliveredIvyFile.exists()); ModuleDescriptor md = XmlModuleDescriptorParser.getInstance().parseDescriptor( new IvySettings(), deliveredIvyFile.toURI().toURL(), true); assertEquals(ModuleRevisionId.newInstance("apache", "resolve-simple", "1.2"), md.getModuleRevisionId()); DependencyDescriptor[] dds = md.getDependencies(); assertEquals(1, dds.length); assertEquals(ModuleRevisionId.newInstance("org1", "mod1.2", "2.0"), dds[0].getDependencyRevisionId()); }