Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to publish a folder structure (NOT a file) to a maven repo using Gradle?

Tags:

We need to publish JavaDoc to our maven repository as a site, not an archive, so that it can be browsed directly from there. Our maven-based projects do this already but we are having trouble finding the way to do this with Gradle - I think using "site deploy".

It is incredibly complicated to search for this as "site" is such an overloaded term and other searches don't produce any results.

like image 717
Learner Avatar asked Jun 16 '17 19:06

Learner


1 Answers

Based on this script, here is a simple one which upload a directory structure. I tested it with my Artifactory OSS and it's working.

#!/bin/bash

# Recursively deploys folder content. Attempt checksum deploy first to optimize upload time.

repo_url="http://ip:port/artifactory"
tgt_repo="simple/myrepo"
user=myuser
pass=mypass

dir="$1"

if [ -z "$dir" ]; then echo "Please specify a directory to recursively upload from!"; exit 1; fi

root=${dir#$(dirname "$dir")/}

find "$dir" -type f | sort | while read f; do
    rel="$(echo "$f" | sed -e "s#$dir##" -e "s# /#/#")";
    echo "Uploading $f"
    curl -k -u $user:$pass -T "$f" "${repo_url}/${tgt_repo}/${root}${rel}"
done

Now, you can turn this into Groovy code with a curl command.

Off course it's not as automatic as a simple Gradle task to execute but the job will be done.

like image 55
ToYonos Avatar answered Sep 23 '22 03:09

ToYonos