本文整理汇总了Java中org.apache.maven.model.building.ModelBuildingException类的典型用法代码示例。如果您正苦于以下问题:Java ModelBuildingException类的具体用法?Java ModelBuildingException怎么用?Java ModelBuildingException使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
ModelBuildingException类属于org.apache.maven.model.building包,在下文中一共展示了ModelBuildingException类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Java代码示例。
示例1: createModelLineage
import org.apache.maven.model.building.ModelBuildingException; //导入依赖的package包/类
/**
* Creates a list of POM models in an inheritance lineage.
* Each resulting model is "raw", so contains no interpolation or inheritance.
* In particular beware that groupId and/or version may be null if inherited from a parent; use {@link Model#getParent} to resolve.
* Internally calls <code>executeModelBuilder</code> so if you need to call both just use the execute method.
* @param pom a POM to inspect
* @param embedder an embedder to use
* @return a list of models, starting with the specified POM, going through any parents, finishing with the Maven superpom (with a null artifactId)
* @throws ModelBuildingException if the POM or parents could not even be parsed; warnings are not reported
*/
public List<Model> createModelLineage(File pom) throws ModelBuildingException {
ModelBuildingResult res = executeModelBuilder(pom);
List<Model> toRet = new ArrayList<Model>();
for (String id : res.getModelIds()) {
Model m = res.getRawModel(id);
normalizePath(m);
toRet.add(m);
}
// for (ModelProblem p : res.getProblems()) {
// System.out.println("problem=" + p);
// if (p.getException() != null) {
// p.getException().printStackTrace();
// }
// }
return toRet;
}
开发者ID:apache,项目名称:incubator-netbeans,代码行数:28,代码来源:MavenEmbedder.java
示例2: build
import org.apache.maven.model.building.ModelBuildingException; //导入依赖的package包/类
@Override
public ModelBuildingResult build(ModelBuildingRequest request) throws ModelBuildingException {
ModelBuildingResult toRet = super.build(request);
Model eff = toRet.getEffectiveModel();
InputSource source = new InputSource();
source.setLocation("");
InputLocation location = new InputLocation(-1, -1, source);
eff.setLocation(NETBEANS_PROFILES, location);
for (String id : toRet.getModelIds()) {
Model mdl = toRet.getRawModel(id);
for (Profile p : mdl.getProfiles()) {
source.setLocation(source.getLocation() + "|" + p.getId());
}
}
return toRet;
}
开发者ID:apache,项目名称:incubator-netbeans,代码行数:17,代码来源:NBModelBuilder.java
示例3: testInvalidRepositoryException
import org.apache.maven.model.building.ModelBuildingException; //导入依赖的package包/类
public void testInvalidRepositoryException() throws Exception { // #197831
File pom = TestFileUtils.writeFile(new File(getWorkDir(), "pom.xml"), "<project xmlns='http://maven.apache.org/POM/4.0.0'>" +
"<modelVersion>4.0.0</modelVersion>" +
"<groupId>grp</groupId>" +
"<artifactId>art</artifactId>" +
"<packaging>jar</packaging>" +
"<version>1.0-SNAPSHOT</version>" +
"<repositories><repository><url>http://nowhere.net/</url></repository></repositories>" +
"</project>");
try {
EmbedderFactory.createProjectLikeEmbedder().createModelLineage(pom);
fail();
} catch (ModelBuildingException x) {
// right
}
}
开发者ID:apache,项目名称:incubator-netbeans,代码行数:17,代码来源:EmbedderFactoryTest.java
示例4: getBundleName
import org.apache.maven.model.building.ModelBuildingException; //导入依赖的package包/类
@Override
public String getBundleName(Artifact artifact)
{
//return artifact.getGroupId() + " " + artifact.getArtifactId(); // don't have access to the name
try
{
Model pom = Maven.getModel(artifact);
String name = pom.getName();
System.out.println(pom);
if(Strings.isNullOrEmpty(name))
return artifact.getArtifactId();
return name;
}
catch(ModelBuildingException | ComponentLookupException e)
{
System.err.println("Exception: " + e);
return artifact.getArtifactId(); // don't have access to the name
}
}
开发者ID:bnavetta,项目名称:tycho-gen,代码行数:20,代码来源:DefaultBundleGenerator.java
示例5: hasMissingParentPom
import org.apache.maven.model.building.ModelBuildingException; //导入依赖的package包/类
private ModelProblem hasMissingParentPom( ProjectBuildingException e )
{
if ( e.getCause() instanceof ModelBuildingException )
{
ModelBuildingException mbe = (ModelBuildingException) e.getCause();
for ( ModelProblem problem : mbe.getProblems() )
{
if ( problem.getException() instanceof UnresolvableModelException )
{
return problem;
}
}
}
return null;
}
开发者ID:gems-uff,项目名称:oceano,代码行数:17,代码来源:MavenMetadataSource.java
示例6: getModelFromFile
import org.apache.maven.model.building.ModelBuildingException; //导入依赖的package包/类
/**f
* Read the given POM so it can be used as the source of coordinates, etc.
* during artifact construction. Note that if this object's
* {@link #snapshots} property is true, and we're working with a development
* build ({@link #buildNumber} ends with 'd'), the POM is modified to remove
* the SNAPSHOT qualifier.
*
* @param pom
* the POM file containing the artifact metadata
* @return A Maven model to be used at
* {@link com.isomorphic.maven.packaging.Module#Module(Model)}
* Module construction
* @throws ModelBuildingException
* if the Model cannot be built from the given POM
* @throws IOException
* if the Model cannot be built from the given POM
*/
private Model getModelFromFile(File pom) throws ModelBuildingException, IOException {
if (buildNumber.endsWith("d") && !snapshots) {
LOGGER.info(
"Rewriting file to remove SNAPSHOT qualifier from development POM '{}'",
pom.getName());
String content = FileUtils.readFileToString(pom);
content = content.replaceAll("-SNAPSHOT", "");
FileUtils.write(pom, content);
}
ModelBuildingRequest request = new DefaultModelBuildingRequest();
request.setPomFile(pom);
ModelBuildingResult result = modelBuilder.build(request);
return result.getEffectiveModel();
}
开发者ID:isomorphic-software,项目名称:isc-maven-plugin,代码行数:35,代码来源:AbstractPackagerMojo.java
示例7: getRawModel
import org.apache.maven.model.building.ModelBuildingException; //导入依赖的package包/类
public Model getRawModel() throws ModelBuildingException {
synchronized(MODEL_LOCK) {
if(model == null) {
MavenEmbedder projectEmbedder = EmbedderFactory.getProjectEmbedder();
ModelBuildingResult br = projectEmbedder.executeModelBuilder(getPOMFile());
model = br.getRawModel();
}
return model;
}
}
开发者ID:apache,项目名称:incubator-netbeans,代码行数:11,代码来源:NbMavenProjectImpl.java
示例8: runMavenValidationImpl
import org.apache.maven.model.building.ModelBuildingException; //导入依赖的package包/类
static List<ModelProblem> runMavenValidationImpl(final File pom) {
//TODO profiles based on current configuration??
MavenEmbedder embedder = EmbedderFactory.getProjectEmbedder();
MavenExecutionRequest meReq = embedder.createMavenExecutionRequest();
ProjectBuildingRequest req = meReq.getProjectBuildingRequest();
req.setValidationLevel(ModelBuildingRequest.VALIDATION_LEVEL_MAVEN_3_1); // currently enables just <reporting> warning
req.setLocalRepository(embedder.getLocalRepository());
List<ArtifactRepository> remoteRepos = RepositoryPreferences.getInstance().remoteRepositories(embedder);
req.setRemoteRepositories(remoteRepos);
req.setRepositorySession(((DefaultMaven) embedder.lookupComponent(Maven.class)).newRepositorySession(meReq));
List<ModelProblem> problems;
try {
problems = embedder.lookupComponent(ProjectBuilder.class).build(pom, req).getProblems();
} catch (ProjectBuildingException x) {
problems = new ArrayList<ModelProblem>();
List<ProjectBuildingResult> results = x.getResults();
if (results != null) { //one code point throwing ProjectBuildingException contains results,
for (ProjectBuildingResult result : results) {
problems.addAll(result.getProblems());
}
} else {
// another code point throwing ProjectBuildingException doesn't contain results..
Throwable cause = x.getCause();
if (cause instanceof ModelBuildingException) {
problems.addAll(((ModelBuildingException) cause).getProblems());
}
}
}
return problems;
}
开发者ID:apache,项目名称:incubator-netbeans,代码行数:31,代码来源:EffectivePomMD.java
示例9: run
import org.apache.maven.model.building.ModelBuildingException; //导入依赖的package包/类
@Override
public void run() {
//#164852 somehow a folder dataobject slipped in, test mimetype to avoid that.
// the root cause of the problem is unknown though
if (current != null && Constants.POM_MIME_TYPE.equals(current.getPrimaryFile().getMIMEType())) { //NOI18N
File file = FileUtil.toFile(current.getPrimaryFile());
// can be null for stuff in jars?
if (file != null) {
try {
List<Model> lin = EmbedderFactory.getProjectEmbedder().createModelLineage(file);
final Children ch = Children.create(new PomChildren(lin), false);
SwingUtilities.invokeLater(new Runnable() {
@Override
public void run() {
treeView.setRootVisible(false);
explorerManager.setRootContext(new AbstractNode(ch));
}
});
} catch (final ModelBuildingException ex) {
SwingUtilities.invokeLater(new Runnable() {
@Override
public void run() {
treeView.setRootVisible(true);
explorerManager.setRootContext(POMModelPanel.createErrorNode(ex));
}
});
}
} else {
SwingUtilities.invokeLater(new Runnable() {
@Override
public void run() {
treeView.setRootVisible(false);
explorerManager.setRootContext(createEmptyNode());
}
});
}
}
}
开发者ID:apache,项目名称:incubator-netbeans,代码行数:39,代码来源:POMInheritancePanel.java
示例10: createErrorNode
import org.apache.maven.model.building.ModelBuildingException; //导入依赖的package包/类
static Node createErrorNode(ModelBuildingException x) {
AbstractNode an = new AbstractNode(Children.LEAF);
StringBuilder b = new StringBuilder();
for (ModelProblem p : x.getProblems()) {
if (b.length() > 0) {
b.append("; ");
}
b.append(p.getMessage());
}
an.setDisplayName(b.toString());
return an;
}
开发者ID:apache,项目名称:incubator-netbeans,代码行数:13,代码来源:POMModelPanel.java
示例11: executeModelBuilder
import org.apache.maven.model.building.ModelBuildingException; //导入依赖的package包/类
/**
*
* @param pom
* @return result object with access to effective pom model and raw models for each parent.
* @throws ModelBuildingException if the POM or parents could not even be parsed; warnings are not reported
*/
public ModelBuildingResult executeModelBuilder(File pom) throws ModelBuildingException {
ModelBuilder mb = lookupComponent(ModelBuilder.class);
assert mb!=null : "ModelBuilder component not found in maven";
ModelBuildingRequest req = new DefaultModelBuildingRequest();
req.setPomFile(pom);
req.setProcessPlugins(false);
req.setValidationLevel(ModelBuildingRequest.VALIDATION_LEVEL_MINIMAL);
req.setLocationTracking(true);
req.setModelResolver(new NBRepositoryModelResolver(this));
req.setSystemProperties(getSystemProperties());
req.setUserProperties(embedderConfiguration.getUserProperties());
return mb.build(req);
}
开发者ID:apache,项目名称:incubator-netbeans,代码行数:21,代码来源:MavenEmbedder.java
示例12: runMavenValidationImpl
import org.apache.maven.model.building.ModelBuildingException; //导入依赖的package包/类
static List<ModelProblem> runMavenValidationImpl(final File pom) {
MavenEmbedder embedder = EmbedderFactory.getProjectEmbedder();
MavenExecutionRequest meReq = embedder.createMavenExecutionRequest();
ProjectBuildingRequest req = meReq.getProjectBuildingRequest();
req.setValidationLevel(ModelBuildingRequest.VALIDATION_LEVEL_MAVEN_3_0); // 3.1 currently enables just <reporting> warning, see issue 223562 for details on why it's bad to show.
req.setLocalRepository(embedder.getLocalRepository());
List<ArtifactRepository> remoteRepos = RepositoryPreferences.getInstance().remoteRepositories(embedder);
req.setRemoteRepositories(remoteRepos);
req.setRepositorySession(((DefaultMaven) embedder.lookupComponent(Maven.class)).newRepositorySession(meReq));
List<ModelProblem> problems;
try {
problems = embedder.lookupComponent(ProjectBuilder.class).build(pom, req).getProblems();
} catch (ProjectBuildingException x) {
problems = new ArrayList<ModelProblem>();
List<ProjectBuildingResult> results = x.getResults();
if (results != null) { //one code point throwing ProjectBuildingException contains results,
for (ProjectBuildingResult result : results) {
problems.addAll(result.getProblems());
}
} else {
// another code point throwing ProjectBuildingException doesn't contain results..
Throwable cause = x.getCause();
if (cause instanceof ModelBuildingException) {
problems.addAll(((ModelBuildingException) cause).getProblems());
}
}
}
List<ModelProblem> toRet = new LinkedList<ModelProblem>();
for (ModelProblem problem : problems) {
if(ModelUtils.checkByCLIMavenValidationLevel(problem)) {
toRet.add(problem);
}
}
return toRet;
}
开发者ID:apache,项目名称:incubator-netbeans,代码行数:36,代码来源:StatusProvider.java
示例13: createModel
import org.apache.maven.model.building.ModelBuildingException; //导入依赖的package包/类
public static Model createModel(File pom) throws ModelBuildingException, ComponentLookupException
{
ModelBuilder builder = mavenContainer.lookup(ModelBuilder.class);
ModelBuildingRequest req = new DefaultModelBuildingRequest();
req.setProcessPlugins(false);
req.setModelResolver(new RepoModelResolver());
req.setPomFile(pom);
return builder.build(req).getEffectiveModel();
}
开发者ID:bnavetta,项目名称:tycho-gen,代码行数:10,代码来源:Maven.java
示例14: getModel
import org.apache.maven.model.building.ModelBuildingException; //导入依赖的package包/类
public static Model getModel(Artifact artifact) throws ModelBuildingException, ComponentLookupException
{
RepositorySystem system = repositorySystem();
RepositorySystemSession session = repositorySystemSession(system);
Metadata metadata = getMetadata(system, session, artifact);
return createModel(metadata.getFile());
}
开发者ID:bnavetta,项目名称:tycho-gen,代码行数:8,代码来源:Maven.java
示例15: loadPomFromFile
import org.apache.maven.model.building.ModelBuildingException; //导入依赖的package包/类
public Model loadPomFromFile(File pomFile, String... profiles)
{
RepositorySystem system = mavenContainer.getRepositorySystem();
Settings settings = mavenContainer.getSettings();
DefaultRepositorySystemSession session = mavenContainer.setupRepoSession(system, settings);
final DefaultModelBuildingRequest request = new DefaultModelBuildingRequest()
.setSystemProperties(System.getProperties())
.setPomFile(pomFile)
.setActiveProfileIds(settings.getActiveProfiles());
ModelBuilder builder = new DefaultModelBuilderFactory().newInstance();
ModelBuildingResult result;
try
{
request.setModelResolver(new MavenModelResolver(system, session,
MavenRepositories.getRemoteRepositories(mavenContainer, settings)));
result = builder.build(request);
}
// wrap exception message
catch (ModelBuildingException e)
{
String pomPath = request.getPomFile().getAbsolutePath();
StringBuilder sb = new StringBuilder("Found ").append(e.getProblems().size())
.append(" problems while building POM model from ").append(pomPath).append("\n");
int counter = 1;
for (ModelProblem problem : e.getProblems())
{
sb.append(counter++).append("/ ").append(problem).append("\n");
}
throw new RuntimeException(sb.toString());
}
return result.getEffectiveModel();
}
开发者ID:forge,项目名称:furnace,代码行数:35,代码来源:ProjectHelper.java
示例16: transformError
import org.apache.maven.model.building.ModelBuildingException; //导入依赖的package包/类
private ProjectBuildingException transformError( ProjectBuildingException e )
{
if ( e.getCause() instanceof ModelBuildingException )
{
return new InvalidProjectModelException( e.getProjectId(), e.getMessage(), e.getPomFile() );
}
return e;
}
开发者ID:gems-uff,项目名称:oceano,代码行数:10,代码来源:DefaultMavenProjectBuilder.java
示例17: getProjectWithDependencies
import org.apache.maven.model.building.ModelBuildingException; //导入依赖的package包/类
protected MavenProject getProjectWithDependencies( File pom )
throws Exception
{
ProjectBuildingRequest configuration = new DefaultProjectBuildingRequest();
configuration.setLocalRepository( getLocalRepository() );
configuration.setRemoteRepositories( Arrays.asList( new ArtifactRepository[] {} ) );
configuration.setProcessPlugins( false );
configuration.setResolveDependencies( true );
initRepoSession( configuration );
try
{
return projectBuilder.build( pom, configuration ).getProject();
}
catch ( Exception e )
{
Throwable cause = e.getCause();
if ( cause instanceof ModelBuildingException )
{
String message = "In: " + pom + "\n\n";
for ( ModelProblem problem : ( (ModelBuildingException) cause ).getProblems() )
{
message += problem + "\n";
}
System.out.println( message );
fail( message );
}
throw e;
}
}
开发者ID:gems-uff,项目名称:oceano,代码行数:32,代码来源:AbstractMavenProjectTestCase.java
示例18: build
import org.apache.maven.model.building.ModelBuildingException; //导入依赖的package包/类
private boolean build( List<ProjectBuildingResult> results, List<MavenProject> projects,
Map<String, MavenProject> projectIndex, List<InterimResult> interimResults,
ProjectBuildingRequest request, Map<File, Boolean> profilesXmls )
{
boolean noErrors = true;
for ( InterimResult interimResult : interimResults )
{
try
{
ModelBuildingResult result = modelBuilder.build( interimResult.request, interimResult.result );
MavenProject project = interimResult.listener.getProject();
initProject( project, projectIndex, result, profilesXmls );
List<MavenProject> modules = new ArrayList<MavenProject>();
noErrors =
build( results, modules, projectIndex, interimResult.modules, request, profilesXmls ) && noErrors;
projects.addAll( modules );
projects.add( project );
project.setExecutionRoot( interimResult.root );
project.setCollectedProjects( modules );
results.add( new DefaultProjectBuildingResult( project, result.getProblems(), null ) );
}
catch ( ModelBuildingException e )
{
results.add( new DefaultProjectBuildingResult( e.getModelId(), interimResult.pomFile, e.getProblems() ) );
noErrors = false;
}
}
return noErrors;
}
开发者ID:gems-uff,项目名称:oceano,代码行数:38,代码来源:DefaultProjectBuilder.java
示例19: getProjectWithDependencies
import org.apache.maven.model.building.ModelBuildingException; //导入依赖的package包/类
protected MavenProject getProjectWithDependencies( File pom )
throws Exception
{
ProjectBuildingRequest configuration = newBuildingRequest();
configuration.setRemoteRepositories( Arrays.asList( new ArtifactRepository[] {} ) );
configuration.setProcessPlugins( false );
configuration.setResolveDependencies( true );
try
{
return projectBuilder.build( pom, configuration ).getProject();
}
catch ( Exception e )
{
Throwable cause = e.getCause();
if ( cause instanceof ModelBuildingException )
{
String message = "In: " + pom + "\n\n";
for ( ModelProblem problem : ( (ModelBuildingException) cause ).getProblems() )
{
message += problem + "\n";
}
System.out.println( message );
}
throw e;
}
}
开发者ID:gems-uff,项目名称:oceano,代码行数:29,代码来源:AbstractMavenProjectTestCase.java
示例20: loadPomModel
import org.apache.maven.model.building.ModelBuildingException; //导入依赖的package包/类
private Model loadPomModel(Path pomFile) {
DefaultModelBuildingRequest request = new DefaultModelBuildingRequest();
request.setPomFile(pomFile.toFile());
try {
ModelBuildingResult result = modelBuilder.build(request);
return result.getRawModel();
} catch (ModelBuildingException | IllegalArgumentException e) {
// IllegalArg can be thrown if the parent POM cannot be resolved.
throw new RuntimeException(e);
}
}
开发者ID:facebook,项目名称:buck,代码行数:12,代码来源:Resolver.java
注:本文中的org.apache.maven.model.building.ModelBuildingException类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论