private void configureGroovydoc() { project.getTasks().withType(Groovydoc.class, new Action<Groovydoc>() { public void execute(final Groovydoc groovydoc) { groovydoc.getConventionMapping().map("groovyClasspath", new Callable<Object>() { public Object call() throws Exception { return groovyRuntime.inferGroovyClasspath(groovydoc.getClasspath()); } }); groovydoc.getConventionMapping().map("destinationDir", new Callable<Object>() { public Object call() throws Exception { return new File(java(project.getConvention()).getDocsDir(), "groovydoc"); } }); groovydoc.getConventionMapping().map("docTitle", new Callable<Object>() { public Object call() throws Exception { return project.getExtensions().getByType(ReportingExtension.class).getApiDocTitle(); } }); groovydoc.getConventionMapping().map("windowTitle", new Callable<Object>() { public Object call() throws Exception { return project.getExtensions().getByType(ReportingExtension.class).getApiDocTitle(); } }); } }); }
public void execute(final FileCollection source, File destDir, boolean use, boolean noTimestamp, boolean noVersionStamp, 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); } }); List<File> combinedClasspath = ImmutableList.<File>builder() .addAll(classpath) .addAll(groovyClasspath) .build(); VersionNumber version = VersionNumber.parse(getGroovyVersion(combinedClasspath)); final Map<String, Object> args = Maps.newLinkedHashMap(); args.put("sourcepath", tmpDir.toString()); args.put("destdir", destDir); args.put("use", use); if (isAtLeast(version, "2.4.6")) { args.put("noTimestamp", noTimestamp); args.put("noVersionStamp", noVersionStamp); } args.put("private", includePrivate); putIfNotNull(args, "windowtitle", windowTitle); putIfNotNull(args, "doctitle", docTitle); putIfNotNull(args, "header", header); putIfNotNull(args, "footer", footer); if (overview != null) { args.put("overview", overview); } invokeGroovydoc(links, combinedClasspath, args); }
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; } }); }
private void configureGroovydoc(final Project project) { Groovydoc groovyDoc = project.getTasks().create(GROOVYDOC_TASK_NAME, Groovydoc.class); groovyDoc.setDescription("Generates Groovydoc API documentation for the main source code."); groovyDoc.setGroup(JavaBasePlugin.DOCUMENTATION_GROUP); JavaPluginConvention convention = project.getConvention().getPlugin(JavaPluginConvention.class); SourceSet sourceSet = convention.getSourceSets().getByName(SourceSet.MAIN_SOURCE_SET_NAME); groovyDoc.setClasspath(sourceSet.getOutput().plus(sourceSet.getCompileClasspath())); GroovySourceSet groovySourceSet = new DslObject(sourceSet).getConvention().getPlugin(GroovySourceSet.class); groovyDoc.setSource(groovySourceSet.getGroovy()); }
private void configureGroovydoc() { project.getTasks().withType(Groovydoc.class, new Action<Groovydoc>() { public void execute(final Groovydoc groovydoc) { groovydoc.getConventionMapping().map("groovyClasspath", new Callable<Object>() { public Object call() throws Exception { FileCollection groovyClasspath = groovyRuntime.inferGroovyClasspath(groovydoc.getClasspath()); // Jansi is required to log errors when generating Groovydoc ConfigurableFileCollection jansi = project.files(moduleRegistry.getExternalModule("jansi").getImplementationClasspath().getAsFiles()); return groovyClasspath.plus(jansi); } }); groovydoc.getConventionMapping().map("destinationDir", new Callable<Object>() { public Object call() throws Exception { return new File(java(project.getConvention()).getDocsDir(), "groovydoc"); } }); groovydoc.getConventionMapping().map("docTitle", new Callable<Object>() { public Object call() throws Exception { return project.getExtensions().getByType(ReportingExtension.class).getApiDocTitle(); } }); groovydoc.getConventionMapping().map("windowTitle", new Callable<Object>() { public Object call() throws Exception { return project.getExtensions().getByType(ReportingExtension.class).getApiDocTitle(); } }); } }); }
/** * Create task to create the GroovyDoc jar * * @param task Tasl to configure * @param groovydocTask Groovydoc task */ @Mutate public void configureGroovydocJarTask(@Path("tasks.groovydocJar") Jar task, @Path("tasks.groovydoc") Groovydoc groovydocTask) { task.setDescription("Assembles a jar archive containing the groovydoc documentation."); task.setGroup("build"); task.setClassifier("groovydoc"); task.from(groovydocTask); }