Declaring a Maven project dependecy on artefact in an Ivy repo - maven

I have a Maven 2 project and now need to declare a dependency on artefacts which are kept in an Ivy repository.
Is this possible and if so how?

Maven is a rather opinionated framework, so only supports Maven repositories.
Do you have any control over the ivy repository? The best solution would be to migrate it's contents over to a Maven repository manager like Nexus (Artifactory, Apache Archiva are other options).
There are lots of advantages to having a repository manager:
Support for all build clients, Maven, Ivy, Gradle, etc
Ability to search for artifacts
..

I ended up migrating this project to Gradle. By default Gradle uses the same project layout as Maven, so the migration was very simple.
Gradle allows you to declare dependencies across many types of repositories:
Maven
Ivy
Flat file
So you could have some dependencies in a Maven repo, others in an Ivy repo and others in a project lib directory (shock, horror!).
Highly recommended.

Try the Ivy Maven Plugin:
https://github.com/remis-thoughts/ivy-maven-plugin
"A plugin to add apache Ivy dependencies to a Maven project. This is a fork of Evgeny Goldin's Ivy Maven Plugin that fixes support for transitive dependencies."
(Note that the early comments below refer to Evgeny Goldin's Ivy Maven Plugin - looks like this fork fixes the problem I was having).

Related

How to reference local Gradle project from Maven build as dependency?

I have several Gradle library projects and main Ant spring web-app project (historically). I'd like to replace Ant with Maven for main project while keeping existing Gradle projects nature.
Is it possible to refer local Gradle projects from pom.xml as local dependencies of Maven project?
Search readily gives me the opposite - "how to refer maven projects from gradle builds", but not my case.
Gradle always builds locally build/libs (or distributions); the only easy way to share the build dependencies between completely different projects is 'as maven repository dependencies'
in your case the options are
Work Local Builds only
add the maven plugin to the gradle builds - do local install
and refer them in the maven build locally.
Build Anywhere
Your Gradle builds publish artefacts to your local nexus
and you refer them properly in your dependencies
--
Gradle by default does not have 'maven install'; it can be added using the maven plugin see - https://docs.gradle.org/current/userguide/maven_plugin.html#header.

How to include csjdbc.jar as part of maven dependency?

I have been looking for a dependency for csjdbc.jar in Maven repository so that I can build my app using maven and retrieve that jar on the fly. However, I cannot find a dependency in Maven repository related to that jar. Can anyone help, please?
Hopefully you have already resolved this issue.
csjdbc.jar is not listed in maven repositories. If you have composite software installed you can copy the jar from
~\Composite Software\CIS 6.1.0\apps\jdbc\lib
directory to your local machine's maven repository like below with proper versioning:
C:\maven\repository\composite\csjdbc\6.1\csjdbc-6.1.jar
(I have 6.1 jar)

Use a snaphot version of the gradle dependency plugin (... in order to test gradle-3.0Mx)

I stumbled over compatibility issues related to the dependency plugin and gradle-3.0M1. Quickly, people told me this might be fixed in the trunk version of the plugin, but not in the latest release version 0.5.7.
Now I wanted to verify this but didn't find an easy way to use the snapshot version of the plugin. In the end, I
downloaded the plugin source by cloning the git repo
rebuilt the plugin
copied the jar file into a folder
made this folder available as flatDir within my build script
Is there a better way to do this? Is there a public mvn repo for the snapshots?
Publish the plugin to your local maven repo (.m2) using either the older maven plugin or the newer maven-publish plugin.
In the project where you want to use/test the plugin you just build, add mavenLocal() as a repository in the buildscript section of build.gradle.

Add Gradle cache to Sonatype Nexus

Is there an option available to add the Gradle dependency cache to Sonatype Nexus repository so that i can use that cached dependencies for my project later.
The easiest way will be writing a Gradle script, that will exact all the artifacts from Gradle cache using Gradle Artifact Query APIĀ and save them in a Maven layout. Then you can import them to Nexus or Artifactory.

How to use gradle without maven

Is it possible to use gradle without maven?
I ask this question because I've encounered a case where it isn't possible. For example, I have a project(let it be project A) which results in a jar file after the build. This project is used by another project(project B). When I change smth in project A, project B has to see those changes. In maven we could simply make mvn install on project A, then refresh dependencies on project B and changes hapen to be seen there(in project B)
Gradle has an opportunity to use maven plugin which can do the descibed thing. But in that case we rely on maven(maven repo in particular). I was founding information(seems on stackoverflow also) that gradle filestore, which is located in GRADLE_USER_HOME, is only a cache and can't be used for such purpose.
So, how to achieve that functionality in gradle
Thanks
Gradle downloads dependencies from repositories. These repositories can be Maven repositories, Ivy repositories, local Maven repositories or file repositories. So, to solve your use-case, you would indeed have to publish A to a repository, and to use this repository as the source of the A dependency in B.
See the documentation for more details.

Resources