@@ -7,6 +7,8 @@ GREEN='\033[32m'
77RED=' \033[31m'
88NC=' \033[0m' # No Color
99
10+ MAVEN_REPO_PATH=" ./build/local-maven-repo"
11+
1012log_error () {
1113 local msg=" $1 "
1214 local headers=" $2 "
@@ -24,7 +26,7 @@ upload_file() {
2426
2527 if [ -f " $file_name " ]; then
2628 echo -e " ${GREEN} Processing file: $file_name ${NC} "
27- pkg_file_name=" mvn${file_name# . / build / local-maven-repo } "
29+ pkg_file_name=" mvn${file_name# " ${MAVEN_REPO_PATH} " } "
2830
2931 # Get signed URL for uploading artifact file
3032 signed_url_response=$( curl -X POST -G " $URL " \
@@ -47,6 +49,7 @@ upload_file() {
4749 md5|sha1|sha256|sha512) content_type=" text/plain" ;;
4850 module) content_type=" application/json" ;;
4951 pom|xml) content_type=" application/xml" ;;
52+ html) content_type=" text/html" ;;
5053 * ) content_type=" application/octet-stream" ;;
5154 esac
5255
@@ -81,16 +84,51 @@ walk_tree() {
8184 done
8285}
8386
87+ generate_instructions () {
88+ cat << EOF > "$MAVEN_REPO_PATH /index.html"
89+ <!DOCTYPE html>
90+ <html>
91+ <head>
92+ <title>Maven Repo</title>
93+ </head>
94+ <body>
95+ <h1>Stainless SDK Maven Repository</h1>
96+ <p>This is the Maven repository for your Stainless Java SDK build.</p>
97+
98+ <h1>Directions</h1>
99+ <p>To use the uploaded Maven repository, add the following to your project's <code>pom.xml</code>:</p>
100+ <pre><repositories>
101+ <repository>
102+ <id>stainless-sdk-repo</id>
103+ <url>https://pkg.stainless.com/s/${PROJECT} /${SHA} /mvn</url>
104+ </repository>
105+ </repositories></pre>
106+
107+ <p>If you're using Gradle, add the following to your <code>build.gradle</code> file:</p>
108+ <pre>repositories {
109+ maven {
110+ url 'https://pkg.stainless.com/s/${PROJECT} /${SHA} /mvn'
111+ }
112+ }</pre>
113+ </body>
114+ </html>
115+ EOF
116+ upload_file " ${MAVEN_REPO_PATH} /index.html"
117+
118+ echo " Configure maven or gradle to use the repo located at 'https://pkg.stainless.com/s/${PROJECT} /${SHA} /mvn'"
119+ echo " For more details, see the directions in https://pkg.stainless.com/s/${PROJECT} /${SHA} /mvn/index.html"
120+ }
121+
84122cd " $( dirname " $0 " ) /.."
85123
86124echo " ::group::Creating local Maven content"
87125./gradlew publishMavenPublicationToLocalFileSystemRepository -PpublishLocal
88126echo " ::endgroup::"
89127
90128echo " ::group::Uploading to pkg.stainless.com"
91- walk_tree " ./build/local-maven-repo "
129+ walk_tree " $MAVEN_REPO_PATH "
92130echo " ::endgroup::"
93131
94132echo " ::group::Generating instructions"
95- echo " Configure maven or gradle to use the repo located at 'https://pkg.stainless.com/s/ ${PROJECT} / ${SHA} /mvn' "
133+ generate_instructions
96134echo " ::endgroup::"
0 commit comments