/** * Emulation of extdirs feature in java >= 1.2. This method adds all files in the given * directories (but not in sub-directories!) to the classpath, so that you don't have to specify * them all one by one. * * @param extdirs - Path to append files to */ public void addExtdirs(Path extdirs) { if (extdirs == null) { String extProp = System.getProperty("java.ext.dirs"); if (extProp != null) { extdirs = new Path(getProject(), extProp); } else { return; } } String[] dirs = extdirs.list(); for (int i = 0; i < dirs.length; i++) { File dir = resolveFile(getProject(), dirs[i]); if (dir.exists() && dir.isDirectory()) { FileSet fs = new FileSet(); fs.setDir(dir); fs.setIncludes("*"); addFileset(fs); } } }
/** * Returns an ant {@link Path} that contains a file set with all included source files. * * @param javaProjectRole the java project role * @return the ant {@link Path} */ public final Path createFilteredSourceFilePath(JavaProjectRole javaProjectRole) { // the ant path Path antPath = new Path(this._projectComponent.getProject()); // the source folder for (String sourceFolder : javaProjectRole.getSourceFolders()) { File folder = javaProjectRole.getEclipseProject().getChild(sourceFolder); String includePattern = javaProjectRole.getIncludePatternsForSourceFolder(sourceFolder); String excludePattern = javaProjectRole.getExcludePatternsForSourceFolder(sourceFolder); FileSet fileSet = new FileSet(); fileSet.setDir(folder); fileSet.setIncludes(includePattern); fileSet.setExcludes(excludePattern); antPath.addFileset(fileSet); } // return the ant path return antPath; }
public void execute() { if (applicationDir == null) { throw new BuildException("No applicationDir set!"); } // Add the properties from application.conf as ant properties for (Map.Entry<String, String> entry : properties().entrySet()) { String key = entry.getKey(); String value = project.replaceProperties(entry.getValue()); project.setProperty(prefix + key, value); project.log("Loaded property '" + prefix + key + "'='" + value + "'", Project.MSG_VERBOSE); } // Add the module classpath as an ant property Path path = new Path(project); FilenameSelector endsToJar = new FilenameSelector(); endsToJar.setName("*.jar"); for (File module : modules()) { File moduleLib = new File(module, "lib"); if (moduleLib.exists()) { FileSet fileSet = new FileSet(); fileSet.setDir(moduleLib); fileSet.addFilename(endsToJar); path.addFileset(fileSet); project.log("Added fileSet to path: " + fileSet, Project.MSG_VERBOSE); } else { project.log( "Ignoring non existing lib dir: " + moduleLib.getAbsolutePath(), Project.MSG_VERBOSE); } } project.addReference(modulesClasspath, path); project.log( "Generated classpath '" + modulesClasspath + "':" + project.getReference(modulesClasspath), Project.MSG_VERBOSE); }
/** * Add a reference to the fileset for processing in Ant. * * @param file */ private void reference(FileSet fs) { if (installedArtifacts != null) { installedArtifacts.addFileset(fs); } }
/** Add the Java Runtime classes to this Path instance. */ public void addJavaRuntime() { if (JavaEnvUtils.isKaffe()) { // newer versions of Kaffe (1.1.1+) won't have this, // but this will be sorted by FileSet anyway. File kaffeShare = new File( System.getProperty("java.home") + File.separator + "share" + File.separator + "kaffe"); if (kaffeShare.isDirectory()) { FileSet kaffeJarFiles = new FileSet(); kaffeJarFiles.setDir(kaffeShare); kaffeJarFiles.setIncludes("*.jar"); addFileset(kaffeJarFiles); } } else if ("GNU libgcj".equals(System.getProperty("java.vm.name"))) { addExisting(systemBootClasspath); } if (System.getProperty("java.vendor").toLowerCase(Locale.ENGLISH).indexOf("microsoft") >= 0) { // TODO is this code still necessary? is there any 1.2+ port? // Pull in *.zip from packages directory FileSet msZipFiles = new FileSet(); msZipFiles.setDir(new File(System.getProperty("java.home") + File.separator + "Packages")); msZipFiles.setIncludes("*.ZIP"); addFileset(msZipFiles); } else { // JDK 1.2+ seems to set java.home to the JRE directory. addExisting( new Path( null, System.getProperty("java.home") + File.separator + "lib" + File.separator + "rt.jar")); // Just keep the old version as well and let addExisting // sort it out. addExisting( new Path( null, System.getProperty("java.home") + File.separator + "jre" + File.separator + "lib" + File.separator + "rt.jar")); // Sun's and Apple's 1.4 have JCE and JSSE in separate jars. String[] secJars = {"jce", "jsse"}; for (int i = 0; i < secJars.length; i++) { addExisting( new Path( null, System.getProperty("java.home") + File.separator + "lib" + File.separator + secJars[i] + ".jar")); addExisting( new Path( null, System.getProperty("java.home") + File.separator + ".." + File.separator + "Classes" + File.separator + secJars[i] + ".jar")); } // IBM's 1.4 has rt.jar split into 4 smaller jars and a combined // JCE/JSSE in security.jar. String[] ibmJars = {"core", "graphics", "security", "server", "xml"}; for (int i = 0; i < ibmJars.length; i++) { addExisting( new Path( null, System.getProperty("java.home") + File.separator + "lib" + File.separator + ibmJars[i] + ".jar")); } // Added for MacOS X addExisting( new Path( null, System.getProperty("java.home") + File.separator + ".." + File.separator + "Classes" + File.separator + "classes.jar")); addExisting( new Path( null, System.getProperty("java.home") + File.separator + ".." + File.separator + "Classes" + File.separator + "ui.jar")); } }