List of usage examples for org.apache.maven.project MavenProject getBuild
public Build getBuild()
From source file:fr.paris.lutece.maven.AbstractLuteceWebappMojo.java
License:Open Source License
/** * Used for multiproject, return the output directory ( /target/lutece/ ) of root project. * * @return File corresponding to the root project output directory *///from www.j a va 2 s .c o m protected File getRootProjectBuildDirectory() { MavenProject mp = null; for (Object o : reactorProjects) { mp = (MavenProject) o; if (mp.isExecutionRoot()) { break; } } return new File(mp.getBuild().getDirectory() + File.separatorChar + LUTECE_DIRECTORY); }
From source file:fr.paris.lutece.maven.AbstractLuteceWebappMojo.java
License:Open Source License
/** * Used for multiproject, return the output directory ( /target ) of root project. * * @return File corresponding to the root project output directory *///from w w w. java 2 s.co m protected File getRootProjectBuildDirectoryTarget() { MavenProject mp = null; for (Object o : reactorProjects) { mp = (MavenProject) o; if (mp.isExecutionRoot()) { break; } } return new File(mp.getBuild().getDirectory()); }
From source file:guru.nidi.maven.tools.backport7to6.AbstractBackport7to6Mojo.java
License:Apache License
private void apply(MavenProject project, ClassFileVisitor v) throws IOException { v.process(new File(project.getBuild().getOutputDirectory())); for (Artifact artifact : project.getArtifacts()) { if (artifact.getArtifactHandler().isAddedToClasspath()) { if (Artifact.SCOPE_COMPILE.equals(artifact.getScope()) || Artifact.SCOPE_PROVIDED.equals(artifact.getScope()) || Artifact.SCOPE_SYSTEM.equals(artifact.getScope())) { v.process(artifact.getFile()); }/*from w ww.j av a 2 s.co m*/ } } }
From source file:guru.nidi.maven.tools.backport7to6.Backport7to6ArtifactMojo.java
License:Apache License
private MavenProject createMavenProject(File dir, Artifact artifact) throws ProjectBuildingException { final MavenProject project = MavenUtil.projectFromArtifact(session, projectBuilder, artifact, true); project.getBuild().setOutputDirectory(dir.getAbsolutePath()); return project; }
From source file:io.fabric8.maven.AbstractFabric8Mojo.java
License:Apache License
Set<File> getDependencies() throws IOException { Set<File> dependnencies = new LinkedHashSet<>(); MavenProject project = getProject(); Path dir = Paths.get(project.getBuild().getOutputDirectory(), "deps"); if (!dir.toFile().exists() && !dir.toFile().mkdirs()) { throw new IOException("Cannot create temp directory at:" + dir.toAbsolutePath()); }/* w ww .j a va 2 s. c o m*/ for (Artifact candidate : project.getDependencyArtifacts()) { File f = candidate.getFile(); if (f == null) { continue; } else if (f.getName().endsWith("jar") && hasKubernetesJson(f)) { getLog().info("Found file:" + f.getAbsolutePath()); try (FileInputStream fis = new FileInputStream(f); JarInputStream jis = new JarInputStream(fis)) { Zips.unzip(new FileInputStream(f), dir.toFile()); File jsonPath = dir.resolve(DEFAULT_CONFIG_FILE_NAME).toFile(); if (jsonPath.exists()) { dependnencies.add(jsonPath); } } } else if (isKubernetesJsonArtifact(candidate.getClassifier(), candidate.getType())) { dependnencies.add(f); } } return dependnencies; }
From source file:io.fabric8.maven.core.extenvvar.ExternalEnvVarHandler.java
License:Apache License
private static JsonSchema getEnvironmentVariableJsonSchema(MavenProject project, Map<String, String> envVars) { try {/*from w ww . j a va 2s. co m*/ JsonSchema schema = ExternalEnvVarHandler.loadEnvironmentSchemas( MavenUtil.getCompileClassLoader(project), project.getBuild().getOutputDirectory()); if (schema == null) { schema = new JsonSchema(); } ExternalEnvVarHandler.addEnvironmentVariables(schema, envVars); return schema; } catch (IOException exp) { throw new IllegalArgumentException("Cannot load environment variables from JSON schema", exp); } }
From source file:io.fabric8.maven.core.util.MavenUtil.java
License:Apache License
public static URLClassLoader getCompileClassLoader(MavenProject project) { try {/*from w ww .j av a2s . c o m*/ List<String> classpathElements = project.getCompileClasspathElements(); return createClassLoader(classpathElements, project.getBuild().getOutputDirectory()); } catch (DependencyResolutionRequiredException e) { throw new IllegalArgumentException("Cannot resolve artifact from compile classpath", e); } }
From source file:io.fabric8.maven.core.util.MavenUtil.java
License:Apache License
public static URLClassLoader getTestClassLoader(MavenProject project) { try {//from w w w . j a v a2s . c o m List<String> classpathElements = project.getTestClasspathElements(); return createClassLoader(classpathElements, project.getBuild().getTestOutputDirectory()); } catch (DependencyResolutionRequiredException e) { throw new IllegalArgumentException("Cannot resolve artifact from test classpath", e); } }
From source file:io.fabric8.maven.generator.javaexec.JavaExecGenerator.java
License:Apache License
protected void addAssembly(AssemblyConfiguration.Builder builder) throws MojoExecutionException { String assemblyRef = getConfig(Config.assemblyRef); if (assemblyRef != null) { builder.descriptorRef(assemblyRef); } else {// w ww .j a v a2s . c o m if (isFatJar()) { FatJarDetector.Result fatJar = detectFatJar(); Assembly assembly = new Assembly(); MavenProject project = getProject(); if (fatJar == null) { DependencySet dependencySet = new DependencySet(); dependencySet.addInclude(project.getGroupId() + ":" + project.getArtifactId()); assembly.addDependencySet(dependencySet); } else { FileSet fileSet = new FileSet(); File buildDir = new File(project.getBuild().getDirectory()); fileSet.setDirectory(toRelativePath(buildDir, project.getBasedir())); fileSet.addInclude(toRelativePath(fatJar.getArchiveFile(), buildDir)); fileSet.setOutputDirectory("."); assembly.addFileSet(fileSet); } assembly.addFileSet(createFileSet("src/main/fabric8-includes/bin", "bin", "0755", "0755")); assembly.addFileSet(createFileSet("src/main/fabric8-includes", ".", "0644", "0755")); builder.assemblyDef(assembly); } else { builder.descriptorRef("artifact-with-dependencies"); } } ; }
From source file:io.fabric8.maven.ZipMojo.java
License:Apache License
protected void generateZip() throws DependencyTreeBuilderException, MojoExecutionException, IOException, MojoFailureException { File appBuildDir = buildDir;/*from w w w. j a v a 2 s. co m*/ if (Strings.isNotBlank(pathInZip)) { appBuildDir = new File(buildDir, pathInZip); } appBuildDir.mkdirs(); if (hasConfigDir()) { copyAppConfigFiles(appBuildDir, appConfigDir); } else { getLog().info("The app configuration files directory " + appConfigDir + " doesn't exist, so not copying any additional project documentation or configuration files"); } MavenProject project = getProject(); if (!ignoreProject) { File kubernetesJson = getKubernetesJson(); if (kubernetesJson != null && kubernetesJson.isFile() && kubernetesJson.exists()) { File jsonFile = new File(appBuildDir, "kubernetes.json"); jsonFile.getParentFile().mkdirs(); Files.copy(kubernetesJson, jsonFile); } // TODO if no iconRef is specified we could try guess based on the project? // lets check if we can use an icon reference copyIconToFolder(appBuildDir); } // lets only generate a app zip if we have a requirement (e.g. we're not a parent pom packaging project) and // we have defined some configuration files or dependencies // to avoid generating dummy apps for parent poms if (hasConfigDir() || !ignoreProject) { if (includeReadMe) { copyReadMe(appBuildDir); } if (generateSummaryFile) { copySummaryText(appBuildDir); } if (generateAppPropertiesFile) { String name = project.getName(); if (Strings.isNullOrBlank(name)) { name = project.getArtifactId(); } String description = project.getDescription(); Properties appProperties = new Properties(); appProperties.put("name", name); if (Strings.isNotBlank(description)) { appProperties.put("description", description); } appProperties.put("groupId", project.getGroupId()); appProperties.put("artifactId", project.getArtifactId()); appProperties.put("version", project.getVersion()); File appPropertiesFile = new File(appBuildDir, "fabric8.properties"); appPropertiesFile.getParentFile().mkdirs(); if (!appPropertiesFile.exists()) { appProperties.store(new FileWriter(appPropertiesFile), "Fabric8 Properties"); } } File outputZipFile = getZipFile(); File legalDir = null; if (includeLegal) { legalDir = new File(project.getBuild().getOutputDirectory(), "META-INF"); } Zips.createZipFile(getLog(), buildDir, outputZipFile, legalDir); projectHelper.attachArtifact(project, artifactType, artifactClassifier, outputZipFile); getLog().info("Created app zip file: " + outputZipFile); } }