in netbeans-l10n-zip/antsrc/org/netbeans/l10n/Package.java [325:449]
void processLocale(String locale) throws BuildException {
DirectoryScanner ds = new DirectoryScanner();
File baseSrcDir = new File(srcDir, locale);
if (!baseSrcDir.exists()) {
log("No files for locale: " + locale);
return;
}
ds.setBasedir(baseSrcDir);
String[] includes = new String[]{"*/*/*", "*/*/ext/*", "*/*/ext/locale/*", "*/*/netbeans/*/*", "*/*/netbeans/*/locale/*", "*/*/netbeans/*/nblib/*", "*/*/netbeans/*/extra/*", "*/*/docs/*", "*/*/locale/*", "*/*/netbeans/config/*/*"};
String[] excludes = new String[]{"other/**", "*/*/netbeans", "*/*/netbeans/*", "*/*/netbeans/*/locale", "*/*/netbeans/*/nblib", "*/*/netbeans/*/extra", "*/*/docs", "*/*/ext", "*/*/ext/locale", "*/*/locale", "*/*/netbeans/config/*"};
ds.setIncludes(includes);
ds.setExcludes(excludes);
ds.scan();
Jar jar = (Jar) getProject().createTask("jar");
Mkdir mkdir = (Mkdir) getProject().createTask("mkdir");
Task locJH = getProject().createTask("locjhindexer");
for (String dir : ds.getIncludedDirectories()) {
String name = dir.substring(dir.lastIndexOf(File.separator) + 1);
name = name.replaceAll("^vw-rh", "visualweb-ravehelp-rave_nbpack");
name = name.replaceAll("^vw-", "visualweb-");
String nbm = dir.substring(dir.indexOf(File.separator) + 1);
nbm = nbm.substring(0, nbm.indexOf(File.separator));
String cluster = dir.substring(0, dir.indexOf(File.separator));
String subPath = dir.substring((cluster + File.separator + nbm + File.separator).length() - 1, dir.lastIndexOf(File.separator));
if (!subPath.startsWith(File.separator + "netbeans")) {
subPath = File.separator + "modules" + subPath;
if (!name.startsWith("org-") && !(subPath.endsWith(File.separator + "ext") || subPath.endsWith(File.separator + "ext" + File.separator + "locale"))) {
name = "org-netbeans-modules-" + name;
} else {
// Handle exception from ext/
if (name.startsWith("web-httpmonitor") || name.startsWith("deployment-deviceanywhere")) {
name = "org-netbeans-modules-" + name;
}
}
} else {
subPath = subPath.substring((File.separator + "netbeans").length());
//Handle exceptions form nblib
if (name.startsWith("j2ee-ant") || name.startsWith("deployment-deviceanywhere") || name.startsWith("mobility-project") || name.startsWith("java-j2seproject-copylibstask")) {
name = "org-netbeans-modules-" + name;
}
}
nbm = nbm.replaceAll("^vw-rh", "visualweb-ravehelp-rave_nbpack");
nbm = nbm.replaceAll("^vw-", "visualweb-");
if (!nbm.startsWith("org-") && !nbm.startsWith("com-")) {
nbm = "org-netbeans-modules-" + nbm;
}
cluster = cluster.replaceAll("^vw", "visualweb");
if (subPath.matches(".*/docs$")) {
ds.setBasedir(new File(baseSrcDir, dir));
ds.setIncludes(new String[]{"**/*.hs"});
ds.setExcludes(new String[]{""});
ds.scan();
if (ds.getIncludedFilesCount() != 1) {
throw new BuildException("Can't find .hs file for " + name + " module.");
}
File hsFile = new File(new File(baseSrcDir, dir), ds.getIncludedFiles()[0]);
File baseJHDir = hsFile.getParentFile();
try {
System.out.println("Basedir: " + baseJHDir.getAbsolutePath());
locJH.getClass().getMethod("setBasedir", File.class).invoke(locJH, baseJHDir);
locJH.getClass().getMethod("setLocales", String.class).invoke(locJH, locale);
locJH.getClass().getMethod("setDbdir", String.class).invoke(locJH, "JavaHelpSearch");
((Path)locJH.getClass().getMethod("createClasspath").invoke(locJH)).add(classpath);
} catch (Exception ex) {
throw new BuildException("Can't run locJHInxeder", ex);
}
locJH.execute();
}
if (!subPath.endsWith("locale")) {
subPath += File.separator + "locale";
}
String jarFileName = name + "_" + locale + ".jar";
File distJarDir = new File(distDir.getAbsolutePath(), cluster + subPath);
mkdir.setDir(distJarDir);
mkdir.execute();
jar.setBasedir(new File(baseSrcDir, dir));
jar.setDestFile(new File(distJarDir, jarFileName));
jar.execute();
Vector<String> nbmFiles = nbms.get(nbm);
if (nbmFiles == null) {
nbmFiles = new Vector<String>();
nbms.put(nbm, nbmFiles);
}
nbmFiles.add(subPath.substring(1) + File.separator + jarFileName);
}
ds.setBasedir(baseSrcDir);
ds.setIncludes(includes);
ds.setExcludes(excludes);
ds.scan();
Copy copy = (Copy) getProject().createTask("copy");
for (String file : ds.getIncludedFiles()) {
String name = file.substring(file.lastIndexOf(File.separator) + 1);
name = name.replaceAll("^vw-rh", "visualweb-ravehelp-rave_nbpack");
name = name.replaceAll("^vw-", "visualweb-");
String nbm = file.substring(file.indexOf(File.separator) + 1);
nbm = nbm.substring(0, nbm.indexOf(File.separator));
String cluster = file.substring(0, file.indexOf(File.separator));
String subPath = file.substring((cluster + File.separator + nbm + File.separator).length() - 1, file.lastIndexOf(File.separator));
if (!subPath.startsWith(File.separator + "netbeans")) {
subPath = File.separator + "modules" + subPath;
} else {
subPath = subPath.substring((File.separator + "netbeans").length());
}
nbm = nbm.replaceAll("^vw-rh", "visualweb-ravehelp-rave_nbpack");
nbm = nbm.replaceAll("^vw-", "visualweb-");
if (!nbm.startsWith("org") || !nbm.startsWith("com")) {
nbm = "org-netbeans-modules-" + nbm;
}
cluster = cluster.replaceAll("^vw", "visualweb");
File distFileDir = new File(distDir.getAbsolutePath(), cluster + subPath);
mkdir.setDir(distFileDir);
mkdir.execute();
copy.setFile(new File(baseSrcDir, file));
copy.setTodir(distFileDir);
copy.execute();
Vector<String> nbmFiles = nbms.get(nbm);
if (nbmFiles == null) {
nbmFiles = new Vector<String>();
nbms.put(nbm, nbmFiles);
}
nbmFiles.add(subPath.substring(1) + File.separator + file);
}
}