Using Proxy with Gradle when accessing certain maven repositories only? - maven

I have a custom maven repo where I host some private maven repositories. In order to access the repository it requires a username and password, and also it requires connection through a proxy.
The problem is, I don't want ALL my gradle traffic going through this proxy. Is there a way to configure it so that only for specific repositories it will go through the proxy?

Proxy configuration in Gradle happens via standard JVM system properties (http.proxyHost etc.). As such there is no way to configure a proxy for a specific repository.
PS: Maven repositories are best hosted on a Maven repository server/service (Artifactory, Nexus, Bintray).

Related

External Custom library for Gradle project

I am building a SpringBoot application in which i want to handle some of the cross cutting concerns like logging, caching, persistence in to a project on its own so in future other rest spring boot components can adopt it and use it as a dependency.
I am using Gradle for dependency management. My question is :-
How can i manage this concerns without publishing it to the public artifactory.
If i have to publish then which is the free artifactory i can use for my development practice
If creating jar is an option as a temp solution then how can it be achieved via gradle. Most of the examples over the internet is for creating the executable jar files.
What are the other options i can try.
How can i manage this concerns without publishing it to the public artifactory.
Publishing has to happen regardless where it will be published to. You can use a private solution such as Nexus Repository.
If i have to publish then which is the free artifactory i can use for my development practice
For development, you can simply publish to your local Maven repository. This is typically ~/.m2. Using the Maven Publish plugin, you can easily publish locally by invoking the publishToMavenLocal task.
If creating jar is an option as a temp solution then how can it be achieved via gradle. Most of the examples over the internet is for creating the executable jar files.
Since you're creating a Spring Boot library, use the Java Library plugin to create the JAR artifact and in combination with the Maven Publish plugin to publish.
In the end, there are 2-3 key components that get published when using Gradle:
JAR artifact
pom.xml: https://maven.apache.org/pom.html
Gradle Module Metadata: https://docs.gradle.org/current/userguide/publishing_gradle_module_metadata.html

How can I specify in pom.xml a dependency to a project in a repository?

I have a project working on my Spring Tool Suite. Also, I have a project in an innersource repository that I want to use in my project of STS.
For that, I need to specify the dependency in the pom.xml file of my project to establish the dependency with this remote project. But I don't know how to specify this dependency and what information about the remote project I need to put in the pom and where I can find it.
At least I need what information I should write in the pom and I will look wherever for that information.
Thank you so much for your help!
A best practice is to use your own / company wide Maven Repository Manager such as Nexus and define a single repository group.
Use this Maven Repository Manager to share closed source artifacts (hosted repository) and to access Open Source repository such as Maven Central (proxy repository).

Adding external private jar to Openshift Application

I want to deploy a Java & Maven micro services application on OpenShift however I have one small issue. These micro services are dependent on a commons project
containing some common components.
How can i add the jar of the commons project ( private jar, not on public repo) to the class path of the micro services about to be deployed on Openshift?
When building the application locally we used a maven plugin which would move the jar of the commons project into the local maven repository, from where it was easily referenced via a dependency tag in the pom file.
Here are some approaches that I thought about:
use an internal maven repository
create a folder on the root of the project and use it as a local maven repo, declaring it via repository tags in the pom files
deploy a nexus repository on the Openshift cluster
The first approach is not viable since our company does not have an internal maven repository.
We also tried the third approach , however we did not manage to deploy a running nexus repo on Openshift.
The only viable solution left is the second one, however I am a little bit reluctant to implement it since it does seem to be the standard way of doing things. What approach would you reccommend?
create a folder on the root of the project and use it as a local maven repo, declaring it via repository tags in the pom files
This won't be a good approach TBH.
My recommendation would be using a nexus/jfrog etc. repo OpenShift internal or externally (a more recommended approach for enterprises) and get the commons and other libraries from that repo via defining maven dependencies.

how to use command line to deploy a war to gcp

I know we can use the maven plugin to deploy the application to GCP. E.G
mvn appengine:deploy
But for certain reason, I would like to deploy the application not from the source code, but from artifacts repository (like Nexus).
What I want to do is to fetch the war from Nexus and use some command line to deploy the war to GCP. Anyone know how to?
I didn't find a way to do it but if you are interested in such functionality, you can use Cloud Source Repositories, which provides private Git repositories hosted on GCP.
You can use them to deploy in App Engine and even automate the process.
If you need to specifically use Nexus, you could file a feature request for App Engine.

Have a proxy repository in bintray from another repository

I try to find out if it is possible to have a private maven repository (nexus, artifactory) run on the net to be proxied to my bintray account. Anybody did this or is aware of such functionality?
Artifactory provides you with the ability to proxy Bintray repositories using Remote Repositories, so the short answer is yes.
The longer answer is that both Bintray and Artifactory were made by the same company, so they are a perfect match for each other.
Artifactory can proxy any type of repository from Bintray (not just Maven) and also provides extensive integration for achieving the opposite direction (i.e. publishing Artifacts to Bintray from Artifactory) using Distribution Repositories.
You can read more about the various Bintray integration options Artifactory provides here.

Resources