I was thinking about a question : is it possible to create an "admin" pom.xml file outside any project on my GitLab server and, when I am in a new project, define it as a parent pom.xml ?
It could help me with CI/CD because I will define the server's configuration and the distribution management for example.
Thanks.
Usually, you have a "company parent POM" for that. It is a separate project that you build with your build server and then reference as a parent POM from everywhere. It contains plugin versions, distribution management, properties etc.
Related
I have 6 microservices in my project and i have seperated them into 6 projects in gitlab. When i tried to build this microservices all together or after building parent POM later child POM seperately outside Gitlab it is working but while using gitlab-ci i am not able to build it as they are failing non resolvable parent POM.Can someone please let me know how can i build this microservices independently(building parent POM and keeping the artifact available for all other projects).
Tried caching and artifacts in gitlab but they are strightly bound to single project
If you always want to build those six microservices together, put them into one multi-module project. Then you have one project on GitLab and everything will be much easier.
If you need to separate, then you need a Maven package manager. You can use the one that is included in GitLab, or you can use an external one like Artifactory.
I have a mule project-A where in I need to call a flow from another mule project-B. I have added <classifier>mule-plugin</classifier> in the project-B's pom. And I have added a dependency with project-B's group-Id, version, artifact-Id, classifier in project-A's pom and also created an "import" config in project-A with flow name of project-B which I want to use. Still I am unable to call the flow of project-B in project-A
If you are implementing this to just test in your local machine, then follow the below steps. You can also look at the concept of Mule Domain Project, which does resource sharing for those apps falling under the same domain ; enabling you to call other apps flow-refs, global configurations and more.
Note : All this below said has to be in Mule 4.
First, export your Project-B as a mule deployable jar.
Steps
Right click on Project-A and goto - > mule
Add a maven dependency.
Choose your Project-B.jar from your local repository and
add.
This will get your project imported as a maven dependency
in your pom.xml file.
Make sure your jar added under your project libraries of 'A' in
the package explorer.
Goto to the global elements of Project-A and select import
configurations.
Add the Import configuration to your elements and specify
your Project-B main XML file you want to use in Project-A.
Finally refresh/restart your main project and check if you can
reference the flows.
If you still can't get this work, try updating to the latest version of studio, like 4.3.1 which is a much stable version.
Detailed explanation is given here -> Mule Shared Projects
Update
You can also try doing the same in your cloudhub runtime. You don't need a Domain project concept to do this. Basically you kind of imported your Project-B into Project-A completely ; Altogether making it a one mashed up Mega project.
I want to define a plugin configuration along with dependencies in the separate project B, then attach it to other project A so I can run phases/goals from the project B from project A. Is this even possible with maven?
You can run goals from plugins from the repository, if you give the full qualified name of the plugin, i.e.
groupId:artifactId:version:goal
If you want to use the short form, you either need to add it to your (parent) pom or to your settings.xml.
New to maven here...coming from the ant world
I need to create a client jar with a few files that will give my client the ability to write to my Db and make rest calls to my services.
These are mainly classes that wrap a Rest connection and db client.
Is it possible to produce this artifact as a side effect of my main maven project ?
Eg: main project produces a bundle when I run mvn package, but I'd like to produce the client jar by providing some other parameters....
What you need here is a multi-module maven project.
The structure goes like this:
-- Parent Module
----- Child 1 Module
----- Child 2 module
Here you can have all your code/files of your main app in child 1 module and put all the code/files for the client in the child 2 module.
The parent module is just an aggregator which produces an artifact of type pom. Whereas each of your child modules will produce individual jars.
You can then you the second jar in your client.
For a detailed understanding how multi-module project works, check this link.
The standard Maven way is "one project, one jar". This means that the cleanest way to achieve your goal is to set up a multi-module project where you have one module for your "normal" jar and one for your "client" jar. But there are other possibilities:
If you are talking about an ejb, you can use the maven-ejb-plugin and create a client artifact. Unfortunately, both artifacts then share the same pom (and, therefore, the same dependencies).
You can use the maven-assembly-plugin to assemble a set of files and deploy them as side artifact (same problem as in (1)).
You can use the maven-install-plugin and maven-deploy-plugin to install/deploy entirely different artifacts along with your main artifact. These artifacts need to be created before, e.g. by a custom maven plugin.
If my company has an artifactory repository set up, what is the best way to ensure all projects can access it?
Currently all repository information is in a master pom project (it also contains stuff other than repo info). Then any other projects have that master pom as the parent to inherit from. Because the projects are independent, we have to use the relativePath property and ensure the master pom is in the correct relative directory.
Is there a better way?
In the settings.xml you have to configure the access to the company repository manager and in your corporate pom you have to setup up the distributionManagement.