Source:
public void execute() throws MojoExecutionException { try { if (outputFile==null) outputFile = new File(getProject().getBasedir(),"target/"+getProject().getArtifactId()+".war"); File war = getJenkinsWarArtifact().getFile(); Zip rezip = new Zip(); rezip.setDestFile(outputFile); rezip.setProject(new Project()); ZipFileSet z = new ZipFileSet(); z.setSrc(war); rezip.addZipfileset(z); getProject().setArtifacts(resolveDependencies(dependencyResolution)); Set<MavenArtifact> projectArtifacts = new LinkedHashSet<>(getProjectArtifacts()); if(addThisPluginToCustomWar) { Optional.ofNullable(getProject()) .map(MavenProject::getArtifact) .map(a -> { projectArtifacts.add(wrap(a)); getLog().debug("This plugin " + a + "to be added to custom war"); return projectArtifacts; }); } for( MavenArtifact a : projectArtifacts ) { if(!a.isPlugin()) continue; Artifact hpi = artifactFactory.createArtifact(a.getGroupId(),a.getArtifactId(),a.getVersion(),null,"hpi"); artifactResolver.resolve(hpi,getProject().getRemoteArtifactRepositories(), localRepository); if (hpi.getFile().isDirectory()) throw new UnsupportedOperationException(hpi.getFile()+" is a directory and not packaged yet. this isn't supported"); z = new ZipFileSet(); z.setFile(hpi.getFile()); z.setFullpath("/WEB-INF/plugins/"+hpi.getArtifactId()+".hpi"); rezip.addZipfileset(z); } rezip.execute(); getLog().info("Generated "+outputFile); projectHelper.attachArtifact(getProject(), "war", outputFile); } catch (IOException e) { throw new MojoExecutionException("Failed to package war",e); } catch (AbstractArtifactResolutionException e) { throw new MojoExecutionException("Failed to package war",e); } }

Target:
public void execute() throws MojoExecutionException { try { if (outputFile==null) outputFile = new File(getProject().getBasedir(),"target/"+getProject().getArtifactId()+".war"); File war = getJenkinsWarArtifact().getFile(); Zip rezip = new Zip(); rezip.setDestFile(outputFile); rezip.setProject(new Project()); ZipFileSet z = new ZipFileSet(); z.setSrc(war); rezip.addZipfileset(z); getProject().setArtifacts(resolveDependencies(dependencyResolution)); Set<MavenArtifact> projectArtifacts = new LinkedHashSet<>(getProjectArtifacts()); if(getProject().getPackaging().equals("hpi") && addThisPluginToCustomWar) { Optional.ofNullable(getProject()) .map(MavenProject::getArtifact) .map(a -> { projectArtifacts.add(wrap(a)); getLog().debug("This plugin " + a + "to be added to custom war"); return projectArtifacts; }); } for( MavenArtifact a : projectArtifacts ) { if(!a.isPlugin()) continue; Artifact hpi = artifactFactory.createArtifact(a.getGroupId(),a.getArtifactId(),a.getVersion(),null,"hpi"); artifactResolver.resolve(hpi,getProject().getRemoteArtifactRepositories(), localRepository); if (hpi.getFile().isDirectory()) throw new UnsupportedOperationException(hpi.getFile()+" is a directory and not packaged yet. this isn't supported"); z = new ZipFileSet(); z.setFile(hpi.getFile()); z.setFullpath("/WEB-INF/plugins/"+hpi.getArtifactId()+".hpi"); rezip.addZipfileset(z); } rezip.execute(); getLog().info("Generated "+outputFile); projectHelper.attachArtifact(getProject(), "war", outputFile); } catch (IOException e) { throw new MojoExecutionException("Failed to package war",e); } catch (AbstractArtifactResolutionException e) { throw new MojoExecutionException("Failed to package war",e); } }