Maven build dependency through pom.xml - maven

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.

Related

How can I get only the JAR file?

I had two projects using the same code for a functionality. To avoid that, I isolated this code in a new project so the two projects can use this functionality by indicating the dependency in their pom.xml file. So, once that I created the new project with the repeated, I save in innersource as a maven repository.
In the pom.xml file of both projects I used tag with and inside to indicate where is the repository. When I update the projects the dependency is downloaded from the remote repository and it works, but when I saw the Maven dependencies section of my project, where all needed JARs are, I found that is not only downloaded the JAR file of the third project, but there is a folder with the project.
So how I can get the JAR and not a folder?
Thank you so much for your help!

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.

Gradle Maven like multi module project

When you define multi module project in Maven, you have one root project and its modules. When you build the root project, Maven transitivelly builds all its modules in correct order. So far pretty similar to Gradle.
But with Maven, you can clone only one submodule from repository and build it locally without need to download the whole project structure. This is because you define dependencies on other modules within the same project just as any other external dependency and it is downloaded and cached from your local repository (Nexus).
With Gradle, you define cross module dependencies as compile project(':other'). So you need to clone whole project structure from repository in order to resolve and build correctly. Is there any way to use Gradle multi module project support, without having to locally clone whole project structure?
I would argue that Maven's multi-module support is a slapped on after-thought. Unlike Gradle, a project dependency is not a first class concept. Instead the maven "reactor" substitutes local artifacts for dependencies when the GAV (group/artifact/version) matches.
If you'd like to use the same approach in Gradle then you can specify your dependencies using the GAV notation and then use the new composite build feature to join two or more separate gradle builds together and substitute repository dependencies for local source dependencies. Note that that you can define the projects included in the composite using groovy so you could easily script this based on custom logic (eg if a subfolder exists in some root folder etc)
Note that composite build support is a new feature added in Gradle 3.1. Prior to Gradle 3.1 you can use Prezi Pride to achieve the same

Bndtools on a multi module maven Project

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.

Add a Maven dependency to a Eclipse Plugin project

just a simple question: I need to add a Maven dependency to a Eclipse Plugin project.
The project has not a POM file, so I converted it to a Maven one.
Now I have plugin.xml file and pom.xml file. POM contains the dependency I need to satisfy, but it's ignored; I mean, I can't resolve an import in source code referring to that import.
Can you help me?
ty
I read about Tycho plugin, but online configurations don't work.
If I'm reading this correctly, you've just started by adding a Maven dependency to your project, but don't have the dependency available for Eclipse to validate your code against.
You will need to start a Maven build after you add a brand new dependency so that Maven can add that to your local cached repository. Once the Maven build is done, Eclipse should recognize your imports properly.
You may want to check whether the dependency you are looking for is available in the Eclipse Orbit.
The Orbit project is basically a repository of libraries to make them available for Eclipse Plug-in Development. What is especially nice in the Orbit libraries is that they also provide the sources. Thus, it is possible to view the implementation and get proper JavaDoc and so on.
Example
One can find the com.google.gson library using the update site
https://download.eclipse.org/tools/orbit/downloads/drops/R20190602212107/repository
Thereby, the part R20190602212107 refers to the Orbit build name that you find on the downloads page of the project.

Resources