mirror of https://github.com/apache/maven.git
o Replaced hard-coded use of "pom.xml" with a component to enable customizers using other formats to use other file names as well
git-svn-id: https://svn.apache.org/repos/asf/maven/maven-3/trunk@823852 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
parent
b55562328b
commit
737bc0f63b
|
@ -27,6 +27,7 @@ import org.apache.maven.execution.MavenExecutionResult;
|
||||||
*/
|
*/
|
||||||
public interface Maven
|
public interface Maven
|
||||||
{
|
{
|
||||||
|
@Deprecated
|
||||||
String POMv4 = "pom.xml";
|
String POMv4 = "pom.xml";
|
||||||
|
|
||||||
MavenExecutionResult execute( MavenExecutionRequest request );
|
MavenExecutionResult execute( MavenExecutionRequest request );
|
||||||
|
|
|
@ -25,9 +25,9 @@ import java.util.HashSet;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Set;
|
import java.util.Set;
|
||||||
|
|
||||||
import org.apache.maven.Maven;
|
|
||||||
import org.apache.maven.artifact.InvalidRepositoryException;
|
import org.apache.maven.artifact.InvalidRepositoryException;
|
||||||
import org.apache.maven.artifact.repository.ArtifactRepository;
|
import org.apache.maven.artifact.repository.ArtifactRepository;
|
||||||
|
import org.apache.maven.model.locator.ModelLocator;
|
||||||
import org.apache.maven.repository.RepositorySystem;
|
import org.apache.maven.repository.RepositorySystem;
|
||||||
import org.apache.maven.settings.Mirror;
|
import org.apache.maven.settings.Mirror;
|
||||||
import org.apache.maven.settings.Proxy;
|
import org.apache.maven.settings.Proxy;
|
||||||
|
@ -55,6 +55,9 @@ public class DefaultMavenExecutionRequestPopulator
|
||||||
@Requirement( hint = "maven" )
|
@Requirement( hint = "maven" )
|
||||||
private SecDispatcher securityDispatcher;
|
private SecDispatcher securityDispatcher;
|
||||||
|
|
||||||
|
@Requirement
|
||||||
|
private ModelLocator modelLocator;
|
||||||
|
|
||||||
public MavenExecutionRequest populateFromSettings( MavenExecutionRequest request, Settings settings )
|
public MavenExecutionRequest populateFromSettings( MavenExecutionRequest request, Settings settings )
|
||||||
throws MavenExecutionRequestPopulationException
|
throws MavenExecutionRequestPopulationException
|
||||||
{
|
{
|
||||||
|
@ -177,7 +180,7 @@ public class DefaultMavenExecutionRequestPopulator
|
||||||
}
|
}
|
||||||
else if ( ( request.getPom() == null ) && ( request.getBaseDirectory() != null ) )
|
else if ( ( request.getPom() == null ) && ( request.getBaseDirectory() != null ) )
|
||||||
{
|
{
|
||||||
File pom = new File( request.getBaseDirectory(), Maven.POMv4 );
|
File pom = modelLocator.locatePom( new File( request.getBaseDirectory() ) );
|
||||||
|
|
||||||
request.setPom( pom );
|
request.setPom( pom );
|
||||||
}
|
}
|
||||||
|
|
|
@ -21,7 +21,6 @@ import java.util.ArrayList;
|
||||||
import java.util.Collections;
|
import java.util.Collections;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
import org.apache.maven.Maven;
|
|
||||||
import org.apache.maven.artifact.Artifact;
|
import org.apache.maven.artifact.Artifact;
|
||||||
import org.apache.maven.artifact.resolver.ArtifactResolutionException;
|
import org.apache.maven.artifact.resolver.ArtifactResolutionException;
|
||||||
import org.apache.maven.artifact.resolver.ArtifactResolutionRequest;
|
import org.apache.maven.artifact.resolver.ArtifactResolutionRequest;
|
||||||
|
@ -39,6 +38,7 @@ import org.apache.maven.model.building.ModelBuildingRequest;
|
||||||
import org.apache.maven.model.building.ModelBuildingResult;
|
import org.apache.maven.model.building.ModelBuildingResult;
|
||||||
import org.apache.maven.model.building.ModelProblem;
|
import org.apache.maven.model.building.ModelProblem;
|
||||||
import org.apache.maven.model.building.UrlModelSource;
|
import org.apache.maven.model.building.UrlModelSource;
|
||||||
|
import org.apache.maven.model.locator.ModelLocator;
|
||||||
import org.apache.maven.model.resolution.ModelResolver;
|
import org.apache.maven.model.resolution.ModelResolver;
|
||||||
import org.apache.maven.project.artifact.ProjectArtifact;
|
import org.apache.maven.project.artifact.ProjectArtifact;
|
||||||
import org.apache.maven.repository.RepositorySystem;
|
import org.apache.maven.repository.RepositorySystem;
|
||||||
|
@ -58,6 +58,9 @@ public class DefaultProjectBuilder
|
||||||
@Requirement
|
@Requirement
|
||||||
private ModelBuilder modelBuilder;
|
private ModelBuilder modelBuilder;
|
||||||
|
|
||||||
|
@Requirement
|
||||||
|
private ModelLocator modelLocator;
|
||||||
|
|
||||||
@Requirement
|
@Requirement
|
||||||
private ProjectBuildingHelper projectBuildingHelper;
|
private ProjectBuildingHelper projectBuildingHelper;
|
||||||
|
|
||||||
|
@ -341,7 +344,7 @@ public class DefaultProjectBuilder
|
||||||
|
|
||||||
if ( moduleFile.isDirectory() )
|
if ( moduleFile.isDirectory() )
|
||||||
{
|
{
|
||||||
moduleFile = new File( moduleFile, Maven.POMv4 );
|
moduleFile = modelLocator.locatePom( moduleFile );
|
||||||
}
|
}
|
||||||
|
|
||||||
if ( !moduleFile.isFile() )
|
if ( !moduleFile.isFile() )
|
||||||
|
|
|
@ -29,7 +29,6 @@ import java.util.StringTokenizer;
|
||||||
import java.util.Map.Entry;
|
import java.util.Map.Entry;
|
||||||
|
|
||||||
import org.apache.commons.cli.CommandLine;
|
import org.apache.commons.cli.CommandLine;
|
||||||
import org.apache.maven.Maven;
|
|
||||||
import org.apache.maven.execution.MavenExecutionRequest;
|
import org.apache.maven.execution.MavenExecutionRequest;
|
||||||
import org.apache.maven.repository.ArtifactTransferListener;
|
import org.apache.maven.repository.ArtifactTransferListener;
|
||||||
import org.codehaus.plexus.util.StringUtils;
|
import org.codehaus.plexus.util.StringUtils;
|
||||||
|
@ -246,21 +245,9 @@ final class CLIRequestUtils
|
||||||
.setGlobalChecksumPolicy( globalChecksumPolicy ) // default: warn
|
.setGlobalChecksumPolicy( globalChecksumPolicy ) // default: warn
|
||||||
.setUserToolchainsFile( userToolchainsFile );
|
.setUserToolchainsFile( userToolchainsFile );
|
||||||
|
|
||||||
File pom;
|
|
||||||
|
|
||||||
if ( alternatePomFile != null )
|
if ( alternatePomFile != null )
|
||||||
{
|
{
|
||||||
pom = new File( alternatePomFile );
|
request.setPom( resolveFile( new File( alternatePomFile ), workingDirectory ) );
|
||||||
pom = resolveFile( pom, workingDirectory );
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
pom = new File( baseDirectory, Maven.POMv4 );
|
|
||||||
}
|
|
||||||
|
|
||||||
if ( pom.exists() )
|
|
||||||
{
|
|
||||||
request.setPom( pom );
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if ( commandLine.hasOption( CLIManager.RESUME_FROM ) )
|
if ( commandLine.hasOption( CLIManager.RESUME_FROM ) )
|
||||||
|
|
|
@ -40,6 +40,7 @@ import org.apache.maven.model.inheritance.InheritanceAssembler;
|
||||||
import org.apache.maven.model.interpolation.ModelInterpolator;
|
import org.apache.maven.model.interpolation.ModelInterpolator;
|
||||||
import org.apache.maven.model.io.ModelParseException;
|
import org.apache.maven.model.io.ModelParseException;
|
||||||
import org.apache.maven.model.io.ModelReader;
|
import org.apache.maven.model.io.ModelReader;
|
||||||
|
import org.apache.maven.model.locator.ModelLocator;
|
||||||
import org.apache.maven.model.management.DependencyManagementInjector;
|
import org.apache.maven.model.management.DependencyManagementInjector;
|
||||||
import org.apache.maven.model.management.PluginManagementInjector;
|
import org.apache.maven.model.management.PluginManagementInjector;
|
||||||
import org.apache.maven.model.normalization.ModelNormalizer;
|
import org.apache.maven.model.normalization.ModelNormalizer;
|
||||||
|
@ -67,6 +68,9 @@ public class DefaultModelBuilder
|
||||||
implements ModelBuilder
|
implements ModelBuilder
|
||||||
{
|
{
|
||||||
|
|
||||||
|
@Requirement
|
||||||
|
private ModelLocator modelLocator;
|
||||||
|
|
||||||
@Requirement
|
@Requirement
|
||||||
private ModelReader modelReader;
|
private ModelReader modelReader;
|
||||||
|
|
||||||
|
@ -519,7 +523,7 @@ public class DefaultModelBuilder
|
||||||
|
|
||||||
if ( pomFile.isDirectory() )
|
if ( pomFile.isDirectory() )
|
||||||
{
|
{
|
||||||
pomFile = new File( pomFile, "pom.xml" );
|
pomFile = modelLocator.locatePom( pomFile );
|
||||||
}
|
}
|
||||||
|
|
||||||
return pomFile;
|
return pomFile;
|
||||||
|
|
|
@ -0,0 +1,41 @@
|
||||||
|
package org.apache.maven.model.locator;
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Licensed to the Apache Software Foundation (ASF) under one
|
||||||
|
* or more contributor license agreements. See the NOTICE file
|
||||||
|
* distributed with this work for additional information
|
||||||
|
* regarding copyright ownership. The ASF licenses this file
|
||||||
|
* to you under the Apache License, Version 2.0 (the
|
||||||
|
* "License"); you may not use this file except in compliance
|
||||||
|
* with the License. You may obtain a copy of the License at
|
||||||
|
*
|
||||||
|
* http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
*
|
||||||
|
* Unless required by applicable law or agreed to in writing,
|
||||||
|
* software distributed under the License is distributed on an
|
||||||
|
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
||||||
|
* KIND, either express or implied. See the License for the
|
||||||
|
* specific language governing permissions and limitations
|
||||||
|
* under the License.
|
||||||
|
*/
|
||||||
|
|
||||||
|
import java.io.File;
|
||||||
|
|
||||||
|
import org.codehaus.plexus.component.annotations.Component;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Locates a POM file within a project base directory.
|
||||||
|
*
|
||||||
|
* @author Benjamin Bentmann
|
||||||
|
*/
|
||||||
|
@Component( role = ModelLocator.class )
|
||||||
|
public class DefaultModelLocator
|
||||||
|
implements ModelLocator
|
||||||
|
{
|
||||||
|
|
||||||
|
public File locatePom( File projectDirectory )
|
||||||
|
{
|
||||||
|
return new File( projectDirectory, "pom.xml" );
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
|
@ -0,0 +1,44 @@
|
||||||
|
package org.apache.maven.model.locator;
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Licensed to the Apache Software Foundation (ASF) under one
|
||||||
|
* or more contributor license agreements. See the NOTICE file
|
||||||
|
* distributed with this work for additional information
|
||||||
|
* regarding copyright ownership. The ASF licenses this file
|
||||||
|
* to you under the Apache License, Version 2.0 (the
|
||||||
|
* "License"); you may not use this file except in compliance
|
||||||
|
* with the License. You may obtain a copy of the License at
|
||||||
|
*
|
||||||
|
* http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
*
|
||||||
|
* Unless required by applicable law or agreed to in writing,
|
||||||
|
* software distributed under the License is distributed on an
|
||||||
|
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
||||||
|
* KIND, either express or implied. See the License for the
|
||||||
|
* specific language governing permissions and limitations
|
||||||
|
* under the License.
|
||||||
|
*/
|
||||||
|
|
||||||
|
import java.io.File;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Locates a POM file within a project base directory.
|
||||||
|
*
|
||||||
|
* @author Benjamin Bentmann
|
||||||
|
*/
|
||||||
|
public interface ModelLocator
|
||||||
|
{
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Locates the POM file within the specified project directory. In case the given project directory does not exist
|
||||||
|
* or does not contain a POM file, the return value indicates the expected path to the POM file. Sub directories of
|
||||||
|
* the project directory will not be considered when locating the POM file. The return value will be an absolute
|
||||||
|
* path if the project directory is given as an absolute path.
|
||||||
|
*
|
||||||
|
* @param projectDirectory The (possibly non-existent) base directory to locate the POM file in, must not be {@code
|
||||||
|
* null}.
|
||||||
|
* @return The path to the (possibly non-existent) POM file, never {@code null}.
|
||||||
|
*/
|
||||||
|
File locatePom( File projectDirectory );
|
||||||
|
|
||||||
|
}
|
Loading…
Reference in New Issue