Skip to main content

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [List Home]
Re: [tycho-user] Conventions/procedures for using properties file resources in Tycho-built applications?

In our Project (Eclipse based RCP) with many Eclipse Plug-ins we do have a Eclipse Fragment Project for each Plug-in. The packaging type of the Fragment Projects are "eclipse-test-plugin" and contain all the tests for a specific plugin, including basic unit tests and more complex tests.
With that approach you do also have separated the test code from the other code like it is done in pure maven using the different folders.
You might want to take a look at the tycho-demo projects "itp01" [1] which contains one Plug-in Project and a Test-Fragment for it. 

[1] http://git.eclipse.org/c/tycho/org.eclipse.tycho-demo.git/tree/itp01
 
-martin


-----Ursprüngliche Nachricht-----
Von: tycho-user-bounces@xxxxxxxxxxx [mailto:tycho-user-bounces@xxxxxxxxxxx] Im Auftrag von David M. Karr
Gesendet: Freitag, 08. April 2016 23:22
An: Tycho user list
Betreff: Re: [tycho-user] Conventions/procedures for using properties file resources in Tycho-built applications?

On 04/08/2016 01:12 PM, SCHREIBER.Martin wrote:
> Hi David,
>
> the structure to have a src/ folder instead of (src/main/java and src/main/resources, ...) is Eclipse specifc.

Really?  Ok.  I guess I'll try to move it back to that structure, then.

I wrote a "true" unit test that doesn't use Tycho (Surefire handles this), so I had put that in "src/test/java", and I also discovered that I had to tell the tycho-compiler-plugin to exclude that.

What exactly is the purpose of the "source.." property?  If I put my "deployable" source files in "src" and created something like "srctestjava" and put my true unit test there (setting the "testSourceDirectory" to that), would that be ok?  Does the "source.." 
property only refer to Java source that the tycho-compiler-plugin will be handling?
> You can put your properties files within that src folder and they should end up in the jar.
> If you want, you can put your properties files (or whatever) in a folder next to your "src" directory, but then you have to make sure that the folder/files get added to your build.properties.
> E.g. if you have images and other text files you could set up your project like that:
>
> src/ (with all the java source files)
> images/ (with all the images)
> resources/ (with all the text resources)
>
> Then you have to add the extra folders to the build.properties so that they end up in the jar:
>
> source.. = src/
> output.. = bin/
> bin.includes = META-INF/,\
>                 images/,\
>                 resources/,\
>                 .
>
> If you want that your text files within the resources directorie get filtered by the maven-resources plugin, you have to tell maven where to find the files you want to filter by adding something like that to your pom:
>   
> 	<build>
> 		<resources>
> 			 <resource>
> 				<directory>resources</directory>
> 				<filtering>true</filtering>
> 				<includes>
> 					<include>**/*.txt</include>
> 				</includes>
> 			</resource>
> 		</resources>
> 	</build>
>
> With that setting, all the txt files within the resources directory 
> gets filtered during a mvn resources:resources run and will end up 
> filtered in the final jar.  Within your plugin code they can be access 
> like in any other java project e.g. 
> getClass().getResourceAsStream("/resources/mytext.txt");
>
> If you want to use the OSGi NLS support you might want to take a look at this tutorial:
>
> http://www.vogella.com/tutorials/EclipseInternationalization/article.h
> tml
>
> hth
> martin
>
> ________________________________________
> Von: tycho-user-bounces@xxxxxxxxxxx <tycho-user-bounces@xxxxxxxxxxx> 
> im Auftrag von David M. Karr <davidmichaelkarr@xxxxxxxxx>
> Gesendet: Freitag, 08. April 2016 17:43
> An: Tycho user list
> Betreff: [tycho-user] Conventions/procedures for using properties file resources in Tycho-built applications?
>
> I'm familiar with how "typical" Maven applications process properties 
> files using the maven-resources-plugin, and I've used Maven for many years.
>
> In the Eclipse codebase I inherited, which uses Tycho, I'm going to 
> have to define some properties that are used at runtime, the values of 
> which will be stored in the POM for the plugin (of several in a 
> multiproject
> build) that needs to access these properties.
>
> As this is my first experience with Tycho and an Eclipse application 
> build, and as I've found some aspects of the Tycho build process 
> somewhat surprising, I'm wondering whether there are particular 
> conventions I should follow for managing properties like this in this 
> ecosystem.
>
> For instance, I assume I would just store this properties file in 
> "src/main/resources", use the maven-resources-plugin to filter 
> property values, and load the file from the classpath.
>
> I noticed that the original authors of this codebase didn't set up a 
> "typical" Maven Java source code folder structure, they just created a 
> source folder named "src", and both Java source files and properties 
> files went into this tree.  That seems lazy to me, but perhaps some 
> convention or aspect of Tycho and Eclipse makes that a reasonable 
> thing to do?
>
> In the case of this application, these properties files are all used 
> as ResourceBundles, and from inspecting the code, it does appear there 
> are conventions for managing these (extending "NLS", for instance).
>
> For the case I'm looking at, the properties I want to manage don't 
> represent localizable messages, so they don't need to be managed as 
> ResourceBundles, although I can see it's tempting to use the existing 
> practice for loading these, which would mean putting them in a 
> resource bundle.
>
> Ironically, the number of properties I'm talking about is very small, 
> perhaps 2-3.
> _______________________________________________
> tycho-user mailing list
> tycho-user@xxxxxxxxxxx
> To change your delivery options, retrieve your password, or 
> unsubscribe from this list, visit 
> https://dev.eclipse.org/mailman/listinfo/tycho-user
> _______________________________________________
> tycho-user mailing list
> tycho-user@xxxxxxxxxxx
> To change your delivery options, retrieve your password, or 
> unsubscribe from this list, visit 
> https://dev.eclipse.org/mailman/listinfo/tycho-user

_______________________________________________
tycho-user mailing list
tycho-user@xxxxxxxxxxx
To change your delivery options, retrieve your password, or unsubscribe from this list, visit https://dev.eclipse.org/mailman/listinfo/tycho-user


Back to the top