Get the library via dependency code using bash command - gradle

I'm trying to make a library for projects using gradle and maven.
To test that if it is possible for the gradle to download it via the dependency code in the bintray, I need something like a bash command to see if the request gets the file from bintray or not.
TL; DR
Is there a terminal command for gradle to get a dependency like
./gradlew dependecies 'com.example.lib:module:2.0.0' ?

Download it's .pom file
You can download the library pom file from maven. All the library dependencies are in a pom file. Gradle uses this file to fetch the dependencies

Related

What is the command line approach to download a bunch of jars using maven without POM?

I am using maven and trying to download a bunch of jars.
I donot want to generate the POM file so i am using the below command
mvn dependency:copy -Dartifact=<group>:<artifact-name>:<version> -DoutputDirectory=./localdirectory
How can i use a similar command in maven to download a bunch of artifacts without the POM file?
Any examples using artifactItems would help
The below code snippet does not work
mvn dependency:copy -DartifactItems='com.google.guava:guava:18.0','com.fasterxml.jackson.core:jackson-databind:2.4.3' -DoutputDirectory=./localdirectory

Download dependencies from url and extract to a folder using gradle

I am a gradle newbie. I see that gradle supports maven and ivy out of the box, however I have a need where the dependency for a java project is to be downloaded from a url. The dependencies are actually jar files which are zipped, I also need it to be extracted.

Gradle trying to unzip a pom typed dependency

In a project of mine I have a dependency on a java matrix library MTJ which I specify like this in build.gradle:
dependencies {
...
compile 'com.googlecode.matrix-toolkits-java:mtj:1.0.4'
...
}
MTJ in turns depends on netlib, more concretely it would be the equivalent of explicitly adding compile 'com.github.fommil.netlib:all:1.1.2' above.
When I run the gradle build. I get the following error:
Could not expand ZIP '/Users/valentin/.gradle/caches/modules-2/files-2.1/com.github.fommil.netlib/all/1.1.2/f235011206ac009adad2d6607f222649aba5ca9e/all-1.1.2.pom'.
archive is not a ZIP archive.
So somehow gradle is confused and treats the file as been a zip file when it is just a pom that points to other dependencies.
Anyone has a fix or knows of a workaround?
Please have a look here. The dependency you specified is of type pom - this type in maven is used to aggregate projects. Gradle downloads it, tries to unzip and fails. It seems that this is not what you're looking for.
Here you can find other artifacts for group: com.github.fommil.netlib. Please find a jar you're looking for and specify the dependency directly.

how to I pack external tools in the package during maven build

I have an existing mvn project which build into a zip file at the end.
now I need to add an external tool to it, the tool is already a single executable so I just need to include it in the final package.
what is the right way to do this?
Thanks,
There are three steps to follow:
Upload your artifact/tool to a maven repository, e.g. on your local maven repository server (Archiva/Artifactory/Nexus etc.)
Use the Maven Dependency Plugin to download your artifact/tool to your project target directory where you assemble your zip file
Use the Maven Assembly Plugin to assemble your zip file

What is the most common way to unpack a jar file after jenkins maven build?

I am new to maven and Jenkins so I do not know what is the most common way to extract the JAR file build by maven in the same Jenkins job.
Running mvn install in a Jenkins job outputs the file /home/user/.jenkins/workspace/$JOB_NAME/project/target/package-2.0.0.jar.
I want to extract it to some directory like /opt/project and call /opt/project/script.sh.
I thought of a post-build shell script calling jar -xvf <path>/package-2.0.0.jar but how to get the version number (2.0.0) then? Maybe there is a maven goal to do this?
define that artifact as a dependency in some other module (the module that will run the shell script) and use the dependency plugin to unpack it
that would mean you'd have (at least) 2 modules in your maven project - one that produces the jar, and the other that does something with the artifact produced by the 1st.
if that doesnt fit your need you could bind the unpack after the install phase (the artifact makes it into the local repository at the install phase, and the dependency plugin only deals with artifacts from the local repository) and do it there.
if youre still not satisfied you can get the artifact name in a maven pom.xml file by using ${project.build.finalName}. the default is ${artifactId}-${version} as you can see here (look at the super pom). if you need it with the suffix it'll be something like ${artifactId}-${version}.${packaging}
if you are running on linux based systems something like
jar -xvf `ls <path>/package-*.jar`
will do the job.

Resources