Java 放置在POM内存中的git提交id不';不要进入舱单
我试图强制我的Maven构建在生成的jar文件的清单中生成如下行:Java 放置在POM内存中的git提交id不';不要进入舱单,java,maven,Java,Maven,我试图强制我的Maven构建在生成的jar文件的清单中生成如下行: SCM-Revision: fdf7abe874a0a54f580aec96da366c168446378c 这样,该值就是git提交id 因此,我找到了,并按照说明进行了设置。详细输出和ant运行输出看起来不错,但生成的清单文件只有原始属性引用,而不是替换的字符串 这是我在多项目构建的父pom中的内容: <plugin> <groupId>pl.project1
SCM-Revision: fdf7abe874a0a54f580aec96da366c168446378c
这样,该值就是git提交id
因此,我找到了,并按照说明进行了设置。详细输出和ant运行输出看起来不错,但生成的清单文件只有原始属性引用,而不是替换的字符串
这是我在多项目构建的父pom中的内容:
<plugin>
<groupId>pl.project13.maven</groupId>
<artifactId>git-commit-id-plugin</artifactId>
<version>2.2.3</version>
<executions>
<execution>
<id>get-the-git-infos</id>
<goals>
<goal>revision</goal>
</goals>
<phase>validate</phase>
</execution>
</executions>
<configuration>
<verbose>true</verbose>
<generateGitPropertiesFile>true</generateGitPropertiesFile>
<failOnNoGitDirectory>true</failOnNoGitDirectory>
<injectAllReactorProjects>true</injectAllReactorProjects>
<dotGitDirectory>${project.basedir}/../../.git</dotGitDirectory>
</configuration>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-jar-plugin</artifactId>
<version>3.0.2</version>
<configuration>
<archive>
<manifestEntries>
<SCM-Revision>${git.commit.id}, ${gitCommit}</SCM-Revision>
</manifestEntries>
</archive>
</configuration>
</plugin>
<plugin>
<artifactId>maven-antrun-plugin</artifactId>
<version>1.8</version>
<executions>
<execution>
<phase>package</phase>
<configuration>
<target>
<echo>Git-Infos: ${git.commit.id}, ${gitCommit}</echo>
</target>
</configuration>
<goals>
<goal>run</goal>
</goals>
</execution>
</executions>
</plugin>
但是,这是我在jar的manifest文件中得到的:
SCM-Revision: ${git.commit.id}, ${git.commit.id}
不知怎的,jar插件中的属性引用没有替换属性值
更新:
我还注意到git.properties文件是在target/classes中创建的,但它不在jar文件中。这意味着该文件是在创建jar文件之后创建的,这意味着这些属性是在创建jar文件之后设置的,这使得这种行为可以理解。这听起来像是“阶段”的问题。我正在为此使用推荐的配置,但这似乎确实是个问题
更新:
我不知道这是否相关,但请注意,我们工件项目的包装类型是“bundle”,而不是“jar”。我们还使用maven bundle插件。我尝试将包装更改为“jar”,这使得属性替换工作正常。但是,它删除了所有必需的osgi属性。正如您在更新中提到的,您的问题是关于
maven bundle插件的
因此,如果除了提交id之外,您不使用maven jar插件
和maven antrun插件
假设您的maven bundle插件
如下所示:
<plugin>
<groupId>org.apache.felix</groupId>
<artifactId>maven-bundle-plugin</artifactId>
<extensions>true</extensions>
<configuration>
<instructions>
<Bundle-SymbolicName>${pom.groupId}.${pom.artifactId}</Bundle-SymbolicName>
<Bundle-Name>Service listener example</Bundle-Name>
<Bundle-Description>A bundle that displays messages at startup and when service events occur</Bundle-Description>
<Bundle-Vendor>Apache Felix</Bundle-Vendor>
<Bundle-Version>1.0.0</Bundle-Version>
<Bundle-Activator>tutorial.example1.Activator</Bundle-Activator>
<Import-Package>org.osgi.framework</Import-Package>
<SCM-Revision>${git.commit.id}, ${gitCommit}</SCM-Revision>
</instructions>
</configuration>
</plugin>
org.apache.felix
maven捆绑插件
真的
${pom.groupId}.${pom.artifactId}
服务侦听器示例
在启动和服务事件发生时显示消息的捆绑包
阿帕奇·费利克斯
1.0.0
tutorial.example1.Activator
org.osgi.framework
${git.commit.id},${gitCommit}
您只需在maven bundle插件中添加属性(即SCM修订版
),将属性作为指令
添加到
部分。这不是他们自己的jira地址吗?哪一个?maven jar插件还是git提交id插件?重点是,这可能是一个交互问题。好吧,我想说第二点——肯定有人已经尝试过了。嘿,当我读到你的问题时,我也想做同样的事情!
SCM-Revision: ${git.commit.id}, ${git.commit.id}
<plugin>
<groupId>org.apache.felix</groupId>
<artifactId>maven-bundle-plugin</artifactId>
<extensions>true</extensions>
<configuration>
<instructions>
<Bundle-SymbolicName>${pom.groupId}.${pom.artifactId}</Bundle-SymbolicName>
<Bundle-Name>Service listener example</Bundle-Name>
<Bundle-Description>A bundle that displays messages at startup and when service events occur</Bundle-Description>
<Bundle-Vendor>Apache Felix</Bundle-Vendor>
<Bundle-Version>1.0.0</Bundle-Version>
<Bundle-Activator>tutorial.example1.Activator</Bundle-Activator>
<Import-Package>org.osgi.framework</Import-Package>
<SCM-Revision>${git.commit.id}, ${gitCommit}</SCM-Revision>
</instructions>
</configuration>
</plugin>