Move all resource files into src/main/resources
Instead of mingling our resource files alongside of our Java source code, move them into the src/main/resources directory where Maven normally expects them to be. We only move the resources which actually have to appear at runtime in our CLASSPATH, which means we can omit the GWT message files and linker scripts (*.gwt.xml) from the resource directory. Change-Id: I18c573501f4d60ced35a247fb6ef6a056f774b1c Signed-off-by: Shawn O. Pearce <sop@google.com>
This commit is contained in:
2
gerrit-common/.gitignore
vendored
2
gerrit-common/.gitignore
vendored
@@ -2,4 +2,4 @@
|
||||
/.classpath
|
||||
/.project
|
||||
/.settings/org.maven.ide.eclipse.prefs
|
||||
/src/main/java/com/google/gerrit/common/Version.properties
|
||||
/src/main/resources/com/google/gerrit/common/Version.properties
|
||||
|
||||
@@ -65,8 +65,9 @@ limitations under the License.
|
||||
<phase>generate-resources</phase>
|
||||
<configuration>
|
||||
<tasks>
|
||||
<property name="src" location="${basedir}/src/main/java/" />
|
||||
<property name="src" location="${basedir}/src/main/resources/" />
|
||||
<property name="pkg" location="${src}/com/google/gerrit/common" />
|
||||
<mkdir dir="${pkg}" />
|
||||
<exec executable="git" outputproperty="v">
|
||||
<arg value="describe"/>
|
||||
<arg value="HEAD"/>
|
||||
|
||||
@@ -258,17 +258,13 @@ public class Init extends SiteProgram {
|
||||
System.err.println();
|
||||
}
|
||||
|
||||
if (!secure_config.exists()) {
|
||||
chmod(0600, secure_config);
|
||||
}
|
||||
if (!replication_config.exists()) {
|
||||
replication_config.createNewFile();
|
||||
}
|
||||
if (!gerrit_sh.exists()) {
|
||||
extract(gerrit_sh, "WEB-INF/extra/bin/gerrit.sh");
|
||||
|
||||
extract(gerrit_sh, Init.class, "gerrit.sh");
|
||||
chmod(0755, gerrit_sh);
|
||||
}
|
||||
}
|
||||
|
||||
private void updateSystemConfig() throws OrmException {
|
||||
final ReviewDb db = schema.open();
|
||||
@@ -371,10 +367,7 @@ public class Init extends SiteProgram {
|
||||
}
|
||||
}
|
||||
|
||||
private static void chmod(final int mode, final File path) throws IOException {
|
||||
if (!path.exists() && !path.createNewFile()) {
|
||||
throw new IOException("Cannot create " + path);
|
||||
}
|
||||
private static void chmod(final int mode, final File path) {
|
||||
path.setReadable(false, false /* all */);
|
||||
path.setWritable(false, false /* all */);
|
||||
path.setExecutable(false, false /* all */);
|
||||
@@ -1074,14 +1067,30 @@ public class Init extends SiteProgram {
|
||||
}
|
||||
}
|
||||
|
||||
private static void extract(final File dst, final String path)
|
||||
throws IOException {
|
||||
final URL u = GerritLauncher.class.getClassLoader().getResource(path);
|
||||
if (u == null) {
|
||||
System.err.println("warn: Cannot read " + path);
|
||||
return;
|
||||
private static void extract(final File dst, final Class<?> sibling,
|
||||
final String name) throws IOException {
|
||||
final InputStream in = open(sibling, name);
|
||||
if (in != null) {
|
||||
copy(dst, in);
|
||||
}
|
||||
copy(dst, u.openStream());
|
||||
}
|
||||
|
||||
private static InputStream open(final Class<?> sibling, final String name)
|
||||
throws IOException {
|
||||
final URL u = sibling.getResource(name);
|
||||
if (u == null) {
|
||||
String pkg = sibling.getName();
|
||||
int end = pkg.lastIndexOf('.');
|
||||
if (0 < end) {
|
||||
pkg = pkg.substring(0, end + 1);
|
||||
pkg = pkg.replace('.', '/');
|
||||
} else {
|
||||
pkg = "";
|
||||
}
|
||||
System.err.println("warn: Cannot read " + pkg + name);
|
||||
return null;
|
||||
}
|
||||
return u.openStream();
|
||||
}
|
||||
|
||||
private static void copy(final File dst, final InputStream in)
|
||||
|
||||
10
pom.xml
10
pom.xml
@@ -295,16 +295,6 @@ limitations under the License.
|
||||
</licenses>
|
||||
|
||||
<build>
|
||||
<resources>
|
||||
<resource>
|
||||
<directory>${basedir}/src/main/java</directory>
|
||||
<excludes>
|
||||
<exclude>**/*.gwt.xml</exclude>
|
||||
<exclude>**/*.java</exclude>
|
||||
</excludes>
|
||||
</resource>
|
||||
</resources>
|
||||
|
||||
<plugins>
|
||||
<plugin>
|
||||
<artifactId>maven-compiler-plugin</artifactId>
|
||||
|
||||
Reference in New Issue
Block a user