how to upload (mvn deploy) jar from local gradle cache to GCP artifact registry - maven

The goal is to have all Java builds done using GCP's CloudBuild, and to have all dependent jars stored in GCP's artifact registry, and configure the Gradle build to use the GCP artifact registry (configured for Maven) instead of the Maven Central repo. When I run mvn deploy and specify a jar file (store on the filesystem is the local gradle cache), it fails because it can't find the pom file (which is inside the jar) - Will mvn deploy try to look inside the jar for a pom file? If not, is there a solution for moving 3rd party jars (with the POMs inside the jar) to a GCP artifact registry? Thanks for any time and guidance you can provide.
I tried several variants and options for mvn deploy, to include not generating a pom, but it always failed

Related

How to download only one jar with pom.xml?

I want to use a project called projectA that I have in a maven repository as dependency of a projectB.
The mvn deploy of projectA is successful (I can see in the repository the projectA-0.0.1-20190902.072951-1.jar, projectA-0.0.1-20190902.072951-1.pom and maven-metadata.xml files), but when I specify the dependency in the pom.xml file of projectB, the project works but it downloads two JARs of projectA from the repository:
- projectA-0.0.1-20190902.072951-1.jar
- projectA-0.0.1-SNAPSHOT.jar and the same issue for every file downloaded by the dependency to this project.
I think that only one JAR is necessary, and I don't know what I need to put maybe in settings.xml or in the pom.xml file of any project to get only one JAR when the dependency is downloaded.
Thank you so much for your help!
In the past it was possible to tell Maven to deploy Non-unique Snapshot Deployments but in Maven 3
... snapshot artifacts will always be deployed using a timestamped version
So:
the files with the timestamps are the one you have deployed to your remote repo (mvn deploy ...) and then downloaded from there as dependencies
the ones with -SNAPSHOT are the result of the local builds (install goal)
If your concern is download traffic - that is not an issue. The -SNAPSHOT ones are not downloaded.
If your concern is disk space then you can have a cron job or use something like Build Helper Maven Plugin to remove old version artifacts from the local repository.

Automated deployment of EAR project without obtain dependencies from a repository

Is it possible deploy an artifact (.ear) into a application server (AS) without obtain its dependencies from a repository?
Let's me explain: the maven project I'm trying to configure for deploy into a AS has 3 modules:
Web (.war - front end)
EJB (.ejb - back end)
Entity (.jar - entities classes)
These modules are wrapped into a EAR module and none of then are available in some repository (like Nexus or JFrog Artifactory). When I try to use Cargo Maven plugin or JBoss Deployment Maven Plugin, both notify that cannot resolve dependencies for these modules.
UPDATED (03/01/2019)
The issue is similar to that quoted in items 6 and 7 of the following link: http://webdev.jhuep.com/~jcs/ejava-javaee/coursedocs/content/html/ejb-basicex-eardeploy.html#ejb-basicex-eardeploy-testmodule
It's a workaround but worked. Instead of the project depends on an internal repository (like Nexus or JFrog Artifactory), it's possible defines a folder as a repository on the local machine using the Maven's parameter -Dmaven.repo.local. Thus, the plugin to deploy the artifact also can use this property and obtaining the others artifacts.
That is, to build the application on the current folder:
mvn -Dmaven.repo.local=. package
To deploy the application (.ear, in this case) using Cargo Maven Plugin, for example, without depending on an internal repository:
mvn -pl app-ear/ -Dmaven.repo.local=. cargo:redeploy
OBS: Using the maven.repo.local property, the folder defined as value will be fill with all dependencies of the project. In my case, it isn't a problem because this commands are been used on a continuous integration pipeline and all files and folder are discard on the final.

Artifactory + TeamCity : How to deploy custom JAR?

I am building a maven project within a Docker container as a TeamCity job configuration.
(This is necessary because the maven project builds a JNA library -- so it must be built on a specific distro)
At the end of running the docker container, I'm left with the target folder of the maven module which contains the JAR & associated other files (i.e. class files etc..)
I'm stumped onto now how to get this JAR published to Artifactory? All the integration with TeamCity seems to be if the JAR was built with the maven runner specifically
Usually, you use mvn deploy to build and deploy an artifact with Maven. It is transferred to the Maven repository that you specified in your distributionManagement.
With Artifactory, you can also use the artifactory-maven-plugin for deployment.

Maven / OSGi: deploying to an OBR which is not the maven repos

My maven build installs artifacts locally and requires access to the project's remote maven repository. I don't have write access to that repository - so my builds (containing my changes) are only local so far.
When I build, I would like to deploy the .jar to a remote OBR which I have control over. This is not a full maven repository (eg. Nexus), just a webserver. A repository.xml describing the OBR should be automatically generated and uploaded.
Simply calling the goal "deploy" will try to upload to the project's maven repo, which fails as I don't have write access.
I want:
build & install locally, getting all dependencies on remote maven repos as required
upload jars to the OBR
generate repository.xml OBR description and upload
How should I configure the maven-bundle-plugin? Which goal must I call?

tycho plugin + maven-dependency-plugin: copy dependencies from local projects instead repositories

Main Goal: deploy a project as jar and eclipse-plugin
current state: project builds fine as jar package
Now i want to create a second project which wraps the jar project as eclipse plugin
use tycho-maven-plugin to create eclipse-plugin
add the jar of the original project (with copy-dependency)
add an Activator
export packages from jar
create correct MANIFEST.MF
i tried to copy the jar with copy-dependencies bound to create-resources. This works as long the jar is found in repository, but the local project gets ignored.
This results in a build failure since the jar is not found.
Is it possible to tell copy-dependencies to take the jar from the target directory of the project? Or should i use some other method than using tycho?
Edit:
I solved my problem with 4 projects:
normal project (nothing special here)
the wrapper project using tycho maven and copy-dependencies.
bound copy dependencies to some goal before compile (e.g. generate-resources). Excluded all artefactid which were set as dependency in the MANIFEST.MF.
a prepare project, which calls the normal project and installs it into the repo. This is needed because the tycho-maven-plugin is bound to validate and it is not possible to call the exec plugin beforehand (at least not easy).
a multi module project which calls the prepare project before the wrapper project.
Build your local project (which artifact was missed) with "mvm install". It will be deployed in your local repository ($USER_HOME$/.m2/repositories). After this dependency should be resolved.
Alternatively you can "mvn deploy" if you have local company maven repository like Artifactory or Nexus.

Resources