You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@tomee.apache.org by rm...@apache.org on 2016/03/24 09:47:05 UTC
tomee git commit: TOMEE-1750 adding same hacks as for maven for gradle
Repository: tomee
Updated Branches:
refs/heads/master 1d0b8b614 -> b222828b9
TOMEE-1750 adding same hacks as for maven for gradle
Project: http://git-wip-us.apache.org/repos/asf/tomee/repo
Commit: http://git-wip-us.apache.org/repos/asf/tomee/commit/b222828b
Tree: http://git-wip-us.apache.org/repos/asf/tomee/tree/b222828b
Diff: http://git-wip-us.apache.org/repos/asf/tomee/diff/b222828b
Branch: refs/heads/master
Commit: b222828b96b36f25a28f6b6e195e6a257b1c63c4
Parents: 1d0b8b6
Author: Romain manni-Bucau <rm...@gmail.com>
Authored: Thu Mar 24 09:46:43 2016 +0100
Committer: Romain manni-Bucau <rm...@gmail.com>
Committed: Thu Mar 24 09:46:43 2016 +0100
----------------------------------------------------------------------
.../openejb/config/AnnotationDeployer.java | 6 +-
.../apache/openejb/config/DeploymentModule.java | 17 +----
.../apache/openejb/config/NameFiltering.java | 73 ++++++++++++++++++++
.../apache/openejb/config/NewLoaderLogic.java | 17 +----
.../apache/openejb/core/TempClassLoader.java | 8 +--
5 files changed, 84 insertions(+), 37 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/tomee/blob/b222828b/container/openejb-core/src/main/java/org/apache/openejb/config/AnnotationDeployer.java
----------------------------------------------------------------------
diff --git a/container/openejb-core/src/main/java/org/apache/openejb/config/AnnotationDeployer.java b/container/openejb-core/src/main/java/org/apache/openejb/config/AnnotationDeployer.java
index 7be6359..6d9938d 100644
--- a/container/openejb-core/src/main/java/org/apache/openejb/config/AnnotationDeployer.java
+++ b/container/openejb-core/src/main/java/org/apache/openejb/config/AnnotationDeployer.java
@@ -1305,8 +1305,10 @@ public class AnnotationDeployer implements DynamicDeployer {
// passing jar location to be able to manage maven classes/test-classes which have the same moduleId
String id = ejbModule.getModuleId();
- if (ejbModule.getJarLocation() != null && ejbModule.getJarLocation().contains(ejbModule.getModuleId() + "/target/test-classes".replace("/", File.separator))) {
- // with maven if both src/main/java and src/test/java are deployed
+ if (ejbModule.getJarLocation() != null &&
+ (ejbModule.getJarLocation().contains(ejbModule.getModuleId() + "/target/test-classes".replace("/", File.separator)) ||
+ ejbModule.getJarLocation().contains(ejbModule.getModuleId() + "/build/classes/test".replace("/", File.separator)))) {
+ // with maven/gradle if both src/main/java and src/test/java are deployed
// moduleId.Comp exists twice so it fails
// here we simply modify the test comp bean name to avoid it
id += "_test";
http://git-wip-us.apache.org/repos/asf/tomee/blob/b222828b/container/openejb-core/src/main/java/org/apache/openejb/config/DeploymentModule.java
----------------------------------------------------------------------
diff --git a/container/openejb-core/src/main/java/org/apache/openejb/config/DeploymentModule.java b/container/openejb-core/src/main/java/org/apache/openejb/config/DeploymentModule.java
index 8ad1f1a..77939f6 100644
--- a/container/openejb-core/src/main/java/org/apache/openejb/config/DeploymentModule.java
+++ b/container/openejb-core/src/main/java/org/apache/openejb/config/DeploymentModule.java
@@ -23,9 +23,7 @@ import org.apache.openejb.util.URLs;
import java.io.File;
import java.net.URI;
-import java.util.ArrayList;
import java.util.LinkedHashSet;
-import java.util.List;
import java.util.Map;
import java.util.Properties;
import java.util.Set;
@@ -147,19 +145,8 @@ public interface DeploymentModule {
return overriden;
}
- private String moduleName(File location) {
- final List<String> invalid = new ArrayList<String>();
- invalid.add("classes");
- invalid.add("test-classes");
- invalid.add("target");
- invalid.add("build");
- invalid.add("dist");
- invalid.add("bin");
-
- while (invalid.contains(location.getName())) {
- location = location.getParentFile();
- }
- return stripExtension(location.getName());
+ private String moduleName(final File location) {
+ return stripExtension(NameFiltering.filter(location).getName());
}
private String stripExtension(final String name) {
http://git-wip-us.apache.org/repos/asf/tomee/blob/b222828b/container/openejb-core/src/main/java/org/apache/openejb/config/NameFiltering.java
----------------------------------------------------------------------
diff --git a/container/openejb-core/src/main/java/org/apache/openejb/config/NameFiltering.java b/container/openejb-core/src/main/java/org/apache/openejb/config/NameFiltering.java
new file mode 100644
index 0000000..3ca4400
--- /dev/null
+++ b/container/openejb-core/src/main/java/org/apache/openejb/config/NameFiltering.java
@@ -0,0 +1,73 @@
+/*
+ * 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.openejb.config;
+
+import java.io.File;
+import java.util.ArrayList;
+import java.util.List;
+
+final class NameFiltering {
+ private static final List<String> INVALID = new ArrayList<String>();
+ static { // for compatibility keep it
+ INVALID.add("classes");
+ INVALID.add("test-classes");
+ INVALID.add("target");
+ INVALID.add("build");
+ INVALID.add("dist");
+ INVALID.add("bin");
+ }
+
+ private NameFiltering() {
+ // no-op
+ }
+
+ public static File filter(final File location) {
+ final String lastName = location.getName();
+
+ // maven
+ if ("test-classes".equals(lastName) || "classes".equals(lastName)) {
+ final File parentFile = location.getParentFile();
+ if (parentFile != null && "target".equals(parentFile.getName())) {
+ final File grandParentFile = parentFile.getParentFile();
+ if (grandParentFile != null) {
+ return grandParentFile;
+ }
+ }
+ }
+
+ // gradle
+ if ("test".equals(lastName) || "main".equals(lastName)) {
+ final File parentFile = location.getParentFile();
+ if (parentFile != null && "classes".equals(parentFile.getName())) {
+ final File grandParentFile = parentFile.getParentFile();
+ if (grandParentFile != null && "build".equals(grandParentFile.getName())) {
+ final File grandGrandParentFile = grandParentFile.getParentFile();
+ if (grandGrandParentFile != null) {
+ return grandGrandParentFile;
+ }
+ }
+ }
+ }
+
+ // common build folders + backward compatibility
+ File current = location;
+ while (current != null && INVALID.contains(current.getName())) {
+ current = current.getParentFile();
+ }
+ return current == null ? location : current;
+ }
+}
http://git-wip-us.apache.org/repos/asf/tomee/blob/b222828b/container/openejb-core/src/main/java/org/apache/openejb/config/NewLoaderLogic.java
----------------------------------------------------------------------
diff --git a/container/openejb-core/src/main/java/org/apache/openejb/config/NewLoaderLogic.java b/container/openejb-core/src/main/java/org/apache/openejb/config/NewLoaderLogic.java
index 5680691..d0feddb 100644
--- a/container/openejb-core/src/main/java/org/apache/openejb/config/NewLoaderLogic.java
+++ b/container/openejb-core/src/main/java/org/apache/openejb/config/NewLoaderLogic.java
@@ -186,7 +186,7 @@ public class NewLoaderLogic {
try {
final File file = URLs.toFile(url);
- final String name = filter(file).getName();
+ final String name = NameFiltering.filter(file).getName();
if (skip(includeFilter, excludeFilter, name)) {
return true;
@@ -382,21 +382,6 @@ public class NewLoaderLogic {
return list.toArray(new String[list.size()]);
}
- private static File filter(File location) {
- final List<String> invalid = new ArrayList<String>();
- invalid.add("classes");
- invalid.add("test-classes");
- invalid.add("target");
- invalid.add("build");
- invalid.add("dist");
- invalid.add("bin");
-
- while (invalid.contains(location.getName())) {
- location = location.getParentFile();
- }
- return location;
- }
-
@SuppressWarnings("UseOfSystemOutOrSystemErr")
public static void _loadFromClasspath(final FileUtils base, final List<URL> jarList, final ClassLoader classLoader) {
http://git-wip-us.apache.org/repos/asf/tomee/blob/b222828b/container/openejb-core/src/main/java/org/apache/openejb/core/TempClassLoader.java
----------------------------------------------------------------------
diff --git a/container/openejb-core/src/main/java/org/apache/openejb/core/TempClassLoader.java b/container/openejb-core/src/main/java/org/apache/openejb/core/TempClassLoader.java
index 7756513..c2aa097 100644
--- a/container/openejb-core/src/main/java/org/apache/openejb/core/TempClassLoader.java
+++ b/container/openejb-core/src/main/java/org/apache/openejb/core/TempClassLoader.java
@@ -302,16 +302,16 @@ public class TempClassLoader extends URLClassLoader {
final String s1 = o1.toExternalForm().replace(File.separatorChar, '/');
final String s2 = o2.toExternalForm().replace(File.separatorChar, '/');
if (FORCE_MAVEN_FIRST) { // tomee maven plugin dev feature
- if (s1.contains("/target/classes/")) {
+ if (s1.contains("/target/classes/") || s1.contains("/build/classes/main/")) {
return -1;
}
- if (s2.contains("/target/classes/")) {
+ if (s2.contains("/target/classes/") || s2.contains("/build/classes/main/")) {
return 1;
}
- if (s1.contains("/target/test-classes/")) {
+ if (s1.contains("/target/test-classes/") || s1.contains("/build/classes/test/")) {
return -1;
}
- if (s2.contains("/target/test-classes/")) {
+ if (s2.contains("/target/test-classes/") || s2.contains("/build/classes/test/")) {
return 1;
}
}