Skip to content

Commit

Permalink
Merge remote-tracking branch 'upstream/master' into convertSearchWorker
Browse files Browse the repository at this point in the history
* upstream/master:
  fixes remaining issues in #4844 (#4950)
  Fix threading issue with opening from recent libraries (#4943)
  New translations JabRef_en.properties (German) (#4946)
  New Crowdin translations (#4945)
  New Crowdin translations (#4944)
  Extract build plugins (#4934)
  • Loading branch information
Siedlerchr committed May 4, 2019
2 parents 2614523 + 6348f64 commit 572b8a1
Show file tree
Hide file tree
Showing 37 changed files with 1,092 additions and 4,171 deletions.
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -344,3 +344,6 @@ gradle-app.setting

# do not distribute Oracle's JDBC driver
lib/ojdbc.jar

# do not ignore the source of the build
!/buildSrc/src/
108 changes: 67 additions & 41 deletions build.gradle
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import groovy.json.JsonSlurper
import org.gradle.internal.os.OperatingSystem
import org.jabref.build.xjc.XjcTask

// to update the gradle wrapper, execute
// ./gradlew wrapper --gradle-version=4.4.1 --distribution-type=bin
Expand Down Expand Up @@ -35,10 +36,11 @@ apply plugin: 'jacoco'
apply plugin: 'install4j'
apply plugin: 'me.champeau.gradle.jmh'
apply plugin: 'checkstyle'
apply plugin: org.jabref.build.antlr.AntlrPlugin
apply plugin: org.jabref.build.xjc.XjcPlugin
apply plugin: org.jabref.build.localization.LocalizationPlugin

apply from: 'eclipse.gradle'
apply from: 'localization.gradle'
apply from: 'xjc.gradle'

group = "org.jabref"
version = "5.0-dev"
Expand Down Expand Up @@ -81,8 +83,6 @@ repositories {
}

configurations {
antlr3
antlr4
errorprone
}

Expand Down Expand Up @@ -174,6 +174,8 @@ dependencies {
testCompile "org.testfx:testfx-junit5:4.0.+"

checkstyle 'com.puppycrawl.tools:checkstyle:8.20'
xjc 'com.sun.xml.bind:jaxb-xjc:2.2.4-1'
jython 'org.python:jython-standalone:2.7.1'
}

jacoco {
Expand Down Expand Up @@ -264,65 +266,87 @@ processResources {
}


task generateSource(dependsOn: ["generateBstGrammarSource", "generateSearchGrammarSource"]) {
task generateSource(dependsOn: ["generateBstGrammarSource",
"generateSearchGrammarSource",
"generateMedlineSource",
"generateBibtexmlSource",
"generateEndnoteSource",
"generateModsSource"]) {
group = 'JabRef'
description 'Generates all Java source files.'
}

task generateBstGrammarSource(type: JavaExec) {
group 'JabRef'
description 'Generates BstLexer.java and BstParser.java from the Bst.g grammar file using antlr3.'
task generateBstGrammarSource(type: org.jabref.build.antlr.AntlrTask) {
group = "JabRef"
description = 'Generates BstLexer.java and BstParser.java from the Bst.g grammar file using antlr3.'

File antlrSource = file('src/main/antlr3/org/jabref/bst/Bst.g')
antlr = ANTLR3
inputFile = 'src/main/antlr3/org/jabref/bst/Bst.g'
outputDir = 'src/main/gen/org/jabref/logic/bst/'
}

inputs.file antlrSource
outputs.file file('src/main/gen/org/jabref/logic/bst/BstLexer.java')
outputs.file file('src/main/gen/org/jabref/logic/bst/BstParser.java')
task generateSearchGrammarSource(type: org.jabref.build.antlr.AntlrTask) {
group = 'JabRef'
description = "Generates java files for Search.g antlr4."

main = 'org.antlr.Tool'
classpath = configurations.antlr3
args = ["-o", file('src/main/gen/org/jabref/logic/bst/'), antlrSource]
antlr = ANTLR4
inputFile = "src/main/antlr4/org/jabref/search/Search.g4"
outputDir = "src/main/gen/org/jabref/search"
javaPackage = "org.jabref.search"
}

task generateSearchGrammarSource(type: JavaExec) {
String grammarFile = "Search"
task generateMedlineSource(type: XjcTask) {
group = 'JabRef'
description = "Generates java files for the medline importer."

group 'JabRef'
description "Generates java files for ${grammarFile}.g antlr4."
schemaFile = "src/main/resources/xjc/medline/medline.xsd"
outputDirectory = "src/main/gen/"
javaPackage = "org.jabref.logic.importer.fileformat.medline"
}

String packagePath = "org/jabref/search"
File antlrPath = file("src/main/antlr4")
File genPath = file("src/main/gen")
task generateBibtexmlSource(type: XjcTask) {
group = 'JabRef'
description = "Generates java files for the bibtexml importer."

File antlrSource = file("$antlrPath/$packagePath/${grammarFile}.g4")
File destinationDir = file("$genPath/$packagePath")
schemaFile = "src/main/resources/xjc/bibtexml/bibtexml.xsd"
outputDirectory = "src/main/gen"
javaPackage = "org.jabref.logic.importer.fileformat.bibtexml"
}

inputs.file antlrSource
outputs.file file("$destinationDir/${grammarFile}Parser.java")
outputs.file file("$destinationDir/${grammarFile}Lexer.java")
outputs.file file("$destinationDir/${grammarFile}Visitor.java")
outputs.file file("$destinationDir/${grammarFile}BaseVisitor.java")
outputs.file file("$destinationDir/${grammarFile}.tokens")
outputs.file file("$destinationDir/${grammarFile}Lexer.tokens")
task generateEndnoteSource(type: XjcTask) {
group = 'JabRef'
description = "Generates java files for the endnote importer."

main = 'org.antlr.v4.Tool'
classpath = configurations.antlr4
args = ["-o", destinationDir, "-visitor", "-no-listener", "-package", "org.jabref.search", antlrSource]
schemaFile = "src/main/resources/xjc/endnote/RSXML.dtd"
outputDirectory = "src/main/gen/"
javaPackage = "org.jabref.logic.importer.fileformat.endnote"
arguments = '-dtd'
}

compileJava {
options.encoding = 'UTF-8'
options.compilerArgs << "-Xlint:none"
//ignore annotation processor from log4j2
options.compilerArgs += '-proc:none'
task generateModsSource(type: XjcTask) {
group = 'JabRef'
description = "Generates java files for the mods importer."

schemaFile = "src/main/resources/xjc/mods/mods-3-7.xsd"
bindingFile = "src/main/resources/xjc/mods/mods-binding.xjb"
outputDirectory = "src/main/gen/"
javaPackage = "org.jabref.logic.importer.fileformat.mods"
arguments = '-npa'
}
compileJava.dependsOn "generateSource"

compileTestJava {
tasks.withType(JavaCompile) {
// use UTF-8
options.encoding = 'UTF-8'

// ignore annotation processor from log4j2
options.compilerArgs += '-proc:none'
}

compileJava {
options.compilerArgs << "-Xlint:none"
dependsOn "generateSource"
}

javadoc {
options {
encoding = 'UTF-8'
Expand All @@ -331,6 +355,8 @@ javadoc {
}
}

localization.script = 'scripts/syncLang.py'

// Test tasks
test {
useJUnitPlatform {
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
package org.jabref.build.antlr

import org.gradle.api.file.FileCollection

class Antlr3CommandLine implements AntlrCommandLine {

private final task

Antlr3CommandLine(AntlrTask task) {
this.task = task
}

@Override
String getMain() {
return "org.antlr.Tool"
}

@Override
FileCollection getClasspath() {
return task.project.configurations.antlr3
}

@Override
List<String> getArguments() {
return ["-o", task.project.file(task.outputDir).toString(), task.project.file(task.inputFile).toString()]
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
package org.jabref.build.antlr

import org.gradle.api.file.FileCollection

class Antlr4CommandLine implements AntlrCommandLine {

private final AntlrTask task

Antlr4CommandLine(AntlrTask task) {
this.task = task
}

@Override
String getMain() {
return "org.antlr.v4.Tool"
}

@Override
FileCollection getClasspath() {
return task.project.configurations.antlr4
}

@Override
List<String> getArguments() {
return ["-o", file(task.outputDir), "-visitor", "-no-listener", "-package", task.javaPackage, file(task.inputFile)]
}

private String file(String path) {
return task.project.file(path).toString()
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
package org.jabref.build.antlr

import org.gradle.api.file.FileCollection

/**
* Encapsulates a command line call to an version of the ANTLR tools.
*/
interface AntlrCommandLine {

String getMain()

FileCollection getClasspath()

List<String> getArguments()

}
23 changes: 23 additions & 0 deletions buildSrc/src/main/groovy/org/jabref/build/antlr/AntlrPlugin.groovy
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
package org.jabref.build.antlr

import org.gradle.api.Plugin
import org.gradle.api.Project

/**
* Configures the project for use with ANTLR 3 or 4.
*/
class AntlrPlugin implements Plugin<Project> {

public static final def ANTLR3_CONFIGURATION_NAME = "antlr3"
public static final def ANTLR4_CONFIGURATION_NAME = "antlr4"

@Override
void apply(Project target) {
def antlr3Cfg = target.configurations.create(ANTLR3_CONFIGURATION_NAME)
antlr3Cfg.description = "Dependencies required to run the ANTLR3 tool."

def antlr4Cfg = target.configurations.create(ANTLR4_CONFIGURATION_NAME)
antlr4Cfg.description = "Dependencies required to run the ANTLR4 tool."
}

}
68 changes: 68 additions & 0 deletions buildSrc/src/main/groovy/org/jabref/build/antlr/AntlrTask.groovy
Original file line number Diff line number Diff line change
@@ -0,0 +1,68 @@
package org.jabref.build.antlr

import org.gradle.api.tasks.JavaExec
import org.gradle.api.tasks.TaskAction

class AntlrTask extends JavaExec {

static def ANTLR3 = Antlr3CommandLine
static def ANTLR4 = Antlr4CommandLine

private Class<? extends AntlrCommandLine> antlr = ANTLR3
private String inputFile = ""
private String outputDir = ""
private String javaPackage = ""

public AntlrTask() {
project.configurations {
antlr3
antlr4
}
}

@TaskAction
@Override
void exec() {
AntlrCommandLine commandLine = antlr.newInstance(this)

main = commandLine.main
classpath = commandLine.classpath
args = commandLine.arguments

super.exec()
}

Class<? extends AntlrCommandLine> getAntlr() {
return antlr
}

void setAntlr(Class<? extends AntlrCommandLine> antlr) {
this.antlr = antlr
}

String getInputFile() {
return inputFile
}

void setInputFile(String inputFile) {
this.inputFile = inputFile
inputs.file(inputFile)
}

String getOutputDir() {
return outputDir
}

void setOutputDir(String outputDir) {
this.outputDir = outputDir
outputs.dir(outputDir)
}

String getJavaPackage() {
return javaPackage
}

void setJavaPackage(String javaPackage) {
this.javaPackage = javaPackage
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
package org.jabref.build.localization

import org.gradle.api.tasks.JavaExec
import org.gradle.api.tasks.TaskAction

class JythonTask extends JavaExec {


public static final String JYTHON_MAIN = 'org.python.util.jython'

@TaskAction
@Override
void exec() {
main JYTHON_MAIN
classpath project.configurations.getByName(LocalizationPlugin.CONFIGURATION_NAME).asPath

super.exec()
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
package org.jabref.build.localization

class LocalizationExtension {

def script

}
Loading

0 comments on commit 572b8a1

Please sign in to comment.