diff --git a/apisupport.project/src/org/netbeans/modules/apisupport/project/Evaluator.java b/apisupport.project/src/org/netbeans/modules/apisupport/project/Evaluator.java --- a/apisupport.project/src/org/netbeans/modules/apisupport/project/Evaluator.java +++ b/apisupport.project/src/org/netbeans/modules/apisupport/project/Evaluator.java @@ -287,7 +287,7 @@ assert nbroot != null : "netbeans.org-type module not in a complete netbeans.org source root " + dir; stock.put("nb_all", nbroot.getAbsolutePath()); // NOI18N // Only needed for netbeans.org modules, since for external modules suite.properties suffices. - stock.put("netbeans.dest.dir", new File(nbroot, ModuleList.DEST_DIR_IN_NETBEANS_ORG).getAbsolutePath()); // NOI18N + stock.put("netbeans.dest.dir", ModuleList.findNetBeansOrgDestDir(nbroot).getAbsolutePath()); // NOI18N } else { nbroot = null; } diff --git a/apisupport.project/src/org/netbeans/modules/apisupport/project/NbModuleProject.java b/apisupport.project/src/org/netbeans/modules/apisupport/project/NbModuleProject.java --- a/apisupport.project/src/org/netbeans/modules/apisupport/project/NbModuleProject.java +++ b/apisupport.project/src/org/netbeans/modules/apisupport/project/NbModuleProject.java @@ -158,7 +158,7 @@ typeProvider = new NbModuleProviderImpl(); if (typeProvider.getModuleType() == NbModuleProvider.NETBEANS_ORG && ModuleList.findNetBeansOrg(getProjectDirectoryFile()) == null) { // #69097: preferable to throwing an assertion error later... - throw new IOException("netbeans.org-type module not in a complete netbeans.org source root: " + this); // NOI18N + throw new IOException("netbeans.org-type module requires at least nbbuild: " + FileUtil.getFileDisplayName(helper.getProjectDirectory())); // NOI18N } eval = new Evaluator(this, typeProvider); // XXX could add globs for other package roots too diff --git a/apisupport.project/src/org/netbeans/modules/apisupport/project/queries/SubprojectProviderImpl.java b/apisupport.project/src/org/netbeans/modules/apisupport/project/queries/SubprojectProviderImpl.java --- a/apisupport.project/src/org/netbeans/modules/apisupport/project/queries/SubprojectProviderImpl.java +++ b/apisupport.project/src/org/netbeans/modules/apisupport/project/queries/SubprojectProviderImpl.java @@ -110,7 +110,7 @@ } File moduleProjectDirF = module.getSourceLocation(); if (moduleProjectDirF == null) { - Util.err.log(ErrorManager.WARNING, "Warning - could not find sources for dependent module " + cnb + " for " + project); + // Do not log, this is pretty normal. continue; } FileObject moduleProjectDir = FileUtil.toFileObject(moduleProjectDirF); diff --git a/apisupport.project/src/org/netbeans/modules/apisupport/project/universe/ModuleList.java b/apisupport.project/src/org/netbeans/modules/apisupport/project/universe/ModuleList.java --- a/apisupport.project/src/org/netbeans/modules/apisupport/project/universe/ModuleList.java +++ b/apisupport.project/src/org/netbeans/modules/apisupport/project/universe/ModuleList.java @@ -95,9 +95,7 @@ static int xmlFilesParsed; static int directoriesChecked; static int jarsOpened; - - public static final String DEST_DIR_IN_NETBEANS_ORG = "nbbuild" + File.separatorChar + "netbeans"; // NOI18N - + /** Synch with org.netbeans.nbbuild.ModuleListParser.FOREST: */ private static final String[] FOREST = { /*root*/null, @@ -237,15 +235,71 @@ static ModuleList findOrCreateModuleListFromNetBeansOrgSources(File root) throws IOException { ModuleList list = sourceLists.get(root); if (list == null) { - list = createModuleListFromNetBeansOrgSources(root); + File nbdestdir = findNetBeansOrgDestDir(root); + if (nbdestdir.equals(new File(new File(root, "nbbuild"), "netbeans"))) { // NOI18N + list = createModuleListFromNetBeansOrgSources(root, nbdestdir); + } else { + // #143236: have a customized dest dir, perhaps referenced from orphan modules. + Map entries = new HashMap(); + doScanNetBeansOrgSources(entries, root, 1, root, nbdestdir, null, false); + ModuleList sources = new ModuleList(entries, root, false); + ModuleList binaries = createModuleListFromBinaries(nbdestdir); + list = merge(new ModuleList[] {sources, binaries}, root); + } sourceLists.put(root, list); } return list; } - - private static ModuleList createModuleListFromNetBeansOrgSources(File root) throws IOException { + + /** + * Gets the platform build directory associated with a netbeans.org source root. + * Normally nbbuild/netbeans/ but can be overridden. + * @param nb_all the (possibly partial) netbeans.org source root + */ + public static File findNetBeansOrgDestDir(File nb_all) { + synchronized (netbeansOrgDestDirs) { + File d = netbeansOrgDestDirs.get(nb_all); + if (d == null) { + File nbbuild = new File(nb_all, "nbbuild"); // NOI18N + d = checkForNetBeansOrgDestDir(new File(nbbuild, "user.build.properties")); // NOI18N + if (d == null) { + d = checkForNetBeansOrgDestDir(new File(nbbuild, "site.build.properties")); // NOI18N + if (d == null) { + d = checkForNetBeansOrgDestDir(new File(System.getProperty("user.home"), ".nbbuild.properties")); // NOI18N + if (d == null) { + d = new File(nbbuild, "netbeans"); // NOI18N + } + } + } + netbeansOrgDestDirs.put(nb_all, d); + } + return d; + } + } + private static final Map netbeansOrgDestDirs = new HashMap(); + private static File checkForNetBeansOrgDestDir(File properties) { + if (properties.isFile()) { + try { + InputStream is = new FileInputStream(properties); + try { + Properties p = new Properties(); + p.load(is); + String d = p.getProperty("netbeans.dest.dir"); // NOI18N + if (d != null) { + return new File(d); + } + } finally { + is.close(); + } + } catch (IOException x) { + LOG.log(Level.INFO, "Could not read " + properties, x); + } + } + return null; + } + + private static ModuleList createModuleListFromNetBeansOrgSources(File root, File nbdestdir) throws IOException { Util.err.log("ModuleList.createModuleListFromSources: " + root); - File nbdestdir = new File(root, DEST_DIR_IN_NETBEANS_ORG); try { return loadNetBeansOrgCachedModuleList(root, nbdestdir); } catch (IOException x) { @@ -870,7 +924,7 @@ boolean isNetBeansOrg = !suiteComponent && !standalone; if (isNetBeansOrg) { defaults.put("nb_all", root.getAbsolutePath()); // NOI18N - defaults.put("netbeans.dest.dir", new File(root, DEST_DIR_IN_NETBEANS_ORG).getAbsolutePath()); // NOI18N + defaults.put("netbeans.dest.dir", findNetBeansOrgDestDir(root).getAbsolutePath()); // NOI18N } defaults.put("code.name.base.dashes", cnb.replace('.', '-')); // NOI18N defaults.put("module.jar.dir", "modules"); // NOI18N @@ -929,9 +983,7 @@ * Whether whether a given dir is root of netbeans.org sources. */ public static boolean isNetBeansOrg(File dir) { - return new File(dir, "nbbuild").isDirectory() && // NOI18N - // Check for both pre- and post-Hg layouts. - (new File(dir, "core").isDirectory() || new File(dir, "openide.util").isDirectory()); // NOI18N + return new File(dir, "nbbuild").isDirectory(); // NOI18N } /** @@ -951,7 +1003,7 @@ } else { continue; } - if (new File(mainrepo, "nbbuild").isDirectory() && new File(mainrepo, "openide.util").isDirectory()) { // NOI18N + if (new File(mainrepo, "nbbuild").isDirectory()) { // NOI18N return mainrepo; } } @@ -1059,7 +1111,7 @@ private void maybeRescanNetBeansOrgSources() { if (lazyNetBeansOrgList) { lazyNetBeansOrgList = false; - File nbdestdir = new File(home, DEST_DIR_IN_NETBEANS_ORG); + File nbdestdir = findNetBeansOrgDestDir(home); Map _entries = new HashMap(entries); // #68513: possible race condition if (new File(home, "openide.util").isDirectory()) { // NOI18N // Post-Hg layout. @@ -1085,7 +1137,7 @@ return e; } if (isNetBeansOrg(home)) { - File nbdestdir = new File(home, DEST_DIR_IN_NETBEANS_ORG); + File nbdestdir = findNetBeansOrgDestDir(home); for (String tree : FOREST) { String name = abbreviate(codeNameBase); File basedir = new File(tree == null ? home : new File(home, tree), name); diff --git a/apisupport.project/src/org/netbeans/modules/apisupport/project/universe/NetBeansOrgEntry.java b/apisupport.project/src/org/netbeans/modules/apisupport/project/universe/NetBeansOrgEntry.java --- a/apisupport.project/src/org/netbeans/modules/apisupport/project/universe/NetBeansOrgEntry.java +++ b/apisupport.project/src/org/netbeans/modules/apisupport/project/universe/NetBeansOrgEntry.java @@ -90,7 +90,7 @@ } public File getDestDir() { - return new File(nball, ModuleList.DEST_DIR_IN_NETBEANS_ORG); + return ModuleList.findNetBeansOrgDestDir(nball); } public String getCodeNameBase() { diff --git a/apisupport.project/src/org/netbeans/modules/apisupport/project/universe/TestEntry.java b/apisupport.project/src/org/netbeans/modules/apisupport/project/universe/TestEntry.java --- a/apisupport.project/src/org/netbeans/modules/apisupport/project/universe/TestEntry.java +++ b/apisupport.project/src/org/netbeans/modules/apisupport/project/universe/TestEntry.java @@ -204,5 +204,14 @@ } return null; } + + @Override + public String toString() { + try { + return "TestEntry[" + jarFile + ",src=" + getSrcDir() + "]"; // NOI18N + } catch (IOException x) { + return "TestEntry[" + jarFile + ",src=<" + x.getMessage() + ">]"; // NOI18N + } + } } diff --git a/nbbuild/antsrc/org/netbeans/nbbuild/ModuleListParser.java b/nbbuild/antsrc/org/netbeans/nbbuild/ModuleListParser.java --- a/nbbuild/antsrc/org/netbeans/nbbuild/ModuleListParser.java +++ b/nbbuild/antsrc/org/netbeans/nbbuild/ModuleListParser.java @@ -500,18 +500,7 @@ /** * Find all modules in a binary build, possibly from cache. */ - private static Map scanBinaries(Map properties, Project project) throws IOException { - String buildS = properties.get("netbeans.dest.dir"); - File basedir = new File(properties.get("basedir")); - if (buildS == null) { - throw new IOException("No definition of netbeans.dest.dir in " + basedir); - } - // Resolve against basedir, and normalize ../ sequences and so on in case they are used. - // Neither operation is likely to be needed, but just in case. - File build = FileUtils.getFileUtils().normalize(FileUtils.getFileUtils().resolveFile(basedir, buildS).getAbsolutePath()); - if (!build.isDirectory()) { - throw new IOException("No such netbeans.dest.dir: " + build); - } + private static Map scanBinaries(Project project, File build) throws IOException { Map entries = BINARY_SCAN_CACHE.get(build); if (entries == null) { if (project != null) { @@ -690,13 +679,23 @@ */ public ModuleListParser(Map properties, int type, Project project) throws IOException { String nball = properties.get("nb_all"); + String buildS = properties.get("netbeans.dest.dir"); + File basedir = new File(properties.get("basedir")); + if (buildS == null) { + throw new IOException("No definition of netbeans.dest.dir in " + basedir); + } + // Resolve against basedir, and normalize ../ sequences and so on in case they are used. + // Neither operation is likely to be needed, but just in case. + File build = FileUtils.getFileUtils().normalize(FileUtils.getFileUtils().resolveFile(basedir, buildS).getAbsolutePath()); + if (!build.isDirectory()) { + throw new IOException("No such netbeans.dest.dir: " + build); + } if (type != ParseProjectXml.TYPE_NB_ORG) { // External module. - File basedir = new File(properties.get("basedir")); if (nball != null && project != null) { project.log("You must *not* declare or for a netbeans.org module in " + basedir + "; fix project.xml to use the /2 schema", Project.MSG_WARN); } - entries = scanBinaries(properties, project); + entries = scanBinaries(project, build); if (type == ParseProjectXml.TYPE_SUITE) { entries.putAll(scanSuiteSources(properties, project)); } else { @@ -709,15 +708,14 @@ if (nball == null) { throw new IOException("You must declare either or for an external module in " + new File(properties.get("basedir"))); } - // If scan.binaries property is set we scan binaries otherwise sources. - if (properties.get("scan.binaries") != null) { - entries = scanBinaries(properties, project); - // module itself has to be added because it doesn't have to be in binaries + if (!build.equals(new File(new File(nball, "nbbuild"), "netbeans"))) { + // Potentially orphaned module to be built against specific binaries, plus perhaps other source deps. + entries = scanBinaries(project, build); + // Add referenced module in case it does not appear otherwise. Entry e = scanStandaloneSource(properties, project); if (e != null) { entries.put(e.getCnb(), e); } - // to allow building of depend modules on top of binary entries.putAll(scanNetBeansOrgSources(new File(nball), properties, project)); } else { entries = scanNetBeansOrgSources(new File(nball), properties, project); diff --git a/nbbuild/build.xml b/nbbuild/build.xml --- a/nbbuild/build.xml +++ b/nbbuild/build.xml @@ -76,8 +76,6 @@ - - - + @@ -1221,7 +1219,7 @@ - + @@ -1296,7 +1294,7 @@ - + @@ -1305,7 +1303,7 @@ - + diff --git a/nbbuild/default-properties.xml b/nbbuild/default-properties.xml --- a/nbbuild/default-properties.xml +++ b/nbbuild/default-properties.xml @@ -43,6 +43,11 @@ + + + + + @@ -52,11 +57,6 @@ - - - - - diff --git a/nbbuild/templates/projectized.xml b/nbbuild/templates/projectized.xml --- a/nbbuild/templates/projectized.xml +++ b/nbbuild/templates/projectized.xml @@ -294,7 +294,10 @@ - + + + +