Posts

Showing posts with the label gradle

Maven Repository on Cloudflare R2 with Gradle

Image
 Here's a challenge with the public availability of the R2 Cloudflare blob storage is it possible to use it as a Maven repository with Gradle as the build system? The short answer is yes! The longer answer is that it is, but it is a bit disappointing with Gradle, I'll explain why it's disappointing later, but first (and probably the only bit you will read) is how. Step 1: R2 storage I'm assuming you have a Cloudflare account and have signed up for the R2 storage option. Navigate to the R2 Storage option on the R2 page Click 'Create bucket' Give the bucket a name, for the purpose of this tutorial I'm calling the bucket ' tutorial-r2-maven-bucket ' Click create and you should have your new bucket all ready for use Make note of the URL for the bucket, you'll need this later Step 2: S3 Auth token The secret sauce with using R2 as a maven repository is to treat it as an S3 bucket and use it's S3 compatible API. To do this you next need an S3 Auth...

Gradle and the parent pom

We've all got used to various maven features that we have come to rely on, and in my effort to migrate to Gradle I have endeavoured to find alternative replacments, one of which is the parent POM functionality. Gradle does not natively have this feature that as Maven users we rely on. Workarounds There are a number of workarounds documented, firstly the most common is to use the apply from to load a file from a URI (you can use a URL) but this is not ideal for many reasons. The alternative is to write your own plugin that alters your build.gradle file. Anorakgirl has a great write-up on how to do this here  Gradle and the parent POM  and is the inspiration for my plugin. Gradle pater-build plugin I love Anorakgirls write up but I was thinking that it really is a workaround and devs would need to start to understand the internal Gradle API, so if the apply from syntax has its short comings as Anorakgirl pointed out then how about subverting or working around them. I cr...

Gradle finding out of date dependencies

Ever wondered how to find dependencies that are no longer up to date in Gradle? Well Ben Manes has the plugin for you in the Gradle Versions Plugin . I'm not going to detail how to use it, it is plainly documented on his site, needless to say ensuring that your dependencies are as up to date as possible is crucial to managing your software, if you don't know that the libraries are out of date then you can't make sensible decisions on your software versioning.

Useful Gradle Build Process Plugins

Gradle is a great tool for building Java projects, in my opinion it is much better than its only real competitor Maven . A lot has been written about Gradle especially with comparison to Maven and building with it, I'm not really going to cover that. What I am going to do is highlight a few plugins which I find invaluable when putting a Gradle script together for a Java project. Release Management Maven has the well known and well publicised 'Maven Release Plugin' , but what is there for Gradle? Well there are a few options out there (search for gradle release plugin) but for me the best one is the Axion Release Plugin . This nicely separates the release management from the building of the software, in addition the versioning is controlled by the source control system tags rather than in Maven where it goes and edits the XML files and has to push these back to the repository. Distribution Ever struggled with the question 'How should I distribute my Java ap...