Publishing artifacts with sources on archiva - maven

At work I'm dipping my toes in managing project dependencies with maven. We use Apache Archiva (1.2.1) as a local repository and proxy. I'm adding artifact for open source project, that is not published on any public repository. I've learned that to publish the sources I should use the Classifier field on Upload artifact page. The sources are then listed alongside the jar and pom when I browse the repository.
But when I update my maven dependencies I get only the jar and pom from the repository. I noticed that sources are also missing when the archiva proxies for me the downloads from other public repositories. I didn't find any configuration options in Archiva's admin pages to serve the sources... What am I missing?
Update: I was missing the fact that artifact sources have to be downloaded manually. I.e. the maven client has to request them, which is controlled by command line option -DdownloadSources=true. Maven Integration for Eclipse has a preference setting to always download them as described in Resolving artifact sources. Archiva then serves the sources for local artifacts or proxies the request to remote repositories and caches the sources for future requests.

Archiva does serve the sources, but Maven does not request them by default. I know since I also use Archiva as my Maven repo. How are you requesting the sources?
If you're using eclipse
you can run mvn eclipse:eclipe -DdownloadSources=true in the project directory;
you can install the Maven Integration for Eclipse.
Both of them should return the sources if they are available.

The sources aren't required to satisfy compile/runtime dependencies. If you wanted to bundle sources with your app, then you would specify a dependency with a source. Or you would use a plug in like assembly to grab them from archiva.

Related

How to download selective dependencies using Maven from JFrog Artifactory?

I have a simple Maven project and its pom.xml has some dependencies to some local jar files inside the project structure. Now I want to upload those local jar files in JFrog Artifactory and change the pom in such a way so as to use selective dependencies from Artifactory and rest of the Pom files remains the same like it was(which includes some spring boot, Junit, surefire dependencies etc etc). How can I alter the pom file so that I can selectively download those jars from Artifactory rather than from my local machine.
I uploaded the local jars in a folder in Artifactory but unable to configure my pom/maven to download those during clean install. I tried as per the documentation in Jfrog to modify the settings.xml and include the server tag and aslo added distribution management in pom.xl to refer to the Jfrog Artifactory. But this is for all the dependencies no? I want selective dependencies to be downloaded from Artifactory.

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?

To create a repository for 3rd party jars using Maven in Nexus

I am new to Maven.
I need to create a repository in Nexus for all 3rd party jars used in our project. These 3rd party jars should be pushed to Nexus repository from the maven repository.
When compiling the java code the 3rd party jars should be downloaded to the .m2 folder (local repository) and the code should be complied.
Could you share the sample pom.xml?
I think you are misunderstanding how things are working. Nexus can proxy the Central Repository and others. When configured correctly Maven will download all needed plugins and jar dependencies via Nexus into the local Maven repository and make them available on the classpath during the build as needed.
See more in the documentation. Esp check out the concepts and the Maven section:
http://books.sonatype.com/nexus-book/reference/concepts.html
http://books.sonatype.com/nexus-book/reference/config.html
You can also try it with the eval guide and the example projects.
http://books.sonatype.com/nexus-book/reference/eval.html

Maven / OSGi: deploying to an OBR which is not the maven repos

My maven build installs artifacts locally and requires access to the project's remote maven repository. I don't have write access to that repository - so my builds (containing my changes) are only local so far.
When I build, I would like to deploy the .jar to a remote OBR which I have control over. This is not a full maven repository (eg. Nexus), just a webserver. A repository.xml describing the OBR should be automatically generated and uploaded.
Simply calling the goal "deploy" will try to upload to the project's maven repo, which fails as I don't have write access.
I want:
build & install locally, getting all dependencies on remote maven repos as required
upload jars to the OBR
generate repository.xml OBR description and upload
How should I configure the maven-bundle-plugin? Which goal must I call?

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.

Resources