looks like you haven't applied either the kotlin o...
# gradle
e
looks like you haven't applied either the kotlin or the java plugins
x
yes, I guess I'm trying to Optionally configure it with a default if java has already been configured
Copy code
public class JavaLib implements Plugin<Project> {

    @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_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, task -> {
            task.useJUnitPlatform();
            task.testLogging( log -> <http://log.info|log.info>( info -> info.getEvents().add( TestLogEvent.PASSED ) ) );
            task.reports( reports -> {
                reports.getJunitXml().setEnabled( false );
                reports.getHtml().setEnabled( false );
            } );
        } );
        project.getTasks().withType( JavaCompile.class, task -> {
            task.getOptions().getCompilerArgs().add( "-parameters" );
        } );

        project.getConvention().configure( JavaPluginConvention.class, conv -> {
            XenoExtension xeno = project.getExtensions().getByType( XenoExtension.class );
            xeno.setSourceSets( Collections.singleton( conv.getSourceSets().findByName( "main" ) ) );
        } );
    }
}
even put it after JavaLibraryPlugin has been applied isn't helping
e
I think you have to go through the extensions block, let me check
try doing:
project.getExtensions.configure(JavaPluginConvention.class, [...]);
JavaPluginConvention javaConvention = project.getConvention().getPlugin(JavaPluginConvention.class); that’s how the java library plugin configures the java plugin
x
just results in the same it's not there yet.. I feel like this is definately some kind of timing issue... how do I configure my plugin post configuring of the java convention, such that it can configure the other plugins
e
oh, i think i get what you’re saying, if you wrap that block in a project.afterEvaluate block, you should get what you want I think
x
when I do that the spotbugs sourcset still ends up empty, that code has already been called... though maybe what I need to do, is put all that in one place...
see my plugin is supposed to configure the spotbugs plugin...
Copy code
project.afterEvaluate( p1 -> {
            ExtensionContainer ext = p1.getExtensions();

            XenoExtension xeno = ext.getByType( XenoExtension.class );
            if ( xeno.getSourceSets().isEmpty() ) {
                JavaPluginConvention plugin = p1.getConvention().getPlugin( JavaPluginConvention.class );
                SourceSet main = plugin.getSourceSets().findByName( SourceSet.MAIN_SOURCE_SET_NAME );
                xeno.setSourceSets( Collections.singleton( main ) );
            }

            ext.getByType( SpotBugsExtension.class ).setSourceSets( xeno.getSourceSets() );
        });
but when I do this, or anything else that doesn't end up with the java convention stacktrace missing, spot bugs extension ends up with a null sourceset, and thus isn't getting scanned...
e
hmm.. i’m not sure then, i’m out of ideas 😞