Skip to content

Instantly share code, notes, and snippets.

View Opalo's full-sized avatar

Maciek Opala Opalo

View GitHub Profile
task cloneProtobuf(type:Exec) {
workingDir '.'
commandLine 'git', 'clone', '[email protected]:google/protobuf.git', 'build/protobuf'
outputs.file 'build/protobuf/.git/config'
}
task t1
task t2 {
dependsOn = t1
}
apply plugin: 'java'
repositories {
mavenCentral()
}
dependencies {
compile "org.springframework:spring-core:3.2.9.RELEASE"
compile "org.springframework:spring-beans:3.2.9.RELEASE"
compile "org.springframework:spring-context:3.2.9.RELEASE"
task whatever(type: Exec) {
commandLine 'find', '.', '-iname', '*build*'
standardOutput = new ByteArrayOutputStream()
errorOutput = new ByteArrayOutputStream()
doLast {
println "std ${standardOutput.toString()}"
println "err ${errorOutput.toString()}"
}
}
DROP TABLE IF EXISTS CAT CASCADE;
CREATE TABLE CAT (
ID BIGINT,
NAME CHARACTER VARYING(255) NOT NULL UNIQUE
);
ALTER TABLE CAT
ADD CONSTRAINT CAT_PK PRIMARY KEY (ID);
@Opalo
Opalo / gist:792c38c689fbedd762670812cb9f7e7c
Last active June 10, 2018 08:38
Postgres embedded DB configuration for spring testing
// configuration (groovy)
import de.flapdoodle.embed.process.runtime.Network
import org.postgresql.ds.PGPoolingDataSource
import org.springframework.context.annotation.Bean
import org.springframework.context.annotation.Configuration
import org.springframework.context.annotation.DependsOn
import org.springframework.context.annotation.Profile
import ru.yandex.qatools.embed.postgresql.PostgresExecutable
import ru.yandex.qatools.embed.postgresql.PostgresProcess
new File('.').listFiles({f,s -> true} as FilenameFilter).each {println it}
//misc.gradle
ext.someMethod = { projects ->
projects.each { p ->
println "$p.name"
}
}
//A build.gradle
apply from: 'misc.gradle'
def lol(String s, Closure c) {
print "s=$s"
c()
}
lol("a") { println "c" }
lol("a", { println "c" })
lol("a")
@Opalo
Opalo / build.gradle
Created October 30, 2015 07:59
Calling execute on a task.
task t1 << {
println 't1'
}
task t2 << {
t1.execute()
}