Say you want to build an executable Jar file - one that can execute from the command line
so:
$java -jar /path/to/myFile.jar
Below is a build.gradle that does this for you, using Maven as an artefact repository and the Shadow Gradle adding
==================================================================
plugins {
// Apply the java plugin to add support for Java
id 'java'
id 'com.github.johnrengelman.shadow' version '5.1.0'
}
repositories {
mavenCentral()
}
sourceSets {
main {
java {
srcDir 'src'
}
resources{
srcDir 'config'
srcDir 'lib'
}
}
}
java{
targetCompatibility = JavaVersion.toVersion(10)
sourceCompatibility = JavaVersion.toVersion(10)
}
shadowJar{
classifier = null
manifest{
attributes 'Main-Class':'com.alignmentsystems.engine.Worker'
attributes 'class-path':'.'
attributes 'Version':'0.9.1.'
}
}
dependencies {
implementation 'org.apache.mina:mina-core:2.0.9'
implementation 'ch.qos.logback:logback-core:1.1.3'
implementation 'ch.qos.logback:logback-classic:1.1.3'
implementation 'org.slf4j:slf4j-api:1.7.21'
}
=====================================================================
so:
$java -jar /path/to/myFile.jar
Below is a build.gradle that does this for you, using Maven as an artefact repository and the Shadow Gradle adding
==================================================================
plugins {
// Apply the java plugin to add support for Java
id 'java'
id 'com.github.johnrengelman.shadow' version '5.1.0'
}
repositories {
mavenCentral()
}
sourceSets {
main {
java {
srcDir 'src'
}
resources{
srcDir 'config'
srcDir 'lib'
}
}
}
java{
targetCompatibility = JavaVersion.toVersion(10)
sourceCompatibility = JavaVersion.toVersion(10)
}
shadowJar{
classifier = null
manifest{
attributes 'Main-Class':'com.alignmentsystems.engine.Worker'
attributes 'class-path':'.'
attributes 'Version':'0.9.1.'
}
}
dependencies {
implementation 'org.apache.mina:mina-core:2.0.9'
implementation 'ch.qos.logback:logback-core:1.1.3'
implementation 'ch.qos.logback:logback-classic:1.1.3'
implementation 'org.slf4j:slf4j-api:1.7.21'
}
=====================================================================
Comments
Post a Comment