Merge "Remove servlet-api from WAR/lib"
diff --git a/gerrit-launcher/src/main/java/com/google/gerrit/launcher/GerritLauncher.java b/gerrit-launcher/src/main/java/com/google/gerrit/launcher/GerritLauncher.java
index b3d1cd5..d49c6c7 100644
--- a/gerrit-launcher/src/main/java/com/google/gerrit/launcher/GerritLauncher.java
+++ b/gerrit-launcher/src/main/java/com/google/gerrit/launcher/GerritLauncher.java
@@ -206,27 +206,10 @@
final ZipEntry ze = e.nextElement();
if (ze.isDirectory()) {
continue;
- }
-
- if (ze.getName().startsWith("WEB-INF/lib/")) {
- String name = ze.getName().substring("WEB-INF/lib/".length());
- final File tmp = createTempFile(safeName(ze), ".jar");
- final FileOutputStream out = new FileOutputStream(tmp);
- try {
- final InputStream in = zf.getInputStream(ze);
- try {
- final byte[] buf = new byte[4096];
- int n;
- while ((n = in.read(buf, 0, buf.length)) > 0) {
- out.write(buf, 0, n);
- }
- } finally {
- in.close();
- }
- } finally {
- out.close();
- }
- jars.put(name, tmp.toURI().toURL());
+ } else if (ze.getName().startsWith("WEB-INF/lib/")) {
+ extractJar(zf, ze, jars);
+ } else if (ze.getName().startsWith("WEB-INF/pgm-lib/")) {
+ extractJar(zf, ze, jars);
}
}
} finally {
@@ -261,6 +244,31 @@
parent);
}
+ private static void extractJar(ZipFile zf, ZipEntry ze,
+ SortedMap<String, URL> jars) throws IOException {
+ File tmp = createTempFile(safeName(ze), ".jar");
+ FileOutputStream out = new FileOutputStream(tmp);
+ try {
+ InputStream in = zf.getInputStream(ze);
+ try {
+ byte[] buf = new byte[4096];
+ int n;
+ while ((n = in.read(buf, 0, buf.length)) > 0) {
+ out.write(buf, 0, n);
+ }
+ } finally {
+ in.close();
+ }
+ } finally {
+ out.close();
+ }
+
+ String name = ze.getName();
+ jars.put(
+ name.substring(name.lastIndexOf('/'), name.length()),
+ tmp.toURI().toURL());
+ }
+
private static void move(SortedMap<String, URL> jars,
String prefix,
List<URL> extapi) {
diff --git a/gerrit-war/pom.xml b/gerrit-war/pom.xml
index 3becf84..723d416 100644
--- a/gerrit-war/pom.xml
+++ b/gerrit-war/pom.xml
@@ -41,6 +41,12 @@
</dependency>
<dependency>
+ <groupId>org.apache.tomcat</groupId>
+ <artifactId>tomcat-servlet-api</artifactId>
+ <scope>provided</scope>
+ </dependency>
+
+ <dependency>
<groupId>com.google.gerrit</groupId>
<artifactId>gerrit-gwtui</artifactId>
<version>${project.version}</version>
@@ -99,6 +105,18 @@
<groupId>com.google.gerrit</groupId>
<artifactId>gerrit-pgm</artifactId>
<version>${project.version}</version>
+ <exclusions>
+ <exclusion>
+ <groupId>org.eclipse.jetty</groupId>
+ <artifactId>jetty-servlet</artifactId>
+ </exclusion>
+ </exclusions>
+ </dependency>
+
+ <dependency>
+ <groupId>org.eclipse.jetty</groupId>
+ <artifactId>jetty-servlet</artifactId>
+ <scope>provided</scope>
</dependency>
</dependencies>
@@ -135,9 +153,46 @@
<plugin>
<groupId>org.apache.maven.plugins</groupId>
+ <artifactId>maven-dependency-plugin</artifactId>
+ <executions>
+ <execution>
+ <id>copy-servlet-api</id>
+ <configuration>
+ <includeGroupIds>org.apache.tomcat,org.eclipse.jetty</includeGroupIds>
+ <excludeArtifactIds>servlet-api</excludeArtifactIds>
+ </configuration>
+ <goals>
+ <goal>copy-dependencies</goal>
+ </goals>
+ </execution>
+ </executions>
+ </plugin>
+
+ <plugin>
+ <groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-antrun-plugin</artifactId>
<executions>
<execution>
+ <id>copy-servlet-api</id>
+ <phase>process-classes</phase>
+ <configuration>
+ <target>
+ <property name="src" location="${project.build.directory}/dependency" />
+ <property name="dst" location="${project.build.directory}/${project.build.finalName}/WEB-INF/pgm-lib" />
+
+ <mkdir dir="${dst}" />
+ <copy overwrite="true" todir="${dst}">
+ <fileset dir="${src}">
+ <include name="*.jar" />
+ </fileset>
+ </copy>
+ </target>
+ </configuration>
+ <goals>
+ <goal>run</goal>
+ </goals>
+ </execution>
+ <execution>
<id>copy-license</id>
<phase>process-classes</phase>
<configuration>
diff --git a/pom.xml b/pom.xml
index 82012dc..6360afc 100644
--- a/pom.xml
+++ b/pom.xml
@@ -373,7 +373,7 @@
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-dependency-plugin</artifactId>
- <version>2.1</version>
+ <version>2.5.1</version>
</plugin>
<plugin>