/** * Initialize the mavenSession bean. * * @throws IOException * when the descriptor file parent can't be resolved */ private void initializeMavenSession() throws IOException { // Even though the rootProject contains the rootContext we set both in // the even that there is no rootProject and the user is requesting goals // to be attained that do not directly relate to a project. A goaly that // may, say, generate the skeletal maven application build. mavenSession = new MavenSession(); mavenSession.setRootContext( getRootContext() ); // note: setRootDescriptor file is a static method MavenSession.setRootDescriptorFile( getDescriptorFile() ); }
/** * Get a given goal's description. * * @param goalName Goal name to get the description for. * @return Goal description. */ public String getGoalDescription( String goalName ) { return getPluginManager().getGoalDescription( goalName ); }
/** Perform pre-build initialization. * * @throws Exception If an error occurs while performing * runtime initialization. */ public void initialize() throws Exception { // THIS NEEDS TO BE SET getRootContext().setMavenSession( this ); initializePluginManager(); initializeRootProject(); }
throws MavenException File descriptorFile = getRootDescriptorFile(); setRootProject( MavenUtils.getProject( descriptorFile, getRootContext() ) ); getRootContext().setProject( globalProject ); globalProject.setContext( getRootContext() ); setRootProject( globalProject );
if ( !MavenSession.getRootDescriptorFile().exists() ) mavenSession.initialize(); mavenSession.attainGoals( mavenSession.getRootProject(), getCli().getArgList() );
try project = MavenUtils.getProject( getDescriptor(), getMavenContext().getMavenSession().getRootContext() ); project.verifyDependencies(); getMavenContext().getMavenSession().getPluginManager().processDependencies( project ); getMavenContext().getMavenSession().attainGoals( project, goalList );
Set goals = mavenSession.getProjectGoals( mavenSession.getRootProject() ); LOGGER.info( "" ); Project rootProject = mavenSession.getRootProject(); if ( ( rootProject.getBuild() != null ) && ( rootProject.getBuild().getDefaultGoal() != null ) ) String msg = mavenSession.getRootProject().getDescription(); if ( msg != null )
private JellyScriptHousing createLazyPluginHousing( File pluginDir ) throws IOException { if ( !pluginDir.isDirectory() || !new File( pluginDir, "project.xml" ).exists() ) { LOGGER.debug( "Not a plugin directory: " + pluginDir ); return null; } String pluginName = pluginDir.getName(); LOGGER.debug( "Loading plugin '" + pluginName + "'" ); JellyScriptHousing jellyScriptHousing = new JellyScriptHousing( pluginDir, mavenSession.getRootContext() ); pluginHousings.put( pluginName, jellyScriptHousing ); return jellyScriptHousing; }
displayDefaultGoal( pluginName, mavenSession.getGoalDescription( pluginName ), false ); continue; displayDefaultGoal( pluginName, mavenSession.getGoalDescription( pluginName ), true ); List l = (List) map.get( pluginName ); Collections.sort( l ); String goalDescription = mavenSession.getGoalDescription( fullGoalName ); if ( goalDescription != null )
LOGGER.info( "" ); LOGGER.info( MavenUtils.getMessage( "displayInfo.info1" ) ); for ( Iterator i = mavenSession.getPluginList().iterator(); i.hasNext(); )
/** * Display helpful information regarding all documented goals. * * @param pluginOnly * show information for the given plugin only * @param plugin * plugin to show info for */ protected void displayGoals( boolean pluginOnly, String plugin ) { String title = MavenUtils.getMessage( "displayGoals.title" ); if ( pluginOnly ) { title = ( plugin == null ? MavenUtils.getMessage( "displayGoals.title.pluginOnly.null" ) : MavenUtils.getMessage( "displayGoals.title.pluginOnly.notNull" ) + plugin ); } LOGGER.info( title ); LOGGER.info( format( "", title.length(), '=' ) ); Set goals = mavenSession.getAllGoalNames(); displayGoals( pluginOnly, plugin, goals ); }
/** * Display the plugin help if the option is present, then exit. * * @throws MavenException * when anything goes wrong */ private void displayPluginHelp() throws MavenException { if ( getCli().hasOption( OPT_DISPLAY_PLUGIN_HELP ) ) { String plugin = getCli().getOptionValue( OPT_DISPLAY_PLUGIN_HELP ); displayGoals( true, plugin ); if ( plugin != null ) { Project project = mavenSession.getPluginProjectFromGoal( plugin ); if ( ( project != null ) && ( project.getDescription() != null ) ) { LOGGER.info( wrapConsoleMessage( project.getDescription(), 0, CONSOLE_WIDTH ) ); } } exit( RC_OK ); } }
getMavenContext().getMavenSession().attainGoals( project, goalList );
setPluginsDir( new File( mavenSession.getRootContext().getPluginsDir() ) ); setUnpackedPluginsDir( new File( mavenSession.getRootContext().getUnpackedPluginsDir() ) ); setUserPluginsDir( new File( mavenSession.getRootContext().getUserPluginsDir() ) );
/** * Return all goals requested to be attained. * * @return All goal names. */ public Set getAllGoalNames() { return getPluginManager().getGoalNames(); }
MavenJellyContext setupBaseContext( Project project ) { MavenJellyContext prevBaseContext = baseContext; baseContext = new MavenJellyContext( mavenSession.getRootContext() ); baseContext.setInherit( true ); JellyUtils.populateVariables( baseContext, project.getContext() ); project.pushContext( baseContext ); baseContext.setProject( project ); return prevBaseContext; }
/** Initialize all plugins. * * @throws Exception If an error occurs while initializing * any plugin. */ private void initializePluginManager() throws Exception { getPluginManager().initialize(); }
.getMavenSession().getRootContext() );
/** * Get the plugin context using the plugin name. * * @param pluginId Plugin name. * @return The plugin context create for the named plugin when it was loaded for * this project. * @throws UnknownPluginException if the plugin could not be found * @todo [1.0] - when we are caching plugins, this should load on demand, also move to plugin manager * @deprecated use the tag instead */ public MavenJellyContext getPluginContext( String pluginId ) throws Exception { PluginManager pluginManager = context.getMavenSession().getPluginManager(); return pluginManager.getPluginContext( pluginId ); }
public void doTag( XMLOutput output ) throws MissingAttributeException, JellyTagException { checkAttribute( file, "file" ); PluginManager manager = getMavenContext().getMavenSession().getPluginManager(); try { manager.installPlugin( file, null, cache ); } catch ( Exception e ) { throw new JellyTagException( "error installing plugin", e ); } } }