Add support for custom jar/pom/fragment directories

This commit is contained in:
Stanislav Ochotnicky 2012-11-09 13:26:13 +01:00
parent 0ae689d405
commit 19395ab0e3
3 changed files with 48 additions and 16 deletions

View File

@ -2,6 +2,7 @@ package org.apache.maven.artifact.resolver;
import java.io.File; import java.io.File;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.Arrays;
import java.util.Hashtable; import java.util.Hashtable;
import java.util.LinkedList; import java.util.LinkedList;
import java.util.List; import java.util.List;
@ -114,27 +115,33 @@ public class JavadirWorkspaceReader implements WorkspaceReader {
return ret; return ret;
} }
} else { } else {
String repos[] = { "/usr/share/maven/repository/", ArrayList<String> repos = new ArrayList<String>();
"/usr/share/maven/repository-java-jni/", String custom_paths = System.getProperty(
"/usr/share/maven/repository-jni/" }; "maven.local.jar.paths", null);
if (custom_paths != null) {
repos.addAll(Arrays.asList(custom_paths.split(":")));
}
repos.add("/usr/share/maven/repository/");
repos.add("/usr/share/maven/repository-java-jni/");
repos.add("/usr/share/maven/repository-jni/");
String verRelativeArtifactPath = groupId + "/" + artifactId String verRelativeArtifactPath = groupId + "/" + artifactId
+ "-" + wantedVersion + "." + artifact.getExtension(); + "-" + wantedVersion + "." + artifact.getExtension();
String relativeArtifactPath = groupId + "/" + artifactId + "." String relativeArtifactPath = groupId + "/" + artifactId + "."
+ artifact.getExtension(); + artifact.getExtension();
for (String repo : repos) { for (String repo : repos) {
path = new StringBuffer(repo + verRelativeArtifactPath);
ret = new File(path.toString()); ret = new File(repo, verRelativeArtifactPath);
MavenJPackageDepmap.debug("Looking for " + ret.getPath());
if (ret.isFile()) { if (ret.isFile()) {
MavenJPackageDepmap.debug("Returning " + repo MavenJPackageDepmap.debug("Returning " + ret.getPath());
+ verRelativeArtifactPath);
return ret; return ret;
} }
path = new StringBuffer(repo + relativeArtifactPath); ret = new File(repo, relativeArtifactPath);
ret = new File(path.toString()); MavenJPackageDepmap.debug("Looking for " + ret.getPath());
if (ret.isFile()) { if (ret.isFile()) {
MavenJPackageDepmap.debug("Returning " + repo MavenJPackageDepmap.debug("Returning " + ret.getPath());
+ relativeArtifactPath);
return ret; return ret;
} }
} }
@ -161,16 +168,25 @@ public class JavadirWorkspaceReader implements WorkspaceReader {
String verfName = groupId.replace(PATH_SEPARATOR, GROUP_SEPARATOR) String verfName = groupId.replace(PATH_SEPARATOR, GROUP_SEPARATOR)
+ "-" + artifactId + "-" + version + ".pom"; + "-" + artifactId + "-" + version + ".pom";
File f; File f;
String[] pomRepos = { "/usr/share/maven2/poms/", String custom_paths = System.getProperty("maven.local.pom.paths", null);
"/usr/share/maven/poms/", "/usr/share/maven-poms/" };
ArrayList<String> pomRepos = new ArrayList<String>();
if (custom_paths != null) {
pomRepos.addAll(Arrays.asList(custom_paths.split(":")));
}
pomRepos.add("/usr/share/maven2/poms/");
pomRepos.add("/usr/share/maven/poms/");
pomRepos.add("/usr/share/maven-poms/");
for (String pomRepo : pomRepos) { for (String pomRepo : pomRepos) {
f = new File(pomRepo + verfName); f = new File(pomRepo, verfName);
MavenJPackageDepmap.debug("Looking for " + f.getPath());
if (f.exists()) { if (f.exists()) {
return new StringBuffer(f.getPath()); return new StringBuffer(f.getPath());
} }
f = new File(pomRepo + fName); f = new File(pomRepo, fName);
MavenJPackageDepmap.debug("Looking for " + f.getPath());
if (f.exists()) { if (f.exists()) {
return new StringBuffer(f.getPath()); return new StringBuffer(f.getPath());
} }

View File

@ -181,6 +181,19 @@ public class MavenJPackageDepmap {
processDepmapFile("/usr/share/maven-fragments/" + fragFilename); processDepmapFile("/usr/share/maven-fragments/" + fragFilename);
} }
String customDepmapDir = System.getProperty("maven.local.depmap.dir",
null);
if (customDepmapDir != null) {
fragmentDir = new File(customDepmapDir);
flist = fragmentDir.list();
if (flist != null) {
java.util.Arrays.sort(flist);
for (String fragFilename : flist)
processDepmapFile(customDepmapDir + File.separator
+ fragFilename);
}
}
String customFileName = System.getProperty("maven.local.depmap.file", String customFileName = System.getProperty("maven.local.depmap.file",
null); null);
if (customFileName != null) { if (customFileName != null) {

View File

@ -2,7 +2,7 @@
Name: maven Name: maven
Version: 3.0.4 Version: 3.0.4
Release: 20%{?dist} Release: 21%{?dist}
Summary: Java project management and project comprehension tool Summary: Java project management and project comprehension tool
Group: Development/Tools Group: Development/Tools
@ -385,6 +385,9 @@ ln -sf `rpm --eval '%%{_jnidir}'` %{_datadir}/%{name}/repository-jni/JPP
%changelog %changelog
* Thu Nov 08 2012 Stanislav Ochotnicky <sochotnicky@redhat.com> - 3.0.4-21
- Add support for custom jar/pom/fragment directories
* Thu Nov 8 2012 Mikolaj Izdebski <mizdebsk@redhat.com> - 3.0.4-20 * Thu Nov 8 2012 Mikolaj Izdebski <mizdebsk@redhat.com> - 3.0.4-20
- Remove all slf4j providers except nop from maven realm - Remove all slf4j providers except nop from maven realm