forked from JabRef/jabref
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
5b6c540
commit 8dce805
Showing
5 changed files
with
169 additions
and
50 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
20 changes: 20 additions & 0 deletions
20
buildSrc/src/main/groovy/org/jabref/build/xjc/XjcPlugin.groovy
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
package org.jabref.build.xjc | ||
|
||
import org.gradle.api.Plugin | ||
import org.gradle.api.Project | ||
|
||
class XjcPlugin implements Plugin<Project> { | ||
|
||
static final def CONFIGURATION_NAME = "xjc" | ||
|
||
@Override | ||
void apply(Project target) { | ||
def configuration = target.configurations.create(CONFIGURATION_NAME) | ||
configuration.description = "Dependencies needed to run the XJC tool." | ||
|
||
target.afterEvaluate { evaluated -> | ||
evaluated.logger.info(evaluated.configurations.xjc.asPath) | ||
evaluated.ant.taskdef(name: 'xjc', classname: 'com.sun.tools.xjc.XJCTask', classpath: evaluated.configurations.getByName(CONFIGURATION_NAME).asPath) | ||
} | ||
} | ||
} |
93 changes: 93 additions & 0 deletions
93
buildSrc/src/main/groovy/org/jabref/build/xjc/XjcTask.groovy
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,93 @@ | ||
package org.jabref.build.xjc | ||
|
||
import org.gradle.api.DefaultTask | ||
import org.gradle.api.tasks.Input | ||
import org.gradle.api.tasks.Optional | ||
import org.gradle.api.tasks.TaskAction | ||
|
||
class XjcTask extends DefaultTask { | ||
|
||
private def schemaFile | ||
@Optional | ||
private def bindingFile | ||
private def outputDirectory | ||
private String javaPackage | ||
@Optional | ||
private String arguments | ||
|
||
@TaskAction | ||
def generateClasses() { | ||
project.mkdir(outputDirectory) | ||
project.ant.xjc(destdir: outputDirectory, package: javaPackage) { | ||
schema(dir: schemaFile.getParent(), includes: schemaFile.getName()) | ||
if (bindingFile != null) { | ||
binding(dir: bindingFile.getParent(), includes: bindingFile.getName()) | ||
} | ||
if (arguments != null) { | ||
arg(value: arguments) | ||
} | ||
} | ||
} | ||
|
||
@Input | ||
File getSchemaFile() { | ||
if (schemaFile == null) { | ||
return null | ||
} | ||
return project.file(schemaFile) | ||
} | ||
|
||
void setSchemaFile(Object schemaFile) { | ||
this.schemaFile = schemaFile | ||
} | ||
|
||
File getOutputDirectory() { | ||
if (outputDirectory == null) { | ||
return null | ||
} | ||
return project.file(outputDirectory) | ||
} | ||
|
||
void setOutputDirectory(Object outputDirectory) { | ||
this.outputDirectory = outputDirectory | ||
updateOutput() | ||
} | ||
|
||
String getJavaPackage() { | ||
return javaPackage | ||
} | ||
|
||
void setJavaPackage(String javaPackage) { | ||
this.javaPackage = javaPackage | ||
updateOutput() | ||
} | ||
|
||
String getArguments() { | ||
return arguments | ||
} | ||
|
||
void setArguments(String args) { | ||
this.arguments = args | ||
} | ||
|
||
@Input | ||
File getBindingFile() { | ||
if (bindingFile == null) { | ||
return null | ||
} | ||
return project.file(bindingFile) | ||
} | ||
|
||
void setBindingFile(Object binding) { | ||
this.bindingFile = binding | ||
} | ||
|
||
private void updateOutput() { | ||
if (outputDirectory != null && javaPackage != null) | ||
outputs.dir(new File(getOutputDirectory(), packageAsPath(javaPackage))) | ||
} | ||
|
||
private static String packageAsPath(String pkg) { | ||
return pkg.replace((char) '.', File.separatorChar) | ||
} | ||
} |
This file was deleted.
Oops, something went wrong.