184 lines
4.6 KiB
Groovy
184 lines
4.6 KiB
Groovy
|
|
plugins {
|
|
id "us.kirchmeier.capsule" version "1.0.1"
|
|
id 'com.google.protobuf' version '0.7.0'
|
|
}
|
|
|
|
apply plugin: 'java'
|
|
apply plugin: 'eclipse'
|
|
apply plugin: 'idea'
|
|
|
|
apply plugin: 'application'
|
|
|
|
apply plugin: 'maven-publish'
|
|
|
|
mainClassName='Demo'
|
|
|
|
// Is this a snapshot version?
|
|
ext { isSnapshot = false }
|
|
|
|
ext {
|
|
groupId = 'org.factcenter'
|
|
nexusRepository = "https://cs.idc.ac.il/nexus/content/groups/${isSnapshot ? 'unstable' : 'public'}/"
|
|
|
|
// Credentials for IDC nexus repositories (needed only for using unstable repositories and publishing)
|
|
// Should be set in ${HOME}/.gradle/gradle.properties
|
|
nexusUser = project.hasProperty('nexusUser') ? project.property('nexusUser') : ""
|
|
nexusPassword = project.hasProperty('nexusPassword') ? project.property('nexusPassword') : ""
|
|
}
|
|
|
|
description = "Meerkat Voting"
|
|
|
|
// Your project version
|
|
version = "0.0"
|
|
|
|
version += "${isSnapshot ? '-SNAPSHOT' : ''}"
|
|
|
|
|
|
dependencies {
|
|
// Logging
|
|
compile 'org.slf4j:slf4j-api:1.7.7'
|
|
runtime 'ch.qos.logback:logback-classic:1.1.2'
|
|
runtime 'ch.qos.logback:logback-core:1.1.2'
|
|
|
|
testCompile 'junit:junit:4.+'
|
|
|
|
runtime 'org.codehaus.groovy:groovy:2.4.+'
|
|
}
|
|
|
|
|
|
/*==== You probably don't have to edit below this line =======*/
|
|
|
|
// Used to generate initial maven-dir layout
|
|
task "create-dirs" { description = "Create default maven directory structure" } << {
|
|
sourceSets*.java.srcDirs*.each { it.mkdirs() }
|
|
sourceSets*.resources.srcDirs*.each { it.mkdirs() }
|
|
}
|
|
|
|
|
|
/*===================================
|
|
* "Fat" Build targets
|
|
*===================================*/
|
|
|
|
task fatjar(type: Jar) {
|
|
description = "Generate a single jar containing everything. Use -Pfatmain=... to override main class"
|
|
|
|
destinationDir = buildDir
|
|
|
|
def fatMain = hasProperty('fatmain') ? fatmain : mainClassName
|
|
def testJar = hasProperty('test')
|
|
|
|
appendix = "${fatMain}-fat"
|
|
|
|
if (testJar) {
|
|
from sourceSets.test.output
|
|
from configurations.testRuntime.collect { it.isDirectory() ? it : zipTree(it) }
|
|
}
|
|
|
|
from sourceSets.main.output // that's it
|
|
from { configurations.runtime.collect { it.isDirectory() ? it : zipTree(it) } }
|
|
|
|
exclude 'META-INF/MANIFEST.MF'
|
|
exclude 'META-INF/*.SF'
|
|
exclude 'META-INF/*.DSA'
|
|
exclude 'META-INF/*.RSA'
|
|
|
|
|
|
manifest { attributes 'Main-Class': fatMain }
|
|
}
|
|
|
|
|
|
task mavenCapsule(type: MavenCapsule){
|
|
description = "Generate a capsule jar that automatically downloads and caches dependencies when run."
|
|
applicationClass mainClassName
|
|
destinationDir = buildDir
|
|
}
|
|
|
|
task fatCapsule(type: FatCapsule){
|
|
description = "Generate a single capsule jar containing everything. Use -Pfatmain=... to override main class"
|
|
|
|
destinationDir = buildDir
|
|
|
|
def fatMain = hasProperty('fatmain') ? fatmain : mainClassName
|
|
|
|
applicationClass fatMain
|
|
|
|
def testJar = hasProperty('test')
|
|
|
|
if (hasProperty('fatmain')) {
|
|
appendix = "fat-${fatMain}"
|
|
} else {
|
|
appendix = "fat"
|
|
}
|
|
|
|
if (testJar) {
|
|
from sourceSets.test.output
|
|
}
|
|
}
|
|
|
|
/*===================================
|
|
* Repositories
|
|
*===================================*/
|
|
|
|
repositories {
|
|
|
|
// Prefer the local nexus repository (it may have 3rd party artifacts not found in mavenCentral)
|
|
maven {
|
|
url nexusRepository
|
|
|
|
if (isSnapshot) {
|
|
credentials { username
|
|
password
|
|
|
|
username nexusUser
|
|
password nexusPassword
|
|
}
|
|
}
|
|
}
|
|
|
|
// Use 'maven central' for other dependencies.
|
|
mavenCentral()
|
|
}
|
|
|
|
task "info" << {
|
|
println "Project: ${project.name}"
|
|
println "Description: ${project.description}"
|
|
println "--------------------------"
|
|
println "GroupId: $groupId"
|
|
println "Version: $version (${isSnapshot ? 'snapshot' : 'release'})"
|
|
println ""
|
|
}
|
|
info.description 'Print some information about project parameters'
|
|
|
|
|
|
/*===================================
|
|
* Publishing
|
|
*===================================*/
|
|
|
|
publishing {
|
|
publications {
|
|
mavenJava(MavenPublication) {
|
|
groupId project.groupId
|
|
pom.withXml {
|
|
asNode().appendNode('description', project.description)
|
|
}
|
|
from project.components.java
|
|
|
|
}
|
|
}
|
|
repositories {
|
|
maven {
|
|
url "https://cs.idc.ac.il/nexus/content/repositories/${project.isSnapshot ? 'snapshots' : 'releases'}"
|
|
credentials { username
|
|
password
|
|
|
|
username nexusUser
|
|
password nexusPassword
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
|
|
|