From 8c14c1bd495317ae7fe9021dfd95e435010abbfb Mon Sep 17 00:00:00 2001 From: Sean Gilligan Date: Tue, 3 Sep 2024 11:02:25 -0700 Subject: [PATCH] Add maven-publish.gradle to enable publishing to GitLab --- build.gradle | 10 +++++++++- gradle/maven-publish.gradle | 29 +++++++++++++++++++++++++++++ 2 files changed, 38 insertions(+), 1 deletion(-) create mode 100644 gradle/maven-publish.gradle diff --git a/build.gradle b/build.gradle index 1833286..4ff3789 100644 --- a/build.gradle +++ b/build.gradle @@ -2,7 +2,10 @@ plugins { id 'com.github.hierynomus.license' version '0.16.1' apply false } -subprojects { +// Projects to be published with maven-publish +ext.publishedProjects = ['secp-api', 'secp-ffm', 'secp-bouncy'] + +subprojects { sub -> apply plugin: 'java' apply plugin: 'groovy' //apply plugin: 'test-report-aggregation' @@ -23,6 +26,10 @@ subprojects { } java { + if (sub.name in publishedProjects) { + withJavadocJar() + } + withSourcesJar() toolchain { // `languageVersion` is used to configure the "Java Toolchain" used for the build. This includes `javac`, // `jlink`, and the `jpackage` tool. @@ -45,4 +52,5 @@ subprojects { } apply from: 'gradle/licenseCheck.gradle' +apply from: 'gradle/maven-publish.gradle' diff --git a/gradle/maven-publish.gradle b/gradle/maven-publish.gradle new file mode 100644 index 0000000..34bd712 --- /dev/null +++ b/gradle/maven-publish.gradle @@ -0,0 +1,29 @@ +subprojects { sub -> + + if (sub.name in publishedProjects) { + apply plugin: 'maven-publish' + + publishing { + publications { + jar(MavenPublication) { + from components.java + } + + } + repositories { + def secpJdkGitLabProjectId = "55956336" + maven { + url "https://gitlab.com/api/v4/projects/${secpJdkGitLabProjectId}/packages/maven" + name "GitLab" + credentials(HttpHeaderCredentials) { + name = 'Private-Token' + value = project.findProperty("gitLabMavenToken") + } + authentication { + header(HttpHeaderAuthentication) + } + } + } + } + } +}