List of usage examples for org.apache.maven.project MavenProject getBuild
public Build getBuild()
From source file:com.phoenixnap.oss.ramlapisync.plugin.ClassLoaderUtils.java
License:Apache License
public static void addLocationsToClassLoader(MavenProject mavenProject) throws MojoExecutionException { List<URL> urls = Lists.newArrayList(); try {//from www . j av a2s . co m urls.add(new File(mavenProject.getBuild().getOutputDirectory()).toURI().toURL()); // Getting all artifacts locations Set<Artifact> artifacts = mavenProject.getArtifacts(); for (Artifact artifact : artifacts) { urls.add(artifact.getFile().toURI().toURL()); } } catch (MalformedURLException e) { // DO NOTHING } /* * this was failing when executing goal on a maven project if (originalClassLoader != null) { throw new * MojoExecutionException( "Context setting of the current thread ClassLoader is allowed only once."); } */ // Store ClassLoader before applying modifications. originalClassLoader = Thread.currentThread().getContextClassLoader(); Thread.currentThread() .setContextClassLoader(new URLClassLoader(urls.toArray(new URL[urls.size()]), originalClassLoader)); }
From source file:com.phoenixnap.oss.ramlapisync.plugin.ClassLoaderUtils.java
License:Apache License
public static List<String> loadPackages(MavenProject mavenProject) throws MojoExecutionException { List<String> packages = Lists.newArrayList(); logger.info("Loading packages in " + mavenProject.getBuild().getSourceDirectory() + "..."); File rootDir = new File(mavenProject.getBuild().getSourceDirectory() + "//"); Collection<File> files = FileUtils.listFilesAndDirs(rootDir, DirectoryFileFilter.DIRECTORY, TrueFileFilter.TRUE);//from w w w. java 2s.c om for (File file : files) { String pack = file.toString().replace(rootDir.toString(), "").replace(File.separator, "."); if (pack.startsWith(".")) { pack = pack.substring(1, pack.length()); } if (!pack.isEmpty()) { packages.add(pack); } } return packages; }
From source file:com.phoenixnap.oss.ramlapisync.plugin.ClassLoaderUtils.java
License:Apache License
public static List<String> loadClasses(MavenProject mavenProject) throws MojoExecutionException { List<String> classes = Lists.newArrayList(); File rootDir = new File(mavenProject.getBuild().getSourceDirectory()); Collection<File> files = FileUtils.listFiles(rootDir, new SuffixFileFilter(".java"), TrueFileFilter.TRUE); for (File file : files) { String clazz = file.getName().replace(".java", ""); if (!clazz.isEmpty()) { classes.add(clazz);//from w w w . j a v a 2s.com } } return classes; }
From source file:com.redhat.tools.nexus.maven.plugin.bundle.BundleConfiguration.java
License:Open Source License
public void initDefaults(final MavenProject project, final MavenSession session) { this.project = project; this.session = session; if (finalName == null) { finalName = project.getBuild().getFinalName(); }//ww w . j a v a 2 s .c o m }
From source file:com.redhat.tools.nexus.maven.plugin.ClasspathUtils.java
License:Open Source License
public static Properties read(final MavenProject project) throws IOException { File cpFile = new File(project.getBuild().getDirectory(), CP_PROPSFILE); if (!cpFile.exists()) { throw new IOException("Cannot find: " + cpFile + ". Did you call 'generate-metadata'?"); }/*from w w w . ja va 2 s .c o m*/ Properties p = new Properties(); FileInputStream stream = null; try { stream = new FileInputStream(cpFile); p.load(stream); } finally { IOUtil.close(stream); } return p; }
From source file:com.redhat.tools.nexus.maven.plugin.ClasspathUtils.java
License:Open Source License
public static void write(final Set<Artifact> classpathArtifacts, final MavenProject project) throws IOException { Properties p = new Properties(); for (Artifact artifact : classpathArtifacts) { File artifactFile = artifact.getFile(); StringBuilder fname = new StringBuilder(); fname.append(artifact.getArtifactId()).append('-').append(artifact.getVersion()); if (artifact.getClassifier() != null) { fname.append('-').append(artifact.getClassifier()); }//from ww w . j a va 2 s . co m fname.append('.').append(artifact.getArtifactHandler().getExtension()); p.setProperty(fname.toString(), artifactFile.getAbsolutePath()); } File cpFile = new File(project.getBuild().getDirectory(), CP_PROPSFILE); FileOutputStream stream = null; try { cpFile.getParentFile().mkdirs(); stream = new FileOutputStream(cpFile); p.store(stream, "Written on: " + new Date()); } finally { IOUtil.close(stream); } }
From source file:com.sap.prd.mobile.ios.mios.FolderLayout.java
License:Apache License
static File getFolderForExtractedHeaders(MavenProject project, final String configuration, final String sdk) { return new File(new File(new File(project.getBuild().getDirectory()), HEADERS_DIR_NAME), configuration + "-" + sdk); }
From source file:com.sap.prd.mobile.ios.mios.FolderLayout.java
License:Apache License
static File getFolderForExtractedLibs(MavenProject project, final String configuration, final String sdk) { return new File(new File(new File(project.getBuild().getDirectory()), LIBS_DIR_NAME), configuration + "-" + sdk); }
From source file:com.sap.prd.mobile.ios.mios.FolderLayout.java
License:Apache License
static File getFolderForExtractedBundles(MavenProject project) { return new File(new File(project.getBuild().getDirectory()), "bundles"); }
From source file:com.sap.prd.mobile.ios.mios.FolderLayout.java
License:Apache License
static File getFolderForExtractedFrameworks(MavenProject project) { return new File(new File(new File(project.getBuild().getDirectory()), XCODE_DEPS_TARGET_FOLDER), "frameworks"); }