Eclipse jar中的Maven筛选文件已过期
我对maven有一个奇怪的问题。我正在使用筛选选项将一些版本信息放入属性文件中。然后我将其包含在jar文件中,以便“Help/About”可以告诉我一些有用的信息。我遇到的问题是jar文件中的版本是以前的版本。因此,例如,如果我在0930运行一个构建,在0940运行另一个构建,那么在0940生成的jar中的属性文件的版本的构建时间将为0930。我也在使用buildNumber插件,但无论我是否启用它,这个问题都存在 更奇怪的是,当我从eclipse中运行构建并运行程序时,“旧”文件显示在help/about上,但当我“刷新”(F5)eclipse项目并重新运行程序时,我得到了正确的版本。那么maven是否会以某种方式接受eclipse版本呢?为什么需要在eclipse中“刷新”以获得最新版本 无论如何,我的pom.xml是Eclipse jar中的Maven筛选文件已过期,eclipse,maven,Eclipse,Maven,我对maven有一个奇怪的问题。我正在使用筛选选项将一些版本信息放入属性文件中。然后我将其包含在jar文件中,以便“Help/About”可以告诉我一些有用的信息。我遇到的问题是jar文件中的版本是以前的版本。因此,例如,如果我在0930运行一个构建,在0940运行另一个构建,那么在0940生成的jar中的属性文件的版本的构建时间将为0930。我也在使用buildNumber插件,但无论我是否启用它,这个问题都存在 更奇怪的是,当我从eclipse中运行构建并运行程序时,“旧”文件显示在help
<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>
<scm>
<url>scm:git:https://github.com/gregryork/DayOneViewer</url>
<developerConnection>scm:git:https://github.com/gregryork/DayOneViewer</developerConnection>
<tag>master</tag>
</scm>
<groupId>uk.co.gregreynolds</groupId>
<artifactId>dayone</artifactId>
<version>0.0.2-SNAPSHOT</version>
<packaging>jar</packaging>
<name>dayone</name>
<url>http://maven.apache.org</url>
<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<version.template.file>src/main/resources/uk/co/gregreynolds/dayone/Version.properties.template</version.template.file>
<version.file>src/main/resources/uk/co/gregreynolds/dayone/Version.properties</version.file>
</properties>
<build>
<plugins>
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>buildnumber-maven-plugin</artifactId>
<version>1.0</version>
<executions>
<execution>
<phase>generate-resources</phase>
<goals>
<goal>create</goal>
</goals>
</execution>
</executions>
<configuration>
<doCheck>false</doCheck>
<doUpdate>false</doUpdate>
<revisionOnScmFailure>true</revisionOnScmFailure>
<format>{0,date,yyyy-MM-dd_HH-mm}_{1}</format>
<items>
<item>timestamp</item>
<item>${user.name}</item>
</items>
</configuration>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.0</version>
<configuration>
<source>1.7</source>
<target>1.7</target>
</configuration>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-shade-plugin</artifactId>
<version>2.1</version>
<executions>
<execution>
<phase>package</phase>
<goals>
<goal>shade</goal>
</goals>
<configuration>
<transformers>
<transformer
implementation="org.apache.maven.plugins.shade.resource.ManifestResourceTransformer">
<mainClass>uk.co.gregreynolds.dayone.DayOneViewer</mainClass>
</transformer>
</transformers>
</configuration>
</execution>
</executions>
</plugin>
<plugin>
<groupId>com.google.code.maven-replacer-plugin</groupId>
<artifactId>maven-replacer-plugin</artifactId>
<version>1.4.0</version>
<executions>
<execution>
<phase>process-resources</phase>
<goals>
<goal>replace</goal>
</goals>
</execution>
</executions>
<configuration>
<file>${version.template.file}</file>
<outputFile>${version.file}</outputFile>
<replacements>
<replacement>
<token>@buildnumber@</token>
<value>${buildNumber}</value>
</replacement>
<replacement>
<token>@buildtime@</token>
<value>${maven.build.timestamp}</value>
</replacement>
<replacement>
<token>@pomversion@</token>
<value>${project.version}</value>
</replacement>
</replacements>
</configuration>
</plugin>
</plugins>
<pluginManagement>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-site-plugin</artifactId>
<version>3.3</version>
<dependencies>
<dependency><!-- add support for ssh/scp -->
<groupId>org.apache.maven.wagon</groupId>
<artifactId>wagon-ssh</artifactId>
<version>1.0</version>
</dependency>
</dependencies>
</plugin>
<!--This plugin's configuration is used to store Eclipse m2e settings
only. It has no influence on the Maven build itself. -->
<plugin>
<groupId>org.eclipse.m2e</groupId>
<artifactId>lifecycle-mapping</artifactId>
<version>1.0.0</version>
<configuration>
<lifecycleMappingMetadata>
<pluginExecutions>
<pluginExecution>
<pluginExecutionFilter>
<groupId>
com.google.code.maven-replacer-plugin
</groupId>
<artifactId>
maven-replacer-plugin
</artifactId>
<versionRange>
[1.4.0,)
</versionRange>
<goals>
<goal>replace</goal>
</goals>
</pluginExecutionFilter>
<action>
<ignore></ignore>
</action>
</pluginExecution>
</pluginExecutions>
</lifecycleMappingMetadata>
</configuration>
</plugin>
</plugins>
</pluginManagement>
</build>
<dependencies>
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>3.8.1</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>com.googlecode.plist</groupId>
<artifactId>dd-plist</artifactId>
<version>1.3</version>
</dependency>
<dependency>
<groupId>org.swinglabs</groupId>
<artifactId>swingx</artifactId>
<version>1.6.1</version>
</dependency>
</dependencies>
<distributionManagement>
<site>
<id>langurmonkey.no-ip.org</id>
<url>scp://langurmonkey.no-ip.org/var/www/dayone/</url>
</site>
</distributionManagement>
</project>
4.0.0
scm:git:https://github.com/gregryork/DayOneViewer
scm:git:https://github.com/gregryork/DayOneViewer
主人
英国格雷诺兹公司
第一天
0.0.2-快照
罐子
第一天
http://maven.apache.org
UTF-8
src/main/resources/uk/co/greynolds/dayone/Version.properties.template
src/main/resources/uk/co/greynolds/dayone/Version.properties
org.codehaus.mojo
buildnumber maven插件
1
产生资源
创造
假的
假的
真的
{0,日期,yyyy-MM-dd{HH-MM}{1}
时间戳
${user.name}
org.apache.maven.plugins
maven编译器插件
3
1.7
1.7
org.apache.maven.plugins
maven阴影插件
2.1
包裹
阴凉处
uk.co.greynolds.dayone.DayOneViewer
com.google.code.maven-replacer-plugin
maven替换插件
1.4.0
过程资源
代替
${version.template.file}
${version.file}
@建筑编号@
${buildNumber}
@构建时间@
${maven.build.timestamp}
@pomversion@
${project.version}
org.apache.maven.plugins
maven站点插件
3.3
org.apache.maven.wagen
马车ssh
1
org.eclipse.m2e
生命周期映射
1.0.0
com.google.code.maven-replacer-plugin
maven替换插件
[1.4.0,)
代替
朱尼特
朱尼特
3.8.1
测试
com.googlecode.plist
德普利斯特
1.3
org.swinglabs
swingx
1.6.1
languarmonkey.no-ip.org
scp://langurmonkey.no-ip.org/var/www/dayone/
第一件事是激活对资源的筛选,如下所示:
<build>
<resources>
<resource>
<directory>src/main/resources/</directory>
<filtering>true</filtering>
</resource>
</resources>
...
</build>
<build>
<plugins>
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>buildnumber-maven-plugin</artifactId>
<version>1.2</version>
<executions>
<execution>
<phase>validate</phase>
<goals>
<goal>create</goal>
</goals>
</execution>
</executions>
<configuration>
<doCheck>false</doCheck>
<doUpdate>false</doUpdate>
<revisionOnScmFailure>UNKNOWN</revisionOnScmFailure>
<format>{0,date,yyyy-MM-dd_HH-mm}_{1}</format>
<items>
<item>timestamp</item>
<item>${user.name}</item>
</items>
</configuration>
</plugin>
在这之后,您可以简单地删除maven replacer插件的用法,在这样简单的场景中您不需要它。您知道
过滤
资源吗?因为您不需要