Problem: You have a public maven repository somewhere (i.e. in the cloud) – but you want to be able to browse it in a user freindly way.
Solution 1: Use a full blown repo manager archiva/artifactory/nexus to host it.
There are use cases for this… i.e., you are a huge company with 100s of developers and you need a scalable interface to host lots of jar artifacts with many versions in a secure manner, and you also need to provide different users different permissions to maintain different repositories, etc… But for a simple maven repo, some might say that a heavy weight repo manager creates a new problem: You are maintaining a server just to host a couple of jar files. The snazzy UI to your jar files is nice – but is it really necessary? Do you really need “roles” and hosted md5 comparisons just to share a few binaries? Probably not.
Now, Admittedly, for big organizations with security issues, etc, a private archiva server is a nice solution…. but probably isnt required for smaller projects which need a simple landing page for their maven artifacts for end users to consume.
Solution 2: Put the maven repo in S3 and use JQueries snazzy XML parser to host a dynamic, HTML5+jquery/javascript front-end. Here’s how:
1) Either use an s3 publisher in your “mvn deploy” invocations, or else, just scp your maven repository into s3://yourbucket/maven/
2) Now, you can look into http://<your_bucket>.s3.amazonaws.com/maven/repositories/internal/<your_repo_path>/maven-metadata.xml”, and you will see that there is a nice layout of all versions of your Jar. For example: http://repo.maven.apache.org/maven2/org/apache/pig/pigsmoke/maven-metadata.xml contains several version tags.
3) Save the code below to s3://<your_bucket>/maven/index.html
<html>
<head>
<title>GlusterFS-Hadoop Releases</title>
<script type="text/javascript"
src="http://code.jquery.com/jquery-1.10.2.min.js"></script>
</head>
<body>
<p> Releases </p>
<div id="releases">
</div>
<script type="text/javascript">
$(document).ready(function(){
$("#msgid").html("--");
});
function UrlExists(url, cb){
jQuery.ajax({
url: url,
dataType: 'text',
type: 'GET',
complete: function(xhr){
if(typeof cb === 'function')
cb.apply(this, [xhr.status]);
}
});
}
$(document).ready(function(){
$("#releases").append("<ul></ul>");
$.ajax({
type: "GET",
url: " http://rhbd.s3.amazonaws.com/<PATH_TO_YOUR_REPO>/maven-metadata.xml",
dataType: "xml",
success: function(xml){
$(xml).find('metadata').each(function(){
var versioning = $(this).find('versioning').text();
var versions = $(this).find('versions').text();
$.each(versions.split("\n"),
function(index,value ) {
var jarlink = "http://<YOUR_BUCKET_NAME>.s3.amazonaws.com/maven/<PATH_TO_YOUR_REPO>/VERSION/<YOUR_ARTIFACT_NAME>-VERSION.jar"
var regex = new RegExp('VERSION', 'g');
var jarversion = jarlink.replace(regex,value.trim());
//$("<li></li>").html(jarversion).appendTo("#releases ul");
$("<li></li>").html("<a href=\""+jarversion+"\">"+value+"</a>").appendTo("#releases ul");
}
);
});
},
error: function() {
alert("An error occurred while processing XML file ");
}
});
});
</script>
</body>
</html>
4) Now, browsing to http://<YOUR_BUCKET>.s3.amazonaws.com/index.html , You will see a nice list of links to your maven jars. This is super easy to modify and maintain, and if using a object store like s3, you can gaurantee that your users will always have access to your artifacts. Moral of the story: You can easily modify your landing page to your maven jars without using a heavy weight repo manager.
Checkout our glustersf-hadoop landing page http://rhbd.s3.amazonaws.com/maven/index.html, as an example of how this works… as long as you continue to use “mvn deploy:deploy” to update your repo, the HTML page will always serve the latest contents, because the maven-metadata.xml page will be automatically updated in the publishing process.
2020 has not been a year we would have been able to predict. With a worldwide pandemic and lives thrown out of gear, as we head into 2021, we are thankful that our community and project continued to receive new developers, users and make small gains. For that and a...
It has been a while since we provided an update to the Gluster community. Across the world various nations, states and localities have put together sets of guidelines around shelter-in-place and quarantine. We request our community members to stay safe, to care for their loved ones, to continue to be...
The initial rounds of conversation around the planning of content for release 8 has helped the project identify one key thing – the need to stagger out features and enhancements over multiple releases. Thus, while release 8 is unlikely to be feature heavy as previous releases, it will be the...