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

View File

@ -181,6 +181,19 @@ public class MavenJPackageDepmap {
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",
null);
if (customFileName != null) {

View File

@ -2,7 +2,7 @@
Name: maven
Version: 3.0.4
Release: 20%{?dist}
Release: 21%{?dist}
Summary: Java project management and project comprehension tool
Group: Development/Tools
@ -385,6 +385,9 @@ ln -sf `rpm --eval '%%{_jnidir}'` %{_datadir}/%{name}/repository-jni/JPP
%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
- Remove all slf4j providers except nop from maven realm