简体   繁体   English

获取具有依赖关系的jar的文件名作为变量

[英]Getting the filename of a jar-with-dependencies as a variable

I'm using the maven-assembly-plugin to package my jar file with dependencies, which works fine and correctly generates a jar file. 我正在使用maven-assembly-plugin打包具有依赖项的jar文件,该文件可以正常工作并正确生成jar文件。 The output file from this is specified with finalName : 此输出文件由finalName指定:

<plugin>
    <!--Many lines omitted-->
    <artifactId>maven-assembly-plugin</artifactId>
    <version>2.5.5</version>
    <configuration>
        <finalName>MyFinalJar-${project.version}</finalName>
    </configuration>
</plugin>

Now, I need to access this finalName in another plugin, which does some packaging of the jar file. 现在,我需要在另一个插件中访问这个finalName ,该插件会对jar文件进行一些打包。 I have the ${project.build.finalName} variable, but that doesn't give me the jar-with-dependencies, it just gives me the plain jar that I don't want. 我有${project.build.finalName}变量,但这没有给我jar-with-dependencies,它只是给了我不需要的普通jar。

How can I access this final jar filename without repeating myself? 如何在不重复自己的情况下访问最终的jar文件名?

On the top of your pom file declare: 在pom文件的顶部声明:

<properties>
  <finalproject.name>someprojectname</finalproject.name>
</properties>

and then use it everywhere else using: 然后使用以下命令在其他地方使用它:

${finalproject.name}

for example: 例如:

<configuration>
    <finalName>${finalproject.name}</finalName>
</configuration>

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM