Bndtools on a multi module maven Project - osgi

I am currently working on migrating a multi module maven osgi project to bnd tools.
What I'm struggling with is the configuration of the build.bnd so I can build the bundles.
If I add a package to the export list i get:
Error finding source package for exported 1 packages
and in the details:
java.lang.NullPointerException
This I understand is due to the directory layout, which is one main folder including all the projects and the parent pom listing all the modules.
so basically the structure is
myMultiMavenProject//project1
myMultiMavenProject//project2
myMultiMavenProject//pom.xml
and the bundles to build are the maven projects themselves, each containing its own bnd.bnd defining the bundle
I already changed the basic project layout to maven for all projects using what bndtools generates when you create a new project and select said option
Then I tried to edit the build.bnd and change directories to something like project:
${basedir}//myMultiMavenProject
and I still fail to get a build.
I'm working on Windows 7, already had path problems configuring plugins and had to keep those in mind.
The bndtools core doesn't work well with those paths in case you use the UI for it.

bnd does not support nested projects. That is, each project must be in the workspace folder as a peer to the cnf folder.

Related

How to make Spring Tool Suite like a multi-maven-module project?

I'm trying to create a Spring Boot project with multiple Maven modules. I've used the tutorial at https://spring.io/guides/gs/multi-module/ .
This site recommends a directory tree like this:
parent
application
src, and other subdirectories
pom.xml
library
src, and other subdirectories
pom.xml
pom.xml
I developed this project using Visual Source Code.
Wanting to see the project in another light, I tried to import the project directories into Spring Tool Suite. I'm using a recent one, where you apply the STS plugin to an up-to-date Eclipse installation.
Well, STS doesn't really like this project.
The (File, Open projects from file system) sees the project, but the Finish button doesn't actually do anything.
The (File, Import, General, Existing Projects into Workspace) imports a project, but as a Maven project (no "J" icon). When I try the (Run, Run Configurations) it won't see my project.
How can such a project be made friendly to Spring Tool Suite?
Thanks,
Jerome.
To make multi maven projects what you can do is, simply download two separate maven projects from start.spring.io and then extract them and move both folders to one parent folder and try grabbing the parent folder to Intellij, so it automatically downloads the dependencies and other requirement for the project in which we have two maven projects in one single entity
Eclipse can be a bit confusing with several different Wizards to import projects. Ironically the wizards are supposed to make importing projects easy, and in a sense they do... but... unfortunately picking the right wizard itself can be a bit challenging / confusing. Which wizard you use depends on the type of project.
Since your projects are maven projects, the best wizard to use would be the one for maven projects. You can find it at "File >> Import >> Existing Maven Projects".
So give that a try, point it at the 'parent' folder of your project and you should be presented with a relatively intuitive UI to import all 3 projects and configure them for use in Eclipse.

How to make IntelliJ reference a local project for a dependency?

Working in a multi-module Maven project, call it "app." I need to work on the source of one of the dependencies, call it "lib", and be able to easily test/debug "app" against my changes in "lib."
In Eclipse this is an option for its Maven and Gradle plug-ins, and is obvious since Eclipse doesn't bind the concepts of "workspace" and "project" as tightly as IntelliJ does. When I cloned the repo for "lib", IntelliJ offered to create a new project for it, but how do I force "app" to use the local working copy of "lib" for compilation and runtime?
To put it another way, can IntelliJ basically encapsulate doing build install on "lib" behind the scenes so that "app" uses the updated (snapshot) of it?
The obvious, cleanest choice would be to combine the two projects into a common Maven multi-pom project. If that is something you can't do (perhaps the projects belong to different teams etc.), then I could imagine you could fake it by using symlinks.
Create a wrapper project with just a pom file and two modules. Instead of folders for the modules, use symbolic links to the actual file locations. Obviously the reactor root pom would not be the parent pom.
Now open the wrapper pom as IntelliJ project.
I don't know if this works, but it's worth a try.

Getting Intellij to link sources between OSGI/Tycho modules

I have a large osgi project with many bundles/modules that I'm trying to get working with Intellij. Currently users edit MANIFEST.MF files in each bundle to manage dependencies and tycho is used to populate the pom.xml files that actually build the project. The target platform is built by maven as a p2 repository.
I've loaded this project into Intellij as a bunch of maven modules in a single project that each have an OSGI facet. At this point everything works pretty well, but I can't get Intellij to resolve sources between bundles.
Concretely, I have two modules in my project, A and B, and B references a class in A. B's manifest imports the package from A that contains the class. When I 'jump to definition' on the class from A within B it takes me to the decompiled class file, rather than the sources in module A. When have multiple maven modules without tycho in an Intellij project however this resolution occurs automatically.
I'd like to be able to resolve sources between such modules when they are built through tycho.

Eclipse Plugin project: manage external files

I'm developing a plugin for Eclipse (4.2 on windows) that uses a bunch of external files (batch scripts, xml files, ecc).
I'm asking if there is a good method to manage those files inside the project in order to:
keep all the plugin resources inside the project for version control in SVN
possibly have an automated plugin installation (including those files outside the plugin jar)
Edit: Can an additional "Feature Project" be a solution?
Instead of having a project I would manage two: one for the plugin and one for the "feature" that references the plugin and gathers the non-plugin data.
In that case, I see that eclipse "Features" have an "installation" section (in "feature.xml"). How could I specify for each "non-plugin" file the install path location?
I'm using nested projects for this.
Create a parent project that will contain everything. For each sub-project, deactivate the default location when you create it and select the parent project's root folder instead.
Here is an example: http://git.eclipse.org/c/tmf/org.eclipse.xtext.git/tree/
It doesn't have a .project file in the root but having one doesn't hurt.
Just remember to import the sub-projects before you start working on them. Otherwise, you and Eclipse might get confused.

Maven build dependency through pom.xml

For my project, I'm using code from another project found on github. I've included the project as a separate folder in my project. My project uses code from that project, so I want to build that project and include it in my project without really making any changes to that project. So how do I specify in my pom.xml to run the sub-projects pom.xml?
If it helps, here is the repository of the other project that I am using: Soda Java
If you're not planning on changing it, simply download it & build it once using Maven. This will install it into your local repository, and you can simply reference it in your pom without any issue.
If you can find it in an external maven repo somewhere, you wouldn't even have to download & build it.
Only if you're planning on changing it do you need the aggregate project approach.
You create an aggregate project with packaging=pom and a modules element that has one module for the dependency and one module for your project, and you build that.

Resources