-
Notifications
You must be signed in to change notification settings - Fork 36
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Rewrite build system to use gradle. Clean up source for the new generation.
- Loading branch information
Showing
111 changed files
with
6,690 additions
and
7,877 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,2 +1,3 @@ | ||
build | ||
.*.swp | ||
.gradle |
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,66 @@ | ||
// Establish version and status | ||
ext.githubProjectName = rootProject.name // Change if github project name is not the same as the root project's name | ||
group = "org.anarres.${githubProjectName}" | ||
|
||
buildscript { | ||
repositories { | ||
// mavenLocal() | ||
mavenCentral() // maven { url 'http://jcenter.bintray.com' } | ||
} | ||
apply from: file('gradle/buildscript.gradle'), to: buildscript | ||
} | ||
|
||
allprojects { | ||
repositories { | ||
// mavenLocal() | ||
mavenCentral() // maven { url: 'http://jcenter.bintray.com' } | ||
} | ||
} | ||
|
||
apply plugin: 'idea' | ||
|
||
apply from: file('gradle/convention.gradle') | ||
apply from: file('gradle/maven.gradle') | ||
apply from: file('gradle/check.gradle') | ||
apply from: file('gradle/license.gradle') | ||
// apply from: file('gradle/release.gradle') | ||
|
||
apply plugin: 'application' | ||
apply plugin: VelocityPlugin | ||
|
||
dependencies { | ||
compile 'com.google.code.findbugs:jsr305:2.0.2' | ||
compile 'gnu.getopt:java-getopt:1.0.13' | ||
compile 'org.apache.ant:ant:1.7.0' | ||
|
||
testCompile 'junit:junit:4.8.1' | ||
} | ||
|
||
velocity { | ||
def p = project | ||
context { | ||
version = p.version | ||
} | ||
} | ||
|
||
test { | ||
systemProperty 'org.apache.commons.logging.Log', 'org.apache.commons.logging.impl.SimpleLog' | ||
systemProperty 'org.apache.commons.logging.simplelog.defaultlog', 'debug' | ||
|
||
testLogging { | ||
if (System.properties['test.single']) { | ||
// events "passed", "skipped", "failed" | ||
events "started", "passed", "skipped", "failed" | ||
showExceptions true | ||
exceptionFormat "full" | ||
showStandardStreams true | ||
} else { | ||
events "failed" | ||
} | ||
|
||
debug { | ||
events "started", "passed", "skipped", "failed", "standard_out", "standard_error" | ||
exceptionFormat "full" | ||
} | ||
} | ||
} |
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,12 @@ | ||
apply plugin: 'groovy' | ||
apply plugin: 'idea' | ||
|
||
repositories { | ||
mavenCentral() | ||
} | ||
|
||
dependencies { | ||
compile gradleApi() | ||
compile 'org.apache.velocity:velocity:1.7' | ||
} | ||
|
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,33 @@ | ||
import org.gradle.api.Plugin | ||
import org.gradle.api.Project | ||
import org.apache.velocity.VelocityContext | ||
import org.apache.velocity.app.VelocityEngine | ||
import org.apache.velocity.runtime.log.SystemLogChute | ||
|
||
class VelocityPluginExtension { | ||
String inputDir = "src/main/velocity" | ||
String outputDir = "build/generated-sources/velocity" | ||
Map<String, Object> contextValues = [:] | ||
def context(Closure closure) { | ||
contextValues.with closure | ||
} | ||
} | ||
|
||
class VelocityPlugin implements Plugin<Project> { | ||
void apply(Project project) { | ||
|
||
project.extensions.create("velocity", VelocityPluginExtension) | ||
|
||
project.task('velocityVpp', type: VelocityTask) { | ||
description "Preprocesses velocity template files." | ||
inputDir = project.file(project.velocity.inputDir) | ||
outputDir = project.file(project.velocity.outputDir) | ||
contextValues = project.velocity.contextValues | ||
} | ||
|
||
project.compileJava.dependsOn(project.velocityVpp) | ||
project.sourceSets.main.java.srcDir project.velocity.outputDir | ||
|
||
} | ||
} | ||
|
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,58 @@ | ||
import org.apache.velocity.VelocityContext | ||
import org.apache.velocity.app.VelocityEngine | ||
import org.apache.velocity.runtime.log.SystemLogChute | ||
import org.gradle.api.DefaultTask | ||
import org.gradle.api.tasks.InputDirectory | ||
import org.gradle.api.tasks.OutputDirectory | ||
import org.gradle.api.tasks.TaskAction | ||
|
||
class VelocityTask extends DefaultTask { | ||
|
||
@InputDirectory | ||
File inputDir | ||
|
||
@OutputDirectory | ||
File outputDir | ||
|
||
String filter = '**/*.java' | ||
|
||
File includeDir | ||
|
||
Map<String, Object> contextValues = [:] | ||
|
||
@TaskAction | ||
void run() { | ||
outputDir.deleteDir() | ||
outputDir.mkdirs() | ||
// println "Velocity: $inputDir -> $outputDir" | ||
|
||
VelocityEngine engine = new VelocityEngine() | ||
engine.setProperty(VelocityEngine.RUNTIME_LOG_LOGSYSTEM_CLASS, SystemLogChute.class.name) | ||
engine.setProperty(VelocityEngine.RESOURCE_LOADER, "file") | ||
engine.setProperty(VelocityEngine.FILE_RESOURCE_LOADER_CACHE, "true") | ||
if (includeDir != null) | ||
engine.setProperty(VelocityEngine.FILE_RESOURCE_LOADER_PATH, includeDir.getAbsolutePath()) | ||
def inputFiles = project.fileTree( | ||
dir: inputDir, | ||
include: filter | ||
) | ||
inputFiles.visit { e -> | ||
if (e.file.isFile()) { | ||
File outputFile = e.relativePath.getFile(outputDir) | ||
VelocityContext context = new VelocityContext() | ||
contextValues.each { context.put(it.key, it.value) } | ||
context.put('project', project) | ||
context.put('package', e.relativePath.parent.segments.join('.')) | ||
context.put('class', e.relativePath.lastName.replaceFirst("\\.java\$", "")) | ||
// println "Parsing ${e.file}" | ||
e.file.withReader { reader -> | ||
outputFile.parentFile.mkdirs() | ||
outputFile.withWriter { writer -> | ||
engine.evaluate(context, writer, e.relativePath.toString(), reader) | ||
} | ||
} | ||
} | ||
} | ||
} | ||
} | ||
|
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,13 @@ | ||
Copyright ${year} Netflix, Inc. | ||
|
||
Licensed under the Apache License, Version 2.0 (the "License"); | ||
you may not use this file except in compliance with the License. | ||
You may obtain a copy of the License at | ||
|
||
http://www.apache.org/licenses/LICENSE-2.0 | ||
|
||
Unless required by applicable law or agreed to in writing, software | ||
distributed under the License is distributed on an "AS IS" BASIS, | ||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
See the License for the specific language governing permissions and | ||
limitations under the License. |
Oops, something went wrong.