提交 cc66deec authored 作者: Thomas Mueller's avatar Thomas Mueller

Issue 344: the build now supports a custom Maven repository location.

上级 3286204a
......@@ -12,10 +12,12 @@ import java.net.InetAddress;
import java.net.InetSocketAddress;
import java.net.ServerSocket;
import java.net.Socket;
import java.util.HashMap;
import java.util.TreeMap;
import java.util.Map.Entry;
import org.h2.build.code.SwitchSource;
import org.h2.build.doc.XMLParser;
/**
* The build definition.
......@@ -789,4 +791,30 @@ public class Build extends BuildBase {
jar("bin/h2console.war", files, "temp");
}
protected String getLocalMavenDir() {
String userHome = System.getProperty("user.home", "");
File file = new File(userHome, ".m2/settings.xml");
XMLParser p = new XMLParser(new String(BuildBase.readFile(file)));
HashMap<String, String> prop = new HashMap<String, String>();
for (String name = ""; p.hasNext();) {
int event = p.next();
if (event == XMLParser.START_ELEMENT) {
name += "/" + p.getName();
} else if (event == XMLParser.END_ELEMENT) {
name = name.substring(0, name.lastIndexOf('/'));
} else if (event == XMLParser.CHARACTERS) {
String text = p.getText().trim();
if (text.length() > 0) {
prop.put(name, text);
}
}
}
String local = prop.get("/settings/localRepository");
if (local == null) {
local = "${user.home}/.m2/repository";
}
local = replaceAll(local, "${user.home}", userHome);
return local;
}
}
......@@ -536,7 +536,7 @@ public class BuildBase {
}
String repoFile = group + "/" + artifact + "/" + version + "/" + artifact + "-" + version + ".jar";
mkdirs(targetFile.getAbsoluteFile().getParentFile());
String localMavenDir = System.getProperty("user.home") + "/.m2/repository";
String localMavenDir = getLocalMavenDir();
if (new File(localMavenDir).exists()) {
File f = new File(localMavenDir, repoFile);
if (!f.exists()) {
......@@ -568,6 +568,10 @@ public class BuildBase {
download(target, fileURL, sha1Checksum);
}
protected String getLocalMavenDir() {
return System.getProperty("user.home") + "/.m2/repository";
}
/**
* Download a file if it does not yet exist.
* If no checksum is used (that is, if the parameter is null), the
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论