本文整理匯總了Java中org.apache.maven.project.MavenProject.getDependencies方法的典型用法代碼示例。如果您正苦於以下問題:Java MavenProject.getDependencies方法的具體用法?Java MavenProject.getDependencies怎麽用?Java MavenProject.getDependencies使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類org.apache.maven.project.MavenProject
的用法示例。
在下文中一共展示了MavenProject.getDependencies方法的2個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: populateArtifactInfo
import org.apache.maven.project.MavenProject; //導入方法依賴的package包/類
@Override public void populateArtifactInfo(ArtifactContext context) throws IOException {
ArtifactInfo ai = context.getArtifactInfo();
if (ai.getClassifier() != null) {
return;
}
try {
MavenProject mp = load(ai);
if (mp != null) {
List<Dependency> dependencies = mp.getDependencies();
LOG.log(Level.FINER, "Successfully loaded project model from repository for {0} with {1} dependencies", new Object[] {ai, dependencies.size()});
dependenciesByArtifact.put(ai, dependencies);
}
} catch (InvalidArtifactRTException ex) {
ex.printStackTrace();
}
}
示例2: resolveDependecyJarPath
import org.apache.maven.project.MavenProject; //導入方法依賴的package包/類
/**
* Returns list of jar path.
*
* @param project maven project
* @param localRepository local repository
* @param remoteRepos remote repository
* @return list of jar paths
*/
private static List<String> resolveDependecyJarPath(MavenProject project, ArtifactRepository localRepository,
List<ArtifactRepository> remoteRepos) {
StringBuilder path = new StringBuilder();
List<String> jarPaths = new ArrayList<>();
for (Dependency dependency : project.getDependencies()) {
path.append(localRepository.getBasedir());
path.append(SLASH);
path.append(getPackageDirPathFromJavaJPackage(dependency.getGroupId()));
path.append(SLASH);
path.append(dependency.getArtifactId());
path.append(SLASH);
path.append(dependency.getVersion());
path.append(SLASH);
path.append(dependency.getArtifactId() + HYPHEN + dependency.getVersion() + PERIOD + JAR);
File jarFile = new File(path.toString());
if (jarFile.exists()) {
jarPaths.add(path.toString());
}
path.delete(0, path.length());
}
for (ArtifactRepository repo : remoteRepos) {
// TODO: add resolver for remote repo.
}
return jarPaths;
}