本文整理匯總了Java中org.apache.maven.project.MavenProject.getFile方法的典型用法代碼示例。如果您正苦於以下問題:Java MavenProject.getFile方法的具體用法?Java MavenProject.getFile怎麽用?Java MavenProject.getFile使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類org.apache.maven.project.MavenProject
的用法示例。
在下文中一共展示了MavenProject.getFile方法的5個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: getParents
import org.apache.maven.project.MavenProject; //導入方法依賴的package包/類
protected List<File> getParents() {
LinkedList<File> ret = new LinkedList<>();
MavenProject project = getOriginalMavenProject();
while(true) {
try {
MavenProject parent = loadParentOf(getEmbedder(), project);
File parentFile = parent != null ? parent.getFile() : null;
if(parentFile != null) {
ret.add(parentFile);
project = parent;
} else {
break;
}
} catch (ProjectBuildingException ex) {
break;
}
}
return ret;
}
示例2: normalizePaths
import org.apache.maven.project.MavenProject; //導入方法依賴的package包/類
/**
* normalize all File references in the object tree.
* @param project
* @since 2.36
*/
public static void normalizePaths(MavenProject project) {
if (project == null) {
return;
}
File f = project.getFile();
if (f != null) {
project.setFile(FileUtil.normalizeFile(f));
}
normalizePath(project.getArtifact());
normalizePaths(project.getAttachedArtifacts());
f = project.getParentFile();
if (f != null) {
project.setParentFile(FileUtil.normalizeFile(f));
}
normalizePath(project.getParentArtifact());
normalizePaths(project.getArtifacts());
normalizePaths(project.getDependencyArtifacts());
normalizePaths(project.getExtensionArtifacts());
normalizePaths(project.getPluginArtifacts());
normalizePath(project.getModel());
normalizePath(project.getOriginalModel());
}
示例3: getBndrunPath
import org.apache.maven.project.MavenProject; //導入方法依賴的package包/類
private String getBndrunPath(MavenProject project) throws MavenExecutionException {
String bndrunName = project.getProperties().getProperty(Constants.PROP_CONFIG_BNDRUN, "");
if (bndrunName.trim().isEmpty()) {
bndrunName = project.getName() + ".bndrun";
}
File existingBndrunFile = new File(project.getBasedir(), bndrunName);
File targetBndrunFile = emProjectHome.resolve(bndrunName).toFile();
if (existingBndrunFile.exists()) {
if (existingBndrunFile.isFile()) {
logger.info("Found `" + existingBndrunFile.getName() + "` in project's folder and will use it as is! POM config is ignored!");
try {
Files.copy(existingBndrunFile.toPath(), targetBndrunFile.toPath());
} catch (IOException e) {
throw new MavenExecutionException("Failed to copy file!", e);
}
} else {
throw new MavenExecutionException("'" + existingBndrunFile + "' is not a file!", project.getFile());
}
} else {
String distro = project.getProperties().getProperty(INTERNAL_DISTRO_FILE, "");
generateBndrun(project, distro, targetBndrunFile);
}
return targetBndrunFile.getAbsolutePath();
}
示例4: expandProjects
import org.apache.maven.project.MavenProject; //導入方法依賴的package包/類
@Override
public Set<MavenProject> expandProjects ( final Collection<MavenProject> projects, final Log log, final MavenSession session )
{
try
{
final Set<MavenProject> result = new HashSet<MavenProject> ();
final Queue<MavenProject> queue = new LinkedList<MavenProject> ( projects );
while ( !queue.isEmpty () )
{
final MavenProject project = queue.poll ();
log.debug ( "Checking project: " + project );
if ( project.getFile () == null )
{
log.info ( "Skipping non-local project: " + project );
continue;
}
if ( !result.add ( project ) )
{
// if the project was already in our result, there is no need to process twice
continue;
}
// add all children to the queue
queue.addAll ( loadChildren ( project, log, session ) );
if ( hasLocalParent ( project ) )
{
// if we have a parent, add the parent as well
queue.add ( project.getParent () );
}
}
return result;
}
catch ( final Exception e )
{
throw new RuntimeException ( e );
}
}
示例5: execute
import org.apache.maven.project.MavenProject; //導入方法依賴的package包/類
public void execute() throws MojoExecutionException {
log = getLog();
try {
OakProperties properties = new OakProperties();
dependencyArtifacts = "io.github.wanghuayao:maven-plugin-oaktree:" + properties.getVersion() + ":dependency-artifacts";
filter = new ProcessingFilter(likePatten, hitePatten, deep);
MavenProject mp = (MavenProject) this.getPluginContext().get("project");
String mavenHomeStr = removeUnusedCharInPath(mavenHome.getPath());
File mvnExecFile = new File(mavenHomeStr + "/bin/mvn");
mvnExec = mvnExecFile.getPath();
String os = System.getProperty("os.name");
if (os.toLowerCase().startsWith("win")) {
mvnExec = mvnExec + ".cmd";
isWindwos = true;
}
File okaBaseDir = new File(outputDirectory, "oaktree");
File okadependencyDir = new File(okaBaseDir, "dependency");
if (!okadependencyDir.exists()) {
okadependencyDir.mkdirs();
}
okadependencyOutputDir = okadependencyDir.getPath();
ArtifactItem rootItem = new ArtifactItem(mp.getGroupId(), mp.getArtifactId(), mp.getPackaging(), mp.getVersion());
File rootPom = mp.getFile();
int startDeep = 2;
for (Object obj : mp.getDependencyArtifacts()) {
DefaultArtifact artifact = (DefaultArtifact) obj;
ArtifactItem chieldern = ArtifactItem.valueOf(artifact);
if (filter.isGoOnProcessing(chieldern, startDeep)) {
calcDependancy(chieldern, startDeep);
rootItem.addChildren(chieldern);
}
}
FileWriter w = null;
try {
File okaFile = new File(okaBaseDir,"okatree.txt");
if(okaFile.exists()) {
okaFile.delete();
}
w = new FileWriter(okaFile);
log.info("writing file : " + okaFile.getPath());
printArtifactItem(w, rootItem, "");
log.info("writing complete.");
}finally {
StreamUtils.quiteClose(w);
}
} catch (Exception ex) {
getLog().error(ex.getMessage(), ex);
throw new MojoExecutionException(ex.getMessage(), ex);
}
}