List of usage examples for org.apache.maven.project MavenProject getBuild
public Build getBuild()
From source file:io.treefarm.plugins.haxe.components.NativeBootstrap.java
License:Apache License
public void clean(MavenProject project) throws Exception { Map<String, Plugin> pluginMap = project.getBuild().getPluginsAsMap(); Plugin plugin = pluginMap.get("io.treefarm.plugins:haxebuildr-maven-plugin"); File pluginHome = initializePluginHome(project, plugin); if (pluginHome.exists()) { logger.info("Deleting " + pluginHome.getAbsolutePath()); FileUtils.deleteQuietly(pluginHome); }// w w w .jav a 2 s. c o m }
From source file:licenseUtil.LicensingList.java
License:Apache License
public void addMavenProject(MavenProject project, String version) { logger.debug("add pom content to current list"); List<Dependency> dependencies = project.getDependencies(); for (Dependency dependency : dependencies) { if (dependency.getScope() == null || !dependency.getScope().equals(excludedScope)) { LicensingObject licensingObject; Artifact depArtifact = new DefaultArtifact(dependency.getGroupId(), dependency.getArtifactId(), "pom", dependency.getVersion()); try { MavenProject depProject = Utils.resolveArtifact(project, depArtifact); licensingObject = new LicensingObject(depProject, project.getArtifactId(), version, licenseUrlMappings); } catch (ArtifactResolutionException | IOException | XmlPullParserException e) { logger.error("Could not resolve Artifact; " + depArtifact.toString()); licensingObject = new LicensingObject(dependency, project.getArtifactId(), version); }/*w w w . j a v a 2s . c o m*/ add(licensingObject); } } List<Plugin> plugins = project.getBuild().getPlugins(); for (Plugin plugin : plugins) { //LicensingObject licensingObject = new LicensingObject(plugin, project.getArtifactId(), version); LicensingObject licensingObject; Artifact depArtifact = new DefaultArtifact(plugin.getGroupId(), plugin.getArtifactId(), "pom", plugin.getVersion()); try { MavenProject depProject = Utils.resolveArtifact(project, depArtifact); licensingObject = new LicensingObject(depProject, project.getArtifactId(), version, licenseUrlMappings); } catch (ArtifactResolutionException | IOException | XmlPullParserException e) { logger.error("Could not resolve Artifact; " + depArtifact.toString()); licensingObject = new LicensingObject(plugin, project.getArtifactId(), version); } add(licensingObject); } }
From source file:net.flexmojos.oss.plugin.war.CopyMojo.java
License:Open Source License
private File getDestinationFile(Artifact artifact) throws MojoExecutionException { boolean isModule = !StringUtils.isEmpty(artifact.getClassifier()); MavenProject pomProject = getProject(artifact); String fileName;//from w w w .j ava 2 s . c o m if (isModule) { if (!stripModuleArtifactInfo) { fileName = artifact.getArtifactId() + "-" + artifact.getVersion() + "-" + artifact.getClassifier() + "." + artifact.getType(); } else { fileName = artifact.getClassifier() + "." + artifact.getType(); } } else { if (!useFinalName) { fileName = artifact.getArtifactId() + "-" + artifact.getVersion() + "." + artifact.getType(); } else { fileName = pomProject.getBuild().getFinalName() + "." + artifact.getType(); } } if (stripVersion && fileName.contains(artifact.getVersion())) { fileName = fileName.replace("-" + artifact.getVersion(), ""); } File destFile = new File(webappDirectory, fileName); return destFile; }
From source file:net.java.javabuild.MavenBuilderExtension.java
License:Apache License
private void addPluginExecutions(MavenProject project) throws MavenExecutionException { Properties properties = new Properties(); try {// ww w . j a v a 2 s .c o m properties.load(this.getClass().getResourceAsStream("version.properties")); } catch (IOException e) { throw new MavenExecutionException("Could not read plugin properties", e); } Plugin plugin = new Plugin(); plugin.setGroupId(properties.getProperty("groupId")); plugin.setArtifactId(properties.getProperty("artifactId")); plugin.setVersion(properties.getProperty("version")); addPluginExecution(plugin, "compile", Phase.GENERATE_SOURCES); addPluginExecution(plugin, "compile", Phase.PRE_SITE); Phase[] lifecyclePhases = Phase.values(); for (int i = 0; i < lifecyclePhases.length; i++) { addPluginExecution(plugin, "execute", lifecyclePhases[i]); } project.getBuild().addPlugin(plugin); }
From source file:net.wasdev.wlp.maven.plugins.applications.InstallAppMojoSupport.java
License:Open Source License
private String getWarFileName(MavenProject project) { String name = project.getBuild().getFinalName() + "." + project.getPackaging(); if (project.getPackaging().equals("liberty-assembly")) { name = project.getBuild().getFinalName() + ".war"; }/* www.j ava 2s. c o m*/ if (stripVersion) { name = stripVersionFromName(name, project.getVersion()); } return name; }
From source file:npanday.assembler.impl.DefaultAssemblyInfoMarshaller.java
License:Apache License
/** * @see AssemblyInfoMarshaller#marshal(npanday.assembler.AssemblyInfo, org.apache.maven.project.MavenProject, * java.io.OutputStream)/*w w w . j a v a2s. c om*/ */ public void marshal(AssemblyInfo assemblyInfo, MavenProject mavenProject, OutputStream outputStream) throws AssemblyInfoException, IOException { StringBuffer sb = new StringBuffer(); sb.append("using System.Reflection;\r\n").append("using System.Runtime.CompilerServices;\r\n"); appendEntry(sb, "Description", assemblyInfo.getDescription()); appendEntry(sb, "Title", assemblyInfo.getTitle()); appendEntry(sb, "Company", assemblyInfo.getCompany()); appendEntry(sb, "Product", assemblyInfo.getProduct()); if (assemblyInfo.getCopyright() != null) { appendEntry(sb, "Copyright", assemblyInfo.getCopyright().replace("\"", "\\")); } appendEntry(sb, "Trademark", assemblyInfo.getTrademark()); appendEntry(sb, "Culture", assemblyInfo.getCulture()); appendEntry(sb, "Version", assemblyInfo.getVersion()); appendEntry(sb, "InformationalVersion", assemblyInfo.getInformationalVersion()); appendEntry(sb, "Configuration", assemblyInfo.getConfiguration()); appendEntry(sb, "KeyName", assemblyInfo.getKeyName()); if (assemblyInfo.getKeyFile() != null) { appendEntry(sb, "KeyFile", assemblyInfo.getKeyFile().getAbsolutePath().replace("\\", "\\\\")); } TargetFramework targetFramework = assemblyInfo.getTargetFramework(); if (targetFramework != null) { String frameworkName = targetFramework.getFrameworkName(); String frameworkDisplayName = targetFramework.getFrameworkDisplayName(); sb.append("[assembly: global::System.Runtime.Versioning.TargetFrameworkAttribute").append("(\"") .append(frameworkName).append("\""); if (frameworkDisplayName != null) { sb.append(",FrameworkDisplayName=\"").append(frameworkDisplayName).append("\""); } sb.append(")]").append("\r\n"); } boolean wroteCustomStringAttribute = false; for (Entry<String, String> e : assemblyInfo.getCustomStringAttributes().entrySet()) { if (StringUtils.isEmpty(e.getValue())) continue; sb.append(createCustomStringEntry(e.getKey(), e.getValue())); wroteCustomStringAttribute = true; } if (wroteCustomStringAttribute) { final String customClass = "\n" + // "[System.AttributeUsage(System.AttributeTargets.Assembly, AllowMultiple = true)]\n" + // "class CustomStringAttribute : System.Attribute {\n" + // " public CustomStringAttribute(string name, string value) {\n" + // " }\n" + // "}\n"; // sb.append(customClass); } FileOutputStream man = null; try { if (outputStream == null) { String src = mavenProject.getBuild().getDirectory() + "/build-sources"; String groupIdAsDir = mavenProject.getGroupId().replace(".", File.separator); File file = new File(src + "/META-INF/" + groupIdAsDir); file.mkdirs(); man = new FileOutputStream(src + "/META-INF/" + groupIdAsDir + File.separator + "AssemblyInfo." + plugin.getExtension()); outputStream = man; } outputStream.write(sb.toString().getBytes()); } catch (IOException e) { throw new AssemblyInfoException("NPANDAY-022-000: Failed to generate AssemblyInfo", e); } finally { if (man != null) { man.close(); } } }
From source file:npanday.executable.impl.CompilerContextImpl.java
License:Apache License
public void init(CompilerCapability capability, CompilerConfig config, MavenProject project) throws PlatformUnsupportedException { this.project = project; this.config = config; libraries = new ArrayList<Artifact>(); directLibraries = new ArrayList<Artifact>(); modules = new ArrayList<Artifact>(); compilerCapability = capability;/*ww w .ja v a 2s.c om*/ // initialize base class super.init(compilerCapability, config); Set<Artifact> artifacts = project.getDependencyArtifacts();//Can add WFC deps prior if (artifacts != null) { for (Artifact artifact : artifacts) { String type = artifact.getType(); logger.debug("NPANDAY-061-006: Artifact Type:" + type); logger.debug("NPANDAY-061-007: Artifact Type:" + ArtifactTypeHelper.isDotnetGenericGac(type)); ArtifactType artifactType = ArtifactType.getArtifactTypeForPackagingName(type); if (ArtifactTypeHelper.isDotnetModule(type)) { modules.add(artifact); } else if (ArtifactTypeHelper.isDotnetAssembly(artifactType)) { libraries.add(artifact); } if (type.equals(ArtifactType.COM_REFERENCE.getPackagingType())) { moveInteropDllToBuildDirectory(artifact); } } } String basedir = project.getBuild().getDirectory() + File.separator + "assembly-resources" + File.separator; linkedResources = new File(basedir, "linkresource").exists() ? Arrays.asList(new File(basedir, "linkresource").listFiles()) : new ArrayList<File>(); getEmbeddedResources(new File(basedir, "resource")); win32resources = new File(basedir, "win32res").exists() ? Arrays.asList(new File(basedir, "win32res").listFiles()) : new ArrayList<File>(); File win32IconDir = new File(basedir, "win32icon"); if (win32IconDir.exists()) { File[] icons = win32IconDir.listFiles(); if (icons.length > 1) { throw new PlatformUnsupportedException( "NPANDAY-061-008: There is more than one win32icon in resource directory: Number = " + icons.length); } if (icons.length == 1) { win32icon = icons[0]; } } }
From source file:npanday.PathUtil.java
License:Apache License
public static File getPrivateApplicationBaseDirectory(MavenProject project) { // Maven already basedir aligns this return new File(project.getBuild().getDirectory()); }
From source file:npanday.PathUtil.java
License:Apache License
public static File getPreparedPackageFolder(MavenProject project) { String folderName = project.getArtifactId(); return new File(new File(project.getBuild().getDirectory(), "packages"), folderName); }
From source file:npanday.plugin.msdeploy.create.Package.java
License:Apache License
public Package(MavenProject project) { this.classifier = null; this.packageSource = PathUtil.getPreparedPackageFolder(project); this.packageFile = new File(project.getBuild().getDirectory(), project.getArtifactId() + "." + ArtifactType.MSDEPLOY_PACKAGE.getExtension()); }