本文整理汇总了Java中org.apache.maven.project.MavenProject.getDependencyArtifacts方法的典型用法代码示例。如果您正苦于以下问题:Java MavenProject.getDependencyArtifacts方法的具体用法?Java MavenProject.getDependencyArtifacts怎么用?Java MavenProject.getDependencyArtifacts使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.apache.maven.project.MavenProject
的用法示例。
在下文中一共展示了MavenProject.getDependencyArtifacts方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: execute
import org.apache.maven.project.MavenProject; //导入方法依赖的package包/类
public void execute() throws MojoExecutionException {
log = getLog();
try {
OakProperties properties = new OakProperties();
dependencyArtifacts = "io.github.wanghuayao:maven-plugin-oaktree:" + properties.getVersion() + ":dependency-artifacts";
filter = new ProcessingFilter(likePatten, hitePatten, deep);
MavenProject mp = (MavenProject) this.getPluginContext().get("project");
String mavenHomeStr = removeUnusedCharInPath(mavenHome.getPath());
File mvnExecFile = new File(mavenHomeStr + "/bin/mvn");
mvnExec = mvnExecFile.getPath();
String os = System.getProperty("os.name");
if (os.toLowerCase().startsWith("win")) {
mvnExec = mvnExec + ".cmd";
isWindwos = true;
}
File okaBaseDir = new File(outputDirectory, "oaktree");
File okadependencyDir = new File(okaBaseDir, "dependency");
if (!okadependencyDir.exists()) {
okadependencyDir.mkdirs();
}
okadependencyOutputDir = okadependencyDir.getPath();
ArtifactItem rootItem = new ArtifactItem(mp.getGroupId(), mp.getArtifactId(), mp.getPackaging(), mp.getVersion());
File rootPom = mp.getFile();
int startDeep = 2;
for (Object obj : mp.getDependencyArtifacts()) {
DefaultArtifact artifact = (DefaultArtifact) obj;
ArtifactItem chieldern = ArtifactItem.valueOf(artifact);
if (filter.isGoOnProcessing(chieldern, startDeep)) {
calcDependancy(chieldern, startDeep);
rootItem.addChildren(chieldern);
}
}
FileWriter w = null;
try {
File okaFile = new File(okaBaseDir,"okatree.txt");
if(okaFile.exists()) {
okaFile.delete();
}
w = new FileWriter(okaFile);
log.info("writing file : " + okaFile.getPath());
printArtifactItem(w, rootItem, "");
log.info("writing complete.");
}finally {
StreamUtils.quiteClose(w);
}
} catch (Exception ex) {
getLog().error(ex.getMessage(), ex);
throw new MojoExecutionException(ex.getMessage(), ex);
}
}