/** * Configures the {@link Test} task to produces a shorter output when executing tests. * * @param project * the {@link Project} that the {@link Plugin} is applied to */ private void configureTestTask(Project project) { Test test = (Test) project.getTasks().getByName("test"); TestLoggingContainer testLogging = test.getTestLogging(); testLogging.events("failed", "passed"); testLogging.setExceptionFormat(TestExceptionFormat.FULL); testLogging.setShowStackTraces(false); }
@Override public void apply( Project project ) { project.getTasks().withType( Test.class ).configureEach( task -> { task.useJUnitPlatform(); task.testLogging( log -> log.info( info -> info.getEvents().add( TestLogEvent.PASSED ) ) ); task.reports( reports -> { reports.getJunitXml().setEnabled( true ); reports.getHtml().setEnabled( false ); } ); } ); } }
@Override public void execute(final Test testTask) { testTask.getTestLogging().setShowStandardStreams(true); final GwtTestExtension testExtension = testTask.getExtensions().create("gwt", GwtTestExtension.class); testExtension.configure(gwtPluginExtension, (IConventionAware) testExtension); project.afterEvaluate(new Action<Project>() { @Override public void execute(Project t) { String gwtArgs = testExtension.getParameterString(); testTask.systemProperty("gwt.args", gwtArgs); logger.info("Using gwt.args for test: "+ gwtArgs); if (testExtension.getCacheDir() != null) { testTask.systemProperty("gwt.persistentunitcachedir", testExtension.getCacheDir()); testExtension.getCacheDir().mkdirs(); logger.info("Using gwt.persistentunitcachedir for test: {0}", testExtension.getCacheDir()); } } }); project.getPlugins().withType(GwtWarPlugin.class, new Action<GwtWarPlugin>() { @Override public void execute(GwtWarPlugin t) { testTask.dependsOn(GwtWarPlugin.TASK_WAR_TEMPLATE); }}); } });
@Override public void apply( Project project ) { project.getPluginManager().apply( JavaLibraryPlugin.class ); DependencyHandler deps = project.getDependencies(); deps.add( TEST_IMPL, String.join( D, Junit.G, Junit.Api.A ) ); deps.add( TEST_IMPL, String.join( D, Junit.G, Junit.Param.A ) ); deps.add( TEST_RUN, String.join( D, Junit.G, Junit.Engine.A ) ); deps.add( TEST_IMPL, String.join( D, AssertJ.G, AssertJ.A ) ); project.getTasks().withType( Test.class ).configureEach( task -> { task.useJUnitPlatform(); task.testLogging( log -> log.info( info -> info.getEvents().add( TestLogEvent.PASSED ) ) ); task.reports( reports -> { reports.getJunitXml().setEnabled( true ); reports.getHtml().setEnabled( false ); } ); } ); } }
@Override public void apply(Project project) { project.getPluginManager().apply(JavaPlugin.class); JavaPluginConvention javaPluginConv = project.getConvention().findPlugin(JavaPluginConvention.class); javaPluginConv.setSourceCompatibility(JavaVersion.VERSION_1_8); javaPluginConv.setTargetCompatibility(JavaVersion.VERSION_1_8); project.getPluginManager().apply(IdeaPlugin.class); project.getRepositories().mavenCentral(); project.getDependencies().add("testCompile", "junit:junit:4.12"); Wrapper wrapper = project.getTasks().create("wrapper", Wrapper.class); wrapper.setGradleVersion("3.5"); Test test = (Test) project.getTasks().getByName("test"); TestLoggingContainer testLogging = test.getTestLogging(); testLogging.events("failed", "passed"); testLogging.setExceptionFormat(TestExceptionFormat.FULL); testLogging.setShowStackTraces(false); } }
@Override public void apply( Project project ) { project.getPluginManager().apply( JavaLibraryPlugin.class ); DependencyHandler deps = project.getDependencies(); deps.add( TEST_IMPL, String.join( D, Junit.G, Junit.Api.A ) ); deps.add( TEST_IMPL, String.join( D, Junit.G, Junit.Param.A ) ); deps.add( TEST_RUN, String.join( D, Junit.G, Junit.Engine.A ) ); deps.add( TEST_IMPL, String.join( D, AssertJ.G, AssertJ.A ) ); project.getTasks().withType( Test.class ).configureEach( task -> { task.useJUnitPlatform(); task.testLogging( log -> log.info( info -> info.getEvents().add( TestLogEvent.PASSED ) ) ); task.reports( reports -> { reports.getJunitXml().setEnabled( true ); reports.getHtml().setEnabled( false ); } ); } ); project.getTasks().withType( JavaCompile.class ).configureEach( task -> { CompileOptions options = task.getOptions(); options.setAnnotationProcessorGeneratedSourcesDirectory( Paths.get( "build/generated/src" ).toFile() ); options.getCompilerArgs().addAll( Arrays.asList( "-parameters", "-Xlint:deprecation" ) ); } ); } }