org.gradle.api.reporting.ReportingExtension Java Examples

The following examples show how to use org.gradle.api.reporting.ReportingExtension. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: GroovyBasePlugin.java    From pushfish-android with BSD 2-Clause "Simplified" License 6 votes vote down vote up
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();
                }
            });
        }
    });
}
 
Example #2
Source File: JavaBasePlugin.java    From pushfish-android with BSD 2-Clause "Simplified" License 6 votes vote down vote up
private void configureJavaDoc(final Project project, final JavaPluginConvention convention) {
    project.getTasks().withType(Javadoc.class, new Action<Javadoc>() {
        public void execute(Javadoc javadoc) {
            javadoc.getConventionMapping().map("destinationDir", new Callable<Object>() {
                public Object call() throws Exception {
                    return new File(convention.getDocsDir(), "javadoc");
                }
            });
            javadoc.getConventionMapping().map("title", new Callable<Object>() {
                public Object call() throws Exception {
                    return project.getExtensions().getByType(ReportingExtension.class).getApiDocTitle();
                }
            });
        }
    });
}
 
Example #3
Source File: JavaBasePlugin.java    From Pushjet-Android with BSD 2-Clause "Simplified" License 6 votes vote down vote up
private void configureJavaDoc(final Project project, final JavaPluginConvention convention) {
    project.getTasks().withType(Javadoc.class, new Action<Javadoc>() {
        public void execute(Javadoc javadoc) {
            javadoc.getConventionMapping().map("destinationDir", new Callable<Object>() {
                public Object call() throws Exception {
                    return new File(convention.getDocsDir(), "javadoc");
                }
            });
            javadoc.getConventionMapping().map("title", new Callable<Object>() {
                public Object call() throws Exception {
                    return project.getExtensions().getByType(ReportingExtension.class).getApiDocTitle();
                }
            });
        }
    });
}
 
Example #4
Source File: GroovyBasePlugin.java    From Pushjet-Android with BSD 2-Clause "Simplified" License 6 votes vote down vote up
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();
                }
            });
        }
    });
}
 
Example #5
Source File: GroovyBasePlugin.java    From pushfish-android with BSD 2-Clause "Simplified" License 6 votes vote down vote up
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();
                }
            });
        }
    });
}
 
Example #6
Source File: JavaBasePlugin.java    From pushfish-android with BSD 2-Clause "Simplified" License 6 votes vote down vote up
private void configureJavaDoc(final Project project, final JavaPluginConvention convention) {
    project.getTasks().withType(Javadoc.class, new Action<Javadoc>() {
        public void execute(Javadoc javadoc) {
            javadoc.getConventionMapping().map("destinationDir", new Callable<Object>() {
                public Object call() throws Exception {
                    return new File(convention.getDocsDir(), "javadoc");
                }
            });
            javadoc.getConventionMapping().map("title", new Callable<Object>() {
                public Object call() throws Exception {
                    return project.getExtensions().getByType(ReportingExtension.class).getApiDocTitle();
                }
            });
        }
    });
}
 
Example #7
Source File: JavaBasePlugin.java    From javaide with GNU General Public License v3.0 6 votes vote down vote up
private void configureJavaDoc(final Project project, final JavaPluginConvention convention) {
    project.getTasks().withType(Javadoc.class, new Action<Javadoc>() {
        public void execute(Javadoc javadoc) {
            javadoc.getConventionMapping().map("destinationDir", new Callable<Object>() {
                public Object call() throws Exception {
                    return new File(convention.getDocsDir(), "javadoc");
                }
            });
            javadoc.getConventionMapping().map("title", new Callable<Object>() {
                public Object call() throws Exception {
                    return project.getExtensions().getByType(ReportingExtension.class).getApiDocTitle();
                }
            });
        }
    });
}
 
Example #8
Source File: GroovyBasePlugin.java    From Pushjet-Android with BSD 2-Clause "Simplified" License 6 votes vote down vote up
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();
                }
            });
        }
    });
}
 
Example #9
Source File: JavaBasePlugin.java    From Pushjet-Android with BSD 2-Clause "Simplified" License 6 votes vote down vote up
private void configureJavaDoc(final Project project, final JavaPluginConvention convention) {
    project.getTasks().withType(Javadoc.class, new Action<Javadoc>() {
        public void execute(Javadoc javadoc) {
            javadoc.getConventionMapping().map("destinationDir", new Callable<Object>() {
                public Object call() throws Exception {
                    return new File(convention.getDocsDir(), "javadoc");
                }
            });
            javadoc.getConventionMapping().map("title", new Callable<Object>() {
                public Object call() throws Exception {
                    return project.getExtensions().getByType(ReportingExtension.class).getApiDocTitle();
                }
            });
        }
    });
}
 
Example #10
Source File: BuildDashboardPlugin.java    From Pushjet-Android with BSD 2-Clause "Simplified" License 5 votes vote down vote up
public void apply(final ProjectInternal project) {
    project.getPlugins().apply(ReportingBasePlugin.class);

    final GenerateBuildDashboard buildDashboardTask = project.getTasks().create(BUILD_DASHBOARD_TASK_NAME, GenerateBuildDashboard.class);
    buildDashboardTask.setDescription("Generates a dashboard of all the reports produced by this build.");
    buildDashboardTask.setGroup("reporting");

    DirectoryReport htmlReport = buildDashboardTask.getReports().getHtml();
    ConventionMapping htmlReportConventionMapping = new DslObject(htmlReport).getConventionMapping();
    htmlReportConventionMapping.map("destination", new Callable<Object>() {
        public Object call() throws Exception {
            return project.getExtensions().getByType(ReportingExtension.class).file("buildDashboard");
        }
    });

    Action<Task> captureReportingTasks = new Action<Task>() {
        public void execute(Task task) {
            if (!(task instanceof Reporting)) {
                return;
            }

            Reporting reporting = (Reporting) task;

            buildDashboardTask.aggregate(reporting);

            if (!task.equals(buildDashboardTask)) {
                task.finalizedBy(buildDashboardTask);
            }
        }
    };

    for (Project aProject : project.getAllprojects()) {
        aProject.getTasks().all(captureReportingTasks);
    }
}
 
Example #11
Source File: JGivenPlugin.java    From JGiven with Apache License 2.0 5 votes vote down vote up
private void configureDefaultReportTask( final Test test, JGivenReportTask reportTask,
        final ReportingExtension reportingExtension ){
    ConventionMapping mapping = ( (IConventionAware) reportTask ).getConventionMapping();
    mapping.map( "results", (Callable<File>) () -> test.getExtensions().getByType( JGivenTaskExtension.class ).getResultsDir() );
    mapping.getConventionValue( reportTask.getReports(), "reports", false )
            .all( (Action<Report>) report -> {
                ConventionMapping reportMapping = ( (IConventionAware) report ).getConventionMapping();
                reportMapping.map( "destination",
                        (Callable<File>) () -> reportingExtension.file( "jgiven" + "/" + test.getName() + "/" + report.getName() ) );
            } );
}
 
Example #12
Source File: JGivenPlugin.java    From JGiven with Apache License 2.0 5 votes vote down vote up
private void addDefaultReports( final Project project ){
    final ReportingExtension reportingExtension = project.getExtensions().findByType( ReportingExtension.class );
    project.getTasks().withType( Test.class, test -> {
        final JGivenReportTask reportTask = project.getTasks()
                .create( "jgiven" + WordUtil.capitalize( test.getName() ) + "Report", JGivenReportTask.class );
        configureDefaultReportTask( test, reportTask, reportingExtension );
    } );
}
 
Example #13
Source File: CpdPlugin.java    From gradle-cpd-plugin with Apache License 2.0 5 votes vote down vote up
/** Set up task defaults for every created {@link Cpd} task. */
private void setupTaskDefaults(Project project, CpdExtension extension) {
    project.getTasks().withType(Cpd.class).configureEach(task -> {
        ConventionMapping taskMapping = task.getConventionMapping();
        taskMapping.map("encoding", extension::getEncoding);
        taskMapping.map("ignoreAnnotations", extension::isIgnoreAnnotations);
        taskMapping.map("ignoreIdentifiers", extension::isIgnoreIdentifiers);
        taskMapping.map("ignoreFailures", extension::isIgnoreFailures);
        taskMapping.map("ignoreLiterals", extension::isIgnoreLiterals);
        taskMapping.map("language", extension::getLanguage);
        taskMapping.map("minimumTokenCount", extension::getMinimumTokenCount);
        taskMapping.map("pmdClasspath", () -> project.getConfigurations().findByName("cpd"));
        taskMapping.map("skipDuplicateFiles", extension::isSkipDuplicateFiles);
        taskMapping.map("skipLexicalErrors", extension::isSkipLexicalErrors);
        taskMapping.map("skipBlocks", extension::isSkipBlocks);
        taskMapping.map("skipBlocksPattern", extension::getSkipBlocksPattern);

        ConventionMapping extensionMapping = ((IConventionAware) extension).getConventionMapping();
        extensionMapping.map("reportsDir", () -> project.getExtensions().getByType(ReportingExtension.class).file("cpd"));

        task.getReports().all(report -> {
            ConventionMapping reportMapping = ((IConventionAware) report).getConventionMapping();
            reportMapping.map("enabled", () -> "xml".equals(report.getName()));
            reportMapping.map("destination", () -> new File(extension.getReportsDir(), task.getName() + "." + report.getName()));
        });
    });
}
 
Example #14
Source File: ReportingBasePlugin.java    From Pushjet-Android with BSD 2-Clause "Simplified" License 5 votes vote down vote up
public void apply(ProjectInternal project) {
    Convention convention = project.getConvention();
    ReportingExtension extension = project.getExtensions().create(ReportingExtension.NAME, ReportingExtension.class, project);

    // This convention is deprecated
    convention.getPlugins().put("reportingBase", new ReportingBasePluginConvention(project, extension));
}
 
Example #15
Source File: BuildDashboardPlugin.java    From Pushjet-Android with BSD 2-Clause "Simplified" License 5 votes vote down vote up
public void apply(final ProjectInternal project) {
    project.getPlugins().apply(ReportingBasePlugin.class);

    final GenerateBuildDashboard buildDashboardTask = project.getTasks().create(BUILD_DASHBOARD_TASK_NAME, GenerateBuildDashboard.class);

    DirectoryReport htmlReport = buildDashboardTask.getReports().getHtml();
    ConventionMapping htmlReportConventionMapping = new DslObject(htmlReport).getConventionMapping();
    htmlReportConventionMapping.map("destination", new Callable<Object>() {
        public Object call() throws Exception {
            return project.getExtensions().getByType(ReportingExtension.class).file("buildDashboard");
        }
    });

    Action<Task> captureReportingTasks = new Action<Task>() {
        public void execute(Task task) {
            if (!(task instanceof Reporting)) {
                return;
            }

            Reporting reporting = (Reporting) task;

            buildDashboardTask.aggregate(reporting);

            if (!task.equals(buildDashboardTask)) {
                task.finalizedBy(buildDashboardTask);
            }
        }
    };

    for (Project aProject : project.getAllprojects()) {
        aProject.getTasks().all(captureReportingTasks);
    }
}
 
Example #16
Source File: ReportingBasePlugin.java    From pushfish-android with BSD 2-Clause "Simplified" License 5 votes vote down vote up
public void apply(ProjectInternal project) {
    Convention convention = project.getConvention();
    ReportingExtension extension = project.getExtensions().create(ReportingExtension.NAME, ReportingExtension.class, project);

    // This convention is deprecated
    convention.getPlugins().put("reportingBase", new ReportingBasePluginConvention(project, extension));
}
 
Example #17
Source File: BuildDashboardPlugin.java    From pushfish-android with BSD 2-Clause "Simplified" License 5 votes vote down vote up
public void apply(final ProjectInternal project) {
    project.getPlugins().apply(ReportingBasePlugin.class);

    final GenerateBuildDashboard buildDashboardTask = project.getTasks().create(BUILD_DASHBOARD_TASK_NAME, GenerateBuildDashboard.class);

    DirectoryReport htmlReport = buildDashboardTask.getReports().getHtml();
    ConventionMapping htmlReportConventionMapping = new DslObject(htmlReport).getConventionMapping();
    htmlReportConventionMapping.map("destination", new Callable<Object>() {
        public Object call() throws Exception {
            return project.getExtensions().getByType(ReportingExtension.class).file("buildDashboard");
        }
    });

    Action<Task> captureReportingTasks = new Action<Task>() {
        public void execute(Task task) {
            if (!(task instanceof Reporting)) {
                return;
            }

            Reporting reporting = (Reporting) task;

            buildDashboardTask.aggregate(reporting);

            if (!task.equals(buildDashboardTask)) {
                task.finalizedBy(buildDashboardTask);
            }
        }
    };

    for (Project aProject : project.getAllprojects()) {
        aProject.getTasks().all(captureReportingTasks);
    }
}
 
Example #18
Source File: BuildDashboardPlugin.java    From pushfish-android with BSD 2-Clause "Simplified" License 5 votes vote down vote up
public void apply(final ProjectInternal project) {
    project.getPlugins().apply(ReportingBasePlugin.class);

    final GenerateBuildDashboard buildDashboardTask = project.getTasks().create(BUILD_DASHBOARD_TASK_NAME, GenerateBuildDashboard.class);
    buildDashboardTask.setDescription("Generates a dashboard of all the reports produced by this build.");
    buildDashboardTask.setGroup("reporting");

    DirectoryReport htmlReport = buildDashboardTask.getReports().getHtml();
    ConventionMapping htmlReportConventionMapping = new DslObject(htmlReport).getConventionMapping();
    htmlReportConventionMapping.map("destination", new Callable<Object>() {
        public Object call() throws Exception {
            return project.getExtensions().getByType(ReportingExtension.class).file("buildDashboard");
        }
    });

    Action<Task> captureReportingTasks = new Action<Task>() {
        public void execute(Task task) {
            if (!(task instanceof Reporting)) {
                return;
            }

            Reporting reporting = (Reporting) task;

            buildDashboardTask.aggregate(reporting);

            if (!task.equals(buildDashboardTask)) {
                task.finalizedBy(buildDashboardTask);
            }
        }
    };

    for (Project aProject : project.getAllprojects()) {
        aProject.getTasks().all(captureReportingTasks);
    }
}
 
Example #19
Source File: ReportingBasePlugin.java    From Pushjet-Android with BSD 2-Clause "Simplified" License 4 votes vote down vote up
public void apply(ProjectInternal project) {
    project.getExtensions().create(ReportingExtension.NAME, ReportingExtension.class, project);
}
 
Example #20
Source File: ReportingBasePluginConvention.java    From Pushjet-Android with BSD 2-Clause "Simplified" License 4 votes vote down vote up
public ReportingBasePluginConvention(ProjectInternal project, ReportingExtension extension) {
    this.project = project;
    this.extension = extension;
}
 
Example #21
Source File: NoHttpCheckstylePlugin.java    From nohttp with Apache License 2.0 4 votes vote down vote up
private void createCheckstyleTaskForProject(Configuration configuration) {
	Logger logger = this.logger;
	Project project = this.project;
	NoHttpExtension extension = this.extension;
	Checkstyle checkstyleTask = project
			.getTasks().create("checkstyleNohttp", Checkstyle.class);
	checkstyleTask.setDescription("Checks for illegal uses of http://");
	checkstyleTask.getReports().all(new Action<SingleFileReport>() {
		@Override
		public void execute(final SingleFileReport report) {
			String reportFileName = report.getDestination().getName();
			report.setDestination(project.getExtensions().getByType(ReportingExtension.class)
					.getBaseDirectory()
					.dir(checkstyleTask.getName())
					.map(reportDir -> reportDir.file(reportFileName).getAsFile())
			);
		}
	});
	ConventionMapping taskMapping = checkstyleTask.getConventionMapping();
	taskMapping.map("classpath", new Callable<FileCollection>() {
		@Override
		public FileCollection call() throws Exception {
			return configuration;
		}
	});
	taskMapping.map("source", new Callable<FileTree>() {
		@Override
		public FileTree call() throws Exception {
			return extension.getSource();
		}
	});
	boolean configureConfigLoc = configureConfigDirectory(checkstyleTask);
	taskMapping.map("configProperties", new Callable<Map<String, Object>>() {
		@Override
		public Map<String, Object> call() throws Exception {
			Map<String, Object> configProperties = new HashMap<>();
			File allowlistFile = extension.getAllowlistFile();
			if (allowlistFile != null) {
				logger.debug("Using allowlist at {}", allowlistFile);
				String allowlistPath = project.relativePath(allowlistFile);
				configProperties.put("nohttp.checkstyle.allowlistFileName", allowlistPath);
			}
			if (configureConfigLoc) {
				configProperties.put("config_loc", project.relativePath(getConfigLocation()));
			}
			return configProperties;
		}
	});
	taskMapping.map("config", new Callable<TextResource>() {
		@Override
		public TextResource call() throws Exception {
			File configLoc = getConfigLocation();
			File defaultCheckstyleFile = new File(configLoc, "checkstyle.xml");
			if (defaultCheckstyleFile.exists()) {
				logger.debug("Found default checkstyle configuration, so configuring checkstyleTask to use it");
				return project.getResources().getText().fromFile(defaultCheckstyleFile);
			}
			logger.debug("No checkstyle configuration provided, so using the default.");
			URL resource = getClass().getResource(
					"/io/spring/nohttp/checkstyle/default-nohttp-checkstyle.xml");
			return project.getResources().getText().fromUri(resource);
		}
	});
}
 
Example #22
Source File: ReportingBasePluginConvention.java    From pushfish-android with BSD 2-Clause "Simplified" License 4 votes vote down vote up
public ReportingBasePluginConvention(ProjectInternal project, ReportingExtension extension) {
    this.project = project;
    this.extension = extension;
}
 
Example #23
Source File: ReportingBasePlugin.java    From pushfish-android with BSD 2-Clause "Simplified" License 4 votes vote down vote up
public void apply(ProjectInternal project) {
    project.getExtensions().create(ReportingExtension.NAME, ReportingExtension.class, project);
}