private ProjectBuildingRequest injectSession( ProjectBuildingRequest request ) { MavenSession session = legacySupport.getSession(); if ( session != null ) { request.setRepositorySession( session.getRepositorySession() ); request.setSystemProperties( session.getSystemProperties() ); if ( request.getUserProperties().isEmpty() ) { request.setUserProperties( session.getUserProperties() ); } MavenExecutionRequest req = session.getRequest(); if ( req != null ) { request.setRemoteRepositories( req.getRemoteRepositories() ); } } else { Properties props = new Properties(); EnvironmentUtils.addEnvVars( props ); props.putAll( System.getProperties() ); request.setSystemProperties( props ); } return request; }
public static RepositoryRequest getRepositoryRequest( MavenSession session, MavenProject project ) { RepositoryRequest request = new DefaultRepositoryRequest(); request.setLocalRepository( session.getLocalRepository() ); if ( project != null ) { request.setRemoteRepositories( project.getPluginArtifactRepositories() ); } request.setOffline( session.isOffline() ); request.setForceUpdate( session.getRequest().isUpdateSnapshots() ); return request; }
this.properties = new Properties(); this.project = session.getCurrentProject(); this.properties.putAll( session.getUserProperties() ); this.properties.putAll( session.getSystemProperties() ); File projectFile = project.getBasedir(); basedir = session.getExecutionRootDirectory();
public PluginDescriptor loadPluginDescriptor( Plugin plugin, MavenProject project, MavenSession session ) throws ArtifactResolutionException, PluginVersionResolutionException, ArtifactNotFoundException, InvalidVersionSpecificationException, InvalidPluginException, PluginManagerException, PluginNotFoundException, PluginVersionNotFoundException { return verifyPlugin( plugin, project, session.getSettings(), session.getLocalRepository() ); }
private Result<ProjectDependencyGraph> sessionDependencyGraph( final MavenSession session ) throws CycleDetectedException, DuplicateProjectException { Result<ProjectDependencyGraph> result = null; if ( session.getProjectDependencyGraph() != null || session.getProjects() != null ) { final ProjectDependencyGraph graph = new DefaultProjectDependencyGraph( session.getAllProjects(), session.getProjects() ); result = Result.success( graph ); } return result; }
private void injectSession( ArtifactResolutionRequest request ) { MavenSession session = legacySupport.getSession(); if ( session != null ) { request.setOffline( session.isOffline() ); request.setForceUpdate( session.getRequest().isUpdateSnapshots() ); request.setServers( session.getRequest().getServers() ); request.setMirrors( session.getRequest().getMirrors() ); request.setProxies( session.getRequest().getProxies() ); } }
/** * Inspects the session's user and project properties for the {@link * DetectMojo#CLASSIFIER_WITH_LIKES_PROPERTY} and separates the property into a list. */ private static List<String> getClassifierWithLikes(MavenSession session) { // Check to see if the project defined the final Properties props = new Properties(); props.putAll(session.getUserProperties()); props.putAll(session.getCurrentProject().getProperties()); return DetectMojo.getClassifierWithLikes( props.getProperty(DetectMojo.CLASSIFIER_WITH_LIKES_PROPERTY)); }
if (!generateGitPropertiesFile || craftPropertiesOutputFile(project.getBasedir(), generateGitPropertiesFilename).exists()) { return; String sourceEncoding = project.getProperties().getProperty("project.build.sourceEncoding"); if (null != sourceEncoding) { sourceCharset = Charset.forName(sourceEncoding); if (!session.getExecutionRootDirectory().equals(session.getCurrentProject().getBasedir().getAbsolutePath())) { log.info("runOnlyOnce is enabled and this project is not the top level project, skipping execution!"); return; properties = new Properties();
private FixedStringSearchInterpolator createRepositoryInterpolator() { final Properties settingsProperties = new Properties(); final MavenSession session = getMavenSession(); if (getLocalRepository() != null) { settingsProperties.setProperty("localRepository", getLocalRepository().getBasedir()); settingsProperties.setProperty("settings.localRepository", getLocalRepository().getBasedir()); } else if (session != null && session.getSettings() != null) { settingsProperties.setProperty("localRepository", session.getSettings().getLocalRepository() ); settingsProperties.setProperty("settings.localRepository", getLocalRepository().getBasedir() ); } return FixedStringSearchInterpolator.create(new PropertiesBasedValueSource(settingsProperties)); }
private FixedStringSearchInterpolator createCommandLinePropertiesInterpolator() { Properties commandLineProperties = System.getProperties(); final MavenSession session = getMavenSession(); if (session != null) { commandLineProperties = new Properties(); if (session.getSystemProperties() != null) { commandLineProperties.putAll(session.getSystemProperties()); } if (session.getUserProperties() != null) { commandLineProperties.putAll(session.getUserProperties()); } } PropertiesBasedValueSource cliProps = new PropertiesBasedValueSource( commandLineProperties ); return FixedStringSearchInterpolator.create( cliProps ); }
/** * Gets the maven session. * * @return the maven session */ public static MavenSession getMavenSession() { PlexusContainer mock = mock( PlexusContainer.class ); MavenExecutionRequest mer = mock( MavenExecutionRequest.class ); Properties systemProperties = new Properties(); systemProperties.put( "maven.version", "3.0" ); when( mer.getUserProperties() ).thenReturn( new Properties() ); when( mer.getSystemProperties() ).thenReturn( systemProperties ); MavenExecutionResult meresult = mock( MavenExecutionResult.class ); return new MavenSession( mock, (RepositorySystemSession) null, mer, meresult ); }
private Date getSessionTimestamp() { Date timestamp; String value = session.getExecutionProperties().getProperty(REACTOR_BUILD_TIMESTAMP_PROPERTY); if (value != null) { timestamp = new Date(Long.parseLong(value)); } else { timestamp = new Date(); session.getExecutionProperties().setProperty(REACTOR_BUILD_TIMESTAMP_PROPERTY, Long.toString(timestamp.getTime())); } return timestamp; }
protected void invokeInstalled(MavenSession session, List<String> goals, boolean updateSnapshots, Map<String, String> properties) throws MojoExecutionException { InvocationRequest request = new DefaultInvocationRequest(); request.setPomFile(session.getRequest().getPom()); request.setGoals(goals); request.setAlsoMake(true); request.setUpdateSnapshots(updateSnapshots); Properties props = new Properties(); props.putAll(properties); request.setProperties(props); Invoker invoker = new DefaultInvoker(); boolean success; try { InvocationResult result = invoker.execute(request); success = result.getExitCode() == 0 && result.getExecutionException() == null; } catch (MavenInvocationException e) { throw new MojoExecutionException("Invocation error! " + ABORT, e); } failIf(!success, "An error occurred. " + ABORT); }
@Override public String get(String key) { Properties userProperties = session.getUserProperties(); return userProperties.getProperty(key); }
value = session.getLocalRepository(); value = session.getProjects(); value = project.getExecutionProject(); value = session.getRepositorySession(); value = session.getSettings(); value = ReflectionValueExtractor.evaluate( pathExpression, session.getSettings() ); value = value + expression.substring( pathSeparator ); value = ReflectionValueExtractor.evaluate( expression.substring( 1 ), session.getSettings() ); value = properties.getProperty( expression ); if ( ( value == null ) && ( ( project != null ) && ( project.getProperties() != null ) ) ) value = project.getProperties().getProperty( expression );
private void setup( String gav, ClassRealm realm ) throws MalformedURLException { // looking into another JRUBY_HOME is for jruby itself only to allow // jruby build to use itself for bootstraping // see if we have shall use jruby from somewhere else String jrubyHome = System.getenv( "POLYGLOT_JRUBY_HOME" ); if ( jrubyHome == null ){ jrubyHome = System.getProperty( JRUBY_HOME ); } if ( jrubyHome == null ){ jrubyHome = legacySupport.getSession().getRequest().getUserProperties().getProperty( JRUBY_HOME ); } if ( jrubyHome == null ){ jrubyHome = legacySupport.getSession().getRequest().getSystemProperties().getProperty( JRUBY_HOME ); } if ( jrubyHome == null && legacySupport.getSession().getCurrentProject() != null ){ jrubyHome = legacySupport.getSession().getCurrentProject().getProperties().getProperty( JRUBY_HOME ); } if (jrubyHome != null ){ setupFromJrubyHome( jrubyHome, realm ); } else { // use jruby from an artifact doSetupArtifact( gav, realm ); } }
public static String getExecutionProperty(final ExecutionEvent event, final String property, final String def) { MavenSession mavenSession = event.getSession(); Properties systemProperties = mavenSession.getSystemProperties(); Properties userProperties = mavenSession.getUserProperties(); Properties projectProperties = mavenSession.getTopLevelProject() == null ? null : mavenSession.getTopLevelProject().getProperties(); String output = userProperties.getProperty(property); output = output == null ? projectProperties != null ? projectProperties.getProperty(property) : null : output; output = output == null ? systemProperties.getProperty(property) : output; return output == null ? def : output; } }
private boolean isProfiling(MavenSession session) { String value = session.getUserProperties().getProperty(PROP_PROFILING); if (value == null) { value = session.getSystemProperties().getProperty(PROP_PROFILING); } return Boolean.parseBoolean(value); }
@Override public void put(String key, String value) { Properties userProperties = session.getUserProperties(); userProperties.setProperty(key, value); } };
/** * Gets the list of watchers from the given MavenSession. * * @param session the Maven session * @return the list of watcher, empty if none. Modifying the resulting list, updates the stored list. */ static synchronized List<Watcher> get(MavenSession session) { List<Watcher> watchers = (List<Watcher>) session.getExecutionProperties().get(WATCHERS_KEY); if (watchers == null) { watchers = new ArrayList<>(); session.getExecutionProperties().put(WATCHERS_KEY, watchers); } return watchers; }