001 package org.apache.maven.project; 002 003 /* 004 * Licensed to the Apache Software Foundation (ASF) under one 005 * or more contributor license agreements. See the NOTICE file 006 * distributed with this work for additional information 007 * regarding copyright ownership. The ASF licenses this file 008 * to you under the Apache License, Version 2.0 (the 009 * "License"); you may not use this file except in compliance 010 * with the License. You may obtain a copy of the License at 011 * 012 * http://www.apache.org/licenses/LICENSE-2.0 013 * 014 * Unless required by applicable law or agreed to in writing, 015 * software distributed under the License is distributed on an 016 * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 017 * KIND, either express or implied. See the License for the 018 * specific language governing permissions and limitations 019 * under the License. 020 */ 021 022 import java.util.Collections; 023 import java.util.LinkedHashSet; 024 import java.util.List; 025 import java.util.Set; 026 027 import org.apache.maven.execution.MavenSession; 028 import org.apache.maven.lifecycle.LifecycleExecutor; 029 import org.apache.maven.lifecycle.MavenExecutionPlan; 030 import org.apache.maven.model.Plugin; 031 import org.apache.maven.model.PluginExecution; 032 import org.apache.maven.plugin.MojoExecution; 033 034 /** 035 * A stub implementation that assumes an empty lifecycle to bypass interaction with the plugin manager and to avoid 036 * plugin artifact resolution from repositories. 037 * 038 * @author Benjamin Bentmann 039 */ 040 public class EmptyLifecycleExecutor 041 implements LifecycleExecutor 042 { 043 044 public MavenExecutionPlan calculateExecutionPlan( MavenSession session, String... tasks ) 045 { 046 return new MavenExecutionPlan( null, null ); 047 } 048 049 public MavenExecutionPlan calculateExecutionPlan( MavenSession session, boolean setup, String... tasks ) 050 { 051 return new MavenExecutionPlan( null, null ); 052 } 053 054 public void execute( MavenSession session ) 055 { 056 } 057 058 public Set<Plugin> getPluginsBoundByDefaultToAllLifecycles( String packaging ) 059 { 060 Set<Plugin> plugins; 061 062 // NOTE: The upper-case packaging name is intentional, that's a special hinting mode used for certain tests 063 if ( "JAR".equals( packaging ) ) 064 { 065 plugins = new LinkedHashSet<Plugin>(); 066 067 plugins.add( newPlugin( "maven-compiler-plugin", "compile", "testCompile" ) ); 068 plugins.add( newPlugin( "maven-resources-plugin", "resources", "testResources" ) ); 069 plugins.add( newPlugin( "maven-surefire-plugin", "test" ) ); 070 plugins.add( newPlugin( "maven-jar-plugin", "jar" ) ); 071 plugins.add( newPlugin( "maven-install-plugin", "install" ) ); 072 plugins.add( newPlugin( "maven-deploy-plugin", "deploy" ) ); 073 } 074 else 075 { 076 plugins = Collections.emptySet(); 077 } 078 079 return plugins; 080 } 081 082 private Plugin newPlugin( String artifactId, String... goals ) 083 { 084 Plugin plugin = new Plugin(); 085 086 plugin.setGroupId( "org.apache.maven.plugins" ); 087 plugin.setArtifactId( artifactId ); 088 089 for ( String goal : goals ) 090 { 091 PluginExecution pluginExecution = new PluginExecution(); 092 pluginExecution.setId( "default-" + goal ); 093 pluginExecution.addGoal( goal ); 094 plugin.addExecution( pluginExecution ); 095 } 096 097 return plugin; 098 } 099 100 public void calculateForkedExecutions( MojoExecution mojoExecution, MavenSession session ) 101 { 102 } 103 104 public List<MavenProject> executeForkedExecutions( MojoExecution mojoExecution, MavenSession session ) 105 { 106 return Collections.emptyList(); 107 } 108 109 }