private void addSourcePath(Resource resource, Javadoc javadoc, Path source) { // // handle the target resource // if (null != resource.getBaseDir()) { File src = new File(resource.getBaseDir(), "target/build/main"); if (src.exists()) { log("Adding src path: " + src); source.createPathElement().setLocation(src); final DirSet packages = new DirSet(); packages.setDir(src); packages.setIncludes("**/*"); String excludes = getPackageExcludes(resource); if (null != excludes) { packages.setExcludes(excludes); } javadoc.addPackageset(packages); } } // add providers String path = resource.getResourcePath(); Resource[] providers = resource.getAggregatedProviders(Scope.RUNTIME, true, false); for (int i = 0; i < providers.length; i++) { Resource provider = providers[i]; if (provider.getResourcePath().startsWith(path)) { String flag = provider.getProperty("project.javadoc.exclude", "false"); if ("false".equals(flag)) { File basedir = provider.getBaseDir(); if (null != basedir) { File src = new File(basedir, "target/build/main"); if (src.exists()) { log("Adding src path: " + src); source.createPathElement().setLocation(src); final DirSet packages = new DirSet(); packages.setDir(src); packages.setIncludes("**/**"); String excludes = getPackageExcludes(provider); if (null != excludes) { packages.setExcludes(excludes); } javadoc.addPackageset(packages); } } } } } }
/** * Add the directories matched by the nested dirsets to the resulting packages list and the base * directories of the dirsets to the Path. It also handles the packages and excludepackages * attributes and elements. * * @param resultantPackages a list to which we add the packages found * @param sourcePath a path to which we add each basedir found * @since 1.5 */ private void parsePackages(List<String> resultantPackages, Path sourcePath) { List<String> addedPackages = new ArrayList<String>(); List<DirSet> dirSets = new ArrayList<DirSet>(packageSets); // for each sourcePath entry, add a directoryset with includes // taken from packagenames attribute and nested package // elements and excludes taken from excludepackages attribute // and nested excludepackage elements if (this.sourcePath != null) { PatternSet ps = new PatternSet(); if (packageNames.size() > 0) { for (String pn : packageNames) { String pkg = pn.replace('.', '/'); if (pkg.endsWith("*")) { pkg += "*"; } ps.createInclude().setName(pkg); } } else { ps.createInclude().setName("**"); } for (String epn : excludePackageNames) { String pkg = epn.replace('.', '/'); if (pkg.endsWith("*")) { pkg += "*"; } ps.createExclude().setName(pkg); } String[] pathElements = this.sourcePath.list(); for (String pathElement : pathElements) { File dir = new File(pathElement); if (dir.isDirectory()) { DirSet ds = new DirSet(); ds.setDefaultexcludes(useDefaultExcludes); ds.setDir(dir); ds.createPatternSet().addConfiguredPatternset(ps); dirSets.add(ds); } else { log.warn("Skipping " + pathElement + " since it is no directory."); } } } for (DirSet ds : dirSets) { File baseDir = ds.getDir(getProject()); log.debug("scanning " + baseDir + " for packages."); DirectoryScanner dsc = ds.getDirectoryScanner(getProject()); String[] dirs = dsc.getIncludedDirectories(); boolean containsPackages = false; for (String dir : dirs) { // are there any groovy or java files in this directory? File pd = new File(baseDir, dir); String[] files = pd.list( new FilenameFilter() { public boolean accept(File dir1, String name) { if (!includeNoSourcePackages && name.equals("package.html")) return true; final StringTokenizer tokenizer = new StringTokenizer(extensions, ":"); while (tokenizer.hasMoreTokens()) { String ext = tokenizer.nextToken(); if (name.endsWith(ext)) return true; } return false; } }); for (String filename : Arrays.asList(files)) { sourceFilesToDoc.add(dir + File.separator + filename); } if (files.length > 0) { if ("".equals(dir)) { log.warn( baseDir + " contains source files in the default package," + " you must specify them as source files not packages."); } else { containsPackages = true; String pn = dir.replace(File.separatorChar, '.'); if (!addedPackages.contains(pn)) { addedPackages.add(pn); resultantPackages.add(pn); } } } } if (containsPackages) { // We don't need to care for duplicates here, // Path.list does it for us. sourcePath.createPathElement().setLocation(baseDir); } else { log.verbose(baseDir + " doesn't contain any packages, dropping it."); } } }
/** Make part of the run classpath. */ private Path makeRunClasspathPart(Module module) { Path classpathPart = new Path(ProjectLocator.getAntProject()); File targetClassesDir = module.getTargetClasses(); classpathPart.createPathElement().setLocation(targetClassesDir); classpathPart.createPathElement().setLocation(module.getSrc()); // System.out.println("RunClasspath:" + m + " " + m.getSrc()); classpathPart.createPathElement().setLocation(module.getResourcesDir()); classpathPart.createPathElement().setLocation(module.getConfigsDir()); // see if we should add the 64 bit library to the classpath // NOTE: we want the 64 bit library directory in the classpath // since ptolemy.data.expr.UtilityFunctions.loadLibrary() searches // the classpath for a JNI library if it is not found in // java.library.path. if (LibPath.use64BitLibs()) { classpathPart.createPathElement().setLocation(module.getLib64Dir()); } classpathPart.createPathElement().setLocation(module.getLibDir()); classpathPart.createPathElement().setLocation(module.getLibImagesDir()); // Add target jar if the target classes dir does not exist if (!targetClassesDir.exists()) { if (module.getTargetJar().exists()) { classpathPart.createPathElement().setLocation(module.getTargetJar()); } } // End add target jar if (!module.getLibDir().exists()) { return classpathPart; } // Get jars from the lib directory. if (module.getLibDir().isDirectory()) { // use wildcards to reduce the size of the classpath. // this gets around the maximum path length on windows. DirSet jarDirs = new DirSet(); jarDirs.setProject(ProjectLocator.getAntProject()); jarDirs.setDir(module.getLibDir()); jarDirs.setIncludes("**/*"); Iterator<Resource> i = jarDirs.iterator(); while (i.hasNext()) { Resource resource = i.next(); if (resource instanceof FileResource) { File file = ((FileResource) resource).getFile(); // System.out.println(file); if (file.isDirectory()) { File wildcardFile = new File(file, "*"); classpathPart.createPathElement().setLocation(wildcardFile); // System.out.println("adding to cp: " + wildcardFile); } } } } // Add the jars in ptolemy, which are located in src/lib if (module.isPtolemy()) { File srcFile = module.getSrc(); File srcLibDir = new File(srcFile, "lib"); if (srcLibDir.isDirectory()) { File wildcardFile = new File(srcLibDir, "*"); classpathPart.createPathElement().setLocation(wildcardFile); } } // add the workflow demos directory so that the demos may be accessed // by ptolemy.actor.gui.HTMLViewer when showing the Help documentation // see http://bugzilla.ecoinformatics.org/show_bug.cgi?id=5194 File userModuleWorkflowDir = new File( DotKeplerManager.getInstance().getPersistentModuleWorkflowsDirString() + File.separator + module.getName() + File.separator + "demos"); File systemModuleDemoDir = module.getDemosDir(); // NOTE: the first time kepler starts with a new version of a module, // the demos directories have not been copied into KeplerData. if // the demo directory exists for the module in the location where // kepler is installed, add the demo directory for where it will be // copied once kepler starts. // see http://bugzilla.ecoinformatics.org/show_bug.cgi?id=5895 if (systemModuleDemoDir.exists() && systemModuleDemoDir.isDirectory()) { // it appears that a directory needs to exist before it can be added // to the classpath if (!userModuleWorkflowDir.exists() && !userModuleWorkflowDir.mkdirs()) { PrintError.message("Could not create directory " + userModuleWorkflowDir); } classpathPart.createPathElement().setLocation(userModuleWorkflowDir); } return classpathPart; }