How to put Maven Tycho Dependency in my Eclipse Plug-in? - eclipse-plugin

I've created a new project using tycho 0.26.0, it runs with Eclipse 4 Neon.2, so all modules are building successfully using maven, now I am trying to add a new dependency in my project, I have created a jar and I want to use it in my project, but I don't understand so good how is it working.
I add I am using a target definition, so I have to add my configuration to this file, this will be used by my modules.

I don't know if I got your question right.
I assume you want to build an Eclipse RCP application with tycho and use an JAR file from one of your plug-ins.
The simplest solution is then to create a new plug-in project from this jar by using the Plug-in from existing JAR Archives-Wizard.
If you have done this, you can add a dependency from this new plug-in to your existing plug-ins. Don't forget to export all packages of the library, by opening Manifest.mf and adding all packages in the Runtime tab.
To get this running with maven you have also to add a pom.xml file to the new Plug-in. This link help me a lot with maven tycho (http://codeandme.blogspot.de/p/tycho-articles.html).
Btw. if you don't need this library as plain JAR, you can also create directly a Plug-in project instead of first creating a JAR and then creating a Plug-in project.

Related

How to use script to build IntelliJ Idea project to a jar

i have created an IntelliJ Idea (Community Edition) java project. the project is quite simple. it only contains a main() method, but uses another 2 jars as dependencies. I also created an artifact to the project to build it to a jar.
My question is there any way to build the jar using script? because I want to add the build process to an existing build script.
thanks
IDEA doesn't do anything with the code on its own, it just counts on the default tools provided by SDK. In short, you will need javac and jar for packaging.

Getting contents and natures of all projects in a Maven build

Currently I'm working on a Maven plugin that should generate files in all projects (OSGi bundles) that have a certain Eclipse project nature.
How can I access the contents of the projects included in the build and the project natures by using the Maven API?
Maven is a standalone build tool, not an Eclipse plugin. You cannot access Eclipse project settings from core Maven API.
Eclipse supports Maven with the M2E Eclipse plugin. It is possible to write M2E extensions and in the extension you can query the project natures via the functions of AbstractProjectConfigurator class.
However, M2E extensions will not run when you compile your code in the command line. I suggest that you choose one of the followings:
Write an Eclipse plugin that generates the source code into the src folder of the maven project. Code generation should be started by the user manually (selecting a context menu in the project or something).
Avoid using Eclipse project natures and solve your questions based on analyzing the source and pom of your project.
If you need to react on certain aspects in the source code like it looks from the thread with Balazs then you can simply write an ordinary maven plugin and include it in the parent pom. It will then run in every project and can analyze the code and react based on it.

Is it possible to use an eclipse plugin project as jar library in a regular java project?

I have an eclipse plugin that I would like to access some classes in a regular Java Project. I was wondering if it is possible to generate a jar file from the plugin and then use that jar file in the Java Project. So in summary:
Is it possible to use an eclipse plugin project as jar library in a regular java project?
Thanks,
-- Tiago
Most of the time,an Eclipse plugin is exactly a jar file/few jar files,and on some other conditions it contains a features folder and other type files.For a single jar which is added dependency to this project,any public/static members can be accessible.
So just add it to the project's build path and you can access them.

How to include required jars in project while using Maven?

I am new to Maven and using it to build a project on my local. This is working nicely on my local. Now, I want to run the same project on my server and the server does not have Maven installed. So I wanted to ask if there is any way by which, when I build a Maven project on my local, I could include all the required jars in it and then simply transfer it to my server? I know Maven creates the repository in C:\Documents and Settings\username\.m2 on Windows.
But how can I include all the jars in project the way we do traditionally? I saw this question. But it talks about creating a custom repository and I don't have Maven installed at all. so I guess it is not a suitable solution to me.
Thanks.
You can use the Maven Assembly Plugin. From the documentation:
The Assembly Plugin for Maven is primarily intended to allow users to aggregate the project output along with its dependencies, modules, site documentation, and other files into a single distributable archive.

Link Maven OSGi to Maven NetBeans Platform Project

I am using NetBeans 6.9 Beta and I would like to accomplish the following:
Set up a project representing the main application using Maven (for instance "Maven Project", "Maven NetBeans Application")
Ideally, the project should only contain the necessary libraries to run in Apache Felix (I would like to be able to right-click the project and select "Run in Felix")
I do not want that the project contains all the NetBean Platform APIs
I would prefer to implement the modules using OSGi. For instance "Maven OSGi Bundle", "Maven NetBeans Module" + OSGi
These are the problems, which I have at the moment:
The standard Maven archetype ("Maven NetBeans Application") seems always to select all APIs and I have not found a way to deselect APIs - in normal NetBeans Platform Applications that can be accomplished by going to the project properties and deselected the platform modules) - I guess it has something to do with the NetBeans repository (http://bits.netbeans.org/maven2)? Do I have to create another repository?
When creating normal "NetBeans Module" with OSGi support, the modules contain both NetBeans Module and OSGi meta data, which is nice. So, for instance the tool support in NetBeans is available for both technologies. But the "Maven NetBeans Modules" have only NetBeans meta data and the Maven OSGi Bundles have only OSGi meta data).
3. I figured out how to add modules to the project by using project / new and then placing the modules in the Maven project folder. However, I do not quite know yet how I could link to modules from other locations (NetBeans uses Maven modules, which have to be in the same directory as the project?).
Below some useful links for Maven + OSGi in NetBeans
wiki.netbeans.org/STS_69_Maven_OSGI NetBeans Maven OSGi Test Specification
platform.netbeans.org/tutorials/nbm-maven-quickstart.html NetBeans Platform Quick Start Using Maven (6.9)
wiki.netbeans.org/MavenBestPractices NetBeans Maven BestPractices
maven.apache.org/pom.html#Aggregation Maven Documentation Multi-Module Projects
(sorry about the missing protocol but couldn't post the message otherwise)
your nbm-application project depends on all platform projects.. just use the regular maven dependency management (adding/removing dependencies, adding dependency excludes to limit your platform
configure the nbm plugin and the bundle plugin yourself to sequentially append content to the manifest file.. I think Fabrizio Guidici's forceten and bluemarine projects do that in some way..
I don't understand the problem entirely. maven modules are a different thing than netbeans modules. you can for sure compose the application from multiple independently build nb module artifacts.