jira-plugin-intellij /src/test/resources/examples/TestScript.groovy

Language Groovy Lines 88
MD5 Hash a1de57f340ddd90d22aa3f6dcafa679b
Repository https://bitbucket.org/sorin/jira-plugin-intellij View Raw File View Project SPDX
 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
import com.atlassian.jira.ComponentManager
import com.onresolve.jira.groovy.PackageScanner
import com.onresolve.jira.groovy.GroovyRunner
import javax.script.ScriptEngine
import javax.script.Invocable
import com.atlassian.plugin.util.ClassLoaderUtils
import com.onresolve.jira.groovy.canned.admin.RealClass
import com.atlassian.jira.issue.Issue

def projectManager = ComponentManager.getInstance().getProjectManager()

log.setLevel (org.apache.log4j.Level.DEBUG)

class Bah{
    public static Issue staticIssue
}

issue = "barse"
5.times {
    println (x)
    Thread.sleep 1000
}
return

log.debug ("issue: $issue")
Issue myIssue = issue
Bah.staticIssue = issue

log.debug ("Issue: ${myIssue.getKey()} ... sleeping...")
Thread.sleep (1000)
log.debug ("Issue: ${myIssue.getKey()} ... waking...")


// log.debug new RealClass().toString()
return

log.debug this.class.classLoader.loadClass("com.onresolve.jira.groovy.canned.admin.RealClass").newInstance()
// log.debug Class.forName("com.onresolve.jira.groovy.canned.admin.RealClass").newInstance()

ScriptEngine engine
try {
    engine = new GroovyRunner().getScriptEngine(new File("groovy"))
} catch (Exception e) {
    log.warn "No groovy script engine"
    return
}

for (String className : PackageScanner.getClassesForPackage("com.onresolve.jira.groovy.canned.admin")) {
    InputStreamReader reader = new InputStreamReader(ClassLoaderUtils.getResourceAsStream("/" + className))

    log.warn reader
    engine.eval(reader)
    reader.close()

    Invocable invocableEngine = (Invocable) engine;
    log.debug "getName: " + invocableEngine.invokeFunction("getName");
    log.debug "getDescription: " + invocableEngine.invokeFunction("getDescription");
    
}




return


//ClassLoader cld = Thread.currentThread().getContextClassLoader();
//Enumeration<URL> resources = cld.getResources("/com/onresolve/jira/groovy/canned");
//log.warn resources
//
//// can be relative
//URL url = new URL("jar:file:/../../work/jiratest/3.13.5/atlassian-jira/WEB-INF/lib/groovyrunner-1.6.1.jar!/com/onresolve/jira/groovy/canned/CopyCustomField.groovy")
//log.warn url
//log.warn new File (url.getFile()).text

//log.warn Class.forName("com.onresolve.jira.groovy.canned.CopyCustomField").newInstance()

return "ended successfully"


/*
public class Arse {
    public static void main(String[] args) {
        println "main"
    }
    println "not main"
}*/
Back to Top