Skip to content

Instantly share code, notes, and snippets.

@Mattamorphic
Created August 22, 2019 12:48
Show Gist options
  • Save Mattamorphic/bfebdb28e3b81bb096d2d2fd69c7734e to your computer and use it in GitHub Desktop.
Save Mattamorphic/bfebdb28e3b81bb096d2d2fd69c7734e to your computer and use it in GitHub Desktop.
MVN Package Gradle Example
plugins {
// Apply the java plugin to add support for Java
id 'java'
// Apply the application plugin to add support for building a CLI application
id 'application'
id 'maven-publish'
}
repositories {
// Use jcenter for resolving dependencies.
// You can declare any Maven/Ivy/file repository here.
jcenter()
}
dependencies {
// This dependency is used by the application.
implementation 'com.google.guava:guava:27.1-jre'
// Use JUnit test framework
testImplementation 'junit:junit:4.12'
}
application {
// Define the main class for the application
mainClassName = 'com.OWNER.gradle.App'
}
group = 'com.OWNER'
version = '1.2'
publishing {
repositories {
maven {
name = "GitHubPackages"
url = "https://maven.pkg.github.com/OWNER/REPO"
credentials {
username project.hasProperty('gpr.user') ? project.property('gpr.user') : System.getenv('GPR_USER')
password project.hasProperty('gpr.key') ? project.property('gpr.key') : System.getenv('GPR_API_KEY')
}
}
}
publications {
gpr(MavenPublication) {
pom
from components.java
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment