Skip to content

Instantly share code, notes, and snippets.

@breskeby
breskeby / build.gralde
Created October 8, 2014 08:15
set language level explicitly
// root projects build.gradle file
apply plugin: 'idea'
idea {
project {
languageLevel = '1.6'
}
}
@breskeby
breskeby / build.gradle
Created October 8, 2014 08:14
overwrite idea gradle import defaults
apply plugin:'idea'
idea {
module {
outputDir = file('out')
testOutputDir = file('testout')
excludeDirs -= file('build')
excludeDirs += file('build/classes')
excludeDirs += file('build/libs')
excludeDirs += file('build/tmp')
}
@breskeby
breskeby / build.gradle
Created October 8, 2014 08:13
simple jaxb source generation with gradle
apply plugin:'idea'
apply plugin:'groovy'
repositories{
jcenter()
}
configurations{
jaxb
}
@breskeby
breskeby / build.gradle
Created September 23, 2014 19:29
whitelisted dependencies
buildscript {
repositories {
mavenCentral()
}
dependencies {
classpath 'org.springframework.boot:spring-boot-gradle-plugin:1.1.1.RELEASE'
}
}
apply plugin: 'spring-boot'
@breskeby
breskeby / gist:eb0a43caa0722b3ec8a7
Last active August 29, 2015 14:06
sample test spec for testing with gradle toolingapi and task options (tested with 2.1)
package org.acme
import org.gradle.tooling.BuildLauncher
import org.gradle.tooling.GradleConnector
import org.gradle.tooling.ProjectConnection
import org.junit.Rule
import org.junit.rules.TemporaryFolder
import spock.lang.Specification
/**
* Created by Rene on 11/09/14.
@breskeby
breskeby / build.gradle
Last active August 29, 2015 14:05
Extending objects in NamedDomainObjectContainers (GRADLE)
import org.gradle.internal.reflect.Instantiator
class Host {
String name
Host(String name){
this.name = name
}
}
@breskeby
breskeby / gist:b8b420d1016e2b173202
Last active August 29, 2015 14:02
react on failed builds
// this needs some more logic to track "build failures". (e.g. via taskListener)
task pushWhenSuccess << {
// react on build successful
}
task resetOnFail << {
// react on build failed
}
@breskeby
breskeby / build.gradle
Created April 25, 2014 08:33
log java compiler warnings with gradle
tasks.withType(JavaCompile){
def warnLogFile = file("$buildDir/${name}Warnings.log")
logging.addStandardErrorListener(new StandardOutputListener(){
void onOutput(CharSequence output){
warnLogFile << output
}
})
}
@breskeby
breskeby / gist:7858657
Last active August 3, 2018 23:37
dos2unix on some text files with gradle
task convertFiles <<{
fileTree("someFolder").matching{ include "**/*.txt"}.each{ aFile ->
exec{
commandLine 'dos2unix'
args aFile.absolutePath
}
}
}
#!/bin/bash
FOUND=0
CURR_PATH="$PWD"
REAL_GRADLEW="$CURR_PATH/gradlew"
REAL_MASTER_GRADLEW="$CURR_PATH/master/gradlew"
# Check current directory, which might be root directory for gradlew
if [ -x "$REAL_GRADLEW" ]; then
FOUND=1