| Summary: | no well-defined resource filtering mechanism (for resources included via bin.includes) | ||
|---|---|---|---|
| Product: | z_Archived | Reporter: | Greg Amerson <gregory.amerson> |
| Component: | Tycho | Assignee: | Project Inbox <tycho-inbox> |
| Status: | VERIFIED FIXED | QA Contact: | |
| Severity: | enhancement | ||
| Priority: | P3 | CC: | bernd.vogt, cvgaviao, gunnar, jan.sievers, mknauer, pwebster, sewe, steven.soloff, sven.rottstock, t-oberlies, thanh.ha, tom, tonny.madsen |
| Version: | unspecified | ||
| Target Milestone: | --- | ||
| Hardware: | All | ||
| OS: | All | ||
| Whiteboard: | |||
| Bug Depends on: | 419849 | ||
| Bug Blocks: | |||
Also see http://stackoverflow.com/q/10410717/796559 for an additional example. In recent Tycho versions, we even have a problem with resources located in src/main/resources, because both the resources-plugin and the tycho-compiler-plugin may copy the resources. This is to be addressed in bug 383872. This is different to the problem described in this bug, which is (as far as I understand) about supporting resource filtering for resources included via the build.properties. *** Bug 360457 has been marked as a duplicate of this bug. *** also see bug 390119 for a workaround proper solution should be provided with this bug Yet another non-general solution to the resource filtering problem: bug 369758. Notice that the files that are not "used" directly by Tycho during the build, can all be handled via the usual Maven resource filters:
E.g. I have the following in my product plug-in:
<build>
<resources>
<resource>
<directory>.</directory>
<includes>
<include>about.mappings</include>
<include>plugin_customization.ini</include>
</includes>
<filtering>true</filtering>
</resource>
</resources>
</build>
Hey Tonny, Is there any more that has to be done in order to get your example to work? I add that to the pom.xml in my branding plugin and re-ran the build, but the output file, the about.ini is not changed. Is there any other configuration required? (In reply to Greg Amerson from comment #7) > Hey Tonny, > > Is there any more that has to be done in order to get your example to work? > I add that to the pom.xml in my branding plugin and re-ran the build, but > the output file, the about.ini is not changed. Is there any other > configuration required? Ohh, I forgot to add a sample about.mappings. You can of cause add the about.ini file as well. But only files NOT USED DIRECTLY by Tycho - so no feature.xml, *.target or *.product! The referenced variables below are the properties from Maven. ${buildQualifier} you get for free - the rest I set in my top-level POM or get from the CI (in my case TeamCity). You still have to added the file(s) to build.properties as well. about.mappings: ------------------ 0=${product.version} 1=${build.number} (${buildQualifier}) 2=${build.type} In my about.ini I have this:
aboutText=Liferay IDE ${unqualifiedVersion}.${buildQualifier}
featureImage=icons/liferay32.png
aboutImage=icons/liferay32.png
And in my build.properties I have this:
bin.includes = META-INF/,\
about.ini,\
icons/,\
OSGI-INF/
And in my pom.xml I have this:
<artifactId>com.liferay.ide.tools.branding</artifactId>
<packaging>eclipse-plugin</packaging>
<name>Liferay IDE Branding</name>
<build>
<resources>
<resource>
<directory>.</directory>
<includes>
<include>about.ini</include>
</includes>
<filtering>true</filtering>
</resource>
</resources>
</build>
However, after I run the tycho build, the compiled jar, if I open the about.ini none of the variables have been filtered. It still is the same:
aboutText=Liferay IDE ${unqualifiedVersion}.${buildQualifier}
Am I missing something else?
In Platform we recently resolved this using a combination of maven-resources-plugin and tycho-packaging-plugin's additionalFileSets [1].
We used a filtering profile for about.mappings [2] (Snippet below). Basically the idea is to use maven-resources-plugin to filter the about.mappings, in our case 0=${buildId} and copy that to ${project.build.directory}.
Next we used tycho-packaging-plugins additionalFileSets [1] parameter to include about.mappings from ${project.build.directory} into the final jar. Note that you will need to use Tycho 0.19.0 for this to work due to bug 419849.
Hope this helps.
[1] http://eclipse.org/tycho/sitedocs/tycho-packaging-plugin/package-plugin-mojo.html#additionalFileSets
[2] http://git.eclipse.org/c/platform/eclipse.platform.releng.aggregator.git/tree/eclipse-platform-parent/pom.xml#n735
--- snippet ---
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-resources-plugin</artifactId>
<version>2.6</version>
<executions>
<execution>
<id>process-about.mappings</id>
<phase>prepare-package</phase>
<configuration>
<outputDirectory>${project.build.directory}</outputDirectory>
<overwrite>true</overwrite>
<resources>
<resource>
<directory>${basedir}</directory>
<includes>
<include>about.mappings</include>
</includes>
<filtering>true</filtering>
</resource>
</resources>
</configuration>
<goals>
<goal>copy-resources</goal>
</goals>
</execution>
</executions>
</plugin>
<plugin>
<groupId>org.eclipse.tycho</groupId>
<artifactId>tycho-packaging-plugin</artifactId>
<version>${tycho.version}</version>
<configuration>
<additionalFileSets>
<fileSet>
<directory>${project.build.directory}</directory>
<includes>
<include>about.mappings</include>
</includes>
</fileSet>
</additionalFileSets>
</configuration>
</plugin>
--- end snippet ---
(In reply to Greg Amerson from comment #9) > However, after I run the tycho build, the compiled jar, if I open the > about.ini none of the variables have been filtered. It still is the same: > aboutText=Liferay IDE ${unqualifiedVersion}.${buildQualifier} > > Am I missing something else? I think the problem here is that when your bin.includes includes a file to be included. Tycho searches the project directory and includes that. Correct me if I'm wrong but I believe maven-resources-plugin by default filters files and copies them to the target/ directory leaving the version of that file untouched in original location (where Tycho looks for the bin.includes). So what's copied to your final jar is the original version and not your filtered version. With bug 419849 now resolved in 0.19.0 you should be able to use the tycho-packaging-plugin's additionalFileSets parameter to tell Tycho to include the filtered version of your about.ini. See comment 10 for an explanation of how we did this in Platform. Hope this helps. Thanks Thanh Ha, That helps a lot and I was able to get it working locally using 0.19.0 and your snippets. (In reply to Greg Amerson from comment #12) > Thanks Thanh Ha, > > That helps a lot and I was able to get it working locally using 0.19.0 and > your snippets. Great! I think this bug is resolved? Feel free to reopen if you think otherwise. Verified with my adopter build. |
The user story is a developer who wants to display the most recent build-id in an about dialog text of an Eclipse RCP product. In order to display the current version this string value would need to be added during build time to properties file from the bundle source. Currently there is no way to modify those property files as they are being copied into the jar. To make this work with version 0.13.0 something like the following approach much be used with ant: <build> <plugins> <plugin> <groupId>org.apache.maven.plugins</groupId> <artifactId>maven-antrun-plugin</artifactId> <version>1.6</version> <executions> <execution> <id>prepare-package</id> <phase>prepare-package</phase> <configuration> <target> <replace file="plugin.properties"> <replacefilter token="_VERSION_" value="${unqualifiedVersion}.${buildQualifier}" /> </replace> </target> </configuration> <goals> <goal>run</goal> </goals> </execution> <execution> <id>package</id> <phase>package</phase> <configuration> <target> <replace file="plugin.properties"> <replacefilter token="${unqualifiedVersion}.${buildQualifier}" value="_VERSION_" /> </replace> </target> </configuration> <goals> <goal>run</goal> </goals> </execution> </executions> </plugin> </plugins> </build>