【发布时间】:2017-03-27 20:50:11
【问题描述】:
我正在开发一个 Maven 插件来自动在服务器上安装 JAR。我的第一步应该是找到编译好的 JAR 并将其移动到服务器,但是我如何找到我的 JAR?
我的第一次尝试是:
public class MyMojo extends AbstractMojo {
@Override
public void execute() throws MojoExecutionException, MojoFailureException {
String workingPath = System.getProperty("user.dir");
File targetDir = new File(workingPath + File.separatorChar + "target");
for (File f : targetDir.listFiles()) {
if (f.isFile() && f.getName().endsWith(".jar") {
System.out.println("Found jar " + f.getName());
}
}
}
}
但我不想使用固定目录“目标”。有什么方法可以知道 jar 将建在哪里?
【问题讨论】:
标签: java maven jar maven-plugin