List of usage examples for org.apache.maven.project MavenProjectHelper attachArtifact
void attachArtifact(MavenProject project, String artifactType, File artifactFile);
From source file:com.inetpsa.seed.plugin.PackageMojo.java
License:Open Source License
@Override public void execute() throws MojoExecutionException, MojoFailureException { MavenProjectHelper helper = new DefaultMavenProjectHelper(); if (capsuleVersion == null) { capsuleVersion = artifactResolver.getHighestVersion(mavenProject, CAPSULE_GROUP_ID, CAPSULE_ARTIFACT_ID, false);//ww w . j a v a2 s. c om } if (!outputDirectory.exists()) { boolean success = outputDirectory.mkdirs(); if (!success) throw new MojoFailureException("Unable to create output directory"); } getLog().info("Packaging SeedStack application using Capsule version " + capsuleVersion); File capsuleFile; if (standalone != null) { try { capsuleFile = buildStandalone(); } catch (Exception e) { throw new MojoExecutionException("Unable to build standalone Capsule", e); } } else { try { capsuleFile = buildLight(); } catch (Exception e) { throw new MojoExecutionException("Unable to build lightweight Capsule", e); } } helper.attachArtifact(mavenProject, capsuleFile, "capsule"); }
From source file:de.lightful.maven.plugins.drools.impl.OutputFileWriter.java
License:Apache License
public void writeOutputFile(Collection<KnowledgePackage> knowledgePackages, PluginLogger logger, MavenProjectDecorator mavenProjectDecorator, MavenProjectHelper projectHelper, String classifier) throws MojoFailureException { MavenProject mavenProject = mavenProjectDecorator.getProject(); ensureCorrectPackaging(mavenProject); Build build = mavenProject.getBuild(); File buildDirectory = new File(build.getDirectory()); File outputFile = new File(buildDirectory, build.getFinalName() + "." + WellKnownNames.FILE_EXTENSION_DROOLS_KNOWLEDGE_MODULE); final String absoluteOutputFileName = outputFile.getAbsolutePath(); logger.info().write("Writing " + knowledgePackages.size() + " knowledge packages into output file " + mavenProjectDecorator.relativeToBasedir(outputFile)).nl(); int counter = 1; for (KnowledgePackage knowledgePackage : knowledgePackages) { String declaredTypesCount = "(unknown)"; String globalsCount = "(unknown)"; String rulesCount = "(unknown)"; if (knowledgePackage instanceof KnowledgePackageImp) { final KnowledgePackageImp packageImp = (KnowledgePackageImp) knowledgePackage; rulesCount = String.valueOf(knowledgePackage.getRules().size()); declaredTypesCount = String.valueOf(packageImp.pkg.getTypeDeclarations().size()); globalsCount = String.valueOf(packageImp.pkg.getGlobals().size()); }//from w ww.j av a 2s .co m logger.info().write(" #" + counter + ": " + knowledgePackage.getName()).write(" (" + rulesCount + " rules, " + declaredTypesCount + " type declarations, " + globalsCount + " globals)").nl(); counter++; } ensureTargetDirectoryExists(buildDirectory); prepareOutputFileForWriting(outputFile, absoluteOutputFileName); KnowledgeIoFactory factory = new KnowledgeIoFactory(); try { final KnowledgeModuleWriter writer = factory .createKnowledgeModuleWriter(new FileOutputStream(outputFile)); writer.writeKnowledgePackages(knowledgePackages); } catch (IOException e) { throw new MojoFailureException("Unable to write compiled knowledge into output file!", e); } if (classifier != null && !"".equals(classifier)) { debug.write("Attaching file " + outputFile.getAbsolutePath() + " as artifact with classifier '" + classifier + "'."); projectHelper.attachArtifact(mavenProject, outputFile, classifier); } else { debug.write(("Setting project main artifact to " + outputFile.getAbsolutePath())).nl(); final Artifact artifact = mavenProject.getArtifact(); artifact.setFile(outputFile); } }
From source file:de.smartics.maven.plugin.projectmetadata.ArchiveMojo.java
License:Apache License
@Override public void execute() throws MojoExecutionException, MojoFailureException { if (!skip) {/*ww w .ja v a 2s .c o m*/ init(); final File jarFile = createArtifact(); if (this.attach) { final MavenProjectHelper helper = new DefaultMavenProjectHelper(); helper.attachArtifact(project, jarFile, classifier); } } else { getLog().info("Skipping projectmetadata plugin since skip=true."); } }
From source file:org.kantega.reststop.maven.dist.RpmBuilder.java
License:Apache License
@Override protected void attachPackage(MavenProjectHelper mavenProjectHelper, MavenProject mavenProject) throws MojoFailureException { File rpms = new File(rpmDirectory(), "RPMS/noarch"); File[] rpmFiles = rpms.listFiles(new FileFilter() { @Override/*from w w w.jav a 2 s .c om*/ public boolean accept(File pathname) { return pathname.getName().endsWith(".rpm"); } }); if (rpmFiles.length != 1) { throw new MojoFailureException( "Expected exactly one .rpm file in " + rpms + ", found " + rpms.length()); } mavenProjectHelper.attachArtifact(mavenProject, "rpm", rpmFiles[0]); }
From source file:org.kantega.reststop.maven.dist.ZipBuilder.java
License:Apache License
@Override protected void attachPackage(MavenProjectHelper mavenProjectHelper, MavenProject mavenProject) throws MojoFailureException { mavenProjectHelper.attachArtifact(mavenProject, "zip", getDestFile()); }