Skip to content

Commit

Permalink
Version bump to 1.4.0-SNAPSHOT.
Browse files Browse the repository at this point in the history
Rewrite build system to use gradle.
Clean up source for the new generation.
  • Loading branch information
shevek committed Dec 27, 2013
1 parent 39264fd commit bdc6c85
Show file tree
Hide file tree
Showing 111 changed files with 6,690 additions and 7,877 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,2 +1,3 @@
build
.*.swp
.gradle
66 changes: 66 additions & 0 deletions build.gradle
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"
}
}
}
46 changes: 0 additions & 46 deletions build.xml

This file was deleted.

12 changes: 12 additions & 0 deletions buildSrc/build.gradle
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'
}

33 changes: 33 additions & 0 deletions buildSrc/src/main/groovy/VelocityPlugin.groovy
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

}
}

58 changes: 58 additions & 0 deletions buildSrc/src/main/groovy/VelocityTask.groovy
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)
}
}
}
}
}
}

13 changes: 13 additions & 0 deletions codequality/HEADER
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.
Loading

0 comments on commit bdc6c85

Please sign in to comment.