How to host a maven repo without Nexus - maven

I have small open-source projects hosted on Github which I want to make available for others via Maven. I have a small webspace where I can host static files. How can I create a repo? Also, I would want to remove old snapshots from there if possible.

Standard maven repository implementations are almost all Tomcat web apps. Each one of them should have a static repository, just as your local repository. The webapp serves to the purpose of searching and management of the artifacts stored in that static repository.
If you want to host the repository with static web access only, you'll have to perform the management manually and provide a static manually generated html page that contains GAV coordinates of all artifacts in the repo. No other user but you could ever upload to the repository unless you give your password or enable anonymous FTP acces.
If maven doesn't try to upload anything to the repo until the deploy phase then this approach is still partly usable, since running a mvn clean deploy should fail.
You can check if is it doable like this (I suppose that you have that projects in your local repo):
upload your local repoistory folder to a URL
for the purpose of testing mirror your central repo to that URL
try to build your project with dependencies from your repo
Open your settings.xml file and under <mirrors> node add:
<mirror>
<url>http://your/url/repo</url>
<mirrorOf>*</mirrorOf>
</mirror>
and see if mvn clean install suceeds. Please feedback.

In this SO answer I have outlined the way I set up my OSS projects which are all hosted in Github. There are actually a number of free services out there you could you when you would like to run an OSS project.
I would recommend publishing to Maven Central, if your plugin is well-tested and expected to bring other people benefits as well. You can use CloudBee's BuildHive as a free Jenkins CI.

A static repo works great, per my experience.
I scp'd up my local repository into a static apache server. Legit repo. Not as easy to maintain as a real repo of course, but quite a bit cheaper if you've already got a plain vanilla web host.
Other than setting the permissions properly (same as required for you to browse the folders), it was a pretty painless procedure.
The only two things I did to make it more reasonable were
1 - Wrote a script to "rm -rf ...." on most of the contents of my local repo so that the only thing I am deploying is those few artifacts that are not available in the general repos.
2 - Tarred it up first before scping to my web host.
Hope this helps.
The guy below did something similar, only using FTP which saves him a lot of hand work if he updates his binaries very often.
http://stuartsierra.com/2009/09/08/run-your-own-maven-repository

I think I know how to do it now. I'm using mvn deploy now to create a local repository on the file system and then I upload it to the webserver. If I'm not wrong, there doesn't even need to be a file listing.
The command I'm using is:
mvn deploy -DaltDeploymentRepository=local::default::file:./repo
This creates/updates the local repository automatically, so the repo can be synced with a server.

Related

Remote repository for a go project in Artifactory doesn't proxy?

I'm trying to understand how to work with a remote repository in Artifactory for a Go project. My initial expectation was that it'll work transparently, all I would need to do is to point GORPOXY variable to a virtual repository (with local and remote behind it), do go build and dependencies will either be downloaded from the Artifactory cache or Artifactory would download them transparently. Similar to the way it works for maven dependencies.
When I tried that, it complained that the dependencies weren't found in artifactory. Ok.
Reading the documentation two things stand out. First, there's nothing there about GOPROXY and everything is about using artifactory cli. That's a big downside for several reasons.
Second, is that you need to publish dependencies manually with jfrog rt go-publish go --self=false --deps=ALL and then dependencies appear under a local repository.
So I'm trying to figure out if 1) I can avoid using JFrog CLI and 2) what's the point of remote repositories if they don't proxy? Or maybe I'm missing something?
Artifactory 6.3.0
I understand your confusion on the blog post you mentioned, though I have a feeling the intent of the writer was to more show how the JFrog CLI can be used.
To answer your questions:
1) Yes, you don't have to use the JFrog CLI to build. Please check out the documentation on how to set up a remote repository for Go. This will guide you through setting up GitHub or GoCenter as a remote repository for your Go builds. This will allow you to set the GOPROXY environment variable following this structure <protocol>://<username>:<password>#<artifactory domain>/api/go/<go repository>.
2) Remote repositories will absolutely act as a proxy, caching the contents you download from the remote repository (copying a part from the user guide: A remote Go repository in Artifactory serves as a caching proxy for a public Go registry such as GoCenter or GitHub.)

Can I keep Maven local repository on another machine and use it in my project?

Where are Maven and pom.xml file kept in a real-time project if the code is at GitHub. I mean can I keep my local repository somewhere in another machine and use it in my project. If yes, how?
Local repositories are not meant for sharing. They are also not "thread-safe" in any way, so accessing them simultaneously from two different builds might break things.
They are populated by the artifacts Maven downloads from MavenCentral and other repositories, and also the stuff you build yourself. As they are more or less a form of cache, there is no need to share them.
If you need a repository that is used from different machines or by different users, set up a Nexus/Artifactory server.

How can I create an Artifactory remote repository that uses a local Bitbucket server as the source for Composer packages

Our organization has a locally running instance of Artifactory, and also a local instance of Bitbucket. We are trying to get them to play well together so that Artifactory can serve up our private PHP packages right out of Bitbucket.
Specifically, we'd like to create a Composer Remote Repository in Artifactory that serves up our private PHP packages, where those packages are sourced from git repositories on our local Bitbucket server.
Note that we'd rather not create and upload our own package zip files for each new package version, as suggested here. Ideally, we just want to be able to commit changes to a PHP package in BitBucket, tag those changes as a new package version, and have that new version be automatically picked up and served by Artifactory.
The Artifactory Composer documentation suggests that this is possible:
A Composer remote repository in Artifactory can proxy packagist.org
and other Artifactory Composer repositories for index files, and
version control systems such as GitHub or BitBucket, or local
Composer repositories in other Artifactory instances for binaries.
We've spent a lot of time trying making this work, but haven't been able to do it. The Remote Repository that we create always remains empty, no matter what we do. Can anyone offer an example to help, or even just confirm that what we're attempting isn't possible?
For reference, we've been trying to find the right settings to put into this setup page:
Thanks!
Artifactory won't download and pack the sources for you, it expects to find binary artifacts.
The mention of source control in the documentation refers to downloading the archives from source control systems, either uploaded there as archives (don't do that), or packed by the source control system on download request (that is what you are looking for).
You can use this REST API to download automatically generated zips from BitBucket. If you can configure the composer client to look for the packages in the right place, you're all set.

Common Local repository for Maven

We want to maintain a common repository for Maven for all the systems within our local network, i.e., there should not be a .m2 directory on every system but on a common server(say with some local ip 172.<>).
Can it be acheived via any file transfer protocol or any other service?
Operating System : Windows
While this is actually possible (you can give Maven a settings.xml on the command line, so you can always point to the one in the network), I would strongly recommend against this:
The Maven local repository is not thread safe. When two guys build against it at the same time, anything might break, especially SNAPSHOT versions. I speak from experience: We tried to have only one local repository on our build server and we got wrong results in different builds.
If you want a repository for your team, you need Nexus or Artifactory.

How to opensource a Maven plugin?

I have a Maven plugin that I want to share with outside world. Is there an official Maven repository I can deploy this plugin too ? What are the steps involved ?
Any links to documentation much appreciated
I've been reading http://www.sonatype.com/people/2008/11/adding-a-jar-to-a-maven-repository-with-sonatype-nexus/ but this just seems to describe deploying to internal Nexus repository, wheras I want to deploy to an external repo so any user can use it.
I would recommend:
Setting up an account in Github in order to have a place to host your source code.
Setting up an account in Cloudbee's BuildHive. This is a free Jenkins CI for Open Source projects. This will test your project on every push to Github.
Request rights to publish your project to Maven Central.
The bit with the request will take around up to a day normally and then you'll be able to publish your code directly to Maven Central.

Resources