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.
Related
I have a situation at the moment where I have:
Project A which is built into a fat jar using Maven assembly plugin.
Project B which uses the jar built in Project A. It is added to the project as a resource and launched in a separate process using a process builder.
I wonder if it's possible to achieve similar behaviour using just one Maven project. I.e build the jar containing only the classes and dependencies required for project A, and then build the rest of the project with the prebuilt jar.
Sorry if I'm not being very clear here.
This is against a few of Maven's core concepts:
One project, one model (POM). Two projects (A, B), two models (POMs).
There's one artifactId in a POM. What is a second artifact (jar) supposed to be named?
One project leads to one artifact. There is no additional "prebuilt jar" built within the very same project.
Dependencies are for the whole project (and possible sub-module projects). I'm not aware of how to "containing only the classes and dependencies required for project A".
Artifacts are stored:
in <project>/target temporarily
in the local Maven repository (default: ~/.m2/repository)
possibly in a remote Maven repository
... while resources are taken from <project>/src/main/resources during the build.
There might be some tricky solutions (which have possibly pitfalls, too) to achieve this if one thinks about it thoroughly. But I'd never ever recommend such.
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.
I have my POJOs and DAOs in one maven project (Project A)
And I have created a Service in another maven project collecting the DAOs I need (in Project B)
And I created a third maven Project with a swing gui main class(Project C)
Project C depends on B and B depends on A.
When I declare my service(Project B) to use the functions to fetch data to the gui (Project C) I get a Java Null Pointer Exception on the Resource use of my service.
Cant the project communicate just trough dependencies or do I need some deserialization etc.?
LOGIC
POJO(implements Serializable) -> DAO -> Service -> GUI
So, it seems that you are executing the code in Project C. It would help to know what the types of these projects are . . . but let's just assume they are jars. By default, a jar is NOT built to include all of it's dependencies inside of itself. This is because Maven expects you to use jars like most people in the java community do, i.e. they are installed into runtimes along with all of the other jars needed. If each jar had it's fully dependency tree included inside of itself, that would be a mess. So, it seems that you are expecting the Maven build to pull all of your dependency chain into your final artifact for Project C, and it's not happening.
There are several ways to get your dependencies into your final artifact. Assuming your swing project is a jar, you could do this with the assembly plugin's "jar-with-dependencies" assembly type. It produces a jar with all of it's dependencies included.
http://maven.apache.org/plugins/maven-assembly-plugin/descriptor-refs.html#jar-with-dependencies
This was what i needed to fetch data from my maven project (Project A) http://www.java2s.com/Code/Java/Spring/LoadconfigwithFileSystemXmlApplicationContext.htm
I am a bit curious about how this works - if I have 5 module projects in a Maven multi-module project, can you import the content and packages into other modules without adding that project as a dependency? Or do you in-fact need the .jar (or a snapshot jar) in order to use structures/functions from other modules?
Thank you,
Inter-module dependencies (adding one module as a dependency in another module's pom.xml) is meaningful in the world of Maven (as a build tool, not an IDE). When you build your multi-module projects from command-line, you don't need concern the dependencies between each module yourself, Maven will topologically sort the modules such that dependencies are always build (hence generate the jar file) before dependent modules (so that it can reference generated jar file as a dependency).
This is not necessary (in theory) if you use IDE like Eclipse, as you can achieve the same result (adding one project as a dependency of another) by some manual settings in Eclipse Right click project and choose Properties -> Java Build Path -> Projects -> Add, which is automatically handled when Eclipse import your multi-module project, if you define inter-module dependency in pom.xml.
The question is why you want to do something unusual (without adding that project as a dependency) that you cannot gain any benefit from it.
I have created a multi-module project base structure. I have another multi-module project base code (created by someone else) which is similar and runs well. Both the projects have same module and similar POMs. Both are Enterprise projects means both are deployed into ear files. I am somewhat new to multi-module maven as well as ear project.
I have a web module and the ear module references the web module. In my ear pom Iv mentioned the web module as a dependency under (not ) Now in the working project all jars are coming from ear to web module inside a library called "Ear Libraries". We can see those jars in "Java EE modules dependencies" of web-module in the working project.
But the jars are not being shown in the web-module of the project I created and so errors are thrown for all external classes (like smartgwt classes). POMs are similar. I even imported the project to another Workspace but of now use. Did the project got corrupted? shall I start from the begining?
Edit
Its not the fault in POM. I am using the same POMs in both applications (Just copy-paste and change name of application). They have same structure, same modules. I am using M2Eclipse 0.9.9 and RAD 7.5
Working project web-module pic
Not Working
We can see under EAR Libraries, jars being reflected in Working project but not in Error-Project.