Wro4jMojo extends AbstractWro4jMojo { @Override protected void doExecute() throws Exception { if (contextPath != null) { getLog().info("contextPath: " + contextPath); } getLog().info("destinationFolder: " + destinationFolder); if (jsDestinationFolder != null) { getLog().info("jsDestinationFolder: " + jsDestinationFolder); } if (cssDestinationFolder != null) { getLog().info("cssDestinationFolder: " + cssDestinationFolder); } if (groupNameMappingFile != null) { getLog().info("groupNameMappingFile: " + groupNameMappingFile); } final Collection<String> groupsAsList = getTargetGroupsAsList(); final StopWatch watch = new StopWatch(); watch.start("processGroups: " + groupsAsList); final Collection<Callable<Void>> callables = new ArrayList<>(); for (final String group : groupsAsList) { for (final ResourceType resourceType : ResourceType.values()) { final File destinationFolder = computeDestinationFolder(resourceType); final String groupWithExtension = group + "." + resourceType.name().toLowerCase(); if (isParallelProcessing()) { callables.add(Context.decorate(new Callable<Void>() { public Void call() throws Exception { processGroup(groupWithExtension, destinationFolder); return null; } })); } else { processGroup(groupWithExtension, destinationFolder); } } } if (isParallelProcessing()) { getTaskExecutor().submit(callables); } watch.stop(); getLog().debug(watch.prettyPrint()); writeGroupNameMap(); }  void setBuildFinalName(final File buildFinalName);  }
@Test public void shouldProcessTargetGroupsWhenDestinationFolderDoesNotExist() throws Exception { victim = new Wro4jMojo() { @Override protected WroManagerFactory newWroManagerFactory() throws MojoExecutionException { return new ExtensionsStandaloneManagerFactory().setHashStrategy(mockHashStrategy); } }; final String constantHash = "hash"; when(mockHashStrategy.getHash(Mockito.any(InputStream.class))).thenReturn(constantHash); setUpMojo(victim); victim.setIgnoreMissingResources(true); final int totalGroups = 10; assertEquals(totalGroups, victim.getTargetGroupsAsList().size()); when(mockBuildContext.isIncremental()).thenReturn(true); when(mockBuildContext.getValue(Mockito.anyString())).thenReturn(constantHash); assertEquals(0, victim.getTargetGroupsAsList().size()); destinationFolder.delete(); assertEquals(totalGroups, victim.getTargetGroupsAsList().size()); victim.doExecute(); }
@Test public void shouldUseMultipleContextFolders() throws Exception { final String defaultContextFolder = victim.getContextFoldersAsCSV(); victim.setTargetGroups("contextRelative"); victim.setContextFolder("invalid, " + defaultContextFolder); victim.doExecute(); victim.setContextFolder(defaultContextFolder + ", invalid"); victim.doExecute(); }