Skip to content

Instantly share code, notes, and snippets.

View musketyr's full-sized avatar
🖥️
I may be slow to respond.

Vladimir Orany musketyr

🖥️
I may be slow to respond.
View GitHub Profile
def stageDir = buildDir.path + '/tmp/fatjar-stage/'
task fatjarStageClasses(type: Copy, dependsOn: classes){
from sourceSets.main.output.classesDir
into stageDir
}
task fatjarStageResources(type: Copy, dependsOn: classes){
from sourceSets.main.output.resourcesDir
into stageDir
// GPars - Groovy Parallel Systems
//
// Copyright © 2008-11 The original author or authors
//
// 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
//
@musketyr
musketyr / gist:4119919
Created November 20, 2012 18:31
GaelykTemplateServlet
import groovy.text.Template
import groovy.transform.CompileStatic
import org.codehaus.groovy.runtime.InvokerInvocationException
class GaelykTemplateServlet {
public static void main(String[] args) {
GaelykTemplateServlet servlet = new GaelykTemplateServlet()
servlet.init(true)
@musketyr
musketyr / AutoCache.java
Created February 10, 2013 09:54
Prototype of automatic cache for GAE
package groovyx.gaelyk.datastore;
import java.util.ArrayList;
import java.util.List;
import com.google.appengine.api.datastore.DeleteContext;
import com.google.appengine.api.datastore.Entity;
import com.google.appengine.api.datastore.Key;
import com.google.appengine.api.datastore.PostDelete;
import com.google.appengine.api.datastore.PostPut;
dependencies {
// eclipse compiler problem again :-(
String groovyVersion = '2.1.2'
if(project.hasProperty('groovy.2.1.eclipse.version')){
groovyVersion = project.getProperty('groovy.2.1.eclipse.version')
}
groovy "org.codehaus.groovy:groovy-all:${groovyVersion}", {
force = true
}
}
package test
import groovy.transform.CompileStatic
@CompileStatic
class GreclipseProblem {
List<Category> categories
int failToCompile(){
@musketyr
musketyr / intIsNotInt.groovy
Created April 12, 2013 06:07
Why integer is not an integer when the variable is used in closure?
int width = null
int height = null
assert width.getClass() == org.codehaus.groovy.runtime.NullObject
assert height.getClass() == org.codehaus.groovy.runtime.NullObject
new File('image.png').image.transform {
resize width, height
}
@musketyr
musketyr / gist:8863308
Created February 7, 2014 14:12
Rewritten parametrized JUnit test to Spock
import spock.lang.Shared
import spock.lang.Specification
import spock.lang.Unroll
import java.util.regex.Pattern
/**
* @author musketyr
*/
class EmailValidatorSpec extends Specification {
package com.example.com;
import java.io.File;
import java.io.IOException;
import java.net.URL;
import java.security.GeneralSecurityException;
import java.util.Arrays;
import java.util.Collections;
import java.util.logging.Level;
import java.util.logging.Logger;
apply plugin: 'groovy'
apply plugin: 'war'
apply plugin: 'gaelyk'
apply plugin: 'idea'
appengine {
disableUpdateCheck = true
appcfg {
oauth2 = true
}