本文介绍了Maven依赖插件问题的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我使用 maven-assembly 插件为我的目标文件夹中的发布创建一个 zip 文件.这个动态名称的包包含一个配置文件;

I use maven-assembly plugin to create a zip file for a release in my target folder. This package with dynamic name includes a configuration file;

/target/dailyrelease-4234.zip/cd/lib/conf/wrapper.conf

现在我还使用 maven-dependency 插件的 build-classpath 目标将依赖项输出为字符串.

Now I also use maven-dependency plugin's build-classpath goal to output the dependencies as a string.

我想把这个输出字符串写到程序集插件创建的配置文件中

I want to write this output string to the configuration file created by the assembly plugin

我有两个问题:

1- 如何在动态命名 zip 中访问此 conf 文件?

1- How can I access this conf file in the dynamic named zip?

2- 我想向 maven 依赖插件创建的字符串添加一些额外的 .jar 路径,但它只从本地存储库复制名称.有没有办法修改这个输出,或者显示依赖插件来使用另一个文件夹来选择 jar 名称而不是从本地存储库中选择?

2- I want to add some extra .jar paths to that string created by maven dependency plugin, but it only copies the names from local repository. is there a way to modify this output, or show dependency plugin to use another folder to pick the jar names and not from local repository?

或者更好地将创建依赖项名称任务作为程序集插件的一部分,这样我就不再需要访问和修改该 zip.

Or even better make the creating dependency names task as a part of assembly-plugin so I dont need to access and modify that zip anymore.

推荐答案

1 - 听起来您动态生成该数字4234"的机制存在于 Maven 之外,而您正试图弄清楚如何从 Maven 内部访问该号码,对吗?

1 - It sounds like your mechanism for dynamically generating that number '4234' exists outside of Maven, and you're trying to figure out how to access that number from within Maven, correct?

如果是这样,我建议使用 buildnumber-maven-plugin 生成一个然后您可以通过 ${buildNumber} 属性从 Maven 内部访问该编号.

If so, I suggest using the buildnumber-maven-plugin which generates a number which you can then access from within Maven via the ${buildNumber} property.

2 - 我建议将标注从 dependency:build-classpath 切换到 dependency:list -DoutputFile=xyz.txt.后者为您提供了一个更清晰的 groupId/artifactId/version 输出,应该很容易编辑.

2 - I suggest switching your callout from dependency:build-classpath to dependency:list -DoutputFile=xyz.txt. The latter gives you a cleaner output of just groupId/artifactId/version which should be easy to edit.

或者更好...执行上述操作,只需使用 配置以确保 dependency:list 在程序集插件运行之前被调用(通常在package 阶段结束),并确保生成的输出文件位于程序集插件将接收它的某个位置.

Or better yet... Do the above, and simply use <phase> configuration to ensure dependency:list gets called before the assembly plugin runs (typically at the end of package phase), and ensure the resulting output file sits somewhere that the assembly plugin will pick it up.

希望有所帮助.

这篇关于Maven依赖插件问题的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

08-15 18:44