Add multiple JARs and Javadoc to local Maven repository - maven

I have a number of JAR files that comprise two different Java SDKs for BOXI R3.1: BusinessObjects Enterprise Java SDK and the Web Services Consumer Java SDK.
The BusinessObjects Enterprise Java SDK has a number of 'core' JARs:
biarengine.jar
biplugins.jar
cecore.jar
celib.jar
ceplugins_client.jar
ceplugins_core.jar
ceplugins_cr.jar
cereports.jar
cesession.jar
ceutils.jar
corbaidl.jar
ebus405.jar
flash.jar
SL_plugins.jar
logging.jar
pluginhelper.jar
xcelsius.jar
and a number of dependencies:
asn1.jar
backport-util-concurrent-2.2.jar
certj.jar
commons-logging.jar
derby.jar
freessl201.jar
jsafe.jar
log4j.jar
rascore.jar
sslj.jar
The Javadocs are available as a ZIP file.
The situation is similar for the web-services SDK, so I will omit the details.
Goal: package each SDK and its Javadoc as a local, Maven repository (it doesn't appear that SAP is providing a remote one).
Questions:
can one Maven repository contain multiple JAR files? The mvn deploy:deploy-file plugin seems to only work on a single file: How to add a jar, source and Javadoc to the local Maven repository?
should Javadocs be kept in ZIP format in a Maven repository?
if i choose to make to repos for a given SDK (i.e. core and dependencies), is specifying the linkage as easy as editing the core repos' configuration file?
rather than creating a repo for the dependencies, I'm assuming that it would be better to identify and reference existing Maven repos (e.g log4j.jar). Will this lead me to JAR hell?

Yes a maven repo can contain multiple files, you can execute mvn deploy:deploy-file on each one (using -Djavadoc and -Dsources as needed).
To specify dependencies for a jar, create a pom file for it (with dependencies) and use -DpomFile (and omit -DgeneratePom) in mvn deploy:deploy-file.
Yes you should not re-invent the wheel and deploy artifacts to your repository that are already in central. You can use tools like http://mvnrepository.com to search for your jars (look META-INF/MANIFEST.MF in your jars to find the version).
For more info see: http://maven.apache.org/plugins/maven-deploy-plugin/deploy-file-mojo.html.

Related

How to convert a Gradle project's dependencies into a local maven repository?

I am building a Java SDK that can be used to work on my app.
When I run ./gradlew :my-sdk-library:dependencies I get my transitive tree of deps.
All my customers refuse to access libraries on the internet. And they do not have a local maven proxy either, so I need to supply my sdk jars and the other open source jars too.
So I would like to convert that into a local maven repository so that I can send it to those who cannot access our maven repository that is hosted on Artifactory, nor Maven central.
The naive approach is the make a shaded (shadow) jar containing all the libraries then import it as a implementation file(path-to-shaded.jar). But that is not good because IDEs do not like huge 200MB shaded jar files. And you lose all the dependency management provided by the GAV values.
So I want to produce a local maven repository I can send along with the SDK.
So if this were Maven I would go to a fresh VM, run mvn install, then just copy the ~/.m2/repository folder and there you go.
I did find a project https://github.com/sinsongdev/gradle-cash-to-maven-repo which might work to create a local maven repo using the gradle cache, but it is not widely used. I'll give it a try.
Basically I want exactly what https://github.com/johnrengelman/shadow does but instead of producing an uber jar, to create a local maven repo.
Is there some option like that in Gradle to create an offline copy of the repo or cache so that developers who are behind strict firewalls can use your SDK?

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.

Maven in Netbeans8: how to add jars to local repository

I use Maven bundled in NetBeans8. I have a lot of Maven projects, but also a lot of jar files provided by third parties which are not available from any online Maven repository.
I have to use these jars in one of my Maven projects. I read in this SO answer that I should copy the jars in my local repository! How can I do that in NetBeans with my bundled Maven?
You can either do it from the command line as explained in your link. Maven is in netbeans installation folder/java/maven/bin/mvn.bat on Windows. Not sure on other platform.
Alternatively, you can expand your project's "Dependencies" folder, right click on the jar and select "Manually install artifact".

How to install a Maven/Gradle project along with all its dependencies to a local repository?

I have a Gradle project that depends on several open-source projects up on Maven Central. I'd like to install the project – along with all its direct and transitive dependencies – to my local maven repository, so that I could later zip it all up and put it on offline machines.
How do I do it with Gradle/Maven?
mvn dependency:get plugin will fetch the artifact with all dependencies to the local repository.
I had also developed a plugin to install remote artifacts to a local machine.
If you want to later ZIP up your project w/ dependencies and move them to a different machine, you could try Maven's appassembler plugin. It collects all dependencies and creates a launcher, all in the target folder, ready for deployment.
But note, this, by default, creates a flat directory structure with all dependencies, it doesn't preserve the Maven format. It also has the option to create a repository.

What is the purpose of providing a downloaded pom.xml on mvnrepository.com

On mvnrepositry, when you search for a certain module, there's a link to download the binary. For some versions it has a pom.xml file available for download instead of the jar. What are you supposed to do with that pom.xml? It seems like if I specify a version that does not have a downloadable jar, but instead downloadable pom.xml, my maven build will fail. Is what I'm seeing correct?
Modules that only have pom files are maven modules with pom packaging. They are used to aggregate multiple modules into one unit. You can use such a module as a dependency for your maven project. Maven will download the pom file, analyze the dependencies included in that pom file and download those & add it to your automatically.
Even modules that have jars (jar packaging) have a pom file associated with them. This pom file defines the other dependencies that are required for using it. Maven will automatically process and fetch those dependencies (transitive dependencies).
This makes specifying and managing dependency for any project. You will specify the top level modules that your projects directly depends on and other things required will automatically figured out and downloaded. It also makes it easier when you have upgrade to a new version - all the transitive dependencies will get upgraded automatically.
One of the reason that cause this is because of licensing issue.
License for such JARs prohibit public redistribution in such approach. So someone provide only the POM so that you can get the JAR yourself and install it to your local maven repo/ internal repo, together with the POM provided.

Resources