Getting oracle JDBC jar from from Nexus with gradle - gradle

I seen this question but nothing seemed to help. I will do my best to make the answer better and hopefully show a solution.
In my build.gradle under dependencies I have:
compile files('oracle/ojdbc7-12.1.0.2.jar') where I was manually placing the jar in the directory.
What I am doing now is trying to pull it from nuxus.
I my local gradle.properties I added my username and password but it pulls ALL dependencies and is not able to get them all from nexus and fails. I want to just pull one jar (jbdc) with gradle build.
Error is here:
> Configure project :api
init.gradle/NexusRepositoryPlugin: MavenRepo at https://repo.maven.apache.org/maven2/ removed.
init.gradle/NexusRepositoryPlugin: __plugin_repository__Gradle Central Plugin Repository kept (not a Maven repository).
init.gradle/NexusRepositoryPlugin: MavenRepo at https://repo.maven.apache.org/maven2/ removed.
init.gradle/NexusRepositoryPlugin: BintrayJCenter at https://jcenter.bintray.com/ removed.
* What went wrong:
Could not resolve all dependencies for configuration ':api:detachedConfiguration1'.
> Could not resolve org.springframework.boot:spring-boot-dependencies:2.0.1.RELEASE.
Required by:
project :api
> Could not resolve org.springframework.boot:spring-boot-dependencies:2.0.1.RELEASE.
Advice?

My understanding of the question indicates that you are replacing the public repository declaration with a private one that contains only that JDBC jar.
You should instead leave the public repository declaration and add the private one. Gradle will then search for the JDBC jar in both the first time and retrieve it.

Related

Gradle artifactory plugin not resolving JAR dependencies

I am upgrading my build to Gradle 7.4.2 running with Java 11 and use Artifactory as my repository. I am using the latest Gradle Artifactory Plugin and my builds are failing to resolve JAR dependencies now.
In Artifactory I'm using a virtual repository to resolve dependencies like Apache Commons Text as well as my own local collection of JARs that I've deployed to a separate Artifactory repository that is connected to the virtual repository.
My build was resolving my JAR dependencies fine under Gradle 5.6.4/Java8. Now my build fails with errors like this.
Resource missing. [HTTP GET: https://artifactory.myco.com:443/artifactory/collective-gradle-virtual/com/myco/a/myjni/2.5-AABBCC/myjni-2.5-AABBCC.pom]
Resource missing. [HTTP GET: https://artifactory.myco.com:443/artifactory/collective-gradle-virtual/com.myco.a/myjni/ivy-2.5-AABBCC.xml]
The final build error message said something similar:
> Could not find myco.com.a:myjni:2.5-AABBCC.
Searched in the following locations:
- https://artifactory.myco.com:443/artifactory/collective-gradle-virtual/com/myco/a/myjni/2.5-PH44157/myjni:2.5-AABBCC.pom
- https://artifactory.myco.com:443/artifactory/collective-gradle-virtual/com.myco.a/myjni/ivy-2.5-AABBCC.xml
Required by:
project :MyJAR
Is there some change between Gradle/the Gradle Artifactory Plugin/Java 11 such that the build can no longer resolve JAR artifacts?
I even tried creating a myjni-2.5-AABBCC.pom file and deployed it to the same path as the JAR. That fails too because the repository has the JAR and POM in com.myco.a and the resolver is looking for it in com/myco/a.
I also changed my dependencies to append #jar at the end in the hopes that would change the resolver behavior. It did not.
My dependency looks like this:
dependencies {
implementation 'com.myco.a:myjni:2.5-AABBCC#jar'
}
My artifactory block is this:
artifactory {
contextUrl = "https://artifactory.myco.com:443/artifactory"
resolve {
repository {
repoKey = 'collective-gradle-virtual'
username = "${artifactoryUser}"
password = "${artifactoryKey}"
maven = true
}
}
}
Update 1
I discovered that even though my existing setup worked fine before the upgrade, for some reason now, it requires a POM file to exist with the actual JAR. I also suspect that the use of dots in the group name is causing problems with locating the POM file. So I'm renaming those groups to not have dots.
UPdate 2
I restructured my repository to change the dotted group name in the repository to a maven-style directory tree and added a POM for each dependency. Now the dependencies resolve, but I don't understand why the behavior changed when I upgraded Java, Gradle and the Gradle Artifactory Plugin.

In gradle, a maven artifact without a pom file works from jcenter but not mavenCentral

I have a Java project using gradle that uses some very old dependencies. One of them has a transitive dependency that works fine with jcenter() but now fails when I try to migrate to mavenCentral(). The artifact exists in Maven Central but has no pom file. Gradle gives me an error like this:
> Could not resolve all files for configuration ':myproject:compileClasspath'.
> Could not find woodstox:wstx-asl:3.2.7.
Searched in the following locations:
- https://repo.maven.apache.org/maven2/woodstox/wstx-asl/3.2.7/wstx-asl-3.2.7.pom
Any attempt on my part to browse the jcenter repository returns a 403 Forbidden so I can't tell if the pom file exists there but somehow Gradle is able to build the project using jcenter().
That leaves me with a few questions:
Are pom files required in (very old) maven artifacts?
How does gradle gain access to https://jcenter.bintray.com/?
Is there any way to find out if the jcenter artifact has a pom file?
If it doesn't have a pom file, why does gradle work with jcenter() but fails with mavenCentral?
Thanks in advance for any help!

Gradle Build issue while using remote repository

Issues which I am facing are related to gradle build. I would like to explain what I am doing.
I created a remote repository on a remote server and I am able to access it from browser (the shared folder under which I have kept some dependency Jars).
Now I want to use that remote repository in my build.gradle (like a remote maven repository) and so I added snippet like this:
apply plugin: 'maven'
repositories{
maven {
//URL of the remote repository
url "http://IP:Port/SharedPath"
}
}
dependencies {
//Dependencies which are there in remote repository.
compile group: "GroupName", name: "DependencyName", version: "Version"
compile group: "GroupName1", name: "DependencyName1", version: ""
}
When I am running gradle build, I am getting error message like this:
FAILURE: Build failed with an exception.
* What went wrong:
Could not resolve all dependencies for configuration ':compileClasspath'.
> Could not find :cachedb.jar:.
Searched in the following locations:
http://IP:Port/SharedPath/GroupName/DependencyName/Version/DependencyName-Version.pom
http://IP:Port/SharedPath/GroupName/DependencyName/Version/DependencyName-Version.jar
Required by:
:site-export-tool:unspecified
> Could not find :cachejdbc:.
Searched in the following locations:
http://IP:Port/SharedPath/GroupName1/DependencyName1//DependencyName1-.pom
http://IP:Port/SharedPath/GroupName1/DependencyName1//DependencyName1-.jar
Required by:
:site-export-tool:unspecified
I don't understand why it is searching the file at the path: url / GroupName / DependencyName / Version / DependencyName-Version.jar
While it should check for the jar at the path in URL only and not under some folder structure on the name of GroupName and DependencyName and so on... or simply say, I dont want to pass GroupName (it is possible?)
Please NOTE: I tried this also:
compile files ('lib/DependencyName-Version.jar',
'lib/DependencyName1.jar')
Please be notified that, When I am keeping those dependencies in my local system and defining them in flatDir, I am NOT facing any issue in that case.
I am trying to use remote repository because we in our organization want to use a centralized location.
Please let me know if I need to do anything with gradle configuration or gradle version which I am using (gradle 2.13) or anything in build.gradle only, I dont understand what is wrong which I am doing here. Stuck from past 2 days :-(
Thanks a ton in Advance!
This is because gradle expects standard maven repository structure when you use maven {url ".."}, which is
/$groupId[0]/../${groupId[n]/$artifactId/$version/$artifactId-$version.$extension
See https://cwiki.apache.org/confluence/display/MAVENOLD/Repository+Layout+-+Final
Either follow that structure or you can try using Ivy repository with custom layout.
https://docs.gradle.org/current/userguide/dependency_management.html#sec:defining_custom_pattern_layout_for_an_ivy_repository

Missing artifact in pom.xml

I'm facing a problem in the pom.xml. It is showing the below error. I'm trying to update maven by adding the required dependencies but unable to solve the issue .
Resource Path Location Type Missing artifact org.springframework.security:spring-security-web:jar:4.2.2.BUILD-SNAPSHOT pom.xml /spring-security-samples-xml-insecure line 171 Maven Dependency Problem
SNAPSHOT dependencies are not retrieved by default. If you really need that specific version you will need to add the spring snapshot repository to maven. Usually one relies on released versions only: maven central
The version you are looking for is in the spring snapshots repository.
The maven manual describes how to work with multiple repositories. Usually people use a repository proxy like Nexus or Artifactory to simplify this.

Maven WAR Plugin / Jenkins repository connector: Omitting transitive dependencies?

Situation
I have a multi-module Maven project. In it, I have several JAR artefacts, it then gets assembled as a WAR file. Thus, the WAR artefact depends on all kinds of JAR artefacts (it also has a WAR overlay), most of them with scope "compile".
Build and deployment to a repository are fine. But when I try to retrieve the WAR artefact, I have issues. previously, I used a simple wget to retrieve it from the Nexus API, but I wanted to try the Jenkins Repository Connector - not the least reason being that it actually shows a list of available versions.
I configure a repository in
Manage Jenkins -> Configure System -> Artifact Resolver
with the URL for our repo:
http://$NEXUS/nexus/content/repositories/releases/
then in the job, i add a parameter:
Maven Repository Artifact
and use the repository configured above, then i add
Artifact Resolver
as a build step and set it up.
Problem
I am not even sure on which side this should be solved: When I run the job to try to get the WAR file from the nexus, it also starts trying to retrieve all kinds of transitive dependencies (some of which are unaccessible to this user) and fails. What I need is just the WAR file. No transitive dependencies (since they're already packaged in the WAR).
The Repository Connector plugin doesn't seem to have a switch for this, and the Maven side it's probably perfectly OK to include those dependencies in the output POM.
Question
What can I do to either stop the repository connector from retrieving transitive dependencies or retrieve the WAR artefact in a different way? Also interesting for me (but a bit broad as a question) would be general ideas about doing this kind of workflow. E.g., does anyone use other ways of deploying the WAR into their Nexus?
i submitted a patch to the repository connector plugin.
my fork:
https://github.com/rmalchow/repository-connector-plugin
working on getting it to be merged:
https://github.com/jenkinsci/repository-connector-plugin/pull/10

Resources