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
// here goes the conf | |
... | |
// append this | |
if (file('user.gradle').exists()) { | |
apply from: 'user.gradle' // if a user file is present, tweak the build (add tasks, ...). This file should not be in VCS. | |
} |
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
apply plugin: "sonar-runner" | |
sonarRunner { | |
sonarProperties { | |
property "sonar.sourceEncoding", "UTF-8" | |
// must choose one and only one language, Sonar doesn't know about polyglot projects! | |
property "sonar.language", "java" | |
} | |
} |
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
// Copy JavadocFixTool.java into buildSrc/src/main/java | |
// this will apply the javadoc fix tool to all generated javadocs | |
// we use it to make sure that the javadocs are not vulnerable independently of the JDK used to build | |
allprojects { | |
tasks.withType(Javadoc).all { | |
doLast { | |
def javadocFix = new JavadocFixTool() | |
javadocFix.recursive = true | |
javadocFix.doPatch = true |
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
class Top { | |
int overload() { 0 } | |
} | |
class Bottom { | |
int overload(String... args) { 1+args.length } | |
} | |
@CompileStatic | |
void boom() { | |
def b = new Bottom() |
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
@Grab('net.sourceforge.htmlcleaner:htmlcleaner:2.4') | |
import org.htmlcleaner.* | |
def src = new File('html').toPath() | |
def dst = new File('asciidoc').toPath() | |
def cleaner = new HtmlCleaner() | |
def props = cleaner.properties | |
props.translateSpecialEntities = false | |
def serializer = new SimpleHtmlSerializer(props) |
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
import groovy.transform.* | |
@Immutable class Coordinates { | |
double latitude, longitude | |
} | |
@Immutable class Path { | |
Coordinates[] coordinates | |
} |
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
@Grab(group='org.gperfutils', module='gbench', version='0.4.2-groovy-2.1') | |
import groovy.transform.CompileStatic | |
import groovy.transform.Memoized | |
def untypedFib(n) { | |
n<2?n:untypedFib(n-1)+untypedFib(n-2) | |
} | |
int typedFib(int n) { | |
n<2?n:typedFib(n-1)+typedFib(n-2) | |
} |
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
package me.champeau.groovydroid | |
import android.app.Activity | |
import android.os.Bundle | |
import android.util.Log | |
import android.view.Menu | |
import android.view.View | |
import android.widget.EditText | |
import com.android.dx.dex.DexFormat | |
import com.android.dx.dex.DexOptions |
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
String.metaClass.grep = { pattern, cl -> | |
def matcher = delegate =~ pattern | |
if (matcher.find()) { | |
cl.doCall(*matcher.collect { it }) | |
} | |
} | |
def address = 'Beverly Hills, 90210'.grep(/([\w\s]+),\s*(\d+)/) { match, city, zip -> | |
[city: city, zip: zip] | |
} | |
assert address == [city: 'Beverly Hills', zip: '90210'] |
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
import org.codehaus.groovy.control.CompilerConfiguration | |
import groovy.transform.ToString | |
import static org.codehaus.groovy.control.customizers.builder.CompilerCustomizationBuilder.* | |
import org.codehaus.groovy.control.customizers.ASTTransformationCustomizer | |
def cc = new CompilerConfiguration() | |
withConfig(cc) { | |
inline(phase: 'CONVERSION') { source, context, classNode -> | |
if (classNode.annotations.any { it.classNode.name == 'Entity' }) { | |
new ASTTransformationCustomizer(ToString, includeNames:true).call(source, context, classNode) |