From 4ad77b590d23aa3156dcdaec36869dbb7ad776b2 Mon Sep 17 00:00:00 2001 From: olivier lamy Date: Mon, 1 Apr 2019 14:39:28 +1000 Subject: [PATCH] Issue #3514 using interpolation for mod files, fix unix socket mod files with adding a distribution test Signed-off-by: olivier lamy --- .../session-store-hazelcast-embedded.mod | 4 +- .../session-store-hazelcast-remote.mod | 6 +-- jetty-home/pom.xml | 6 +-- .../jetty-memcached-sessions/pom.xml | 13 ++--- .../session-data-cache/xmemcached.mod | 2 +- jetty-nosql/pom.xml | 3 +- .../config/modules/session-store-mongo.mod | 2 +- .../src/main/config/modules/server.mod | 6 +-- .../src/main/config/modules/unixsocket.mod | 26 ++++----- .../src/main/config/modules/log4j-impl.mod | 2 +- .../src/main/config/modules/logback-impl.mod | 2 +- .../src/main/config/modules/slf4j-api.mod | 2 +- pom.xml | 36 ++++++++++++- tests/test-distribution/pom.xml | 6 +++ .../tests/distribution/DistributionTests.java | 53 +++++++++++++++++++ 15 files changed, 131 insertions(+), 38 deletions(-) diff --git a/jetty-hazelcast/src/main/config/modules/session-store-hazelcast-embedded.mod b/jetty-hazelcast/src/main/config/modules/session-store-hazelcast-embedded.mod index 2263ae0807b8..de1faa3c1bcd 100644 --- a/jetty-hazelcast/src/main/config/modules/session-store-hazelcast-embedded.mod +++ b/jetty-hazelcast/src/main/config/modules/session-store-hazelcast-embedded.mod @@ -13,7 +13,7 @@ session-store sessions [files] -maven://com.hazelcast/hazelcast/3.8.2|lib/hazelcast/hazelcast-3.8.2.jar +maven://com.hazelcast/hazelcast/@hazelcast.version@|lib/hazelcast/hazelcast-@hazelcast.version@.jar [xml] etc/sessions/hazelcast/default.xml @@ -33,4 +33,4 @@ jetty.session.hazelcast.mapName=jetty-distributed-session-map jetty.session.hazelcast.hazelcastInstanceName=JETTY_DISTRIBUTED_SESSION_INSTANCE #jetty.session.hazelcast.configurationLocation= jetty.session.gracePeriod.seconds=3600 -jetty.session.savePeriod.seconds=0 \ No newline at end of file +jetty.session.savePeriod.seconds=0 diff --git a/jetty-hazelcast/src/main/config/modules/session-store-hazelcast-remote.mod b/jetty-hazelcast/src/main/config/modules/session-store-hazelcast-remote.mod index c6a26fc7123f..5e09c4dd6ed0 100644 --- a/jetty-hazelcast/src/main/config/modules/session-store-hazelcast-remote.mod +++ b/jetty-hazelcast/src/main/config/modules/session-store-hazelcast-remote.mod @@ -13,8 +13,8 @@ session-store sessions [files] -maven://com.hazelcast/hazelcast/3.8.2|lib/hazelcast/hazelcast-3.8.2.jar -maven://com.hazelcast/hazelcast-client/3.8.2|lib/hazelcast/hazelcast-client-3.8.2.jar +maven://com.hazelcast/hazelcast/@hazelcast.version@|lib/hazelcast/hazelcast-@hazelcast.version@.jar +maven://com.hazelcast/hazelcast-client/@hazelcast.version@|lib/hazelcast/hazelcast-client-@hazelcast.version@.jar [xml] etc/sessions/hazelcast/remote.xml @@ -35,4 +35,4 @@ jetty.session.hazelcast.hazelcastInstanceName=JETTY_DISTRIBUTED_SESSION_INSTANCE jetty.session.hazelcast.onlyClient=true #jetty.session.hazelcast.configurationLocation= jetty.session.gracePeriod.seconds=3600 -jetty.session.savePeriod.seconds=0 \ No newline at end of file +jetty.session.savePeriod.seconds=0 diff --git a/jetty-home/pom.xml b/jetty-home/pom.xml index 70e3d3deea92..ad586a7e6bcf 100644 --- a/jetty-home/pom.xml +++ b/jetty-home/pom.xml @@ -78,7 +78,7 @@ version txt true - ${assembly-directory}/ + ${assembly-directory}/ VERSION.txt @@ -290,7 +290,7 @@ 3.1.0 true ${assembly-directory}/lib - servlet-api-3.1.jar + servlet-api-${servlet.api.distributed.version}.jar org.eclipse.jetty.toolchain @@ -298,7 +298,7 @@ 3.1.M0 true ${assembly-directory}/lib - jetty-schemas-3.1.jar + jetty-schemas-${jetty.schema.distributed.version}.jar diff --git a/jetty-memcached/jetty-memcached-sessions/pom.xml b/jetty-memcached/jetty-memcached-sessions/pom.xml index 5172a0ae573d..02aef923f06f 100644 --- a/jetty-memcached/jetty-memcached-sessions/pom.xml +++ b/jetty-memcached/jetty-memcached-sessions/pom.xml @@ -10,6 +10,11 @@ jetty-memcached-sessions Jetty :: Memcached :: Sessions + + ${project.groupId}.session + 2.4.5 + + org.eclipse.jetty @@ -19,12 +24,12 @@ com.googlecode.xmemcached xmemcached - 2.4.5 + ${memcache.version} org.slf4j slf4j-simple - 1.7.9 + ${slf4j.version} test @@ -46,10 +51,6 @@ - - ${project.groupId}.session - - diff --git a/jetty-memcached/jetty-memcached-sessions/src/main/config/modules/sessions/session-data-cache/xmemcached.mod b/jetty-memcached/jetty-memcached-sessions/src/main/config/modules/sessions/session-data-cache/xmemcached.mod index 77a21ea759f9..9ee3a597826d 100644 --- a/jetty-memcached/jetty-memcached-sessions/src/main/config/modules/sessions/session-data-cache/xmemcached.mod +++ b/jetty-memcached/jetty-memcached-sessions/src/main/config/modules/sessions/session-data-cache/xmemcached.mod @@ -11,7 +11,7 @@ session-store slf4j-api [files] -maven://com.googlecode.xmemcached/xmemcached/2.4.5|lib/xmemcached/xmemcached-2.4.5.jar +maven://com.googlecode.xmemcached/xmemcached/@memcache.version@|lib/xmemcached/xmemcached-@memcache.version@.jar [lib] lib/jetty-memcached-sessions-${jetty.version}.jar diff --git a/jetty-nosql/pom.xml b/jetty-nosql/pom.xml index 4a1e7bfaa843..cd55a911326f 100644 --- a/jetty-nosql/pom.xml +++ b/jetty-nosql/pom.xml @@ -10,6 +10,7 @@ http://www.eclipse.org/jetty ${project.groupId}.nosql + 2.13.2 install @@ -36,7 +37,7 @@ org.mongodb mongo-java-driver - 2.13.2 + ${mongo.version} jar compile diff --git a/jetty-nosql/src/main/config/modules/session-store-mongo.mod b/jetty-nosql/src/main/config/modules/session-store-mongo.mod index e3ffafdd42df..4e2e76a56da1 100644 --- a/jetty-nosql/src/main/config/modules/session-store-mongo.mod +++ b/jetty-nosql/src/main/config/modules/session-store-mongo.mod @@ -14,7 +14,7 @@ sessions sessions/mongo/${connection-type} [files] -maven://org.mongodb/mongo-java-driver/2.13.2|lib/nosql/mongo-java-driver-2.13.2.jar +maven://org.mongodb/mongo-java-driver/@mongo.version@|lib/nosql/mongo-java-driver-@mongo.version@.jar [lib] lib/jetty-nosql-${jetty.version}.jar diff --git a/jetty-server/src/main/config/modules/server.mod b/jetty-server/src/main/config/modules/server.mod index dd039a01fb1c..bdc1a7abee94 100644 --- a/jetty-server/src/main/config/modules/server.mod +++ b/jetty-server/src/main/config/modules/server.mod @@ -14,8 +14,8 @@ threadpool bytebufferpool [lib] -lib/servlet-api-3.1.jar -lib/jetty-schemas-3.1.jar +lib/servlet-api-@servlet.api.distributed.version@.jar +lib/jetty-schemas-@jetty.schema.distributed.version@.jar lib/jetty-http-${jetty.version}.jar lib/jetty-server-${jetty.version}.jar lib/jetty-xml-${jetty.version}.jar @@ -26,7 +26,7 @@ lib/jetty-io-${jetty.version}.jar etc/jetty.xml [jpms] -patch-module: servlet.api=lib/jetty-schemas-3.1.jar +patch-module: servlet.api=lib/jetty-schemas-@jetty.schema.distributed.version@.jar [ini-template] ### Common HTTP configuration diff --git a/jetty-unixsocket/src/main/config/modules/unixsocket.mod b/jetty-unixsocket/src/main/config/modules/unixsocket.mod index 84a45d218314..9e32a5fc73ed 100644 --- a/jetty-unixsocket/src/main/config/modules/unixsocket.mod +++ b/jetty-unixsocket/src/main/config/modules/unixsocket.mod @@ -19,26 +19,26 @@ server etc/jetty-unixsocket.xml [files] -maven://com.github.jnr/jnr-unixsocket/0.8|lib/jnr/jnr-unixsocket-0.8.jar -maven://com.github.jnr/jnr-ffi/2.0.3|lib/jnr/jnr-ffi-2.0.3.jar -maven://com.github.jnr/jffi/1.2.9|lib/jnr/jffi-1.2.9.jar -maven://com.github.jnr/jffi/1.2.9/jar/native|lib/jnr/jffi-1.2.9-native.jar -maven://org.ow2.asm/asm/5.0.1|lib/jnr/asm-5.0.1.jar -maven://org.ow2.asm/asm-commons/5.0.1|lib/jnr/asm-commons-5.0.1.jar -maven://org.ow2.asm/asm-analysis/5.0.3|lib/jnr/asm-analysis-5.0.3.jar -maven://org.ow2.asm/asm-tree/5.0.3|lib/jnr/asm-tree-5.0.3.jar -maven://org.ow2.asm/asm-util/5.0.3|lib/jnr/asm-util-5.0.3.jar +maven://com.github.jnr/jnr-unixsocket/@jnr-unixsocket.version@|lib/jnr/jnr-unixsocket-@jnr-unixsocket.version@.jar +maven://com.github.jnr/jnr-ffi/2.1.9|lib/jnr/jnr-ffi-2.1.9.jar +maven://com.github.jnr/jffi/1.2.17|lib/jnr/jffi-1.2.17.jar +maven://com.github.jnr/jffi/1.2.16/jar/native|lib/jnr/jffi-1.2.16-native.jar +maven://org.ow2.asm/asm/@asm.version@|lib/jnr/asm-@asm.version@.jar +maven://org.ow2.asm/asm-commons/@asm.version@|lib/jnr/asm-commons-@asm.version@.jar +maven://org.ow2.asm/asm-analysis/@asm.version@|lib/jnr/asm-analysis-@asm.version@.jar +maven://org.ow2.asm/asm-tree/@asm.version@|lib/jnr/asm-tree-@asm.version@.jar +maven://org.ow2.asm/asm-util/@asm.version@|lib/jnr/asm-util-@asm.version@.jar maven://com.github.jnr/jnr-x86asm/1.0.2|lib/jnr/jnr-x86asm-1.0.2.jar -maven://com.github.jnr/jnr-constants/0.8.7|lib/jnr/jnr-constants-0.8.7.jar -maven://com.github.jnr/jnr-enxio/0.9|lib/jnr/jnr-enxio-0.9.jar -maven://com.github.jnr/jnr-posix/3.0.12|lib/jnr/jnr-posix-3.0.12.jar +maven://com.github.jnr/jnr-constants/0.9.11|lib/jnr/jnr-constants-0.9.11.jar +maven://com.github.jnr/jnr-enxio/0.18|lib/jnr/jnr-enxio-0.18.jar +maven://com.github.jnr/jnr-posix/3.0.46|lib/jnr/jnr-posix-3.0.46.jar [lib] lib/jetty-unixsocket-${jetty.version}.jar lib/jnr/*.jar [license] -Jetty UnixSockets is implmented using the Java Native Runtime, which is an +Jetty UnixSockets is implemented using the Java Native Runtime, which is an open source project hosted on Github and released under the Apache 2.0 license. https://github.com/jnr/jnr-unixsocket http://www.apache.org/licenses/LICENSE-2.0.html diff --git a/jetty-util/src/main/config/modules/log4j-impl.mod b/jetty-util/src/main/config/modules/log4j-impl.mod index 5be5f77f3851..fbd0e1da5554 100644 --- a/jetty-util/src/main/config/modules/log4j-impl.mod +++ b/jetty-util/src/main/config/modules/log4j-impl.mod @@ -28,5 +28,5 @@ Log4j is released under the Apache 2.0 license. http://www.apache.org/licenses/LICENSE-2.0.html [ini] -log4j.version?=1.2.17 +log4j.version?=@log4j.version@ jetty.webapp.addServerClasses+=,${jetty.base.uri}/lib/log4j/ diff --git a/jetty-util/src/main/config/modules/logback-impl.mod b/jetty-util/src/main/config/modules/logback-impl.mod index 18c067b4d3f7..184a4a98794e 100644 --- a/jetty-util/src/main/config/modules/logback-impl.mod +++ b/jetty-util/src/main/config/modules/logback-impl.mod @@ -36,5 +36,5 @@ or (per the licensee's choosing) under http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html [ini] -logback.version?=1.2.3 +logback.version?=@logback.version@ jetty.webapp.addServerClasses+=,${jetty.base.uri}/lib/logback/ diff --git a/jetty-util/src/main/config/modules/slf4j-api.mod b/jetty-util/src/main/config/modules/slf4j-api.mod index ef29cce1351c..46f205373c92 100644 --- a/jetty-util/src/main/config/modules/slf4j-api.mod +++ b/jetty-util/src/main/config/modules/slf4j-api.mod @@ -16,7 +16,7 @@ maven://org.slf4j/slf4j-api/${slf4j.version}|lib/slf4j/slf4j-api-${slf4j.version lib/slf4j/slf4j-api-${slf4j.version}.jar [ini] -slf4j.version?=1.7.25 +slf4j.version?=@slf4j.version@ jetty.webapp.addServerClasses+=,${jetty.base.uri}/lib/slf4j/ [license] diff --git a/pom.xml b/pom.xml index 822f5fce5edd..1416f8e3ecbc 100644 --- a/pom.xml +++ b/pom.xml @@ -21,11 +21,18 @@ 1.4 1.7.25 2.11.1 + 1.2.17 1.2.3 1.2 1.1.3.v20160715 8.5.35.1 9.4.8.Final + 0.20 + + 3.1 + 3.1 undefined 2.0.0 @@ -442,7 +449,7 @@ org.eclipse.jetty.toolchain jetty-assembly-descriptors - 1.0 + 1.1-SNAPSHOT @@ -1051,7 +1058,7 @@ com.github.jnr jnr-unixsocket - 0.20 + ${jnr-unixsocket.version} junit @@ -1145,6 +1152,31 @@ + + maven-resources-plugin + + + copy-resources + prepare-package + + copy-resources + + + ${project.build.directory}/config + + + src/main/config + true + + + false + + @ + + + + + org.apache.maven.plugins maven-assembly-plugin diff --git a/tests/test-distribution/pom.xml b/tests/test-distribution/pom.xml index b366b52fcafe..da937ba83adb 100644 --- a/tests/test-distribution/pom.xml +++ b/tests/test-distribution/pom.xml @@ -80,6 +80,12 @@ jetty-test-helper test + + org.eclipse.jetty + jetty-unixsocket + ${project.version} + test + diff --git a/tests/test-distribution/src/test/java/org/eclipse/jetty/tests/distribution/DistributionTests.java b/tests/test-distribution/src/test/java/org/eclipse/jetty/tests/distribution/DistributionTests.java index 11718fed86f6..d1a7b9b1fce2 100644 --- a/tests/test-distribution/src/test/java/org/eclipse/jetty/tests/distribution/DistributionTests.java +++ b/tests/test-distribution/src/test/java/org/eclipse/jetty/tests/distribution/DistributionTests.java @@ -19,6 +19,8 @@ package org.eclipse.jetty.tests.distribution; import java.io.File; +import java.nio.file.Files; +import java.nio.file.Path; import java.nio.file.Paths; import java.util.concurrent.TimeUnit; @@ -27,6 +29,9 @@ import org.eclipse.jetty.http.HttpStatus; import org.eclipse.jetty.http2.client.HTTP2Client; import org.eclipse.jetty.http2.client.http.HttpClientTransportOverHTTP2; +import org.eclipse.jetty.toolchain.test.FS; +import org.eclipse.jetty.unixsocket.client.HttpClientTransportOverUnixSockets; +import org.eclipse.jetty.util.StringUtil; import org.junit.jupiter.api.Test; import org.junit.jupiter.api.condition.DisabledOnJre; import org.junit.jupiter.api.condition.JRE; @@ -204,4 +209,52 @@ public void testDemoBase() throws Exception assertThat(response.getContentAsString(), not(containsString("<%"))); } } + + @Test + public void unixSocket() throws Exception + { + Path sockFile; + String unixSocketTmp = System.getProperty("unix.socket.tmp"); + if(StringUtil.isNotBlank(unixSocketTmp)) + { + sockFile = Files.createTempFile(Paths.get(unixSocketTmp), "unix", ".sock"); + } else { + sockFile = Files.createTempFile("unix", ".sock" ); + } + assertTrue(Files.deleteIfExists(sockFile),"temp sock file cannot be deleted"); + + + String jettyVersion = System.getProperty("jettyVersion"); + DistributionTester distribution = DistributionTester.Builder.newInstance() + .jettyVersion(jettyVersion) + .mavenLocalRepository(System.getProperty("mavenRepoPath")) + .build(); + + String[] args1 = { + "--create-startd", + "--add-to-start=unixsocket-http,deploy,jsp", + "--approve-all-licenses" + }; + try (DistributionTester.Run run1 = distribution.start(args1)) + { + assertTrue(run1.awaitFor(5, TimeUnit.SECONDS)); + assertEquals(0, run1.getExitValue()); + + File war = distribution.resolveArtifact("org.eclipse.jetty.tests:test-simple-webapp:war:" + jettyVersion); + distribution.installWarFile(war, "test"); + + try (DistributionTester.Run run2 = distribution.start("jetty.unixsocket="+sockFile.toString())) + { + assertTrue(run2.awaitConsoleLogsFor("Started @", 10, TimeUnit.SECONDS)); + + startHttpClient(() -> new HttpClient( new HttpClientTransportOverUnixSockets(sockFile.toString()), null)); + ContentResponse response = client.GET("http://localhost/test/index.jsp"); + assertEquals(HttpStatus.OK_200, response.getStatus()); + assertThat(response.getContentAsString(), containsString("Hello")); + assertThat(response.getContentAsString(), not(containsString("<%"))); + } + } finally { + FS.delete(sockFile); + } + } }