I'm trying to deploy a maven web app with two modules and I tried using mvn package to get a war. Instead I got a pom.xml for the parent app and two jars for the submodules. That's...that's just great. How do I deploy that? I was expecting a war. Also, trying to deploy to jboss.
Edit: What goes in web.xml?
Make sure that your sub-modules declare <packaging>war</packaging>.
If you define not a packaging-type maven will choose jar as default.
If your parent-pom defines your modules it should be a POM as packaging (guess the parent-pom is in 99.9% cases POM as packaging-type). So as result for the parent-pom you get just a pom.xml.
For deploy you need to specifiy a <distributionManagent>.
<distributionManagement>
<repository>
<id>corp1</id>
<name>Corporate Repository</name>
<url>scp://repo/maven2</url>
</repository>
</distributionManagement>
For username and password i prefer to declare a <server> in the ~/.m2/settings.xml
so your password is not public for everyone.
I recommend to look into the maven-book from Sonatype.
If this don't help, please edit your post and insert your POMs.
Here is a good reference for building multi-module project from Maven into one war file.
The war file can be deployed via jboss-maven plugin.
Related
Some background:
I have copied the master branch of an external github repository, not owned by me, into a personal repository
This repo contains a Java project and uses Maven for building and compilation
The group ID defined in all pom.xml files is org.mylibrary (let's assume)
When deploying to Artifactory, the deployment is done to myrepo/org/mylibrary/...
I'd like to deploy instead to:
myrepo/org/myorganization/mylibrary
but I would like to avoid editing all the pom.xml files, and replacing all lines containing:
<groupId>org.mylibrary</groupId>
with:
<groupId>org.myorganization.mylibrary</groupId>.
I'm configuring the deployment via the distributionManagement element:
<distributionManagement>
<repository>
<name>releases</name>
<id>deployment.credentials</id>
<url>https://artifactory.lab.myorg.org/artifactory/myrepo</url>
</repository>
</distributionManagement>
What's a clean way of solving this? Replacing the groupId definition in all pom.xml files does the trick, but, as said, that's something I want to avoid.
Thanks!
When deploying to any repository, Artifactory utilizes the layout that is configured for this repository. By default, for Maven repositories, Artifactory uses the "maven-default" layout.
I would recommend you to first add your requested layout and then configure your repository with the newly created layout.
I hope this information is found helpful.
I have a SpringBoot Maven project. I am dependent on another set of libraries. Currently am pointing to their repository path , downloading it to .m2 repository and using.
But the repository website is not reliable. SO I wanted to package the dependent libraries as part of JAR in the resources folder.
After putting the jars in resource folder. How can I get references of the Types/libraries ?
Currently:
<dependencies>
<dependency>
<groupId>org.dcm4che</groupId>
<artifactId>dcm4che-core</artifactId>
<version>5.23.1</version>
</dependency>
</dependencies>
<repositories>
<repository>
<id>www.dcm4che.org</id>
<name>dcm4che Repository</name>
<url>https://www.dcm4che.org/maven2</url>
</repository>
</repositories>
You can put all your libraries in a single folder either in your project or in some folder in your local. You can then add them to your maven POM.
Lets say you put all your jars in a folder called libs in your base project directory. You can then add something similar to the below in your maven POM.
<groupId>com.abc.xyz</groupId>
<artifactId>my-artifact-id</artifactId>
<version>1.0.0</version>
<scope>system</scope>
<systemPath>${basedir}/libs/my-jar-name.jar</systemPath>
You need to use the scope system. Excerpt from Maven website,
Scope : system - This scope is similar to provided except that you
have to provide the JAR which contains it explicitly. The artifact is
always available and is not looked up in a repository.
Maven Documentation
If you read further, it also mentions that this has been deprecated. So, its a nice quickfix or a hack but then the best thing would be to set up a repository manager as suggested by others.
I have Mule Project "A" which refers a Domain Project "X". I would like to run my MUnits for Project "A" in Jenkins but it fails as it's unable to find the dependency Domain project "X".
To resolve this I added the "dependency" for domain project"A" in, project "X" pom. xml. But no luck.
Please give me details how it can be resolved to run my MUnits ion Jenkins as a post-build action.
Thanks,
Ikram
to be able to do that I had to:
First, add the domain dependency in your pom with "test" scope
<dependency>
<groupId>com.mygroupid</groupId>
<artifactId>mule-domain-id</artifactId>
<version>1.0.0</version>
<scope>test</scope>
<type>zip</type>
</dependency>
Second, you have to install the domain artifact in one artifact repository (Nexus for example).This way, the dependency is accessible from Jenkins. And then add that repository to your pom.xml
<repositories>
<repository>
<id>alm-nexus</id>
<name>ALM Nexus Repo</name>
<url>https://nexus.alm.corp/repository/maven-public</url>
<layout>default</layout>
</repository>
</repositories>
One important thing when runing MUnits in Jenkins is the following. The root folder name has to be exactly the same as the artifactId, so in Jenkins you have to set the workspace with a custom one
If using a Jenkinsfile you can do this with the following:
customWorkspace
"${env.JOB_NAME}/${env.BUILD_ID}/artifact-id-has-to-go-here"
With these steps we are able to have a working pipeline with MUnit testing as one of the stages.
As per this below snapshot, I see list of packages for hibernate:
I regularly see update index activity by m2e plugin(maven) in eclipse, for which I have no clue, What does it mean?
Where are these packages fetched from and displayed?
What is groupId/ArtifactId? Why can't one just say package/class instead?
Where are these packages fetched from and displayed?
By default, Maven will download from the Maven Central Repository, which is located at this URL: http://search.maven.org/
You can also add a custom repository by using the <repository> tag. Here is an example of how you can add the JBoss repository to your Maven project:
<project>
<repositories>
<repository>
<id>JBoss repository</id
<url>http://repository.jboss.org/nexus/content/groups/public/</url>
</repository>
</repositories>
</project>
Maven will download the artifacts when it needs them. So doing an mvn update or mvn install would trigger Maven to go to the repository if it doesn't already have the necessary JARs locally. And the local folder where the JAR files gets stored is C:\Users\your_windows_user\.m2\repository by default.
What is groupId/ArtifactId? Why can't one just say package/class instead?
Maven operates by managing dependencies, which are individual JAR files. So if you need to use a class, Maven will pull in the entire JAR file containing that class. The main reason for this is that Java libraries typically ship as JAR files, not individual classes.
I'm new to OSGi and Amdatu and I'm using OSGi with Maven.
Usually I import bundles like this
sudo mvn pax:import-bundle -DgroupId=org.eclipse.jetty.osgi -DartifactId=jetty-osgi-boot -Dversion=9.1.3.v20140225
In upper case importing works great because the bundle can be found in maven central repository.
But there is no amdatu bundle in maven central repository, so I tried to add amdatu repositories in pom.xml.
<repositories>
<repository>
<id>dependencies</id>
<name>Amdatu Dependencies</name>
<url>http://repository.amdatu.org/dependencies/</url>
</repository>
<repository>
<id>snapshot</id>
<name>AmdatuSnapshots</name>
<url>http://repository.amdatu.org/snapshot/</url>
</repository>
<repository>
<id>release</id>
<name>AmdatuRelease</name>
<url>http://repository.amdatu.org/release/</
</repository>
</repositories>
I can see added maven repositories in Netbeans, however when exploring any repository I get the message <No result, processing index...>
If I open the link in browser I can see the repository with index.xml file.
So I tried to install a jaxrs bundle and no luck.
sudo mvn pax:import-bundle -DgroupId=org.amdatu.web.rest.jaxrs -DartifactId=org.amdatu.web.rest.jaxrs -Dversion=1.0.4
What am I doing wrong? How can I use maven amdatu repository and import bundles?
Thank you!
What you're doing wrong is assuming that the Amdatu repositories are Maven repositories. They are not. They are in fact OSGi Bundle Repositories, and we provide an index in both the "old" (repository.xml) and "new" (index.xml) format.
Within the Amdatu project, we don't use Maven, we develop with Bndtools, so you would have to provide the proper metadata (pom.xml) yourself and then import the bundles into your own Maven repository. If someone would contribute a tool to automatically generate the proper metadata and/or upload artifacts in Maven central, we would be happy to accept that though.
Marcel, thank you for your help.
I have downloaded all bundles and install them in local maven repository with next command.
mvn org.apache.maven.plugins:maven-install-plugin:2.5.1:install-file -Dfile=path-to-your-artifact-jar \
-DgroupId=your.groupId \
-DartifactId=your-artifactId \
-Dversion=version \
-Dpackaging=jar \
-DlocalRepositoryPath=path-to-specific-local-repo
I saw that you already found a way to automatically generate pom.xml with BND Tools.
https://amdatu.atlassian.net/browse/AMDATU-712