ScribeMojo extends AbstractMojo { @Override public void execute() throws MojoFailureException { var graph = new ClassGraph().enableClassInfo().enableAnnotationInfo().addClassLoader(Processor.loader(classpaths)); var environment = new MavenEnvironment(project()); try (var processor = new MavenProcessor(environment, graph)) { processor.run(); if (valid(environment)) { var yaml = YAML.fromFile("Scribe Maven Plugin", new File(folder, "plugin.yml")); yaml.write(environment.mappings); } else { throw new MojoFailureException("Could not resolve annotations"); } } }  @Override void execute();  }
@Test void execute() throws MojoFailureException { doReturn(true).when(mojo).valid(any()); mojo.execute(); assertTrue(file.exists()); }