/** * Deletes a directory and its contents. * * @param dir * The base directory of the included and excluded files. * @throws IOException * @throws MojoExecutionException * When a directory failed to get deleted. */ public static void removeDirectory( File dir ) throws IOException { if ( dir != null ) { Log log = new SilentLog(); FileSetManager fileSetManager = new FileSetManager( log, false ); FileSet fs = new FileSet(); fs.setDirectory( dir.getPath() ); fs.addInclude( "**/**" ); fileSetManager.delete( fs ); } }
@Before public void setupNativeHelper() { MavenProject project = new MavenProject(); project.setDependencyArtifacts(Collections.<Artifact>emptySet()); ArtifactStub apklib = new ArtifactStub() { @Override public String getId() { return getArtifactId(); } }; apklib.setArtifactId("some-apklib"); apklib.setGroupId("group"); apklib.setType(AndroidExtension.APKLIB); project.addAttachedArtifact(apklib); final DependencyGraphBuilder dependencyGraphBuilder = new DefaultDependencyGraphBuilder(); nativeHelper = new NativeHelper(project, dependencyGraphBuilder, new SilentLog()); }
private void execute(String goal, String target) throws Exception { Mojo mojo = mojoRule.lookupMojo(goal, new File("src/test/resources/net/bytebuddy/test/" + target + ".pom.xml")); if (goal.equals("transform")) { mojoRule.setVariableValueToObject(mojo, "outputDirectory", project.getAbsolutePath()); mojoRule.setVariableValueToObject(mojo, "compileClasspathElements", Collections.emptyList()); } else if (goal.equals("transform-test")) { mojoRule.setVariableValueToObject(mojo, "testOutputDirectory", project.getAbsolutePath()); mojoRule.setVariableValueToObject(mojo, "testClasspathElements", Collections.emptyList()); } else { throw new AssertionError("Unknown goal: " + goal); } mojoRule.setVariableValueToObject(mojo, "repositorySystem", repositorySystem); mojoRule.setVariableValueToObject(mojo, "groupId", FOO); mojoRule.setVariableValueToObject(mojo, "artifactId", BAR); mojoRule.setVariableValueToObject(mojo, "version", QUX); mojo.setLog(new SilentLog()); mojo.execute(); }
public static GitLogJiraIssuesRenderer createRendererWithParams(String currentVersion, CalculateRuleForSinceTagName rule) { return new GitLogJiraIssuesRenderer( null, null, null, null, currentVersion, rule, null, null, new SilentLog()); }
protected AbstractXmlMojo newMojo( String pDir ) throws Exception { File testPom = new File( new File( getBasedir(), pDir ), "pom.xml" ); MavenExecutionRequest executionRequest = new DefaultMavenExecutionRequest(); ProjectBuildingRequest buildingRequest = executionRequest.getProjectBuildingRequest(); ProjectBuilder projectBuilder = this.lookup(ProjectBuilder.class); MavenProject project = projectBuilder.build(testPom, buildingRequest).getProject(); // final Build build = new Build(); // build.setDirectory( "target" ); // project.setBuild(build); project.getBuild().setDirectory("target"); AbstractXmlMojo vm = (AbstractXmlMojo) lookupConfiguredMojo(project, getGoal()); setVariableValueToObject( vm, "basedir", new File( getBasedir(), pDir ) ); final Log log = new SilentLog(); DefaultResourceManager rm = new DefaultResourceManager(); setVariableValueToObject( rm, "logger", log ); setVariableValueToObject( vm, "locator", rm ); final Map<String, ResourceLoader> resourceLoaders = new HashMap<String, ResourceLoader>(); resourceLoaders.put( "file", new FileResourceLoader() ); resourceLoaders.put( "jar", new JarResourceLoader() ); resourceLoaders.put( "classloader", new ThreadContextClasspathResourceLoader() ); URLResourceLoader url = new URLResourceLoader(); setVariableValueToObject( url, "logger", log ); resourceLoaders.put( "url", url ); setVariableValueToObject( rm, "resourceLoaders", resourceLoaders ); // MavenProjectStub project = new MavenProjectStub() // { // public Build getBuild() // { // return build; // } // }; // setVariableValueToObject( vm, "project", project ); return vm; }
@Test public void getJavaPackages() throws Exception { Log log = new SilentLog(); Set<String> packages = Utils.getJavaPackages(log); assertTrue(packages.contains("java.util")); assertTrue(packages.contains("org.xml.sax.helpers")); for (String pkg: packages) { assertFalse(pkg.isEmpty()); assertFalse(pkg.contains(" ")); assertFalse(pkg.contains("#")); assertTrue(pkg.contains(".")); } }