How to build a standalone AWS SDK .jar that includes all the dependencies - maven

We are trying to build a standalone .jar (.zip file) that includes all the dependencies based on aws-sdk-java-1.11.86 using maven command line.
The pom file for AWS is quite complex and we are concern changing it or writing or own since it might not be compatible with newer version of AWS.
Does somebody knows how to do it?

The command is:
mvn package
The actual maven target is "aws-java-sdk-bundle".

Related

Maven clean package produces two jars

I packaged my java application using mvn clean package. This produced two jars in my target directory - one is myapp-0.1.2-SNAPSHOT.jar and the other is myapp-0.1.2-SNAPSHOT-sources.jar.
Can someone explain the difference between these two?
If I want to deploy my application to a server which one should I use?
myapp-0.1.2-SNAPSHOT-sources.jar contains all your source code along with your project, during development it is easier to debug when the sources are attached. It is most likely generated by the maven-source-plugin. You will likely find it configured in your pom.xml. When deploying, use the other jar: myapp-0.1.2-SNAPSHOT.jar

Setup maven pom to work with dependencies across environments

I have a Java projects a-1.0.jar with ojdbc.jar dependency and b.jar that depends on a-1.0.jar and ojdbc.jar. I am trying to make it work on my machine, new user machine and a Bamboo server.
Desired behavior:
On local machine git clone <git_url>, mvn clean install, java -jar b.jar project should run. Bamboo should checkout and run project.
On Bamboo: a plan can check out a project and run it. Build should track version of b.jar built and a.jar used.
So far I saw these options:
<systemPath>${project.basedir}/lib/a-1.0.jar</systemPath>: maven warns that it will fail to resolve dependencies
A Perl script to run mvn install for each dependent jar before building the project
(1) defeats the purpose of DevOps automation
(2) makes it unclear which version of a jar was used
(3) installs the jar, but java -jar b.jar fails a.jar is missing
I can overcome this with another Perl script that adds the dependent jars to a classpath
These are basic tasks and as a build tool Maven should be able to do it.
How to tell Maven to three goals below?
(1) For each unknown import - get a jar from lib folder
(2) Make a set of dependent jars. That is don't import ojdbc twice
(3) Pack a self sufficient jar that runs, not fails with "stuff is missing"
Seems like you need to create an executable jar - and for this, you can use various approaches.
One of them is, add maven-shade-plugin which puts all dependencies into single jar, while taking care of potential resource collisions.
Try non-maven-jar-maven plugin. It adds jars that are not in the maven central.

Use Maven to start programs

I apologize if this sounds to simple (or the fact that there are other links that define this problem) - but I'm a complete beginner to Maven and even Java.
All that I'm trying to do is to run this code to see what it does:
https://github.com/semanticvectors/semanticvectors/wiki/GettingStarted
The Wiki says that uses can either download the .jar file or use the maven repo. I downloaded their .jar file and tried to run it but failed. I use this code:
java -jar /home/user/semanticvectors-5.6.jar
That .jar file didn't work for me and from other stackoverflow links, it seems that either the .jar file is not setup properly or I have a non-compatitble java version.
In any case, I've decided to try using Maven to get this running. I've installed Maven using:
sudo apt-get install maven
It seems to be working as everything was successful in setup. But now I'm not too sure what to do after. This Wiki (linked above) as go to this Maven repo site (https://oss.sonatype.org/#nexus-search;quick%7Esemanticvectors). To my understanding (and correct me if I'm wrong) I thought Maven is a super repository for developers and testers to work from the same code, so I thought I could use Maven as an alternative to running to program. Anyways, I'm open to any suggestions to get the program running to see what it does, thanks.
If you're interested in knowing more about me: I'm running a 16.04 Ubuntu system with Java 8.
The idea is that you can either build the JAR yourself - get the source from SVN and build it (using maven commands, as maven is a build tool), or you can use the existing JAR that is already "prepared" and ready for use in the maven-repository (nexus, in this case).
The result should be the same - if you use the JAR as a dependency in your code (add it to your pom.xml) or if you build it yourself.
You can learn more about Maven and things will be much clearer...

Why after compiling/building my AWS sdk jar is only 3kb?

I was previously on 1.6.x and mvn clean install builds wit no issues; end up with a 10mb jar and able to run all my code.
Now I want to upgrade to 1.10.x for the new lambda/apig/ddb support, I changed the version from 1.6.x to 1.10.x.
But after I build with mvn clean install, I see the jar is only 3kb, why is that? Has something changed with the way the AWS sdk works? At least from I've seen, one new way is you can be pick specific services rather than the whole sdk.
Edit:
The 3kb jar has the following:
pom.properties:
version=1.10.66
groupId=com.amazonaws
artifactId=aws-java-sdk
pom.xml, which lists all the aws sdk services
Have you uncompresssed the jar file and looked up what is in that folder? Based on the information in your question, I guess you have just got your own source files there but not the dependencies. If any, maven dependencies are usually located at META-INF\maven in jar. BTW, do you use maven plugins? For example, maven-jar-plugin only outputs your source code in jar while maven-assembly-plugin also outputs maven dependencies.

Maven integration with native libraries

I am using Android with Maven in my project . It depends on zbar.jar which in turn depends on the secondary artifacts like .so files. I am able to install the zbar.jar in the maven repository , but my secondary artifacts like .so files are not getting pulling through the Maven repository.
Any advice is appreciated.
Maven is designed to handle Java code. The .so files are binaries compiled for a specific architecture.
Are you fully aware on the implications of using .so files?
You can
Either package the so file in a jar file and write custom code to
copy them in their correct position before your application runs
or locate a maven plugin that does what you want. (or even an
Android-Maven specific plugin)
See also Maven2 Dependencies and Native Libraries

Resources