Skip to content

Instantly share code, notes, and snippets.

@rjrudin
Last active July 12, 2021 19:47
Show Gist options
  • Save rjrudin/28898afaf0a0aa6772aeaac1ae890e6a to your computer and use it in GitHub Desktop.
Save rjrudin/28898afaf0a0aa6772aeaac1ae890e6a to your computer and use it in GitHub Desktop.
Bare minimum build.gradle file for publishing to Maven Central
// In addition to what's in this file, you'll need to define the following properties in your
// gradle.properties file:
//
// mavenCentralUsername=
// mavenCentralPassword=
// mavenCentralUrl=https://oss.sonatype.org/service/local/staging/deploy/maven2/
//
// In order for the "signing" plugin to work correctly, you'll also need to define the following properties, either
// in your gradle.properties file or at runtime:
//
// signing.keyId=YourKeyId
// signing.password=YourPublicKeyPassword
// signing.secretKeyRingFile=PathToYourKeyRingFile
//
plugins {
id "java-library"
id "maven-publish"
id "signing"
}
group = "com.marklogic"
version = "4.2.0"
repositories {
mavenCentral()
}
dependencies {
// Add any dependencies that your project has here
}
task sourcesJar(type: Jar, dependsOn: classes) {
classifier 'sources'
from sourceSets.main.allSource
}
task javadocJar(type: Jar, dependsOn: javadoc) {
classifier "javadoc"
from javadoc
}
javadoc.failOnError = false
artifacts {
archives javadocJar, sourcesJar
}
signing {
sign configurations.archives
}
publishing {
publications {
mainJava(MavenPublication) {
pom {
name = "${group}:${project.name}"
description = "CHANGEME Provide a description of your project here"
packaging = "jar"
url = "https://github.com/marklogic-community/${project.name}"
licenses {
license {
name = "The Apache License, Version 2.0"
url = "http://www.apache.org/licenses/LICENSE-2.0.txt"
}
}
developers {
developer {
id = "marklogic"
name = "MarkLogic Github Contributors"
email = "general@developer.marklogic.com"
organization = "MarkLogic"
organizationUrl = "https://www.marklogic.com"
}
}
scm {
url = "git@github.com:marklogic-community/${project.name}.git"
connection = "scm:git@github.com:marklogic-community/${project.name}.git"
developerConnection = "scm:git@github.com:marklogic-community/${project.name}.git"
}
}
from components.java
artifact sourcesJar
artifact javadocJar
}
}
repositories {
maven {
name = "central"
url = mavenCentralUrl
credentials {
username mavenCentralUsername
password mavenCentralPassword
}
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment