@Test public void applyPlugin() { final Project project = ProjectBuilder.builder().build(); project.getPlugins().apply(NullfreePlugin.class); Assert.assertThat(project.getTasks().findByName("nullfree"), IsNull.notNullValue()); }
@Override public void apply(final Project target) { target.getExtensions().create("nullfree", NullfreeExtension.class); target.task("nullfree").doLast(task -> { final NullfreeExtension settings = target.getExtensions().getByType(NullfreeExtension.class); try { final Origin origin = new Goo( new File(target.getRootDir(), ".git") ).origin(); final Badge badge = new SimpleNullfree( new SimpleSources( target.getRootDir(), new JavaSourceFileFactory() ), nulls -> { final Nulls wrapped; if (settings.getSkipComparisions()) { wrapped = new ExcludeComparisions( new ExcludeSuppressed(nulls) ); } else { wrapped = new ExcludeSuppressed(nulls); } return new SimpleBadge( wrapped, settings.getThreshold() ); } ).badge(); if (!settings.getOffline()) { badge.send( new URL( String.format( "https: origin.user(), origin.repo() ) ) ); } badge.failIfRed(); } catch (final GooException e) { throw new GradleScriptException("Can not get the origin from git repo.", e); } catch (final NullfreeException e) { throw new GradleScriptException("Can not make the nullfree analysis.", e); } catch (MalformedURLException e) { throw new GradleScriptException("Can not make the url for sending nullfree badge.", e); } } ); }
NullfreePlugin implements Plugin<Project> { @Override public void apply(final Project target) { target.getExtensions().create("nullfree", NullfreeExtension.class); target.task("nullfree").doLast(task -> { final NullfreeExtension settings = target.getExtensions().getByType(NullfreeExtension.class); try { final Origin origin = new Goo( new File(target.getRootDir(), ".git") ).origin(); final Badge badge = new SimpleNullfree( new SimpleSources( target.getRootDir(), new JavaSourceFileFactory() ), nulls -> { final Nulls wrapped; if (settings.getSkipComparisions()) { wrapped = new ExcludeComparisions( new ExcludeSuppressed(nulls) ); } else { wrapped = new ExcludeSuppressed(nulls); } return new SimpleBadge( wrapped, settings.getThreshold() ); } ).badge(); if (!settings.getOffline()) { badge.send( new URL( String.format( "https: origin.user(), origin.repo() ) ) ); } badge.failIfRed(); } catch (final GooException e) { throw new GradleScriptException("Can not get the origin from git repo.", e); } catch (final NullfreeException e) { throw new GradleScriptException("Can not make the nullfree analysis.", e); } catch (MalformedURLException e) { throw new GradleScriptException("Can not make the url for sending nullfree badge.", e); } } ); } }
NullfreePlugin implements Plugin<Project> { @Override public void apply(final Project target) { target.getExtensions().create("nullfree", NullfreeExtension.class); target.task("nullfree").doLast(task -> { final NullfreeExtension settings = target.getExtensions().getByType(NullfreeExtension.class); try { final Origin origin = new Goo( new File(target.getRootDir(), ".git") ).origin(); final Badge badge = new SimpleNullfree( new SimpleSources( target.getRootDir(), new JavaSourceFileFactory() ), nulls -> { final Nulls wrapped; if (settings.getSkipComparisions()) { wrapped = new ExcludeComparisions( new ExcludeSuppressed(nulls) ); } else { wrapped = new ExcludeSuppressed(nulls); } return new SimpleBadge( wrapped, settings.getThreshold() ); } ).badge(); if (!settings.getOffline()) { badge.send( new URL( String.format( "https: origin.user(), origin.repo() ) ) ); } badge.failIfRed(); } catch (final GooException e) { throw new GradleScriptException("Can not get the origin from git repo.", e); } catch (final NullfreeException e) { throw new GradleScriptException("Can not make the nullfree analysis.", e); } catch (MalformedURLException e) { throw new GradleScriptException("Can not make the url for sending nullfree badge.", e); } } ); }  }
NullfreePlugin implements Plugin<Project> { @Override public void apply(final Project target) { target.getExtensions().create("nullfree", NullfreeExtension.class); target.task("nullfree").doLast(task -> { final NullfreeExtension settings = target.getExtensions().getByType(NullfreeExtension.class); try { final Origin origin = new Goo( new File(target.getRootDir(), ".git") ).origin(); final Badge badge = new SimpleNullfree( new SimpleSources( target.getRootDir(), new JavaSourceFileFactory() ), nulls -> { final Nulls wrapped; if (settings.getSkipComparisions()) { wrapped = new ExcludeComparisions( new ExcludeSuppressed(nulls) ); } else { wrapped = new ExcludeSuppressed(nulls); } return new SimpleBadge( wrapped, settings.getThreshold() ); } ).badge(); if (!settings.getOffline()) { badge.send( new URL( String.format( "https: origin.user(), origin.repo() ) ) ); } badge.failIfRed(); } catch (final GooException e) { throw new GradleScriptException("Can not get the origin from git repo.", e); } catch (final NullfreeException e) { throw new GradleScriptException("Can not make the nullfree analysis.", e); } catch (MalformedURLException e) { throw new GradleScriptException("Can not make the url for sending nullfree badge.", e); } } ); }  @Override void apply(final Project target); }
NullfreePlugin implements Plugin<Project> { @Override public void apply(final Project target) { target.getExtensions().create("nullfree", NullfreeExtension.class); target.task("nullfree").doLast(task -> { final NullfreeExtension settings = target.getExtensions().getByType(NullfreeExtension.class); try { final Origin origin = new Goo( new File(target.getRootDir(), ".git") ).origin(); final Badge badge = new SimpleNullfree( new SimpleSources( target.getRootDir(), new JavaSourceFileFactory() ), nulls -> { final Nulls wrapped; if (settings.getSkipComparisions()) { wrapped = new ExcludeComparisions( new ExcludeSuppressed(nulls) ); } else { wrapped = new ExcludeSuppressed(nulls); } return new SimpleBadge( wrapped, settings.getThreshold() ); } ).badge(); if (!settings.getOffline()) { badge.send( new URL( String.format( "https: origin.user(), origin.repo() ) ) ); } badge.failIfRed(); } catch (final GooException e) { throw new GradleScriptException("Can not get the origin from git repo.", e); } catch (final NullfreeException e) { throw new GradleScriptException("Can not make the nullfree analysis.", e); } catch (MalformedURLException e) { throw new GradleScriptException("Can not make the url for sending nullfree badge.", e); } } ); }  @Override void apply(final Project target);  }