I want to create two types of executable Jar by command both of them reference same code and external Jar, only diff thing is including xml file when they are built When I input command “dev” after input “gradle start” I want to create executable jar including xml file(where at ‘/src/env/dev’)
Here’s my gradle source, I have tried various way to create Jar but it couldn’t include source or find main class is there something wrong in my source?
apply plugin: 'java'
sourceSets {
main{
java.srcDir 'src'
}
}
dependencies {
compile fileTree(dir: 'lib', include: '*.jar')
}
task start <<{
def buildType = System.console().readLine("\nSelect Build Type (live, dev)\n")
if(buildType == 'live'){
tasks.live.execute()
}else if(buildType == 'dev'){
tasks.dev.execute()
}else{
println 'Selected Wrong Type!!'
}
}
task dev(type: Jar){
destinationDir = file('build/dev')
from('/src/env/dev'){
include('*.cfg.xml')
}
manifest {
attributes (
'Main-Class': 'com.ServerManager',
'Class-Path': '. '+configurations.compile.collect { './lib/'+it.getName() }.join(' ')
)
}
}
task live(type: Jar){
destinationDir = file('build/live')
from('/src/env/live'){
include('*.cfg.xml')
}
manifest {
attributes (
'Main-Class': 'com.ServerManager',
'Class-Path': '. '+configurations.compile.collect { './lib/'+it.getName() }.join(' ')
)
}
}