I have 2 project A and B.
Each has an interface "I" with its implementation.
In Project A, I want to use the implementation "I" of the project B, and it is not enough to add the dependency of project B to get there.
I ask the necessary configuration in pom.xml of the project A.
Research about writing a 'reactor build' file that would reference both projects and thus build them both; this build would first see which project depends on the other and thus build the dependency first.
Related
I need to transfer a Java class to a new Java project, with all of its dependencies.
Meaning I may have class a, which class b calls it, and class c calls class b, etc.
In this case, I will have to transfer classes a, b and c.
Is there a way to do this for all of the projects?
My problem is that I can't download any files to my computer. I use Intellij as IDE.
Have you tried dependency management tools like Maven or Gradle? A quick Maven tutorial https://maven.apache.org/guides/getting-started/maven-in-five-minutes.html
With Maven you can just create a Maven project from your IDE and provide it with a pom.xml that specifies how you wanna build the project and all its dependencies. For each dependency you specify, Maven could transitively pull other dependencies for you.
The ultimate goal is to find out a way to functional test a library.
I have a parent project A with sub modules B,C and D.
Let us assume that the module C has a dependency on module B (B being the library) and is included as a maven dependency using the <dependency> tag.
I am just curious to know when I start up the application server say Tomcat would a jar for B (along with others) be created and then C uses this jar?
I tried to monitor my directories to see whether jars were being created every time the server was started up but that doesn't seem to be the case.
If B isn't used as a jar then it would not exactly be a FT since the ultimate goal is to be able to use B as a library in other projects as well. I feel like this shouldn't be a problem since the code itself does not change but I'd like to get some insight into the same and comments if any. Thank you !
I hope I get it right, because you seem to mix building, deploying and testing
Maven will only build the current pom. It will not build dependency libraries but expect to find them in the repository.
Only if module A is a multi-module build, then B, C and D will be built when you build A.
Starting a tomcat will not trigger any build.
For a functional test you would build, package and deploy and execute your tests against the full application.
I have 2 projects, Project A and Project B. Project A is a Play2 App that depends on Project B (which is a client library.) Currently Project B is pulled from our artifactory with SBT. I would like to set up IntelliJ such that Project B is pulled from the project source on my computer, rather than from the artifactory that is specified in.
I have added Project B as a module of Project A and added Module B to the dependencies of Module A. I then ordered Module B to be at the very top of the dependency list. The static analysis of the code seems to be working fine, there's not compilation errors showing when I updated Project A's code to use a new method signature that I've updated in Project B. However, when I run the Play App I get a compilation error stating that the method signature is incorrect.
Is there a way to override the module used at runtime for SBT and the Play App?
You can do this via sbt. In your build.sbt, for example:
val localDep = ProjectRef(file("/Users/me/projects/b"), "b")
dependsOn(localDep)
IntelliJ will import this dependency as a module. You should remove the library dependency however, to avoid conflicting classpaths.
Naturally, this makes the project hard to share unless other developers have the project in the same location. In that case, I would create a multi-project build instead, which is usually the best choice for tightly coupled projects with individual resulting artifacts.
Another option is a git project dependency:
val projectDep = ProjectRef(uri("git://github.com/me/b"),"b")
I have three independent projects A, B and C. Projects B and C depend on project A jar. Every time there is a change in project A, i have to manually build it before building B and C.
I am trying to figure out, if there is a way to Build project A; every time i build project B or C independently. As these are independent projects, i don't think i have to use modules here.
If you need to rebuild B and C every time you introduce changes to A, I'd say, this is not a simple dependency between otherwise independent projects, and the coupling here is tighter than it seems.
You seem to know what maven modules are, and I would suggest to go that way.
Wrap all three of your projects with a ROOT maven project, and add them as modules to the root pom.xml.
Otherwise, think about Continuous Integration Server, like Jenkins or Hudson. In there, you can easily relate separate builds to trigger other builds, and also set them up, so they start automatically on every change comitted to version control system like SVN or GIT.
A scenario here would be quite simple:
SVN change => triggers build of A => triggers build of B, C
I've recently tried to work with NetBeans and I don't understand how it handles Maven multi-module projects.
My project has fairly complicated modules structure and when we're working on it (we mainly use IntelliJ community edition) we don't want to open all its modules (~50 modules) because it will take hours to load the project, instead we've created a 'workspace' module: a folder with pom.xml that has a packaging type pom and defines modules that I would like to load.
Lets say it defines modules A, B, C.
We have our main method (we don't use any type of container) in module A which is a low-level infrastructure module.
As a runtime dependency we need A, B, C. But A doesn't really depend on B, C, but rather B and C depend on A (in terms of Maven dependencies).
So we've created another module, lets call it runner, where we define all the dependencies. Our workspace pom.xml has module declaration of runner, so in order to run the project from IntelliJ, we use a 'classpath of module runner' while running method main in module A.
Now, How can I achieve the same affect with the latest Netbeans (7.1.2)?
I understand that question is kind of newbie's style, but I struggle with it a lot of time with no luck.
Just struggled with the same issue - from what's listed in the Netbeans wiki it seems that every module represents it's own Netbeans project and everything else would be expressed with project dependencies. See http://wiki.netbeans.org/MavenBestPractices
A project with modules is known as a multimodule, or aggregator project. Modules are projects that this POM lists, and are executed as a group. The Maven projects in NetBeans lists these modules as "Required Projects". So you will only get the required projects list populated for Maven projects with "pom" packaging that have modules defined.