public void execute(FileCollection classpath, final FileCollection executionData, final File destinationFile) { ant.withClasspath(classpath).execute(new Closure<Object>(this, this) { @SuppressWarnings("UnusedDeclaration") public Object doCall(Object it) { final GroovyObjectSupport antBuilder = (GroovyObjectSupport) it; antBuilder.invokeMethod("taskdef", ImmutableMap.of( "name", "jacocoMerge", "classname", "org.jacoco.ant.MergeTask" )); Map<String, File> arguments = ImmutableMap.of("destfile", destinationFile); antBuilder.invokeMethod("jacocoMerge", new Object[]{arguments, new Closure<Object>(this, this) { public Object doCall(Object ignore) { executionData.addToAntBuilder(antBuilder, "resources"); return null; } }}); return null; } }); }
private void invokeGroovydoc(final Set<Groovydoc.Link> links, List<File> combinedClasspath, final Map<String, Object> args) { ant.withClasspath(combinedClasspath).execute(new Closure<Object>(this, this) { @SuppressWarnings("UnusedDeclaration") public Object doCall(Object it) { final GroovyObjectSupport antBuilder = (GroovyObjectSupport) it; antBuilder.invokeMethod("taskdef", ImmutableMap.of( "name", "groovydoc", "classname", "org.codehaus.groovy.ant.Groovydoc" )); antBuilder.invokeMethod("groovydoc", new Object[]{args, new Closure<Object>(this, this) { public Object doCall(Object ignore) { for (Groovydoc.Link link : links) { antBuilder.invokeMethod("link", new Object[]{ ImmutableMap.of( "packages", Joiner.on(",").join(link.getPackages()), "href", link.getUrl() ) }); } return null; } }}); return null; } }); }
public void execute(final FileCollection source, File destDir, boolean use, String windowTitle, String docTitle, String header, String footer, String overview, boolean includePrivate, final Set<Groovydoc.Link> links, final Iterable<File> groovyClasspath, Iterable<File> classpath, Project project) { final File tmpDir = new File(project.getBuildDir(), "tmp/groovydoc"); FileOperations fileOperations = (ProjectInternal) project; fileOperations.delete(tmpDir); fileOperations.copy(new Action<CopySpec>() { public void execute(CopySpec copySpec) { copySpec.from(source).into(tmpDir); } }); final Map<String, Object> args = Maps.newLinkedHashMap(); args.put("sourcepath", tmpDir.toString()); args.put("destdir", destDir); args.put("use", use); args.put("private", includePrivate); putIfNotNull(args, "windowtitle", windowTitle); putIfNotNull(args, "doctitle", docTitle); putIfNotNull(args, "header", header); putIfNotNull(args, "footer", footer); putIfNotNull(args, "overview", overview); List<File> combinedClasspath = ImmutableList.<File>builder() .addAll(classpath) .addAll(groovyClasspath) .build(); ant.withClasspath(combinedClasspath).execute(new Closure<Object>(this, this) { @SuppressWarnings("UnusedDeclaration") public Object doCall(Object it) { final GroovyObjectSupport antBuilder = (GroovyObjectSupport) it; antBuilder.invokeMethod("taskdef", ImmutableMap.of( "name", "groovydoc", "classname", "org.codehaus.groovy.ant.Groovydoc" )); antBuilder.invokeMethod("groovydoc", new Object[]{args, new Closure<Object>(this, this) { public Object doCall(Object ignore) { for (Groovydoc.Link link : links) { antBuilder.invokeMethod("link", new Object[]{ ImmutableMap.of( "packages", Joiner.on(",").join(link.getPackages()), "href", link.getUrl() ) }); } return null; } }}); return null; } }); }
public static List<GroovyCompletionSuggestion> buildAndCacheSuggestions(Class<?> cls) { if (cache.containsKey(cls.getName())) { return cache.get(cls.getName()); } List<GroovyCompletionSuggestion> ret = new LinkedList<GroovyCompletionSuggestion>(); //go through the class's public and non synthetic methods //we want all the public methods. Method[] methods = cls.getMethods(); for(Method m : methods) { if (m.getDeclaringClass().equals(Object.class)) { continue; } if (m.getDeclaringClass().equals(GroovyObject.class)) { continue; } if (m.getDeclaringClass().equals(GroovyObjectSupport.class)) { continue; } if (m.getDeclaringClass().getName().startsWith("groovy.lang")) { continue; } //we will not care about mutators String propName = getAccessorPropertyName(m); if (propName != null) { addToCollectionIfNotThere(ret, new GroovyCompletionSuggestion( GroovyCompletionSuggestionType.PROPERTY, propName, m.getReturnType().getName())); continue; } //we could be in the situation where a set-method is not a mutator //but we can take the risk of not presenting all the possibilities if (m.isSynthetic() || isPropertyMutator(m)) { continue; } addToCollectionIfNotThere(ret, new GroovyCompletionSuggestion( GroovyCompletionSuggestionType.METHOD, m.getName(), m.getReturnType().getName())); } ret = Collections.unmodifiableList(ret); cache.put(cls.getName(), ret); return ret; }