Source:
public void execute() throws MojoExecutionException { if (modules == null) { modules = new ArrayList<Module>(1); } if (modules.isEmpty()) { Module module = new Module(); module.setArtifactId(project.getArtifactId()); module.setGroupId(project.getGroupId()); modules.add(module); } File targetDir = new File(project.getBuild().getDirectory()); modulesDir = new File(targetDir, "modules"); getLog().info("Creating modules directory \"" + modulesDir + "\""); if (!modulesDir.exists()) { if (!modulesDir.mkdirs()) { throw new MojoExecutionException( "Can't create target modules directory \"" + modulesDir.getAbsolutePath() + "\""); } } String sourcePath = "src" + File.separator + "main" + File.separator + "modules"; File sourceDir = new File(project.getBasedir(), sourcePath); getLog().info("Copying module resources to \"" + modulesDir + "\""); if (sourceDir.exists()) { try { FileUtils.copyDirectoryStructure(sourceDir, modulesDir); } catch (IOException exception) { throw new MojoExecutionException( "Can't copy source modules directory \"" + sourceDir.getAbsolutePath() + "\" " + "to target modules directory \"" + modulesDir.getAbsolutePath() + "\"", exception); } } for (Module module: modules) { createModule(module); } File modulesArchive = new File(targetDir, String.format( "%s-%s-modules.zip", project.getBuild().getFinalName(), category)); ZipArchiver modulesArchiver = new ZipArchiver(); modulesArchiver.setDestFile(modulesArchive); modulesArchiver.addDirectory(modulesDir); getLog().info("Creating module archive \"" + modulesArchive + "\""); try { modulesArchiver.createArchive(); } catch (Exception exception) { throw new MojoExecutionException( "Can't generate modules archive \"" + modulesArchive.getAbsolutePath() + "\"", exception); } getLog().info("Attaching modules artifact \"" + modulesArchive + "\""); projectHelper.attachArtifact(project, "zip", "modules", modulesArchive); }

Target:
public void execute() throws MojoExecutionException { if (modules == null) { modules = new ArrayList<Module>(1); } if (modules.isEmpty()) { Module module = new Module(); module.setArtifactId(project.getArtifactId()); module.setGroupId(project.getGroupId()); modules.add(module); } File targetDir = new File(project.getBuild().getDirectory()); modulesDir = new File(targetDir, "modules"); getLog().info("Creating modules directory \"" + modulesDir + "\""); if (!modulesDir.exists()) { if (!modulesDir.mkdirs()) { throw new MojoExecutionException( "Can't create target modules directory \"" + modulesDir.getAbsolutePath() + "\""); } } String sourcePath = "src" + File.separator + "main" + File.separator + "modules"; File sourceDir = new File(project.getBasedir(), sourcePath); getLog().info("Copying module resources to \"" + modulesDir + "\""); if (sourceDir.exists()) { try { FileUtils.copyDirectoryStructure(sourceDir, modulesDir); } catch (IOException exception) { throw new MojoExecutionException( "Can't copy source modules directory \"" + sourceDir.getAbsolutePath() + "\" " + "to target modules directory \"" + modulesDir.getAbsolutePath() + "\"", exception); } } for (Module module: modules) { createModule(module); } File modulesArchive = new File(targetDir, String.format( "%s-%s-modules.zip", project.getBuild().getFinalName(), category)); ZipArchiver modulesArchiver = new ZipArchiver(); modulesArchiver.setDestFile(modulesArchive); modulesArchiver.addDirectory(modulesDir); getLog().info("Creating module archive \"" + modulesArchive + "\""); try { modulesArchiver.createArchive(); } catch (Exception exception) { throw new MojoExecutionException( "Can't generate modules archive \"" + modulesArchive.getAbsolutePath() + "\"", exception); } getLog().info("Attaching modules artifact \"" + modulesArchive + "\""); projectHelper.attachArtifact( project, "zip", String.format("%s-modules", category), modulesArchive); }