Use Nexus As Dependency Resolver using Gradle in Spring Boot Application - spring

I am developing application using spring boot, i am using gradle as build tool, i want to configure gradle to resolve their dependencies instead of maven central or jcenter go to my Local nexus server get all dependencies from their and build project. I did't found any configuration.

Add your nexus url in build.gradle.
repositories {
// mavenLocal()
// mavenCentral()
// jcenter()
//maven { url 'http://10.9.0.31:8099/repository/maven-public/' }
maven { url 'http://ip:port/repository/maven-public/' }
}
For nexus configuration look at this

Related

How to implement micronaut dependency in grails gradle?

I'm trying to add micronaut dependency in grails build.gradle. And I found no proper solution. And getting the following error.
build.gradle file
dependencies {
*these are the dependencies I would like to add*
// implementation("io.micronaut.reactor:micronaut-reactor")
// implementation("io.micronaut.reactor:micronaut-reactor-http-client")
// implementation("io.micronaut.security:micronaut-security-jwt")
// implementation("io.micronaut.views:micronaut-views-velocity")
// compileOnly("io.micronaut.security:micronaut-security-annotations")
}
I tried adding mavenCentral() and mavenLocal() in the repositories. And it didn't work. Does anyone know how can I implement micronaut dependencies?
Error
grails:test: Could not find io.micronaut.reactor:micronaut-reactor:.
Required by:
project :
You need to tell Gradle what version of the dependencies to pull down.
repositories {
mavenCentral()
}
dependencies {
implementation platform('io.micronaut:micronaut-bom:3.5.2') // <1>
implementation("io.micronaut.reactor:micronaut-reactor")
implementation("io.micronaut.reactor:micronaut-reactor-http-client")
implementation("io.micronaut.security:micronaut-security-jwt")
implementation("io.micronaut.views:micronaut-views-velocity")
compileOnly("io.micronaut.security:micronaut-security-annotations")
}
The Bill of materials (BOM), which contains all the dependency version numbers for the Micronaut Framework 3.5.2 release.

Spring native can't be found

Can't add spring native to an existing project, if I create a new one with spring native selected it works.
org.gradle.internal.exceptions.LocationAwareException: Build file
'/Users/jakob/Documents/worklivery-backend/build.gradle.kts' line: 6
Plugin [id: 'org.springframework.experimental.aot', version: '0.10.4']
was not found in any of the following sources:
Gradle Core Plugins (plugin is not in 'org.gradle' namespace)
plugins{
...
id("org.springframework.experimental.aot") version "0.10.4"
}
repositories {
mavenCentral()
maven { url = uri("https://repo.spring.io/release") }
}
The AOT plugin isn't published to Gradle's plugin portal, it's only available from https://repo.spring.io. You need to add some configuration to your project's settings.gradle file so that it can be resolved:
pluginManagement {
repositories {
maven { url 'https://repo.spring.io/release' }
mavenCentral()
gradlePluginPortal()
}
}
The above matches the configuration from a project generated by https://start.spring.io and adds Maven Central and https://repo.spring.io/release to the plugin repositories in addition to the default Gradle Plugin Portal.

Java Spring Boot project error on download gradle dependency

One of my coworkers recently deleted his ".gradle" directory. He was not able to build the project again, because of the following error:
Caused by: org.gradle.api.resources.ResourceException: Could not get resource 'https://repo.spring.io/plugins-release/com/github/node-gradle/gradle-node-plugin/2.2.1/gradle-node-plugin-2.2.1.pom'.
at org.gradle.internal.resource.ResourceExceptions.failure(ResourceExceptions.java:74)
at org.gradle.internal.resource.ResourceExceptions.getFailed(ResourceExceptions.java:57)
at org.gradle.api.internal.artifacts.repositories.resolver.DefaultExternalResourceArtifactResolver.downloadByCoords(DefaultExternalResourceArtifactResolver.java:138)
at org.gradle.api.internal.artifacts.repositories.resolver.DefaultExternalResourceArtifactResolver.downloadStaticResource(DefaultExternalResourceArtifactResolver.java:97)
at org.gradle.api.internal.artifacts.repositories.resolver.DefaultExternalResourceArtifactResolver.resolveArtifact(DefaultExternalResourceArtifactResolver.java:64)
at org.gradle.api.internal.artifacts.repositories.metadata.AbstractRepositoryMetadataSource.parseMetaDataFromArtifact(AbstractRepositoryMetadataSource.java:69)
at org.gradle.api.internal.artifacts.repositories.metadata.AbstractRepositoryMetadataSource.create(AbstractRepositoryMetadataSource.java:59)
at org.gradle.api.internal.artifacts.repositories.resolver.ExternalResourceResolver.resolveStaticDependency(ExternalResourceResolver.java:244)
at org.gradle.api.internal.artifacts.repositories.resolver.MavenResolver.doResolveComponentMetaData(MavenResolver.java:127)
at org.gradle.api.internal.artifacts.repositories.resolver.ExternalResourceResolver$RemoteRepositoryAccess.resolveComponentMetaData(ExternalResourceResolver.java:445)
at org.gradle.api.internal.artifacts.ivyservice.ivyresolve.CachingModuleComponentRepository$ResolveAndCacheRepositoryAccess.resolveComponentMetaData(CachingModuleComponentRepository.java:378)
at org.gradle.api.internal.artifacts.ivyservice.ivyresolve.ErrorHandlingModuleComponentRepository$ErrorHandlingModuleComponentRepositoryAccess.resolveComponentMetaData(ErrorHandlingModuleComponentRepository.java:138)
And I tried to access the URL 'https://repo.spring.io/plugins-release/com/github/node-gradle/gradle-node-plugin/2.2.1/gradle-node-plugin-2.2.1.pom' directly on browser, and it's now asking user and password.
Did somewone known what's happening? Did this repo was moved to another host?
Thanks in advance.
edit: My gradle repositories:
repositories {
mavenLocal()
mavenCentral()
jcenter()
maven { url "https://repo.spring.io/plugins-release" }
maven { url "https://plugins.gradle.org/m2/" }
}
Looks like you are downloading from a jfrog repository and are missing the gradle.properties file ..
The .gradle folder contains a file called "gradle.properties" which contains the credentials (usually encrypted from the above repo in case of employer controlled repo)to access the jars/poms.
The steps to generate and download :
1.Go to https://repo.spring.io/ and login if you have workplace credentials for accessing the repo.
2.search for "plugins-release" is the "set-me-up" scroller.
3. select Gradle in "tools" drop-down and Generate gradle.properties.
4.download this "gradle.properties" and put it in .gradle folder under the username directory.
switch the order of the last 2 lines under repositories. It becomes:
repositories {
mavenLocal()
mavenCentral()
jcenter()
maven { url "https://plugins.gradle.org/m2/" }
maven { url "https://repo.spring.io/plugins-release" }
}
This way Gradle will resolve gradle-node-plugin from the official Gradle plugin portal (https://plugins.gradle.org/m2/), instead of from Spring's Artifactory (which caches 3rd party artifacts, but you don't really want to fetch non Spring plugins from it).
Also see this answer: https://stackoverflow.com/a/22170251/2591231
PS:
I am assuming that in your build.gradle you apply the plugin "com.moowork.node" as shown here under "Using legacy plugin application", and that the repositories block is inside a buildscript block. Otherwise, your repositories block has no effect on plugin resolution.

Gradle can't find dependency in private nexus repo

I'm having trouble getting gradle to find a dependency I put in my private nexus repo. The dependency is in maven, but I can't seem to get it to find it there either. I did get it into my nexus repo and the location is http://nexus.hq.chris.com/content/repositories/emoji4j/
Could not resolve all dependencies for configuration ':business:compile'.
> Could not find com.kcthota:emoji4j:6.0.
Searched in the following locations:
http://nexus.hq.chris.com/content/groups/public/com/kcthota/emoji4j/6.0/emoji4j-6.0.pom
http://nexus.hq.chris.com/content/groups/public/com/kcthota/emoji4j/6.0/emoji4j-6.0.jar
file:/Users/chris/.m2/repository/com/kcthota/emoji4j/6.0/emoji4j-6.0.pom
file:/Users/chris/.m2/repository/com/kcthota/emoji4j/6.0/emoji4j-6.0.jar
Required by:
Build.gradle snipet
dependencies {
// https://mvnrepository.com/artifact/com.kcthota/emoji4j
compile group: 'com.kcthota', name: 'emoji4j', version: '6.0'
}
buildscript {
repositories {
maven {
url "http://nexus.hq.chris.com/content/groups/public/"
}
maven { url "https://repo1.maven.org/maven2/" }
maven { url "http://nexus.hq.chris.com/content/repositories/emoji4j/" }
mavenCentral()
}
dependencies {
classpath 'com.jcraft:jsch:0.1.54'
}
}
Anyone know how I can get gradle to look in both http://nexus.hq.chris.com/content/groups/public/ and http://nexus.hq.chris.com/content/repositories/emoji4j/ for all my dependencies? I need the http://nexus.hq.chris.com/content/groups/public/ location for other dependencies. I tried adding it in there but I only have read access to that repo.
Another acceptable solution would be to get gradle to look in both http://nexus.hq.chris.com/content/groups/public/ and maven central for it. Any help would be appreciated.
I think you may be confusing dependencies for your build script and application dependencies.
You've configured your build script repositories, but you'll need to also configure your application repositories as well:
// build.gradle
repositories {
maven {
url "http://nexus.hq.chris.com/content/groups/public/"
}
maven { url "https://repo1.maven.org/maven2/" }
maven { url "http://nexus.hq.chris.com/content/repositories/emoji4j/" }
mavenCentral()
}

Is it possible to serve top-level buildscript dependencies using Artifactory?

Here is a sample top-level build.gradle configured with Artifactory:
buildscript {
repositories {
jcenter()
google()
}
dependencies {
classpath "org.jfrog.buildinfo:build-info-extractor-gradle:x.x.x"
classpath 'com.android.tools.build:gradle:x.x.x'
}
}
allprojects {
apply plugin: 'com.jfrog.artifactory'
}
artifactory {
contextUrl = "${artifactory_contextUrl}"
//... standard artifactory plugin auto-generated from web interface
}
I would like com.android.tools.build:gradle:x.x.x and to be served from an Artifactory remote, rather than from jcenter or the Google Maven Repository since these are blocked by a hostile workplace proxy.
However, it seems that the artifactory Gradle plugin is only available after the buildscript closure has been applied. How can I get the other buildscript dependencies to be served from Artifactory?
You can make simple Maven remote repositories to serve the buildscript dependencies. Since these remote repositories simply mirror the public repositories, you can make the access anonymous. This means that at the time for executing the buildscript closure, there is no need for configuring artifactory_user and artifactory_contextUrl.
A sample build.gradle would look something like this:
buildscript {
repositories {
maven {
url "http:///example.com:8082/artifactory/list/jcenter/"
}
maven {
url "http://example.com:8082/artifactory/list/google-remote/"
}
}
dependencies {
classpath "org.jfrog.buildinfo:build-info-extractor-gradle:x.x.x"
classpath 'com.android.tools.build:gradle:x.x.x'
}
}
where google-remote is the name (repository key) of the remote repository mirroring the Google Maven Repository you have configured yourself.
As for configuring the Artifactory remote for the Google Maven Repository itself, the address is simply maven.google.com as per the picture below:

Resources