Can we use Maven Dependency in Gradle Project Remotely - maven

I am trying to host maven Dependency basically which I can use in Some other Gradle project.
I have also try this locally but I want to do it remotely.
I also try to do this in some other manner - I just host one jar file in tomcat server and tried to download in my gradle project.
"http://10.10.177.157:8080/face_rec/images/jmf-2.1.1e.jar" this is the hosted jar path in which we can eaisly download jar file by hitting this ulr.And "C:/Users/USERNAME/.m2/repository/commons-io/commons-io/2.2/commons-io-2.2.jar" this is my local .m2 repository.
In this gradle project I can easily download the jar files using compile files ("C:/Users/USERNAME/.m2/repository/commons-io/commons-io/2.2/commons-io-2.2.jar") but I am not able to download hosted jars i.e - http://10.10.177.157:8080/face_rec/images/jmf-2.1.1e.jar
Can someone give me any idea about this that how can it is possible.
thanks

Related

Gradle init using corporate maven repo

I am trying to convert a maven multi module project to a gradle project using gradle init. I am using a corporate maven repository and am not allowed to download artifacts directly from the internet. I need to route all requests through the corporate maven repo.
I am using Windows 7. I tried adding a init.gradle script in the .gradle folder under my user home directory. However when I try the command gradle init, it detects the pom, asks to convert, but then fails in resolving the dependencies.
Can somone help?

creating spring boot project without maven

I am working recently with spring boot framework
my problem is that I need to set up to environment in a device that has no internet
I have searched A lot but all I found is using maven that will handle the processes of downloading all the dependencies
put I need to add the required dependencies like the old way when you download the jar files and add them to the class-path
is there a way to do so with STS
or is there a way to change where the maven download the dependencies to be from local instead of internet
Never used STS but I assume it uses maven/gradle under the hood.
You can set up local repository and point maven/gradle to it. For example you could use Nexus:
https://www.sonatype.com/products/repository-oss
Another way is to pull dependencies (they get downloaded when you do maven or gradle build and are saved under ~/.m2 or ~/.gradle directories), then copy your ~/.gradle or ~/.m2 directory to the PC with no internet and build offline. With gradle it looks like this.
./gradlew build --offline

Cannot every time use internet for downloading spring-boot-starter-parent-2.3.3.RELEASE.pom from central

Is there any mechanism that if i keep all the pom dependencies locally at some path that everytime it gets picked from that path when i run Spring Boot app from command line?
Example: Everytime i dont't want to donwload the pom dependencies from repository as below and want to keep somewhere locally for use.
Downloading from central: https://repo.maven.apache.org/maven2/org/springframework/boot/spring-boot-starter-parent/2.3.3.RELEASE/spring-boot-starter-parent-2.3.3.RELEASE.pom
I feel your question is a bit strange because it describes the main feature of maven.
When building a project with maven, all the dependencies required by your project are downloaded into a local repository. Future builds won't download again those dependencies.
When running a springboot application using maven, the downloaded dependencies are provided to the application's classpath so they aren't downloaded again.
When running a packaged springboot application, the dependencies are already inserted in the springboot fat jar so they aren't downloaded again.
Another point, if you want to ensure maven does not download anything you can execute maven in "offline mode" using the following parameter "-o"

Spring Boot Maven build offline when machine has no internet connectivity

I'm working on a Spring Boot project that uses Maven. The problem is that I need to build the application as a Jar on a machine that doesn't have internet connectivity.
I have tried downloading all dependencies and copying across my .m2 folder from my Mac over to the machine with no network, but Maven still won't build the project, as it throws up an error such as this;
mvn -o package
Non-resolveable parent POM for com.domain.visualisation: Cannot access central https://repo.maven.apache.org/maven2 in offline mode and the artifact org.springframework.boot:spring-boot-starter-parent:pom:2.0.4.RELEASE has not bee downloaded from it before.
Is there a way to get this working without internet connectivity?
If You are sure all the dependencies are inside your local m2 folder, _remote.repositories files might be the reason for this error. Search and remove every _remote.repositories file inside local m2 folder and try your build again.

How to download maven dependencies from Jenkins without a binary repository

Are there any plugins or ways to download the dependencies for a maven project from Jenkins? I am using Jenkins for a multi-module desktop application. Although I know I could just archive all dependencies, I don't see why there isn't the ability to download dependencies using maven which installed on the same machine as Jenkins. Preferably one would specify the location of a pom and then have the ability with one click to download all the dependencies for that pom. Can you do this? I do not need or want an entire binary repository for this feature.
Edit: I will try and rephrase this as I don't think people are understanding.
In Jenkins one has the ability to archive artifacts at the end of a build. Also in jenkins you have integration with maven. When building a jar in maven you have arguablly 2 options:
You can either use the assembly plugin which zips all .class files
together with those produced from your source code resulting in 1 jar
You can create a jar just source code which references all
dependency jars which are located in a separate folder.
In Jenkins one also has the ability to download the latest artifact. Now if I am using Option 2, I can either archieve just the jar which my sources produced, which I would say is more desirable for space and is the whole purpose of the archive functionality, or you can also archive the libraries too.
Here is the PROBLEM!! If I don't archive the libraries then I cannot easily run this jar, as it is a desktop application and its dependencies cannot be obtained in the same mannor as clicking on a link from jenkins. So lets say my question is what is the easiest way to obtain them? Extra info: assume jenkins is running as a server and you can't use artifactory or another server application, that seems to me to be massive over kill.
Use the maven plugin and create a maven job for your project. Jenkins will then use the maven command you provide in the job configuration to build the project. This means maven will download the projects dependencies and store them on the machine jenkins is running. Normally this would be <JENKINS_HOME>/.m2/repository. This way you get a local repository that only contains the dependencies of the projects you created maven jobs for.

Resources