我正在尝试使用 Maven 和 Jcabi-Aether 获取/解决一些工件。我想我已经准备好了大部分代码,但是我很难弄清楚如何加载用户的代码settings.xml
,以便我可以将 Maven 存储库加载到remotes
Aether 使用的变量中:
import com.jcabi.aether.Aether;
import java.io.File;
import java.util.Arrays;
import org.apache.maven.project.MavenProject;
import org.sonatype.aether.artifact.Artifact;
import org.sonatype.aether.repository.RemoteRepository;
import org.sonatype.aether.util.artifact.DefaultArtifact;
public class Main {
public static void main(String[] args) {
File local = new File("/tmp/local-repository");
Collection<RemoteRepository> remotes = Arrays.asList(
new RemoteRepository(
"maven-central",
"default",
"http://repo1.maven.org/maven2/"
)
);
Collection<Artifact> deps = new Aether(remotes, local).resolve(
new DefaultArtifact("junit", "junit-dep", "", "jar", "4.10"),
"runtime"
);
}
}
是否可以加载settings.xml
和获取存储库信息?