/** * Creates a new result with the specified contents. * * @param project The project that was built, may be {@code null}. * @param problems The problems that were encountered, may be {@code null}. * @param dependencyResolutionResult The result of the resolution for the project dependencies, may be {@code null}. */ DefaultProjectBuildingResult( MavenProject project, List<ModelProblem> problems, DependencyResolutionResult dependencyResolutionResult ) { this.projectId = ( project != null ) ? project.getGroupId() + ':' + project.getArtifactId() + ':' + project.getVersion() : ""; this.pomFile = ( project != null ) ? project.getFile() : null; this.project = project; this.problems = problems; this.dependencyResolutionResult = dependencyResolutionResult; }
/** * Default toString */ public String toString() { StringBuffer sb = new StringBuffer(30); sb.append( "MavenProject: " ); sb.append( this.getGroupId() ); sb.append( ":" ); sb.append( this.getArtifactId() ); sb.append( ":" ); sb.append( this.getVersion() ); sb.append( " @ " ); try { sb.append( this.getFile().getPath() ); } catch (NullPointerException e) { //don't log it. } return sb.toString(); }
/** * Default toString */ @Override public String toString() { StringBuilder sb = new StringBuilder( 128 ); sb.append( "MavenProject: " ); sb.append( getGroupId() ); sb.append( ':' ); sb.append( getArtifactId() ); sb.append( ':' ); sb.append( getVersion() ); sb.append( " @ " ); try { sb.append( getFile().getPath() ); } catch ( NullPointerException e ) { // don't log it. } return sb.toString(); }
return selectedProject.equals( project.getFile() );
public ProjectArtifact( MavenProject project ) { super( project.getGroupId(), project.getArtifactId(), project.getVersion(), null, "pom", null, new PomArtifactHandler() ); this.project = project; setFile( project.getFile() ); setResolved( true ); }
private static MavenProject findProject( String projectName, Map projectMap, MavenProject topLevelProject ) throws MissingProjectException { MavenProject project = (MavenProject) projectMap.get( projectName ); if ( project != null ) return project; // in that case, it must be a file path File baseDir; if ( topLevelProject == null ) { baseDir = new File( System.getProperty( "user.dir" ) ); } else { baseDir = topLevelProject.getBasedir(); // or should this be .getFile().getParentFile() ? } File projectDir = new File( baseDir, projectName ); if ( !projectDir.exists() ) { throw new MissingProjectException( "Couldn't find specified project dir: " + projectDir.getAbsolutePath() ); } if ( !projectDir.isDirectory() ) { throw new MissingProjectException( "Couldn't find specified project dir (not a directory): " + projectDir.getAbsolutePath() ); } for ( Iterator i = projectMap.values().iterator(); i.hasNext(); ) { project = (MavenProject) i.next(); if ( projectDir.equals( project.getFile().getParentFile() ) ) return project; } throw new MissingProjectException( "Couldn't find specified project in module list: " + projectDir.getAbsolutePath() ); }
File moduleFile = moduleProject.getFile();
File moduleFile = moduleProject.getFile();
@Deprecated public static Set<Artifact> createArtifacts( ArtifactFactory artifactFactory, List<Dependency> dependencies, String inheritedScope, ArtifactFilter dependencyFilter, MavenProject project ) throws InvalidDependencyVersionException { Set<Artifact> artifacts = new LinkedHashSet<>(); for ( Dependency d : dependencies ) { Artifact dependencyArtifact; try { dependencyArtifact = createDependencyArtifact( artifactFactory, d, inheritedScope, dependencyFilter ); } catch ( InvalidVersionSpecificationException e ) { throw new InvalidDependencyVersionException( project.getId(), d, project.getFile(), e ); } if ( dependencyArtifact != null ) { artifacts.add( dependencyArtifact ); } } return artifacts; }
return project.getFile();
setFile( project.getFile() );
project.setArtifact( projectArtifact ); if ( project.getFile() != null )
setFile( project.getFile() );
parentDescriptor = parentProject.getFile();
/** * On windows we can't play with the exit code, so check for the pom file modification dates. * * @return {@code true} if the pom file was modified. {@code false} otherwise. */ private boolean pomFileModified() { File pom = project.getFile(); return pom.lastModified() > lastPomFileModification; }
public File alignToBaseDirectory(final File file) { File basedir; if (project != null && project.getFile() != null) { basedir = project.getFile().getParentFile(); } else { basedir = new File(".").getAbsoluteFile().getParentFile(); } return new File(pathTranslator.alignToBaseDirectory(file.getPath(), basedir)); } }
/** * {@inheritDoc} * * @since 1.0-alpha-1 */ public void execute() throws MojoExecutionException, MojoFailureException { File outFile = project.getFile(); process( outFile ); }
/** * Gets the raw model before any interpolation what-so-ever. * * @param project The project to get the raw model for. * @return The raw model. * @throws IOException if the file is not found or if the file does not parse. */ public static Model getRawModel( MavenProject project ) throws IOException { return getRawModel( project.getFile() ); }