Looking at Tycho tutorials and answers here at Stackoverflow a lot of then contain the variable ${tycho-version} example:
<plugin>
<groupId>org.eclipse.tycho</groupId>
<artifactId>tycho-maven-plugin</artifactId>
<version>${tycho-version}</version>
<extensions>true</extensions>
</plugin>
What is nowhere described is who is responsible for resolving this variable. Is it done automatically by Eclipse/M2Eclipse plugin or does this variable means the developer is responsible for specifying the version?
If the developer is responsible where to get the list of versions?
This is a standard idiom for ensuring all Tycho plug-ins are from the same version: if plug-ins from multiple versions clash, it can result in very hard to debug issues. If this is the only place you enter a tycho version, this might seem unnecessary, but if you have to provide configuration for multiple elements, this will be responsible.
In other words, the build configuration should include a value for this property (or it should be set via the -D property syntax, e.g. mvn clean install -Dtycho-version=1.0.0).
In order to find out the possible versions, you could execute a search on maven central; where you can see the latest version as of today (3rd Apr, 2017) is 1.0.0.
Related
I’m using Felix Framework for my OSGi project, but I’ve came across a severe problem concerning third party dependencies.
I’m using eclipse and maven-bundle-plugin to generate my bundles from the sources and the MANIFEST.MF from the POM.XML file. So far so good. however when I have some third party dependency in my bundle, I find myself looking for an infinite list of JARs, which usually are not bundles, and putting them in my /bundle Felix directory until no more dependencies are missing.
I call this process “Downloading the Internet for my OSGi application to work”.
What am I doing wrong? Sure I must be doing something very wrong, because I can’t imagine anyone having a bundle A that depends on B, which then depends on C and D, and then those two will depend on several others and so on… to go look for ALL those dependencies manually using google or maven central! That's insane!
What is the correct way to automate this? I would love to have one of the two solutions:
1) Be able to create a massive JAR file with all of its dependencies embedded, but exporting only the packages I want, and, of corse, not importing any package.
2) (My preferred solution) Having a way to get all my dependencies into individual JAR files that I can simply paste into the /bundle directory.
3) (Even more preferred) Having a way to use third party JARs without downloading 8GB of dependencies to my project.
I have found tools that do me this, but just for direct (1st degree) dependencies, leaving transitive dependencies for me to solve manually.
This problem is critical. The lack of such a tool hampers the usage of OSGi. I’ve searched and searched and searched, I’ve came across all the 101 solutions such as PAX, bndtools, and friends, but it seems that they do not solve this issue…
Please help me. Please provide a living example if you can, people like me around the world will benefit from the solution to this problem.
Thanks!
-
-
Edit: I am attaching a example project where I'm trying to use JScience but the resulting JAR bundle keeps asking me for new Imports, i.e., it is not self-contained.
Link to the example: https://www.dropbox.com/s/svo3nu3vawvv2xn/RequireJscienceExample.zip?dl=0
I usually try to convert 3rd party JARs into bundles using Eclipse, but they always have to Import packages that I do not have, so it is an endless situation as you have stated.
I could not find any documentation concerning the tag Conditional_Package for maven-bundle-plugin. However related searches show me the inline option that I have tried before without success.
I created a basic project where I have one class using JScience library, and in its POM.XML I have the following:
<plugins>
<plugin>
<groupId>org.apache.felix</groupId>
<artifactId>maven-bundle-plugin</artifactId>
<version>2.3.7</version>
<extensions>true</extensions>
<configuration>
<instructions>
<Bundle-SymbolicName>${project.artifactId};singleton:=true
</Bundle-SymbolicName>
<Bundle-Version>${project.version}</Bundle-Version>
<Export-Package>shared.properties.api, shared.properties.base
</Export-Package>
<Embed-Dependency>!org.osgi.*;scope=compile|runtime;inline=true</Embed-Dependency>
<Embed-Transitive>true</Embed-Transitive>
</instructions>
</configuration>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-javadoc-plugin</artifactId>
</plugin>
</plugins>
I am saying maven to inline all packages which are not from the osgi framework itself. And Looking at the resulting JAR it looks pretty good, I now have embedded only packages instead of entire JARs (however it looks to me that I didn’t need all those inlined packages since I’m using just two of them). Moreover, if I open the MANIFEST.MF file I can see this problematic line:
Manifest-Version: 1.0
Bnd-LastModified: 1414164534170
Build-Jdk: 1.6.0_65
Built-By: Pedro
Bundle-ManifestVersion: 2
Bundle-Name: RequireJscienceExample
Bundle-SymbolicName: RequireJscienceExample;singleton:=true
Bundle-Version: 0.0.1.SNAPSHOT
Created-By: Apache Maven Bundle Plugin
Embed-Dependency: !org.osgi.*;scope=compile|runtime;inline=true
Embed-Transitive: true
Import-Package: org.joda.convert,org.xml.sax <------ Problem...
Tool: Bnd-1.50.0
saying that I’m missing org.joda.convert and org.xml.sax.
What amazes me is that we are talking about a library (JScience) that states being OSGi compatible: http://jscience.org/
What am I missing? I really cannot afford not using JScience. And I have rejected several 3rd party libraries before, that would spare me development time, because of these OSGi 3rd party integration difficulties.
Why not just let Maven to resolve transitive dependency and download them for you.
Once you add them in pom.xml, IDE like Eclipse (m2e plugin actually) can already resolve, download and show resulted jars. (You can use mvn dependency:tree from command line as well)
Then review, and exclude unwanted, e.g. optional or with packages already exported by other bundle.
And yes, use provided scope e.g. for org.osgi.*
<Embed-Dependency>*;scope=compile|runtime;inline=true</Embed-Dependency>
<Embed-Transitive>true</Embed-Transitive>
I'm using the Tycho eclipserun plugin to generate Java source code for an EMF model during build (as opposed to having the sources checked in). Configuring the plugin to run as part of the maven build works fine, but I would also like to configure m2e so that the same goal is executed when building from inside Eclipse. So, I imagined that could get away with just specifying <execute/> instead of <ignore/> in the lifecycle mapping metadata, like so:
<pluginExecution>
<pluginExecutionFilter>
<groupId>org.eclipse.tycho.extras</groupId>
<artifactId>tycho-eclipserun-plugin</artifactId>
<versionRange>[0.21.0,)</versionRange>
<goals>
<goal>eclipse-run</goal>
</goals>
</pluginExecutionFilter>
<action>
<execute />
</action>
</pluginExecution>
But then m2e complains saying
Execution default of goal
org.eclipse.tycho.extras:tycho-eclipserun-plugin:0.21.0:eclipse-run
failed: java.lang.IllegalStateException: Cannot run multiple Equinox
instances in one build. Consider configuring the Tycho build
extension, so that all mojos using Tycho functionality share the same
Equinox runtime.
(org.eclipse.tycho.extras:tycho-eclipserun-plugin:0.21.0:eclipse-run:default:generate-sources)
Ok, so m2e cannot run a nested Equinox instance in the same build, which kind of make sense.
Is there a solution for this? One solution I could imagine would be to execute a standalone Eclipse, but I really like the way the eclipserun plugin allows be to do that just by specifying a remote p2 repo and a bunch of features to include, instead of having to set up a standalone Eclipse more or less manually.
If you are already running in Eclipse, you could execute your EMF generation steps in that runtime directly. So you'd need to configure a builder which does the same steps as the tycho-eclipserun-plugin.
In general, for the case where some build step needs to be executed in Eclipse, but in a different way than in Maven, m2e has the concept of configurators: A configurator could tell m2e what to do when it encounters a certain build plug-in. So in case of the tycho-eclipserun-plugin, the configurator could let the goal run in a forked process instead of in-process. However, I'm not aware of such a m2e configurator, and it remains to decide whether it is really a good idea to fork processes as part of the incremental Eclipse build.
This is related to How to avoid Eclipse importing a class when putting the class name in the comments, so that checkstyle does not complain later?, but is a different issue.
I have a bunch of Javadoc references with import statements, as describe in the referenced question. Eclipse does not warn about this, but I still get compiler warnings when building my code with Maven/Tycho. I thought that specifying <compilerId>jdt</compilerId> should make Maven use the same compiler as Eclipse does, and there by generate identical sets of warnings.
I understand that I can use the fully qualified name in the Javadoc tag to avoid the import statement, but what I wonder here is how do I get the same set of compiler warnings when building with Maven/Tycho as when I build in Eclipse?
Tycho uses the JDT compiler by default, so you don't need to set the <compilerId>. However the compiler settings defaults may be different in Tycho and in Eclipse, or you may have changed the default settings in your workspace. You could try to configure the compiler in Tycho via the <compilerArgs> parameter to match your workspace settings, but this may get quite tricky.
With Tycho 0.22.0 (cf. bug 404633) there is much easier way to get the exact same compiler settings in Eclipse and in Tycho:
Enable project-specific Java compiler settings in Eclipse and configure them in the way you want them. This creates a file .settings/org.eclipse.jdt.core.prefs in the project.
Add the following Maven configuration:
<plugin>
<groupId>org.eclipse.tycho</groupId>
<artifactId>tycho-compiler-plugin</artifactId>
<version>${tycho-version}</version>
<configuration>
<useProjectSettings>true</useProjectSettings>
</configuration>
</plugin>
This makes the JDT compiler in Tycho use the Eclipse project settings whenever they are present.
Note that you need to put the .settings/org.eclipse.jdt.core.prefs files under version control to make your build reproducible.
I am trying to setup my developer env so that I can use maven to compile my LESS files for formal builds, but also have Eclipse compile the LESS for incremental builds so I dont have to keep kicking of maven tasks every time I make a LESS change. Having looked around - it seems like wro4j & the maven plugin & the m2e-wtp plugin should provide all that.
My setup is as follows: I have just installed the latest stable Eclipse (Java EE package, that includes the WTP stuff - v4.3) and I have installed the m2e plugin and the m2e-wtp plugins.
pom.xml:
<plugin>
<groupId>ro.isdc.wro4j</groupId>
<artifactId>wro4j-maven-plugin</artifactId>
<version>1.4.5</version>
<executions>
<execution>
<phase>compile</phase>
<goals>
<goal>run</goal>
</goals>
</execution>
</executions>
<configuration>
<targetGroups>roa-all</targetGroups>
<destinationFolder>${project.build.directory}/${project.build.finalName}</destinationFolder>
<cssDestinationFolder>${project.build.directory}/${project.build.finalName}/css/</cssDestinationFolder>
<jsDestinationFolder>${project.build.directory}/${project.build.finalName}/js/</jsDestinationFolder>
<wroManagerFactory>ro.isdc.wro.maven.plugin.manager.factory.ConfigurableWroManagerFactory</wroManagerFactory>
</configuration>
</plugin>
wro.properties:
preProcessors=cssImport,semicolonAppender
postProcessors=lessCss,cssMinJawr
wro.xml:
<groups xmlns="http://www.isdc.ro/wro">
<group name="roa-all">
<css>/less/*.less</css>
</group>
</groups>
Inside my /less/ folder are basically a few css files that I have renamed .less files, and one where I have actually added some LESS syntax with a few colour variables set. This mostly works, as I make changes to my LESS, the plugin detects and rebuilds my uber css file, however, rather critically, it doesn't seem to be compiling the LESS - it combines the files, and minifies, but my #variables are all still in LESS syntax.
I also noticed that the maven plugin was up to v 1.7.0 so tried upgrading to that to see if that was the problem, but that just does nothing at all (nothing gets built at all and I have no uber css etc)
Anyone had any experience setting this up or know anything I have missed in the setup?
The problem was because I had some invalid LESS in one of my files - this basically meant the compile step was failing, so the other LESS files were not being compiled to CSS (which resulted in the LESS variables being output in my file) - With the Eclipse incremental build, this failure was not being reported so I didn't see it.
I discovered it by explicitly running the maven command, and then got the normal maven logs which included details of the compilation failure.
That aside, the eclipse incremental build for LESS is working really nicely since!
As mentioned in the comments above, I wrote up how to set it all up here:
Eclipse & LESS - Better development time with incremental builds
This is going to be a pretty long question, so bear with me. I'm looking for a solution to build custom update sites (or p2 repositories) for use in an offline development environment, with the following things in mind:
Each site will contain a mix of 3rd-party and custom Eclipse plugins.
I'd like to create a single site per IDE configuration. e.g. Developers using Helios only need to add 1 update site containing m2e, Subversive, and CustomPluginA. Developers using Flash Builder can add a different site containing m2e and CustomPluginB.
Since development is offline, we currently mirror 3rd-party update sites with a script. The custom sites need to draw plugins from these copies.
Our custom Eclipse plugins are currently built with Maven + Tycho on Jenkins. If possible, I'd like to configure the update sites to build automatically with Jenkins as well. Then, if a custom plugin is updated, it can trigger the necessary update site builds.
Custom categories in the update sites would be nice.
I'm trying to find the best and cleanest way to approach this. How can I set something like this up using Tycho to build the sites? Is Tycho even the best option? Do I want the 3rd-party plugins to be copied to each site, or do I want to create p2 composite repositories which point to each of the mirrored 3rd-party sites. Is it possible to create custom categories with a p2 composite repository?
And finally, what is the easiest way to actually define which plugins and features are included in a site? In Eclipse I can create an Update Site Project which makes editing very easy, but I can only include plugins which exist in that Eclipse installation. Creating a site.xml or p2 ant script by hand solves this problem, but determining installable unit IDs and versions by hand is difficult and error-prone.
Thanks for taking the time to read all this. If anyone can actually address all of my concerns that would be amazing and I'd probably have to add a bounty to this question.
I will suggest two ways, one with Tycho and one with the B3 aggregator.
1) Tycho:
Step 1.: Define a target platform using PDE built-in tools, that uses your existing local update sites, and save it as a .target file. Then you can reference this file in your build like the following:
<plugin>
<groupId>org.eclipse.tycho</groupId>
<artifactId>target-platform-configuration</artifactId>
<version>${tycho.version}</version> <configuration>
<resolver>p2</resolver>
<target>
<artifact>
<groupId>org.eclipse.viatra2</groupId>
<artifactId>«project name where the target file resides»</artifactId>
<version>«artifact version»</version>
<classifier>«target filename without extension»</classifier>
</artifact>
</target>
<ignoreTychoRepositories>true</ignoreTychoRepositories>
</configuration>
</plugin>
Step 2.: Define a new project as an update site. The project should contain a category.xml referring the used versions of the used features of the target platform from the previous step. You can create this category.xml using the PDE Category definition wizard/editor.
Step 3.: Simply publish your build using the update site archetype:
<packaging>eclipse-repository</packaging>
<build>
<plugins>
<plugin>
<groupId>org.eclipse.tycho</groupId>
<artifactId>tycho-p2-publisher-plugin</artifactId>
<version>${tycho.version}</version>
<configuration>
<publishArtifacts>true</publishArtifacts>
</configuration>
</plugin>
</plugins>
</build>
2) B3 Aggregator:
The Eclipse B3 project contains an aggregator feature. Using the Aggregator you define a model which uses existing update sites, then simply execute this model using the Aggregator, and the result is an update site. In the latter case you can either build a composite update site, that refers to other update sites, or you can create a standalone copy from the original data. The manual contains a simple example, it is easy to use.
3) Comparison
Defining the mirroring logic is more straightforward in B3, as the model contains only the mirroring description, and also allows the creation of composite update sites that only reference the existing sites. However, if you want to do anything else besides update site building, then it is harder to do. Additionally, it can be executed in headless builds (e.g. from Jenkins), but it needs an installation of a headless Eclipse instance. The documentation contains the details, but the tool is not standalone like in case of Maven/Tycho.
In case of Tycho it is harder to see the structure of the resulting update site, however, the resulting build is more extensible (e.g. you can simply add your own features using the same kind of build), and to do a build you only need Maven installed.
So alltogether, both tools might fit your needs - you need to evaluate their strengths and weaknesses in you case.