How to use gradle without maven - gradle

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.

Related

Redirect Gradle project dependency on Maven artifact to another Gradle project

Is there any way to redirect a Gradle project dependency on Maven artifact coordinates to the output of another Gradle project in the same build?
I don’t see the point in having dependencies on things like project(‘:xyz’), since that requires that project :xyz be on my file system & built, and for the referencing project to know that :xyz is also in the same build. It makes more sense to me to have dependencies on Maven artifact coordinates, and to use artifacts built from projects in the same build that specify matching coordinates, instead of downloading the artifact from a repository.
If this functionality exists, or if I were to make it myself, I’d imagine that it would be implemented as an object that can be listed in the repositories closure before all other repositories like mavenCentral().
What you are looking for is composite builds. It will allow you to define that a build includes another build and thus Gradle figures out that a dependency notation group:name:version gets replaced by an included build.
However I would still recommend using the project(:xyz) notation when the projects belong to the same unit, which usually is a single checkout from source control.
You can publish xyz in your local repository.
In the project xyz, use this plugin :
apply plugin: 'maven-publish'
And just run gradle publishToMavenLocal
Then, in the "root" project, use in addition the local repository and use xyz as a regular dependency :
repositories {
mavenLocal()
}
dependencies {
compile('your.company:xyz:1.0.0')
}

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

Adding all jars from a Nexus repo to Leiningen dependencies list

I want to add all jars from the local Nexus repo to a Leiningen :dependencies list. I've added the Nexus repo to the :repositories list in project.clj. Is there any way to add all jars to :dependencies, instead of specifying them one by one?
Thanks!
pom to project
"Java project's lib folder contains lots of jars"
Does this Java project fetch these jars directly from nexus repo (e.g. via pom.xml), because it should.
And if it does, and you just don't want to manually craft project.clj with all these dependencies, you can use something like lein-nevam to convert it to project.clj to start you off.
less dependency, more independency
Does the Clojure library really need all these Java project's dependencies though? Or just a subset of them? As I mentioned in comments, it is always best to narrow down the number of dependencies due to many reasons: code collision, transitive dependencies, version management, compatibility, etc.. rather thаn to "just include them all"
In order to use Nexus you just have to configure Leiningen to use Nexus as the repository. Then you can specify all your dependencies as usual but they will be retrieved from Nexus. This can include components from Central, clojars and any other repo you want to add to the public group.
More details are in the Nexus book chapter about tool config and especially the Leiningen section.
If you then specifiy the dependencies you need in your library (and only those) and publish to Nexus with a pom that specifies these any Java project that uses Maven or Gradle or whatever to build can consume your library and will also get the correct transitive dependencies. Same is if your code was e.g., created with Maven and written in Java.

How does Maven resolve sbt transitive dependencies? Is this Maven at all?

I have a maven project that depends on several sbt project, which in turn depends on more projects. Are these transitive dependencies being resolved by maven? E.g. in packing of assemby jar?
Let me answer this question with mine: How can you know what build tool was used in a dependency?
You can't unless the build tool leaves some files to let you guess what the build tool could have been. But still, they're just files that are generated as part of the publishing process so the other build tools could resolve dependencies.
That's the point of any build tool to let you integrate with the other build systems in a less troublesome way.
Maven requires pom.xml and an appropriate repository layout. sbt follows the rules while publishing project artifacts to Maven repositories.
Ivy requires other files in repositories and sbt does generate them (by default).
Gradle plugs itself in to the game by following Maven's standard files and directory layout.
Read about publish task. You may want to consult the official documentation of sbt. Start with http://www.scala-sbt.org/0.13/docs/Publishing.html.

Maven―Dependencies, static content from remote repository

I am a bit new to maven, but I have some experiences with ant and the build process. I would like to do one thing that is kind of driving me nuts:
Given:
A remote repository (git, svn, hg,…) that holds static content (like images),
one maven project that uses/manages the mentioned repository in the same way as it does with all other dependencies (checkout on install, update whenever updates occur), in other words: the maven project depends on that repository
I finally want to be able to access the content (no *.svn or *.git) and copy it into my build, on build time*.
I want maven to store a local copy of that repository in maven`s local repository (~/.m2/repository) only once on each machine and manage it like all other dependencies.
*I am not trying to build a Java project
Thanks for help!
From what I've seen, Maven projects don't use version control repositories as external artifacts. That's a little too fine-grained for what you want, I think.
I've done something similar, when Project A wanted to use resources from Project B.
Project B, as part of its build procedure, collected it's resources into a ZIP file and deployed the ZIP file into a maven repository.
Project A then references the ZIP file artifact, unpacking it when building to where it needs it.
Look into the dependency plugin for maven, especially the dependency:unpack and dependency:unpack-dependencies goal.
Have fun

Resources