Isolate plugin class directories from each other
Configure Eclipse to compile/copy each plugin's classes and resources into its own private classes folder. This should fix the duplicate resource warnings for about.md or other documentation and static image assets. Move test and utility classes into their own directories too. This has no real impact on the runtime classpath at this time, but opens the door to do something more creative later. Change-Id: If2a048dfe0349f671a17f9e80d6f22a69a5c0ade
This commit is contained in:
parent
80d9cdbb88
commit
9e4d5aa347
@ -556,6 +556,50 @@ public final class GerritLauncher {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Locate the path of the {@code buck-out} directory in a source tree.
|
||||||
|
*
|
||||||
|
* @throws FileNotFoundException if the directory cannot be found.
|
||||||
|
*/
|
||||||
|
public static File getDeveloperBuckOut() throws FileNotFoundException {
|
||||||
|
// Find ourselves in the CLASSPATH, we should be a loose class file.
|
||||||
|
Class<GerritLauncher> self = GerritLauncher.class;
|
||||||
|
URL u = self.getResource(self.getSimpleName() + ".class");
|
||||||
|
if (u == null) {
|
||||||
|
throw new FileNotFoundException("Cannot find class " + self.getName());
|
||||||
|
} else if (!"file".equals(u.getProtocol())) {
|
||||||
|
throw new FileNotFoundException("Cannot find extract path from " + u);
|
||||||
|
}
|
||||||
|
|
||||||
|
// Pop up to the top level classes folder that contains us.
|
||||||
|
File dir = new File(u.getPath());
|
||||||
|
String myName = self.getName();
|
||||||
|
for (;;) {
|
||||||
|
int dot = myName.lastIndexOf('.');
|
||||||
|
if (dot < 0) {
|
||||||
|
dir = dir.getParentFile();
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
myName = myName.substring(0, dot);
|
||||||
|
dir = dir.getParentFile();
|
||||||
|
}
|
||||||
|
|
||||||
|
dir = popdir(u, dir, "classes");
|
||||||
|
dir = popdir(u, dir, "eclipse");
|
||||||
|
if ("buck-out".equals(dir.getName())) {
|
||||||
|
return dir;
|
||||||
|
}
|
||||||
|
throw new FileNotFoundException("Cannot find buck-out from " + u);
|
||||||
|
}
|
||||||
|
|
||||||
|
private static File popdir(URL u, File dir, String name)
|
||||||
|
throws FileNotFoundException {
|
||||||
|
if (dir.getName().equals(name)) {
|
||||||
|
return dir.getParentFile();
|
||||||
|
}
|
||||||
|
throw new FileNotFoundException("Cannot find buck-out from " + u);
|
||||||
|
}
|
||||||
|
|
||||||
private GerritLauncher() {
|
private GerritLauncher() {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -77,7 +77,6 @@ import java.io.PrintWriter;
|
|||||||
import java.net.MalformedURLException;
|
import java.net.MalformedURLException;
|
||||||
import java.net.URI;
|
import java.net.URI;
|
||||||
import java.net.URISyntaxException;
|
import java.net.URISyntaxException;
|
||||||
import java.net.URL;
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.EnumSet;
|
import java.util.EnumSet;
|
||||||
import java.util.Enumeration;
|
import java.util.Enumeration;
|
||||||
@ -452,7 +451,7 @@ public class JettyServer {
|
|||||||
try {
|
try {
|
||||||
baseResource = unpackWar(GerritLauncher.getDistributionArchive());
|
baseResource = unpackWar(GerritLauncher.getDistributionArchive());
|
||||||
} catch (FileNotFoundException err) {
|
} catch (FileNotFoundException err) {
|
||||||
if (err.getMessage() == GerritLauncher.NOT_ARCHIVED) {
|
if (GerritLauncher.NOT_ARCHIVED.equals(err.getMessage())) {
|
||||||
baseResource = useDeveloperBuild(app);
|
baseResource = useDeveloperBuild(app);
|
||||||
} else {
|
} else {
|
||||||
throw err;
|
throw err;
|
||||||
@ -537,39 +536,7 @@ public class JettyServer {
|
|||||||
|
|
||||||
private Resource useDeveloperBuild(ServletContextHandler app)
|
private Resource useDeveloperBuild(ServletContextHandler app)
|
||||||
throws IOException {
|
throws IOException {
|
||||||
// Find ourselves in the CLASSPATH. We should be a loose class file.
|
final File dir = GerritLauncher.getDeveloperBuckOut();
|
||||||
//
|
|
||||||
URL u = getClass().getResource(getClass().getSimpleName() + ".class");
|
|
||||||
if (u == null) {
|
|
||||||
throw new FileNotFoundException("Cannot find web application root");
|
|
||||||
}
|
|
||||||
if (!"file".equals(u.getProtocol())) {
|
|
||||||
throw new FileNotFoundException("Cannot find web root from " + u);
|
|
||||||
}
|
|
||||||
|
|
||||||
// Pop up to the top level classes folder that contains us.
|
|
||||||
//
|
|
||||||
File dir = new File(u.getPath());
|
|
||||||
String myName = getClass().getName();
|
|
||||||
for (;;) {
|
|
||||||
int dot = myName.lastIndexOf('.');
|
|
||||||
if (dot < 0) {
|
|
||||||
dir = dir.getParentFile();
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
myName = myName.substring(0, dot);
|
|
||||||
dir = dir.getParentFile();
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!dir.getName().equals("classes")) {
|
|
||||||
throw new FileNotFoundException("Cannot find web root from " + u);
|
|
||||||
}
|
|
||||||
dir = dir.getParentFile(); // pop classes
|
|
||||||
|
|
||||||
if (!"buck-out".equals(dir.getName())) {
|
|
||||||
throw new FileNotFoundException("Cannot find web root from " + u);
|
|
||||||
}
|
|
||||||
|
|
||||||
final File gen = new File(dir, "gen");
|
final File gen = new File(dir, "gen");
|
||||||
final File root = dir.getParentFile();
|
final File root = dir.getParentFile();
|
||||||
final File dstwar = makeWarTempDir();
|
final File dstwar = makeWarTempDir();
|
||||||
|
@ -72,12 +72,14 @@ def gen_classpath():
|
|||||||
impl = minidom.getDOMImplementation()
|
impl = minidom.getDOMImplementation()
|
||||||
return impl.createDocument(None, 'classpath', None)
|
return impl.createDocument(None, 'classpath', None)
|
||||||
|
|
||||||
def classpathentry(kind, path, src=None):
|
def classpathentry(kind, path, src=None, out=None):
|
||||||
e = doc.createElement('classpathentry')
|
e = doc.createElement('classpathentry')
|
||||||
e.setAttribute('kind', kind)
|
e.setAttribute('kind', kind)
|
||||||
e.setAttribute('path', path)
|
e.setAttribute('path', path)
|
||||||
if src:
|
if src:
|
||||||
e.setAttribute('sourcepath', src)
|
e.setAttribute('sourcepath', src)
|
||||||
|
if out:
|
||||||
|
e.setAttribute('output', out)
|
||||||
doc.documentElement.appendChild(e)
|
doc.documentElement.appendChild(e)
|
||||||
|
|
||||||
doc = make_classpath()
|
doc = make_classpath()
|
||||||
@ -112,16 +114,29 @@ def gen_classpath():
|
|||||||
gwt_src.add(m.group(1))
|
gwt_src.add(m.group(1))
|
||||||
|
|
||||||
for s in sorted(src):
|
for s in sorted(src):
|
||||||
|
out = None
|
||||||
|
|
||||||
|
if s.startswith('lib/'):
|
||||||
|
out = 'buck-out/eclipse/lib'
|
||||||
|
elif s.startswith('plugins/'):
|
||||||
|
out = 'buck-out/eclipse/' + s
|
||||||
|
|
||||||
p = path.join(s, 'java')
|
p = path.join(s, 'java')
|
||||||
if path.exists(p):
|
if path.exists(p):
|
||||||
classpathentry('src', p)
|
classpathentry('src', p, out=out)
|
||||||
continue
|
continue
|
||||||
|
|
||||||
for env in ['main', 'test']:
|
for env in ['main', 'test']:
|
||||||
|
o = None
|
||||||
|
if out:
|
||||||
|
o = out + '/' + env
|
||||||
|
elif env == 'test':
|
||||||
|
o = 'buck-out/eclipse/test'
|
||||||
|
|
||||||
for srctype in ['java', 'resources']:
|
for srctype in ['java', 'resources']:
|
||||||
p = path.join(s, 'src', env, srctype)
|
p = path.join(s, 'src', env, srctype)
|
||||||
if path.exists(p):
|
if path.exists(p):
|
||||||
classpathentry('src', p)
|
classpathentry('src', p, out=o)
|
||||||
|
|
||||||
for libs in [lib, gwt_lib]:
|
for libs in [lib, gwt_lib]:
|
||||||
for j in sorted(libs):
|
for j in sorted(libs):
|
||||||
@ -133,14 +148,15 @@ def gen_classpath():
|
|||||||
classpathentry('lib', j, s)
|
classpathentry('lib', j, s)
|
||||||
|
|
||||||
for s in sorted(gwt_src):
|
for s in sorted(gwt_src):
|
||||||
classpathentry('lib', path.join(ROOT, s, 'src', 'main', 'java'))
|
p = path.join(ROOT, s, 'src', 'main', 'java')
|
||||||
|
classpathentry('lib', p, out='buck-out/eclipse/gwtsrc')
|
||||||
|
|
||||||
classpathentry('con', JRE)
|
classpathentry('con', JRE)
|
||||||
classpathentry('output', 'buck-out/classes')
|
classpathentry('output', 'buck-out/eclipse/classes')
|
||||||
|
|
||||||
p = path.join(ROOT, '.classpath')
|
p = path.join(ROOT, '.classpath')
|
||||||
with open(p, 'w') as fd:
|
with open(p, 'w') as fd:
|
||||||
doc.writexml(fd, addindent=' ', newl='\n', encoding='UTF-8')
|
doc.writexml(fd, addindent='\t', newl='\n', encoding='UTF-8')
|
||||||
|
|
||||||
try:
|
try:
|
||||||
if args.src:
|
if args.src:
|
||||||
|
Loading…
Reference in New Issue
Block a user