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
|
/.classpath
|
||||||
/.project
|
/.project
|
||||||
/.settings/org.maven.ide.eclipse.prefs
|
/.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>
|
<phase>generate-resources</phase>
|
||||||
<configuration>
|
<configuration>
|
||||||
<tasks>
|
<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" />
|
<property name="pkg" location="${src}/com/google/gerrit/common" />
|
||||||
|
<mkdir dir="${pkg}" />
|
||||||
<exec executable="git" outputproperty="v">
|
<exec executable="git" outputproperty="v">
|
||||||
<arg value="describe"/>
|
<arg value="describe"/>
|
||||||
<arg value="HEAD"/>
|
<arg value="HEAD"/>
|
||||||
|
|||||||
@@ -258,16 +258,12 @@ public class Init extends SiteProgram {
|
|||||||
System.err.println();
|
System.err.println();
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!secure_config.exists()) {
|
|
||||||
chmod(0600, secure_config);
|
|
||||||
}
|
|
||||||
if (!replication_config.exists()) {
|
if (!replication_config.exists()) {
|
||||||
replication_config.createNewFile();
|
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);
|
chmod(0755, gerrit_sh);
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private void updateSystemConfig() throws OrmException {
|
private void updateSystemConfig() throws OrmException {
|
||||||
@@ -371,10 +367,7 @@ public class Init extends SiteProgram {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private static void chmod(final int mode, final File path) throws IOException {
|
private static void chmod(final int mode, final File path) {
|
||||||
if (!path.exists() && !path.createNewFile()) {
|
|
||||||
throw new IOException("Cannot create " + path);
|
|
||||||
}
|
|
||||||
path.setReadable(false, false /* all */);
|
path.setReadable(false, false /* all */);
|
||||||
path.setWritable(false, false /* all */);
|
path.setWritable(false, false /* all */);
|
||||||
path.setExecutable(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)
|
private static void extract(final File dst, final Class<?> sibling,
|
||||||
throws IOException {
|
final String name) throws IOException {
|
||||||
final URL u = GerritLauncher.class.getClassLoader().getResource(path);
|
final InputStream in = open(sibling, name);
|
||||||
if (u == null) {
|
if (in != null) {
|
||||||
System.err.println("warn: Cannot read " + path);
|
copy(dst, in);
|
||||||
return;
|
|
||||||
}
|
}
|
||||||
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)
|
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>
|
</licenses>
|
||||||
|
|
||||||
<build>
|
<build>
|
||||||
<resources>
|
|
||||||
<resource>
|
|
||||||
<directory>${basedir}/src/main/java</directory>
|
|
||||||
<excludes>
|
|
||||||
<exclude>**/*.gwt.xml</exclude>
|
|
||||||
<exclude>**/*.java</exclude>
|
|
||||||
</excludes>
|
|
||||||
</resource>
|
|
||||||
</resources>
|
|
||||||
|
|
||||||
<plugins>
|
<plugins>
|
||||||
<plugin>
|
<plugin>
|
||||||
<artifactId>maven-compiler-plugin</artifactId>
|
<artifactId>maven-compiler-plugin</artifactId>
|
||||||
|
|||||||
Reference in New Issue
Block a user