Skip to content

Instantly share code, notes, and snippets.

@aalmiray
Created January 10, 2020 19:25
Show Gist options
  • Save aalmiray/0eb645379bde00fe948acb5e7b590229 to your computer and use it in GitHub Desktop.
Save aalmiray/0eb645379bde00fe948acb5e7b590229 to your computer and use it in GitHub Desktop.
plugins {
id 'java-library'
id 'application'
id 'maven-publish'
id 'com.github.johnrengelman.shadow'
}
group = 'com.acme'
version = '0.0.0-SNAPSHOT'
application {
mainClassName = 'com.acme.Main'
}
// define any configurations you'd like
// here we mimic the default 'implementation' configuration
configurations {
customImplementation
}
repositories {
jcenter()
}
// use our custom configuration
dependencies {
customImplementation 'org.apache.commons:commons-lang3:3.9'
}
sourceSets {
main {
// wire the custom configuration tom the `compileClasspath`
// make sure to not miss it!
compileClasspath += configurations.customImplementation
runtimeClasspath += compileClasspath
}
}
shadowJar {
// instruct shadowJar to fetch dependencies from our custom configuration
configurations = [project.configurations.customImplementation]
// override classifier so that shadow overwrites the default JAR
archiveClassifier.set ''
}
// let shadow run after jar
jar.finalizedBy shadowJar
publishing {
publications {
mavenJava(MavenPublication) {
// benefit from default settings
from components.java
}
}
repositories {
maven {
url = "$buildDir/repo"
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment