我使用了ManifestResourceTransformer
,并在那里声明了manifestEntries。
<!-- Maven Shade Plugin -->
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-shade-plugin</artifactId>
<version>2.4.2</version>
<executions>
<!-- Run shade goal on package phase -->
<execution>
<phase>package</phase>
<goals>
<goal>shade</goal>
</goals>
<configuration>
<transformers>
<transformer implementation="org.apache.maven.plugins.shade.resource.ServicesResourceTransformer"/>
<transformer implementation="org.apache.maven.plugins.shade.resource.ManifestResourceTransformer">
<mainClass>app.MainApp</mainClass>
<manifestEntries>
<Implementation-Build>${buildNumber}</Implementation-Build>
</manifestEntries>
</transformer>
</transformers>
<filters>
<filter>
<artifact>*:*</artifact>
<excludes>
<exclude>META-INF/*.SF</exclude>
<exclude>META-INF/*.DSA</exclude>
<exclude>META-INF/*.RSA</exclude>
</excludes>
</filter>
</filters>
</configuration>
</execution>
</executions>
</plugin>
从mvn软件包的结果日志中正确生成内部版本号。
然后,我阅读生成的清单:
Manifest mf = new Manifest();
mf.read(getClass().getResourceAsStream("/META-INF/MANIFEST.MF"));
Attributes attr = mf.getMainAttributes();
System.out.println("Manifest-Version : " + attr.getValue("Manifest-Version"));
System.out.println("Created by : " + attr.getValue("Created-By"));
System.out.println("Built by : " + attr.getValue("Built-By"));
System.out.println("Implementation-Build: " + mf.getEntries().get("Implementation-Build"));
Manifest-Version : 1.0
Created by : 1.6.0_65-b14-466-11M4802 (Apple Inc.)
Built by : null
Implementation-Build: null
为了更好地衡量,我甚至硬编码了版本号。
<manifestEntries>
<Implementation-Build>123123</Implementation-Build>
</manifestEntries>
结果还是一样。
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>MyGroupId</groupId>
<artifactId>MyArtifactId</artifactId>
<name>MyApp</name>
<scm>
<connection>scm:git:https://github.com/myorg/myrepo.git</connection>
<developerConnection>scm:git:https://github.com/myorg/myrepo.git</developerConnection>
<tag>DEVELOP</tag>
<url>https://github.com/myorg/myrepo.git</url>
</scm>
<build>
<sourceDirectory>src</sourceDirectory>
<resources>
<resource>
<directory>src</directory>
<excludes>
<exclude>**/*.java</exclude>
</excludes>
</resource>
<resource>
<directory>resources</directory>
<excludes>
<exclude>**/*.java</exclude>
</excludes>
</resource>
</resources>
<plugins>
<!-- Maven Shade Plugin -->
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-shade-plugin</artifactId>
<version>2.4.2</version>
<executions>
<!-- Run shade goal on package phase -->
<execution>
<phase>package</phase>
<goals>
<goal>shade</goal>
</goals>
<configuration>
<transformers>
<!-- add Main-Class to manifest file -->
<transformer implementation="org.apache.maven.plugins.shade.resource.ServicesResourceTransformer"/>
<transformer implementation="org.apache.maven.plugins.shade.resource.ManifestResourceTransformer">
<mainClass>app.MainApp</mainClass>
<manifestEntries>
<Implementation-Build>${buildNumber}</Implementation-Build>
</manifestEntries>
</transformer>
</transformers>
<filters>
<filter>
<artifact>*:*</artifact>
<excludes>
<exclude>META-INF/*.SF</exclude>
<exclude>META-INF/*.DSA</exclude>
<exclude>META-INF/*.RSA</exclude>
</excludes>
</filter>
</filters>
</configuration>
</execution>
</executions>
</plugin>
<plugin>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.3</version>
<configuration>
<source>1.8</source>
<target>1.8</target>
</configuration>
</plugin>
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>buildnumber-maven-plugin</artifactId>
<version>1.4</version>
<executions>
<execution>
<phase>validate</phase>
<goals>
<goal>create</goal>
</goals>
</execution>
</executions>
<configuration>
<format>{0,date,yyyyMMddHHmmss}</format>
<items>
<item>timestamp</item>
</items>
<doCheck>true</doCheck>
<doUpdate>true</doUpdate>
</configuration>
</plugin>
<plugin>
<!-- Deploy the web site -->
<groupId>com.github.github</groupId>
<artifactId>site-maven-plugin</artifactId>
<version>0.9</version>
<executions>
<execution>
<goals>
<goal>site</goal>
</goals>
<phase>site-deploy</phase>
<configuration>
<!-- must match the server's id -->
<server>github</server>
<!-- The commit message -->
<message>Building site for my project</message>
<!-- The location where the site is uploaded -->
<path>${site.path}</path>
<!-- Use merge or override the content -->
<merge>true</merge>
</configuration>
</execution>
</executions>
</plugin>
</plugins>
</build>
<repositories>
<repository>
<id>4thline-repo</id>
<url>http://4thline.org/m2</url>
<snapshots>
<enabled>false</enabled>
</snapshots>
</repository>
<repository>
<id>clojars.org</id>
<url>http://clojars.org/repo</url>
</repository>
</repositories>
<dependencies>
<dependency>
<groupId>com.thoughtworks.xstream</groupId>
<artifactId>xstream</artifactId>
<version>1.4.7</version>
</dependency>
...
</dependencies>
</project>
如何运行所附代码?如果您将其作为测试运行,它将产生您的输出,因为测试类路径不包括MANIFEST. MF文件。您需要在类路径中包含生成的(阴影)jar,以便运行该代码。
问题内容: 我正在开发一个非常消耗内存的应用程序,并且想要使用largeHeap- Tag,这应该为应用程序提供更多的内存。无论我在AndroidManifest.xml中将此标签设置为什么,它对我给定的实际内存都没有影响。我正在这样读出我的最大内存: 我的清单看起来像这样: 我在模拟器中运行3.1,上面的日志输出始终为48MB。有人可以帮忙吗? 问题答案: 使用ActivityManager.g
它完全忽略了: 所以我得到了例外: 原因:android。看法WindowManager$BadTokenException:无法添加Windows android。看法ViewRootImpl$W@86fb55b--此窗口类型的权限被拒绝 它甚至没有列出: 我应该如何修复它?谢谢 编辑: 它列在配置应用程序/高级/绘制其他应用程序中。所以我打开它,现在它工作正常,但是为什么在我运行我的应用程序时
问题内容: 我试图在IntelliJ IDEA CE中使用NodeJS插件,但无法使其正常工作。插件安装完毕并重新启动IDE后,它说找不到NodeJS必需的Javascript插件(尽管在文档中没有说明)。 NodeJS插件仅在IntelliJ IDEA的许可版本中有效吗? 问题答案: NodeJS插件需要IntelliJ IDEA Ultimate,因为它依赖于仅在商业版中可用的JavaScri
我有以下问题--我用插件创建了一个名为“Spring”的简单Gradle项目。但是当我运行Gradle build和任务并输入http://localhost:8080/spring时,我得到404错误。当然,在构建和服务器启动期间,我没有收到任何错误消息。有Build.Gradle: 我还有一个名为的jsp文件放在中: 和文件放在中: 如您所见,服务器似乎正在成功启动:
问题内容: 当我在带有选项create emulator的Jenkins上运行测试时,出现以下问题: [android]无法创建Android模拟器:无法运行AVD创建命令 当我以现有仿真器为目标时,会遇到以下问题: 致命:C:\ Windows \ system32 \ config \ systemprofile.android \ avd \ AVD_2.2.ini(系统找不到指定的路径)j
我想将视图渲染为pdf,并尝试使用Grails渲染插件2.0.3 我尝试了最简单的gsp-file开始: 在控制器中: 最后是: 我错过了什么?或者它不应该与这个版本的grails(3.2.4)一起使用? 也许有更好的插件可以使用?