Current setup:
Maven
Spring Boot
Angular
12 maven project + 1 Pom project
Git
Jenkin
Currently i have separate 13 project.
Every time if i have to setup on another machine then i have to clone each project individually.
Also i did the Jenkin pipeline setup for auto build.
Looking for
Once i clone the single pom/main project , all other project should get cloned
If i take pull of the main project then all other projects code should get updated
Child project should get head revision every time i start the jenkin
build.
Want to keep separate repo for each sub projects so that it can be reuse in other project as i have multiple requirements.
Solution that i have thought of:
Maven Child projects
Git Sub modules
Issues facing in above solution
1. Maven Child projects
--> If we are using maven child projects then we are literally copying the sub projects in pom/main project.
In this case i cannot reuse the project. Every time i have to clone the project to use it.
For big project with number of team member working, merging issue will come.
2. Git Sub modules
--> This is best solution for me but when we create sub module it always point to commit not the head revision.
Every time i have to manually pull the latest code push it to parent project.
This approach we can not use in Jenkins.
Is there best approach which can resolve all the issue.
You can add git sub-modules by specifying what modules to be added from other repositories. A .gitmodules file will be created on root that will contain list of all submodules and other preferences of yours.
Creating git submodules for projects in different repositories
There are set of commands available that you can use to sync up the git module and all it's sub-modules.
Set of steps that you could take is:
Add all submodules in project using git submodule add [ssh or https path] e.g. git submodule add https://github.com/test
Add other submodules and push the changes
Fetch submodule content by running
git submodule init
git submodule update
or alternatively run git clone --recurse-submodules https://github.com/chaconinc/MainProject to get sub-modules as well
I would recommend that you read through this link and ensure your requirement is fulfilled by this.
Related
We have Github repository with the structure as:
Project Name
- submoduleA
- submoduleB
- submoduleC
Every submodule is an extra microservice present inside the same branch. It is maven project. Every submodule is having a seperate jar which are not having any build dependencies.
I want to setup a Jenkins job which will get triggered when there is some changes to the submodule directory and build the respective jar.
Is there any way we can achieve that or is my approach is not correct? I also want to integrate Sonarqube analysis with it.
I suggest you refer to these blogs to setup the automatic trigger process step by step, my favorite is the 3rd blog.
Trigger Jenkins builds by pushing to Github
Automatically triggering a Jenkins build on Git commit
Triggering a Jenkins build from a push to Github
If someone could help me out here it would save me a lot of time.
I maintain an open source library that gets pushed out to a sonatype repository. I make changes to that library a few times a day and push it out to the 1.0_snapshot build using mvn deploy.
Let's call it project1
I work constantly in another project that uses that library let's call it project2.
Right now, whenever i make changes to project 1 or 2, i need to first build and deploy project 1 to the repo, then build project 2 so it downloads a fresh copy of project1.jar
Project2 has Project1 as a dependency in a pom.xml:
<dependency>
<groupId>com.group</groupId>
<artifactId>project1</artifactId>
<version>1.0-SNAPSHOT</version>
</dependency>
in order to build in a way where all of my changes can be tested, I have to do something like this:
mvn -f ./project1/pom.xml clean deploy
mvn -U -f ./project2/pom.xml clean package
this uploads my project1.jar to sonatype, then project2 downloads the new snapshot and builds it.
This is a simplified picture of what i'm doing on a larger scale, where my compiles take 5 minutes of up and downloads.
Question: What is the proper way to use maven so it knows to use the source of project1 in a dependency in project 2?
IDE:
install m2e in eclipse
import your both projects into workspace
from consumer project (right click > maven > enable workspace resolution)
this will put project2's classes in classpath from its target/classes instead of the actual jar
native straight maven:
You can create a maven project tree, if this two are open source project going through same build cycle it must have one already, if they are not related but related for your usecase then you can temporarily create a maven tree on top of these 2 projects and build the top parent it will build from bottom up in one command
it will find the leaf project, build it install it in maven's cache and now while building projectA it will refer it from maven's cache so no need to deploy to sonatype
You can also point project2 to build using offline mode :
mvn -o package
Then you drop the upload part of the project1 build to the remote repo.
Check the following link: Intro to repositories and How do I configure Maven for offline development?
I have a client-server program splited in 3 net beans projects, 1. client 2. server 3. common classes
I would like to push them in one bitbucket git repository but after pushing one of the projects i can't push others
Remote Repository Updates
Branch : master
Old Id : dfe16274e865383a78be5ddc294d828650cd73b0
New Id : 855f9f0355e9151330e82948cfda8bfc7a412d65
Result : REJECTED_NONFASTFORWARD
Local Repository Updates
Branch : origin/master
Old Id : null
New Id : 855f9f0355e9151330e82948cfda8bfc7a412d65
Result : NOT_ATTEMPTED
Note that there is no package and file name conflicts in these projects.
As looks like there is nothing like/equivalent to Solution in Visual Studio to group related projects in net beans, is it a good idea and correct use of git to push all these 3 projects into one repo?
How to push other two projects to my repo?
git version: 1.8.3.1 Net beans version: 7.3
You need to create a single repository from the parent folder. I would suggest that you put the three project folders into a folder lets say: myproject. Then initialize the repository inside myproject and push that to the bitbucket git repository. This way any changes in any of the projects will be pushed to your repository.
I have a Maven 3 multi-module project (~50 modules) which is stored in Git. Multiple developers are working on this code and building it, and we also have automated build machines that run cold builds on every push.
Most individual changelogs alter code in a fairly small number of modules, so it's a waste of time to rebuild the entire source tree with every change. However, I still want the final result of running the parent project build to be the same as if it had built the entire codebase. And I don't want to start manually versioning modules, as this would become a nightmare of criss-crossing version updates.
What I would like to do is add a plugin which intercepts some step in build or install, and takes a hash of the module contents (ideally pulled from Git), then looks in a shared binary repository for an artifact stored under that hash. If one is found, it uses that artifact and doesn't even execute the full build. If it finds nothing in the cache it performs the build as normal, then stores its artifact in the cache. It would also be good to rebuild any modules which have dependencies (direct or transient) which themselves had a cache miss.
Is there anything out there which does anything like this already? If not, what would be the cleanest way to go about adding it to Maven? It seems like plugins might be able to accomplish it, but for a couple pieces I'm having trouble finding the right way to attach to Maven. Specifically:
How can you intercept the "install" goal to check the cache, and only invoke the module's 'native' install goal on a cache miss?
How should a plugin pass state from one module to another regarding which cache misses have occurred in order to force rebuilds of dependencies with changes?
I'm also open to completely different ways to achieve the same end result (fewer redundant builds) although the more drastic the solution the less value it has for me in the near term.
I have previously implemented a more complicated solution with artifact version manipulation and deployment to private Maven repository. However, I think this will fit your needs better and is somewhat more simple:
Split your build into multiple builds (e.g., with a single build per module using maven -pl argument).
Setup parent-child relationships between these builds. (Bamboo even has additional support for figuring out Maven dependencies, but I'm not sure how it works.)
Configure Maven settings.xml to use a different local repository location - specify a new directory inside your build working directory. See docs: https://maven.apache.org/guides/mini/guide-configuring-maven.html
Use mvn install goal to ensure newly built artifacts are added to local repository
Use Bamboo artifact sharing to expose built artifacts from local repository - you should probably filter this to include only the package(s) you're interested in
Set dependent builds to download all artifacts from parent builds and put them into proper subdirectory of local repository (which is customized to be in working directory)
This should even work for feature branch builds thanks to the way Bamboo handles parent-child relations for branch builds.
Note that this implies that Maven will redownload all other dependencies, so you should use a proxy private Maven repository on local network, such as Artifactory or Nexus.
If you want, I can also describe the more complicated scenario I've already implemented that involves modifying artifact versions and deploying to private Maven repository.
The Jenkins plugin allows you to manage/minimize dependent builds
whenever a SNAPSHOT dependency is built (determined by Maven)
after other projects are built (manually via Jenkins jobs)
And if you do a 'mvn deploy' to save the build into your corporate Maven repo then you don't have to worry about dependencies when builds run on slave Jenkins machines. The result is that no module is ever built unless it or one of its dependencies has changed.
Hopefully you can apply these principles to a solution with Bamboo.
I have one project that I have modularized using Google Guice. But now when I build subproject I have many steps:
1) Update subproject version number.
2) Pacakage subproject.
3) Update local repository with subproject new version.
4) Update main project pom.xml with subproject newest version number.
5) Update main project dependencies.
6) Run main project as web appliaction, to test changes in subproject.
Is it possible to cut down some of these steps to make my development faster? I'm using local repository and installing subproject jars manually to local repository.
Take a look at m2eclipse plugin, it should help a lot in your situation.