Skip to content

Instantly share code, notes, and snippets.

View Opalo's full-sized avatar

Maciek Opala Opalo

View GitHub Profile
@Opalo
Opalo / build.gradle
Created June 21, 2015 17:36
Gradle arquillian-spock-container
apply plugin: 'java'
repositories {
mavenCentral()
}
dependencies {
testCompile 'org.jboss.arquillian.spock:arquillian-spock-container:1.0.0.Beta3'
}
def lol(Map m, String s) {
println("s=$s")
println("m=$m")
}
lol("a", type:3)
@Opalo
Opalo / build.gradle
Created October 30, 2015 07:59
Calling execute on a task.
task t1 << {
println 't1'
}
task t2 << {
t1.execute()
}
def lol(String s, Closure c) {
print "s=$s"
c()
}
lol("a") { println "c" }
lol("a", { println "c" })
lol("a")
//misc.gradle
ext.someMethod = { projects ->
projects.each { p ->
println "$p.name"
}
}
//A build.gradle
apply from: 'misc.gradle'
new File('.').listFiles({f,s -> true} as FilenameFilter).each {println it}
@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
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);
task whatever(type: Exec) {
commandLine 'find', '.', '-iname', '*build*'
standardOutput = new ByteArrayOutputStream()
errorOutput = new ByteArrayOutputStream()
doLast {
println "std ${standardOutput.toString()}"
println "err ${errorOutput.toString()}"
}
}
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"