List of usage examples for org.apache.maven.project MavenProject getPackaging
public String getPackaging()
From source file:cn.org.once.cstack.maven.plugin.mojo.CloudunitMojo.java
License:Open Source License
protected String getAbsolutePathWarFile() { MavenProject mavenProject = (MavenProject) getPluginContext().get("project"); String directory = mavenProject.getBuild().getDirectory(); String finalName = mavenProject.getBuild().getFinalName(); String packaging = mavenProject.getPackaging(); String fullPath = directory + "/" + finalName + "." + packaging; getLog().debug("absolutePathWarFile : " + fullPath); return fullPath; }
From source file:com.alibaba.citrus.maven.eclipse.base.eclipse.EclipsePlugin.java
License:Apache License
/** * If this is a war module peek into the reactor an search for an ear module that defines the context root of this * module./*www. ja v a 2 s . c om*/ * * @param config config to save the context root. */ private void collectWarContextRootsFromReactorEarConfiguration(EclipseWriterConfig config) { if (reactorProjects != null && wtpContextName == null && Constants.PROJECT_PACKAGING_WAR.equals(project.getPackaging())) { for (Iterator iter = reactorProjects.iterator(); iter.hasNext();) { MavenProject reactorProject = (MavenProject) iter.next(); if (Constants.PROJECT_PACKAGING_EAR.equals(reactorProject.getPackaging())) { Xpp3Dom[] warDefinitions = IdeUtils.getPluginConfigurationDom(reactorProject, JeeUtils.ARTIFACT_MAVEN_EAR_PLUGIN, new String[] { "modules", "webModule" }); for (int index = 0; index < warDefinitions.length; index++) { Xpp3Dom groupId = warDefinitions[index].getChild("groupId"); Xpp3Dom artifactId = warDefinitions[index].getChild("artifactId"); Xpp3Dom contextRoot = warDefinitions[index].getChild("contextRoot"); if (groupId != null && artifactId != null && contextRoot != null && groupId.getValue() != null && artifactId.getValue() != null && contextRoot.getValue() != null) { getLog().info("Found context root definition for " + groupId.getValue() + ":" + artifactId.getValue() + " " + contextRoot.getValue()); if (project.getArtifactId().equals(artifactId.getValue()) && project.getGroupId().equals(groupId.getValue())) { config.setContextName(contextRoot.getValue()); } } else { getLog().info("Found incomplete ear configuration in " + reactorProject.getGroupId() + ":" + reactorProject.getGroupId() + " found " + warDefinitions[index].toString()); } } } } } if (config.getContextName() == null && Constants.PROJECT_PACKAGING_WAR.equals(project.getPackaging())) { if (wtpContextName == null) { config.setContextName(project.getArtifactId()); } else if ("ROOT".equals(wtpContextName)) { config.setContextName(""); } else { config.setContextName(wtpContextName); } } }
From source file:com.alibaba.citrus.maven.eclipse.base.eclipse.writers.wtp.AbstractWtpResourceWriter.java
License:Apache License
protected void writeWarOrEarResources(XMLWriter writer, MavenProject project, ArtifactRepository localRepository) throws MojoExecutionException { // use /WEB-INF/lib for war projects and / or the configured defaultLibBundleDir for ear projects String deployDir = IdeUtils.getPluginSetting(config.getProject(), JeeUtils.ARTIFACT_MAVEN_EAR_PLUGIN, "defaultLibBundleDir", "/"); if (project.getPackaging().equals(Constants.PROJECT_PACKAGING_WAR)) { deployDir = "/WEB-INF/lib"; }//from w ww.j av a 2 s. com // dependencies for (int j = 0; j < config.getDeps().length; j++) { IdeDependency dep = config.getDeps()[j]; String type = dep.getType(); // NB war is needed for ear projects, we suppose nobody adds a war dependency to a war/jar project // exclude test and provided and system dependencies outside the project if ((!dep.isTestDependency() && !dep.isProvided() && !dep.isSystemScopedOutsideProject(project)) && (Constants.PROJECT_PACKAGING_JAR.equals(type) || Constants.PROJECT_PACKAGING_EJB.equals(type) || "ejb-client".equals(type) || Constants.PROJECT_PACKAGING_WAR.equals(type))) //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$ { addDependency(writer, dep, localRepository, config.getProject().getBasedir(), deployDir); } } }
From source file:com.collir24.policyextractor.PolicyExtractorReport.java
License:Apache License
/** * Gets the permissions required for the source of this maven project and * writes them to the report sink// w ww. j a v a 2s . c o m * * @param sink * a Doxia sink to write to * @param project * the Maven project * @param build * the build details of the maven project * @return A set of permissions required by this project * @throws IOException */ private Set<String> generateProjectPermissions(Sink sink, MavenProject project, Build build) { Set<String> policySet = new TreeSet<String>(); if (project.getPackaging().equals("war") || project.getPackaging().equals("jar")) { String packagedPath = getProjectPackagePath(project, build); JarFile jf; try { jf = new JarFile(packagedPath); } catch (IOException e) { LOGGER.log(Level.SEVERE, "Can't open file at: " + packagedPath, e); return policySet; } ModulePermissions mps = Extract.examineFile(jf); permissionList.add(mps); sink.table(); sink.tableRow(); sink.tableHeaderCell(); sink.text("Class"); sink.tableHeaderCell_(); sink.tableHeaderCell(); sink.text("Line"); sink.tableHeaderCell_(); sink.tableHeaderCell(); sink.text("Permission"); sink.tableHeaderCell_(); sink.tableRow_(); for (ModulePermission mp : mps.getPermissions()) { sink.tableRow(); sink.tableCell(); sink.monospaced(); sink.text(mp.getClassName().replace('/', '.')); sink.monospaced_(); sink.tableCell_(); sink.tableCell(); if (linkXRef) { StringBuilder linkBuilder = new StringBuilder(); linkBuilder.append(xrefLocation).append("/").append(mp.getClassName()).append(".html#") .append(mp.getLine()); sink.link(linkBuilder.toString()); sink.text(Integer.toString(mp.getLine())); sink.link_(); } else { sink.text(Integer.toString(mp.getLine())); } sink.tableCell_(); sink.tableCell(); sink.monospaced(); for (String policy : mp.getPolicy()) { sink.text(policy); sink.lineBreak(); } sink.monospaced_(); sink.tableCell_(); sink.tableRow_(); policySet.addAll(mp.getPolicy()); } sink.tableCaption(); sink.text(mps.getModuleName()); sink.tableCaption_(); sink.table_(); } return policySet; }
From source file:com.collir24.policyextractor.PolicyExtractorReport.java
License:Apache License
private static String getProjectPackagePath(MavenProject project, Build build) { StringBuilder sb = new StringBuilder(); String packagedPath = sb.append(build.getDirectory()).append(File.separatorChar) .append(build.getFinalName()).append('.').append(project.getPackaging()).toString(); return packagedPath; }
From source file:com.datacoper.maven.util.DCProjectUtil.java
public static void validatePackaging(EnumPackaging enumPackaging, MavenProject project) throws DcRuntimeException { String packaging = enumPackaging.getPackaging(); if (!project.getPackaging().equals(packaging)) { throw new DcRuntimeException("The project packaging does not match with ({0})", packaging); }/*from w w w . j a v a2 s. c o m*/ }
From source file:com.datacoper.maven.util.DCProjectUtil.java
public static boolean isProjectType(EnumDCProjectType projectType, MavenProject project) { return projectType.getPackaging().getPackaging().equals(project.getPackaging()) && isTerminateWith(project, projectType.getQualifier()); }
From source file:com.github.ferstl.maven.pomenforcers.PedanticDependencyManagementLocationEnforcer.java
License:Apache License
private boolean isDependencyManagementAllowedInParentPom(MavenProject project) { return this.allowParentPoms && "pom".equals(project.getPackaging()); }
From source file:com.github.ferstl.maven.pomenforcers.PedanticModuleOrderEnforcer.java
License:Apache License
private boolean isPomProject(MavenProject project) { return "pom".equals(project.getPackaging()); }
From source file:com.github.ferstl.maven.pomenforcers.PedanticPluginManagementLocationEnforcer.java
License:Apache License
private boolean isPluginManagementAllowedInParentPom(MavenProject project) { return this.allowParentPoms && "pom".equals(project.getPackaging()); }