Skip to content

Instantly share code, notes, and snippets.

@liqweed
Forked from aalmiray/build.gradle
Created January 10, 2020 22:37
Show Gist options
  • Save liqweed/7460c109d669ced537d1fe2b3f13d0fd to your computer and use it in GitHub Desktop.
Save liqweed/7460c109d669ced537d1fe2b3f13d0fd 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