You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@tomee.apache.org by an...@apache.org on 2015/05/12 00:43:43 UTC
tomee git commit: Fix m2Home alternate location & allow https prefix.
Fix init.
Repository: tomee
Updated Branches:
refs/heads/tomee-1.7.x fdc3cc41c -> 4226f5465
Fix m2Home alternate location & allow https prefix.
Fix init.
Project: http://git-wip-us.apache.org/repos/asf/tomee/repo
Commit: http://git-wip-us.apache.org/repos/asf/tomee/commit/4226f546
Tree: http://git-wip-us.apache.org/repos/asf/tomee/tree/4226f546
Diff: http://git-wip-us.apache.org/repos/asf/tomee/diff/4226f546
Branch: refs/heads/tomee-1.7.x
Commit: 4226f54654c97cca63c9a156a88c7c4e14aa754e
Parents: fdc3cc4
Author: AndyGee <an...@gmx.de>
Authored: Tue May 12 00:43:18 2015 +0200
Committer: AndyGee <an...@gmx.de>
Committed: Tue May 12 00:43:18 2015 +0200
----------------------------------------------------------------------
.gitignore | 1 +
.../openejb/arquillian/common/MavenCache.java | 4 +-
.../apache/openejb/loader/ProvisioningUtil.java | 39 ++++++++++++++++++--
3 files changed, 38 insertions(+), 6 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/tomee/blob/4226f546/.gitignore
----------------------------------------------------------------------
diff --git a/.gitignore b/.gitignore
index 92dd6e3..7da116c 100644
--- a/.gitignore
+++ b/.gitignore
@@ -10,3 +10,4 @@ target
quick.bat
/tomee/tomee-plume-webapp/overlays/
/tomee/tomee-plus-webapp/overlays/
+/arquillian/arquillian-tomee-remote/temp
http://git-wip-us.apache.org/repos/asf/tomee/blob/4226f546/arquillian/arquillian-tomee-common/src/main/java/org/apache/openejb/arquillian/common/MavenCache.java
----------------------------------------------------------------------
diff --git a/arquillian/arquillian-tomee-common/src/main/java/org/apache/openejb/arquillian/common/MavenCache.java b/arquillian/arquillian-tomee-common/src/main/java/org/apache/openejb/arquillian/common/MavenCache.java
index 09bab04..3c87072 100644
--- a/arquillian/arquillian-tomee-common/src/main/java/org/apache/openejb/arquillian/common/MavenCache.java
+++ b/arquillian/arquillian-tomee-common/src/main/java/org/apache/openejb/arquillian/common/MavenCache.java
@@ -36,7 +36,7 @@ public class MavenCache {
// initializing the SystemInstance because we'll need it for configuration
try {
- SystemInstance.get().init(new Properties());
+ SystemInstance.init(new Properties());
} catch (final Exception e) {
// no-op
}
@@ -84,7 +84,7 @@ public class MavenCache {
os.write(buffer, 0, bytesRead);
}
} catch (final Exception e) {
- throw new DownloadException("Unable to download " + source + " to " + file.getAbsolutePath(), e);
+ throw new DownloadException("Unable to download " + source + " to " + file, e);
} finally {
if (is != null) {
try {
http://git-wip-us.apache.org/repos/asf/tomee/blob/4226f546/container/openejb-loader/src/main/java/org/apache/openejb/loader/ProvisioningUtil.java
----------------------------------------------------------------------
diff --git a/container/openejb-loader/src/main/java/org/apache/openejb/loader/ProvisioningUtil.java b/container/openejb-loader/src/main/java/org/apache/openejb/loader/ProvisioningUtil.java
index fb25a8d..2d4a26b 100644
--- a/container/openejb-loader/src/main/java/org/apache/openejb/loader/ProvisioningUtil.java
+++ b/container/openejb-loader/src/main/java/org/apache/openejb/loader/ProvisioningUtil.java
@@ -16,12 +16,17 @@
*/
package org.apache.openejb.loader;
+import org.w3c.dom.Document;
import org.xml.sax.Attributes;
import org.xml.sax.SAXException;
import org.xml.sax.helpers.DefaultHandler;
+import javax.xml.parsers.DocumentBuilder;
+import javax.xml.parsers.DocumentBuilderFactory;
import javax.xml.parsers.SAXParser;
import javax.xml.parsers.SAXParserFactory;
+import javax.xml.xpath.XPath;
+import javax.xml.xpath.XPathFactory;
import java.io.BufferedInputStream;
import java.io.ByteArrayInputStream;
import java.io.ByteArrayOutputStream;
@@ -51,6 +56,7 @@ public final class ProvisioningUtil {
public static final String OPENEJB_DEPLOYER_CACHE_FOLDER = "openejb.deployer.cache.folder";
public static final String HTTP_PREFIX = "http";
+ public static final String HTTPS_PREFIX = "https";
public static final String MVN_PREFIX = "mvn:";
public static final String SNAPSHOT_SUFFIX = "-SNAPSHOT";
@@ -119,7 +125,7 @@ public final class ProvisioningUtil {
}
public static String realLocation(final String rawLocation) {
- if (rawLocation.startsWith(HTTP_PREFIX)) {
+ if (hasHttpOrHttpsPrefix(rawLocation)) {
final File file = cacheFile(lastPart(rawLocation));
if (file.exists()) {
return file.getAbsolutePath();
@@ -149,7 +155,8 @@ public final class ProvisioningUtil {
if (rawLocation.startsWith(MVN_PREFIX)) {
try {
final String repo1Url = quickMvnUrl(rawLocation.substring(MVN_PREFIX.length()).replace(":", "/"));
- return realLocation(repo1Url).replace(":", "/").replace("///","/");
+ final String real = realLocation(repo1Url);
+ return real;
} catch (final MalformedURLException e1) {
Logger.getLogger(ProvisioningUtil.class.getName()).severe("Can't find " + rawLocation);
}
@@ -213,7 +220,27 @@ public final class ProvisioningUtil {
}
private static String m2Home() {
- return SystemInstance.get().getProperty("openejb.m2.home", System.getProperty("user.home") + "/.m2/repository/");
+ String home = "";
+ File f = new File(SystemInstance.get().getProperty("openejb.m2.home", System.getProperty("user.home") + "/.m2/repository/"));
+
+ if (f.exists()) {
+ home = f.getAbsolutePath();
+ } else {
+ f = new File(SystemInstance.get().getProperty("openejb.m2.home", System.getProperty("user.home") + "/.m2/settings.xml"));
+ if (f.exists()) {
+ try {
+ final DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance();
+ final DocumentBuilder builder = factory.newDocumentBuilder();
+ final Document document = builder.parse(f);
+ final XPathFactory xpf = XPathFactory.newInstance();
+ final XPath xp = xpf.newXPath();
+ home = xp.evaluate("//settings/localRepository/text()", document.getDocumentElement());
+ } catch (final Exception ignore) {
+ }
+ }
+ }
+
+ return (home.endsWith("/") ? home : home + "/");
}
private static String mvnArtifactPath(final String toParse, final String snapshotBase) throws MalformedURLException {
@@ -243,7 +270,7 @@ public final class ProvisioningUtil {
builder.append(version).append("/");
String artifactVersion;
- if (snapshotBase != null && snapshotBase.startsWith(HTTP_PREFIX) && version.endsWith(SNAPSHOT_SUFFIX)) {
+ if (snapshotBase != null && hasHttpOrHttpsPrefix(snapshotBase) && version.endsWith(SNAPSHOT_SUFFIX)) {
final String meta = snapshotBase + builder.toString() + "maven-metadata.xml";
final URL url = new URL(meta);
final ByteArrayOutputStream out = new ByteArrayOutputStream();
@@ -280,6 +307,10 @@ public final class ProvisioningUtil {
return builder.append(".").append(type).toString();
}
+ private static boolean hasHttpOrHttpsPrefix(final String str) {
+ return str.startsWith(HTTP_PREFIX) || str.startsWith(HTTPS_PREFIX);
+ }
+
private static String extractLastSnapshotVersion(final String defaultVersion, final InputStream metadata) {
final QuickMvnMetadataParser handler = new QuickMvnMetadataParser();
try {