aboutsummaryrefslogtreecommitdiff
path: root/build.gradle
blob: 83db6b90fc6c183a3787a790e7b1cdd262947f8c (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
/*
 buildfile for gradle (http://gradle.org/)
*/

// we compile java
apply plugin: 'java'
// allow creating files for IntelliJ IDEA
apply plugin: 'idea'
// ... as well as eclipse
apply plugin: 'eclipse'
// code coverage reporting
apply plugin: 'jacoco'
// publish repository for other projects to use
apply plugin: 'ivy-publish'

// put stuff build by gradle in this directory to avoid
// confusion with IDE-generated stuff
buildDir = "$projectDir/build-gradle"   

sourceCompatibility = "1.6"
targetCompatibility = "1.6"

// specify where to get jars
repositories {
  // we either get them from the libs dir
  flatDir {
    dirs 'lib'
  }
  // or from the maven central repository
  mavenCentral()
}

dependencies {
  compile group: 'com.google.guava', name: 'guava', version: '16.0.1'
  compile group: 'junit', name: 'junit', version: '4.11'
  compile group: 'log4j', name: 'log4j', version: '1.2.16'
  compile group: 'org.slf4j', name: 'slf4j-api', version: '1.6.4'
  compile group: 'org.slf4j', name: 'slf4j-log4j12', version: '1.6.4'
}


task showClasspath << {
  System.out.println(configurations.compile.asPath);
}

task showDeps << {
  configurations.compile.each { File file -> println file.getPath() }
}


compileJava.options.debugOptions.debugLevel = "source,lines,vars"

// Define task and dependencies for creating an IZPack installer.

project.ext.installerFile = "$projectDir/gnunet-java-installer.jar"

task installer (type: Exec) {
  description "build an IZPack installer for gnunet-java"
  workingDir "$projectDir"

  outputs.file("$installerFile")
}

installer.dependsOn "build","javadoc"

installer.outputs.upToDateWhen { false }

installer.doFirst {
  def izpack = System.getenv("IZPACK_COMPILER")
  if (izpack == null) {
    throw new RuntimeException("environment variable IZPACK_COMPILER not defined")
  }
  installer.commandLine "$izpack", "$projectDir/izpack-installer.xml", "-o", "$installerFile"
}


// Which gradle version do we want to use
// for the wrapper?
task wrapper(type: Wrapper) {
    gradleVersion = '1.11'
}


test {
    // Print test name, so that we can easily find out
    // which test does not terminate.
    beforeTest{ descr ->
        logger.warn("Starting test ${descr.className} : ${descr.name}")    
    }
}


task copyDeps(type: Copy) {
  into "$projectDir/lib"
  from configurations.runtime
}

task createResourcesDir << {
  def myDir = new File('src/main/resources')  
  myDir.mkdirs()
}


task msgtypes (type: JavaCompile, dependsOn: 'createResourcesDir') {
  description = "Updates the index of GNUnet message types known to gnunet-java."
  classpath = project.sourceSets.main.runtimeClasspath
  source = files(project.sourceSets.main.allJava)
  options.setCompilerArgs(["-processor", "org.gnunet.construct.MessageIdAnnotationProcessor",
                           "-proc:only",
                           // generated "source" files should resources, tell the annotation processor!
                           "-s", "src/main/resources"])
  destinationDir = file("$buildDir/classes/main/")
}



publishing {
  publications {
    ivyGnuNetJava (IvyPublication) {
      organisation 'org.gnunet'
      module 'gnunet-java'
      revision 'svn'
      from components.java
    }
  }
  repositories {
    ivy {
      url "$projectDir/ivy-repo"
    }
  }
}


javadoc.exclude '**/messages/**'