Imported Upstream version 2.11~beta2+ds
[debian/jabref.git] / build.gradle
index 055a1ec6810b55a9ec1882825b32dde6048f59eb..64e5d5b422da9b77ad58df31ecf41f57bdcf3660 100644 (file)
-apply plugin: 'java'
+apply plugin: "java"
+apply plugin: "eclipse"
+apply plugin: "idea"
+apply plugin: "application"
+apply plugin: 'project-report'
 
-// with gradle 1.1, Sonar 3.2 is not working. One needs Sonar 3.1.1
-apply plugin: 'sonar'
+
+// enables fatjar, the creation of a jar with all dependencies bundled inside
+buildscript {
+    repositories {
+        mavenCentral()
+    }
+    dependencies {
+        classpath 'eu.appsatori:gradle-fatjar-plugin:0.2'
+    }
+}
+apply plugin: 'fatjar'
+fatJar {
+    classifier 'fat'
+    manifest {
+        attributes 'Main-Class': "net.sf.jabref.JabRefMain"
+    }
+}
+
+test {
+    testLogging {
+        exceptionFormat "full" // default is "short"
+    }
+}
+
+version = "2.11b2"
+
+repositories {
+    mavenCentral()
+}
 
 sourceSets {
-       main {
-               java {
-                       srcDir 'src/java'
-               }
-               resources {
-                       srcDir 'src/resource'
-               }
-       }
+    main {
+        java {
+            srcDirs = ["src/main/java", "src/main/gen"]
+        }
+    }
+}
+
+configurations {
+    generateClasspath
+    antlr3
+    antlr2
 }
+
+dependencies {
+
+    // jgoodies
+    compile 'com.jgoodies:jgoodies-common:1.4.0'
+    compile 'com.jgoodies:jgoodies-forms:1.6.0'
+    compile 'com.jgoodies:jgoodies-looks:2.5.2'
+    compile fileTree(dir: 'lib/jgoodies/', includes: ['*.jar']) // instead of having the source code inside
+
+    compile 'org.apache.pdfbox:pdfbox:1.7.1'
+    compile 'org.apache.pdfbox:fontbox:1.7.1'
+    compile 'org.apache.pdfbox:jempbox:1.7.1'
+
+    // option parser
+    compile fileTree(dir: 'lib/ritopt/', includes: ['*.jar']) // instead of having the source code inside
+
+    compile 'org.openoffice:juh:3.2.1'
+    compile 'org.openoffice:jurt:3.2.1'
+    compile 'org.openoffice:ridl:3.2.1'
+    compile 'org.openoffice:unoil:3.2.1'
+
+    antlr2 'antlr:antlr:2.7.7'
+    antlr3 'org.antlr:antlr:3.4'
+    compile 'org.antlr:antlr-runtime:3.4'
+
+    compile 'mysql:mysql-connector-java:5.0.7'
+    compile 'org.postgresql:postgresql:9.2-1002-jdbc4'
+
+    compile fileTree(dir: 'lib', includes: ['glazedlists-1.8.0_java15.jar', 'jayatana-1.2.4.jar', 'microba.jar', 'spin.jar'])
+
+    compile 'net.java.dev.jna:jna:4.1.0'
+
+    // not available in maven repository
+    compile fileTree(dir: 'lib/plugin', includes: ['jpf.jar', 'jpf-boot.jar', 'commons-logging.jar', 'JPFCodeGenerator-rt.jar'])
+
+    compile fileTree(dir: 'lib/spl/jersey', includes: ['*.jar'])
+    compile fileTree(dir: 'lib/spl/sciplore', includes: ['*.jar'])
+
+    compile 'junit:junit:4.11'
+
+    generateClasspath fileTree(dir: 'lib/plugin', includes: ['jpf.jar', 'jpf-boot.jar', 'JPFCodeGenerator.jar', 'velocity-dep-1.5.jar'])
+}
+
+// use ant targets with prefix antTargets.XXXXX
+ant.importBuild "build-wrapper.xml"
+
+sourceCompatibility = 1.6
+mainClassName = "net.sf.jabref.JabRefMain"
+
+task wrapper(type: Wrapper) {
+    gradleVersion = '2.1'
+}
+
+compileJava {
+    // files are all encoded using UTF-8
+    options.encoding = 'UTF-8'
+    options.compilerArgs << "-Xlint:unchecked"
+}
+
+compileTestJava {
+    // files are all encoded using UTF-8
+    options.encoding = 'UTF-8'
+}
+
+javadoc {
+    options {
+        // files are all encoded using UTF-8
+        encoding = 'UTF-8'
+        version = true
+        author = true
+    }
+}
+
+// jabref specific tasks
+compileJava.dependsOn "generateSource"
+
+task generateSource(dependsOn: ["generatePluginSource", "generateBstGrammarSource", "generateSearchTreeParserSource"]) {
+    group = 'JabRef'
+    description = 'Generates all Java source files.'
+}
+
+task generatePluginSource(type: JavaExec) {
+    group = 'JabRef'
+    description = 'Generates _JabRefPlugin.java with JPF.'
+
+    ext.pluginsDir = "src/main/resources/plugins"
+
+    inputs.dir file(ext.pluginsDir)
+    outputs.file file("src/main/gen/net/sf/jabref/plugin/core/generated/_JabRefPlugin.java")
+
+    main = "net.sf.jabref.plugin.util.CodeGenerator"
+    args = [ext.pluginsDir]
+    classpath = configurations.generateClasspath
+}
+
+task generateBstGrammarSource(type: JavaExec) {
+    group = 'JabRef'
+    description = 'Generates BstLexer.java and BstParser.java from the Bst.g grammar file using antlr.'
+
+    File antlrSource = file('src/main/antlr3/net/sf/jabref/bst/Bst.g')
+
+    inputs.file antlrSource
+    outputs.file file('src/main/gen/net/sf/jabref/bst/BstLexer.java')
+    outputs.file file('src/main/gen/net/sf/jabref/bst/BstParser.java')
+
+    main = 'org.antlr.Tool'
+    classpath = configurations.antlr3
+    args = ["-o", file('src/main/gen/net/sf/jabref/bst/'), antlrSource]
+}
+
+task generateSearchLexerSource(type: JavaExec) {
+    String grammarFile = "Lexer"
+
+    group = 'JabRef'
+    description = "Generates java files for ${grammarFile}.g antlr2."
+
+    String packagePath = "net/sf/jabref/search"
+    File antlr2Path = file("src/main/antlr2")
+    File genPath = file("src/main/gen")
+
+    File antlrSource = file("$antlr2Path/$packagePath/${grammarFile}.g")
+    File destinationDir = file("$genPath/$packagePath")
+
+    inputs.file antlrSource
+    outputs.file file("$destinationDir/SearchExpression${grammarFile}.java")
+    outputs.file file("$destinationDir/SearchExpression${grammarFile}.smap")
+    outputs.file file("$destinationDir/SearchExpression${grammarFile}TokenTypes.java")
+    outputs.file file("$destinationDir/SearchExpression${grammarFile}TokenTypes.txt")
+
+    main = 'antlr.Tool'
+    classpath = configurations.antlr2
+    args = ["-o", destinationDir, antlrSource]
+}
+
+task generateSearchParserSource(type: JavaExec, dependsOn: "generateSearchLexerSource") {
+    String grammarFile = "Parser"
+
+    group = 'JabRef'
+    description = "Generates java files for ${grammarFile}.g antlr2."
+
+    String packagePath = "net/sf/jabref/search"
+    File antlr2Path = file("src/main/antlr2")
+    File genPath = file("src/main/gen")
+
+    File antlrSource = file("$antlr2Path/$packagePath/${grammarFile}.g")
+    File destinationDir = file("$genPath/$packagePath")
+
+    inputs.file antlrSource
+    outputs.file file("$destinationDir/SearchExpression${grammarFile}.java")
+    outputs.file file("$destinationDir/SearchExpression${grammarFile}.smap")
+    outputs.file file("$destinationDir/SearchExpression${grammarFile}TokenTypes.java")
+    outputs.file file("$destinationDir/SearchExpression${grammarFile}TokenTypes.txt")
+
+    main = 'antlr.Tool'
+    classpath = configurations.antlr2
+    args = ["-o", destinationDir, antlrSource]
+}
+
+task generateSearchTreeParserSource(type: JavaExec, dependsOn: "generateSearchParserSource") {
+    String grammarFile = "TreeParser"
+
+    group = 'JabRef'
+    description = "Generates java files for ${grammarFile}.g antlr2."
+
+    String packagePath = "net/sf/jabref/search"
+    File antlr2Path = file("src/main/antlr2")
+    File genPath = file("src/main/gen")
+
+    File antlrSource = file("$antlr2Path/$packagePath/${grammarFile}.g")
+    File destinationDir = file("$genPath/$packagePath")
+
+    inputs.file antlrSource
+    outputs.file file("$destinationDir/SearchExpression${grammarFile}.java")
+    outputs.file file("$destinationDir/SearchExpression${grammarFile}.smap")
+    outputs.file file("$destinationDir/SearchExpression${grammarFile}TokenTypes.java")
+    outputs.file file("$destinationDir/SearchExpression${grammarFile}TokenTypes.txt")
+
+    main = 'antlr.Tool'
+    classpath = configurations.antlr2
+    args = ["-o", destinationDir, antlrSource]
+}
+
+// git support in intellij idea
+idea.project.ipr {
+    withXml { provider ->
+        provider.node.component.find { it.@name == 'VcsDirectoryMappings' }.mapping.@vcs = 'Git'
+    }
+}
\ No newline at end of file