You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@tomee.apache.org by db...@apache.org on 2021/04/18 05:30:24 UTC
[tomee] branch master updated: Ensure the TomEE libraries have the
expected -SNAPSHOT name TOMEE-3721 Remove dependencies between tomee-webapp
modules
This is an automated email from the ASF dual-hosted git repository.
dblevins pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/tomee.git
The following commit(s) were added to refs/heads/master by this push:
new b35d902 Ensure the TomEE libraries have the expected -SNAPSHOT name TOMEE-3721 Remove dependencies between tomee-webapp modules
b35d902 is described below
commit b35d9020b59da74cbdeb24c328a08afc4e5423d3
Author: David Blevins <da...@gmail.com>
AuthorDate: Sat Apr 17 22:30:07 2021 -0700
Ensure the TomEE libraries have the expected -SNAPSHOT name
TOMEE-3721 Remove dependencies between tomee-webapp modules
---
.../java/org/apache/tomee/installer/Installer.java | 77 +++++++++++++++-------
.../org/apache/tomee/installer/InstallerTest.java | 65 ++++++++++++++++++
2 files changed, 120 insertions(+), 22 deletions(-)
diff --git a/tomee/tomee-common/src/main/java/org/apache/tomee/installer/Installer.java b/tomee/tomee-common/src/main/java/org/apache/tomee/installer/Installer.java
index df409c5..a6e6ce6 100644
--- a/tomee/tomee-common/src/main/java/org/apache/tomee/installer/Installer.java
+++ b/tomee/tomee-common/src/main/java/org/apache/tomee/installer/Installer.java
@@ -36,6 +36,7 @@ public class Installer implements InstallerInterface {
private static final boolean LISTENER_INSTALLED;
private static final boolean AGENT_INSTALLED;
+
static {
final Options opts = SystemInstance.get().getOptions();
// is the OpenEJB listener installed
@@ -284,6 +285,8 @@ public class Installer implements InstallerInterface {
*/
private void moveLibs() {
+ final String tomeeVersion = System.getProperty("tomee.version");
+
final File libs = paths.getCatalinaLibDir();
final File[] files = paths.getOpenEJBLibDir().listFiles();
if (files != null) {
@@ -291,24 +294,54 @@ public class Installer implements InstallerInterface {
if (file.isDirectory()) {
continue;
}
- if (!file.getName().endsWith(".jar")) {
+
+ final String name = normalizeVersion(tomeeVersion, file.getName());
+
+ if (!name.endsWith(".jar")) {
continue;
}
try {
- Installers.copyFile(file, new File(libs, file.getName()));
+ Installers.copyFile(file, new File(libs, name));
if (!file.delete()) {
file.deleteOnExit();
}
- alerts.addInfo("Copy " + file.getName() + " to lib");
+ alerts.addInfo("Copy " + name + " to lib");
} catch (final IOException e) {
- alerts.addError("Unable to " + file.getName() + " to Tomcat lib directory. This will need to be " +
+ alerts.addError("Unable to " + name + " to Tomcat lib directory. This will need to be " +
"performed manually.", e);
}
}
}
}
+ /**
+ * Maven will occasionally give a datestamped version of a snapshot. Our TCK
+ * test harness and likely tooling others have expects the version number to
+ * be predictable ("8.0.7-SNAPSHOT" or "8.0.5") so it can build paths without
+ * fancy logic, i.e. a simple "openejb-core-" + version +" .jar"
+ *
+ * This doesn't work if the version number essentially contains a random string.
+ *
+ * If we see any Maven datestamps on our jars where we are expecting SNAPSHOT,
+ * rename the jar to the expected "-SNAPSHOT" name.
+ */
+ public static String normalizeVersion(final String tomeeVersion, final String jarName) {
+ if (!tomeeVersion.contains("-SNAPSHOT")) return jarName;
+
+ final String versionNumber = tomeeVersion.replaceAll("-SNAPSHOT", "");
+ if (!jarName.contains(versionNumber)) return jarName;
+
+ // Replace 8.0.7-20210418.035728-165 with 8.0.7-SNAPSHOT
+
+ final String regex = ""
+ // turn 8.0.7 into 8\.0\.7
+ + versionNumber.replace(".", "\\.")
+ // replace the 'd' with '[0-9]'
+ + "-dddddddd.dddddd-ddd".replace("d", "[0-9]");
+
+ return jarName.replaceAll(regex, tomeeVersion);
+ }
/*
private void addJavaeeInEndorsed() {
final File endorsed = new File(paths.getCatalinaHomeDir(), "endorsed");
@@ -550,14 +583,14 @@ public class Installer implements InstallerInterface {
}
boolean isCatalinaShExecutable = paths.getCatalinaShFile().canExecute();
- if(!isCatalinaShExecutable) {
+ if (!isCatalinaShExecutable) {
try {
isCatalinaShExecutable = paths.getCatalinaShFile().setExecutable(true);
} catch (final SecurityException e) {
alerts.addWarning("Cannot change CatalinaSh executable attribute.");
}
}
- if(!isCatalinaShExecutable) {
+ if (!isCatalinaShExecutable) {
alerts.addWarning("CatalinaSh is not executable.");
}
@@ -722,20 +755,20 @@ public class Installer implements InstallerInterface {
systemPropertiesWriter = new FileWriter(openejbSystemProperties);
systemPropertiesWriter.write("# Licensed to the Apache Software Foundation (ASF) under one or more\n" +
- "# contributor license agreements. See the NOTICE file distributed with\n" +
- "# this work for additional information regarding copyright ownership.\n" +
- "# The ASF licenses this file to You under the Apache License, Version 2.0\n" +
- "# (the \"License\"); you may not use this file except in compliance with\n" +
- "# the License. You may obtain a copy of the License at\n" +
- "#\n" +
- "# http://www.apache.org/licenses/LICENSE-2.0\n" +
- "#\n" +
- "# Unless required by applicable law or agreed to in writing, software\n" +
- "# distributed under the License is distributed on an \"AS IS\" BASIS,\n" +
- "# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n" +
- "# See the License for the specific language governing permissions and\n" +
- "# limitations under the License.\n" +
- "\n");
+ "# contributor license agreements. See the NOTICE file distributed with\n" +
+ "# this work for additional information regarding copyright ownership.\n" +
+ "# The ASF licenses this file to You under the Apache License, Version 2.0\n" +
+ "# (the \"License\"); you may not use this file except in compliance with\n" +
+ "# the License. You may obtain a copy of the License at\n" +
+ "#\n" +
+ "# http://www.apache.org/licenses/LICENSE-2.0\n" +
+ "#\n" +
+ "# Unless required by applicable law or agreed to in writing, software\n" +
+ "# distributed under the License is distributed on an \"AS IS\" BASIS,\n" +
+ "# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n" +
+ "# See the License for the specific language governing permissions and\n" +
+ "# limitations under the License.\n" +
+ "\n");
systemPropertiesWriter.write("# all this properties are added at JVM system properties at startup\n");
@@ -744,8 +777,8 @@ public class Installer implements InstallerInterface {
systemPropertiesWriter.write("\n");
systemPropertiesWriter.write(
- "# allowed packages to be deserialized, by security we denied all by default, " +
- "tune tomee.serialization.class.whitelist packages to change it\n");
+ "# allowed packages to be deserialized, by security we denied all by default, " +
+ "tune tomee.serialization.class.whitelist packages to change it\n");
systemPropertiesWriter.write("# tomee.remote.support = true\n");
systemPropertiesWriter.write("tomee.serialization.class.blacklist = *\n");
systemPropertiesWriter.write("# tomee.serialization.class.whitelist = my.package\n");
diff --git a/tomee/tomee-common/src/test/java/org/apache/tomee/installer/InstallerTest.java b/tomee/tomee-common/src/test/java/org/apache/tomee/installer/InstallerTest.java
new file mode 100644
index 0000000..7ccc2df
--- /dev/null
+++ b/tomee/tomee-common/src/test/java/org/apache/tomee/installer/InstallerTest.java
@@ -0,0 +1,65 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.tomee.installer;
+
+import org.junit.Test;
+
+import static org.junit.Assert.assertEquals;
+
+public class InstallerTest {
+
+ @Test
+ public void normalizeVersion() {
+
+ assertVersion("openejb-api-8.0.7-SNAPSHOT.jar", "openejb-api-8.0.7-20210418.032427-163.jar");
+ assertVersion("openejb-client-8.0.7-SNAPSHOT.jar", "openejb-client-8.0.7-20210418.032621-163.jar");
+ assertVersion("openejb-core-8.0.7-SNAPSHOT.jar", "openejb-core-8.0.7-20210418.032600-163.jar");
+ assertVersion("openejb-core-eclipselink-8.0.7-SNAPSHOT.jar", "openejb-core-eclipselink-8.0.7-20210418.033130-163.jar");
+ assertVersion("openejb-cxf-8.0.7-SNAPSHOT.jar", "openejb-cxf-8.0.7-20210418.032810-163.jar");
+ assertVersion("openejb-cxf-rs-8.0.7-SNAPSHOT.jar", "openejb-cxf-rs-8.0.7-20210418.032736-163.jar");
+ assertVersion("openejb-cxf-transport-8.0.7-SNAPSHOT.jar", "openejb-cxf-transport-8.0.7-20210418.032721-163.jar");
+ assertVersion("openejb-derbynet-8.0.7-SNAPSHOT.jar", "openejb-derbynet-8.0.7-SNAPSHOT.jar");
+ assertVersion("openejb-ejbd-8.0.7-SNAPSHOT.jar", "openejb-ejbd-8.0.7-20210418.032656-163.jar");
+ assertVersion("openejb-hsql-8.0.7-SNAPSHOT.jar", "openejb-hsql-8.0.7-20210418.032814-163.jar");
+ assertVersion("openejb-http-8.0.7-SNAPSHOT.jar", "openejb-http-8.0.7-20210418.032703-163.jar");
+ assertVersion("openejb-javaagent-8.0.7-SNAPSHOT.jar", "openejb-javaagent-8.0.7-20210418.032436-163.jar");
+ assertVersion("openejb-javaagent.jar", "openejb-javaagent.jar");
+ assertVersion("openejb-jee-8.0.7-SNAPSHOT.jar", "openejb-jee-8.0.7-20210418.032447-163.jar");
+ assertVersion("openejb-jee-accessors-8.0.7-SNAPSHOT.jar", "openejb-jee-accessors-8.0.7-20210418.032458-163.jar");
+ assertVersion("openejb-jpa-integration-8.0.7-SNAPSHOT.jar", "openejb-jpa-integration-8.0.7-20210418.032423-164.jar");
+ assertVersion("openejb-loader-8.0.7-SNAPSHOT.jar", "openejb-loader-8.0.7-20210418.032432-163.jar");
+ assertVersion("openejb-rest-8.0.7-SNAPSHOT.jar", "openejb-rest-8.0.7-20210418.032713-163.jar");
+ assertVersion("openejb-server-8.0.7-SNAPSHOT.jar", "openejb-server-8.0.7-20210418.032647-163.jar");
+ assertVersion("openejb-webservices-8.0.7-SNAPSHOT.jar", "openejb-webservices-8.0.7-20210418.032756-163.jar");
+ assertVersion("tomee-catalina-8.0.7-SNAPSHOT.jar", "tomee-catalina-8.0.7-SNAPSHOT.jar");
+ assertVersion("tomee-common-8.0.7-SNAPSHOT.jar", "tomee-common-8.0.7-SNAPSHOT.jar");
+ assertVersion("tomee-config-8.0.7-SNAPSHOT.jar", "tomee-config-8.0.7-20210418.032613-163.jar");
+ assertVersion("tomee-jaxrs-8.0.7-SNAPSHOT.jar", "tomee-jaxrs-8.0.7-SNAPSHOT.jar");
+ assertVersion("tomee-jdbc-8.0.7-SNAPSHOT.jar", "tomee-jdbc-8.0.7-20210418.032642-163.jar");
+ assertVersion("tomee-loader-8.0.7-SNAPSHOT.jar", "tomee-loader-8.0.7-SNAPSHOT.jar");
+ assertVersion("tomee-mojarra-8.0.7-SNAPSHOT.jar", "tomee-mojarra-8.0.7-20210418.032823-163.jar");
+ assertVersion("tomee-plume-webapp-9.0.0-M7-SNAPSHOT.jar", "tomee-plume-webapp-9.0.0-M7-SNAPSHOT.jar");
+ assertVersion("tomee-security-8.0.7-SNAPSHOT.jar", "tomee-security-8.0.7-20210418.033034-163.jar");
+ assertVersion("tomee-webservices-8.0.7-SNAPSHOT.jar", "tomee-webservices-8.0.7-20210418.032838-163.jar");
+
+ }
+
+ private static void assertVersion(final String expected, final String jarName) {
+ final String s = Installer.normalizeVersion("8.0.7-SNAPSHOT", jarName);
+ assertEquals(expected, s);
+ }
+}