Including a non-Mavenized dependency so it works with maven-shade-plugin - jar

I want to include GData Client, which doesn't use Maven, as a dependency into my Maven project. It ships as a bunch of JAR files.
Additionaly, I use Maven Shade Plugin to build an executable JAR without any external dependencies (with the default configuration, no renaming/including/excluding/transforming of dependencies).
How can I do that?
(Just adding the JARs as resources wouldn't work, since the Shade plugin must extract them).

you want to check the maven docs on installing 3rd party jars
Once installed into your local maven repository, shade should be able to use them like any other dependency.

See this answer if you don't want to install the JARs in your repository for whatever reason: Add a dependency in Maven

Related

Why does Artifactory have both Gradle and Maven repositories?

After evaluating Artifactory for the first time, I find it confusing that when going through the initial setup, and selecting both Maven and Gradle integration, it creates two sets of repositories for me
platform-gradle-dev-local
platform-gradle-release-local
platform-libs-release-local
platform-libs-snapshot-local
While I have used Maven for many years, I am new to Gradle. The mystery to me is, I cannot see any utility in having separate repos for Gradle and Maven builds, and I cannot fathom from JFrog documentation why they do this.
Is there any reason to use the two gradle repos, or can I just use the standard Maven repos for all builds? Gradle, Maven, SBT, etc.
Artifactory Gradle repositories have a different layout than Maven repositories.
The layout used for Gradle repositories is compatible with the one use by the default Gradle Ivy repository layout.
Unless you need to use this repository layout, you should be perfectly fine working with a Maven repository.

How to use external AMP in alfresco Maven Project

I'm trying to use the alfresco-pdf-toolkit addon in my Alfresco Maven project, is there anyway to include the amp in the pom.xml file of my project?
Yes, assuming your project uses the all-in-one archetype of the Alfresco Maven SDK, you can add an AMP dependency as an overlay.
Go look in the repo pom.xml for an example. You'll see something like:
<overlay>
<groupId>${alfresco.groupId}</groupId>
<artifactId>alfresco-spp</artifactId>
<type>amp</type>
</overlay>
Which is how the all-in-one project brings in the SPP dependency. You can add additional AMPs below that.
You must have already run "mvn install" for the AMPs you are depending on so that they are installed in your local Maven repo, or they must be available in some other maven repo that your build knows about.

Unable to find Lucene contrib jar in maven repository

This is probably a very basic question, but I am unable to find Lucene contrib jar in Apache's Maven repository. For e.g. I looked here, but there's only a .pom, there's no jar file, same with repositories mentioned here.
Am I missing anything obvious?
You can download the jars for maven repositories in here: http://mvnrepository.com/artifact/org.apache.lucene/lucene-core/4.4.0
For the contrib package there is a .jar only for the 3.0.2 and not 3.0.3 (don't know why):
http://mvnrepository.com/artifact/org.apache.lucene/lucene-contrib
Also, you can still download de source code and generate the .jar yourself. Should be as easy as running mvn package.
I found out the answer. Except for couple of versions mentioned by Felipe Hummel, there is not single contrib jar. Contrib contains multiple components such as analyzers, highlighters, etc. and each of them have a JAR.

Robolectric 2.x - dependent jars are downloading while running the tests

How will I download all the robolectric dependent jars, to avoid runtime downloading and make it offline? I need to use Robolectric.buildActivity(), which is part of 2.x.x versions.
any idea on this ?
Starting with Robolectric 2.4 they added two system properties to allow you to tell the Robolectric test runner to use local copies of the dependencies. See the Configuring Robolectric page.
The settings are:
robolectric.offline - Set to true to disable runtime fetching of jars
robolectric.dependency.dir - When in offline mode, specifies a folder containing runtime dependencies
One way to figure out which files you need to copy to the dependencyDir, is to run gradlew testDebug -i (or maybe with -d) and watch the output to see which jars are being downloaded at runtime. Then copy them to a known location on your build machine. (Another way to see which files you need, is to look at SdkConfig.java and get the dependency jars mentioned there along with their dependencies.)
For the current Robolectric 3.0-rc2, these are the files it needs:
accessibility-test-framework-1.0.jar
android-all-5.0.0_r2-robolectric-1.jar
icu4j-53.1.jar
json-20080701.jar
robolectric-annotations-3.0-rc2.jar
robolectric-resources-3.0-rc2.jar
robolectric-utils-3.0-rc2.jar
shadows-core-3.0-rc2.jar
sqlite4java-0.282.jar
tagsoup-1.2.jar
vtd-xml-2.11.jar
Copy these files to a known location, like say /home/jenkins/robolectric-files/, and then edit your build.gradle with something like this:
afterEvaluate {
project.tasks.withType(Test) {
systemProperties.put('robolectric.offline', 'true')
systemProperties.put('robolectric.dependency.dir', '/home/jenkins/robolectric-files/')
}
}
Here is how I solved it for org.robolectric:robolectric:3.0
https://gist.github.com/kotucz/60ae91767dc71ab7b444
I downloads the runtime dependencies into the build folder and configures the tests to use it - see setting the system properties.
I had this issue too, and found the cause to be the org.robolectric.Testrunner creating a org.robolectric.MavenCentral object, which declares a Maven repository using an Internet-url (Robolectric 2.3-release). Offline builds will not be able to access that url.
In my case I'm required to use a Maven repository proxy, so I replaced the url pointing to http://oss.sonatype.org with my local Maven repository proxy. That meant subclassing RobolectricTestRunner to org.robolectric.MyRobolectricTestRunner, and creating a custom MavenCentral object for it to use, and overriding the methods where RobolectricTestRunner references its private MAVEN_CENTRAL object.
The source code for RobolectricTestRunner and MavenCentral are available on Robolectric's Github page.
I used Robolectric version 3.0, and the dependency jars were downloaded from my repository, instead of sonatype.

Adobe Flex/AIR Maven integration

I am writing an Adobe AIR application that needs to build in a CI using maven and nexus. I tried to follow this article which is the most up to date article from the source, but I still don't understand these things:
Are the first and second pom.xml examples in the article in the same pom.xml file?
How do I get the Flex SDK dependencies on my CI?
It would be awesome if someone had a complete project setup and went through the whole thing.
This blog has some useful information on building Air applications with Maven 2.
As far as your numbered questions are concerned
Part 1: The two POMs in the tutorial are different. The first creates the swf package containing your application components. The second POM has a dependency on the swf package (note the dependency in the second POM for the artifactId Air in the first). The second POM defines processing to unpack the swf package (using the dependency plugin), then uses the exec plugin to invoke adt on the unpacked package contents.
The process described is therefore in two parts. The first POM packages the swf files so they are available in the repository. The second POM will retrieve any packages required from the Maven repository and invoke adt to compile them. So if you have multiple Air packages, the second POM can be modified to download the extra packages and compile them.
Part 2: Most of the dependencies you need are hosted in the Sonatype public repository, one notable exception seems to be the adt.jar. You can deploy the adt.jar to a Maven repository manager such as Nexus using the deploy plugin's deploy-file goal.
This would deploy the adt.jar to the repository with credentials matching the tutorial:
mvn deploy:deploy-file -Durl=http://path/to/repository -DrepositoryId=[some.id]
-Dfile=adt.jar -DgroupId=com.adobe.flex.compiler -DartifactId=adt
-Dversion=3.3.0.4852 -DgeneratePom=true -DgeneratePom.description="Flex ADT"
To reference the Nexus public repository, add a repository declaration to your settings.xml or pom.xml like this:
<repositories>
<repository>
<id>nexus-public</id>
<url>http://repository.sonatype.org/content/groups/public</url>
</repository>
</repositories>

Resources