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 @@ -951,7 +1005,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 +1113,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 +1139,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() {