Imported Upstream version 2.11~beta2+ds
[debian/jabref.git] / build.gradle
index aa66adaba3ebf8f9d6f05a2bb93d0185110eaba8..64e5d5b422da9b77ad58df31ecf41f57bdcf3660 100644 (file)
-apply plugin: 'java'\r
-\r
-// with gradle 1.1, Sonar 3.2 is not working. One needs Sonar 3.1.1\r
-apply plugin: 'sonar'\r
-\r
-sourceSets {\r
-       main {\r
-               java {\r
-                       srcDir 'src/java'\r
-               }\r
-               resources {\r
-                       srcDir 'src/resource'\r
-               }\r
-       }\r
-}\r
-\r
-repositories {\r
-       mavenCentral()\r
-}\r
-\r
-/* ANTLR support for Bst.g\r
-Source: http://fenrock.wordpress.com/2012/05/17/gradle-and-antlr-3-x/\r
-*/\r
-\r
-configurations {\r
-       antlr3\r
-}\r
-\r
-dependencies {\r
-       compile 'org.antlr:antlr-runtime:3.4'\r
-       antlr3 'org.antlr:antlr:3.4'\r
-}\r
-task generateGrammarSource(type: JavaExec) {\r
-    def antlrSource = 'src/java/net/sf/jabref/bst'\r
-    destinationDir = antlrSource\r
-\r
-    inputs.dir file(antlrSource)\r
-    outputs.dir file(destinationDir)\r
-\r
-    def grammars = fileTree(antlrSource).include('**/*.g')\r
-\r
-    main = 'org.antlr.Tool'\r
-    classpath = configurations.antlr3\r
-    args = ["-o", "${destinationDir}", grammars.files].flatten()\r
-}\r
-\r
-/*\r
- Code for JavaNCSS adapted from http://gradle.codehaus.org/Cookbook#Cookbook-usingJavaNCSS\r
- JavaNCSS: http://www.kclee.de/clemens/java/javancss/\r
-\r
-Cyclomatic\r
-Complexity             Ease of       Risk\r
-Number (CCN)           maintenance\r
-(McCabe metric)\r
----------------------------------------------\r
-1-10, simple           easy          minimum\r
-11-20, complex         moderate      moderate\r
-21-50, more complex    hard          high\r
->50, unstable          very hard     very high\r
-*/\r
-\r
-configurations {\r
-    javancssConf\r
-}\r
-\r
-dependencies {\r
-    javancssConf 'org.codehaus.javancss:javancss:32.53'\r
-}\r
-\r
-task javancss << {\r
-    println 'Running javancss quality metrics tool'\r
-    ant {\r
-        taskdef(name:'javancss', classname:'javancss.JavancssAntTask', classpath: configurations.javancssConf.asPath)\r
-        javancss(\r
-                       srcdir:'src/java',\r
-                       includes:'**/*.java',\r
-                       excludes:'jama/**/*.java, jmat/**/*.java, cformat/**/*.java',\r
-                       abortOnFail:'false',\r
-                       generateReport:'true',\r
-                       outputfile:'build/javancss_report.plain',\r
-                       ccnPerFuncMax:'30',\r
-                       format:'plain',\r
-                       packageMetrics:'true',\r
-                       classMetrics:'false',\r
-                       functionMetrics:'false'\r
-               )\r
-    }\r
-}\r
+apply plugin: "java"
+apply plugin: "eclipse"
+apply plugin: "idea"
+apply plugin: "application"
+apply plugin: 'project-report'
+
+
+// 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 {
+            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