diff options
Diffstat (limited to 'framework/src/maven/apache-maven-3.3.3/maven-model-builder/src/main/java/org/apache/maven/model/profile')
11 files changed, 0 insertions, 1594 deletions
diff --git a/framework/src/maven/apache-maven-3.3.3/maven-model-builder/src/main/java/org/apache/maven/model/profile/DefaultProfileActivationContext.java b/framework/src/maven/apache-maven-3.3.3/maven-model-builder/src/main/java/org/apache/maven/model/profile/DefaultProfileActivationContext.java deleted file mode 100644 index bb38a2e0..00000000 --- a/framework/src/maven/apache-maven-3.3.3/maven-model-builder/src/main/java/org/apache/maven/model/profile/DefaultProfileActivationContext.java +++ /dev/null @@ -1,259 +0,0 @@ -package org.apache.maven.model.profile; - -/* - * 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 java.util.Collections; -import java.util.Enumeration; -import java.util.HashMap; -import java.util.List; -import java.util.Map; -import java.util.Properties; - -/** - * Describes the environmental context used to determine the activation status of profiles. - * - * @author Benjamin Bentmann - */ -public class DefaultProfileActivationContext - implements ProfileActivationContext -{ - - private List<String> activeProfileIds = Collections.emptyList(); - - private List<String> inactiveProfileIds = Collections.emptyList(); - - private Map<String, String> systemProperties = Collections.emptyMap(); - - private Map<String, String> userProperties = Collections.emptyMap(); - - private Map<String, String> projectProperties = Collections.emptyMap(); - - private File projectDirectory; - - @Override - public List<String> getActiveProfileIds() - { - return activeProfileIds; - } - - /** - * Sets the identifiers of those profiles that should be activated by explicit demand. - * - * @param activeProfileIds The identifiers of those profiles to activate, may be {@code null}. - * @return This context, never {@code null}. - */ - public DefaultProfileActivationContext setActiveProfileIds( List<String> activeProfileIds ) - { - if ( activeProfileIds != null ) - { - this.activeProfileIds = Collections.unmodifiableList( activeProfileIds ); - } - else - { - this.activeProfileIds = Collections.emptyList(); - } - - return this; - } - - @Override - public List<String> getInactiveProfileIds() - { - return inactiveProfileIds; - } - - /** - * Sets the identifiers of those profiles that should be deactivated by explicit demand. - * - * @param inactiveProfileIds The identifiers of those profiles to deactivate, may be {@code null}. - * @return This context, never {@code null}. - */ - public DefaultProfileActivationContext setInactiveProfileIds( List<String> inactiveProfileIds ) - { - if ( inactiveProfileIds != null ) - { - this.inactiveProfileIds = Collections.unmodifiableList( inactiveProfileIds ); - } - else - { - this.inactiveProfileIds = Collections.emptyList(); - } - - return this; - } - - @Override - public Map<String, String> getSystemProperties() - { - return systemProperties; - } - - /** - * Sets the system properties to use for interpolation and profile activation. The system properties are collected - * from the runtime environment like {@link System#getProperties()} and environment variables. - * - * @param systemProperties The system properties, may be {@code null}. - * @return This context, never {@code null}. - */ - @SuppressWarnings( "unchecked" ) - public DefaultProfileActivationContext setSystemProperties( Properties systemProperties ) - { - if ( systemProperties != null ) - { - this.systemProperties = Collections.unmodifiableMap( (Map) systemProperties ); - } - else - { - this.systemProperties = Collections.emptyMap(); - } - - return this; - } - - /** - * Sets the system properties to use for interpolation and profile activation. The system properties are collected - * from the runtime environment like {@link System#getProperties()} and environment variables. - * - * @param systemProperties The system properties, may be {@code null}. - * @return This context, never {@code null}. - */ - public DefaultProfileActivationContext setSystemProperties( Map<String, String> systemProperties ) - { - if ( systemProperties != null ) - { - this.systemProperties = Collections.unmodifiableMap( systemProperties ); - } - else - { - this.systemProperties = Collections.emptyMap(); - } - - return this; - } - - @Override - public Map<String, String> getUserProperties() - { - return userProperties; - } - - /** - * Sets the user properties to use for interpolation and profile activation. The user properties have been - * configured directly by the user on his discretion, e.g. via the {@code -Dkey=value} parameter on the command - * line. - * - * @param userProperties The user properties, may be {@code null}. - * @return This context, never {@code null}. - */ - @SuppressWarnings( "unchecked" ) - public DefaultProfileActivationContext setUserProperties( Properties userProperties ) - { - if ( userProperties != null ) - { - this.userProperties = Collections.unmodifiableMap( (Map) userProperties ); - } - else - { - this.userProperties = Collections.emptyMap(); - } - - return this; - } - - /** - * Sets the user properties to use for interpolation and profile activation. The user properties have been - * configured directly by the user on his discretion, e.g. via the {@code -Dkey=value} parameter on the command - * line. - * - * @param userProperties The user properties, may be {@code null}. - * @return This context, never {@code null}. - */ - public DefaultProfileActivationContext setUserProperties( Map<String, String> userProperties ) - { - if ( userProperties != null ) - { - this.userProperties = Collections.unmodifiableMap( userProperties ); - } - else - { - this.userProperties = Collections.emptyMap(); - } - - return this; - } - - @Override - public File getProjectDirectory() - { - return projectDirectory; - } - - /** - * Sets the base directory of the current project. - * - * @param projectDirectory The base directory of the current project, may be {@code null} if profile activation - * happens in the context of metadata retrieval rather than project building. - * @return This context, never {@code null}. - */ - public DefaultProfileActivationContext setProjectDirectory( File projectDirectory ) - { - this.projectDirectory = projectDirectory; - - return this; - } - - @Override - public Map<String, String> getProjectProperties() - { - return projectProperties; - } - - public DefaultProfileActivationContext setProjectProperties( Properties projectProperties ) - { - if ( projectProperties != null ) - { - - this.projectProperties = Collections.unmodifiableMap( toMap( projectProperties ) ); - } - else - { - this.projectProperties = Collections.emptyMap(); - } - - return this; - } - - private Map<String, String> toMap( Properties properties ) - { - if ( properties == null ) - { - return Collections.emptyMap(); - } - Map<String, String> map = new HashMap<String, String>(); - Enumeration keys = properties.keys(); - while ( keys.hasMoreElements() ) - { - String key = (String) keys.nextElement(); - map.put( key, properties.getProperty( key ) ); - } - return map; - } -} diff --git a/framework/src/maven/apache-maven-3.3.3/maven-model-builder/src/main/java/org/apache/maven/model/profile/DefaultProfileInjector.java b/framework/src/maven/apache-maven-3.3.3/maven-model-builder/src/main/java/org/apache/maven/model/profile/DefaultProfileInjector.java deleted file mode 100644 index aeed0235..00000000 --- a/framework/src/maven/apache-maven-3.3.3/maven-model-builder/src/main/java/org/apache/maven/model/profile/DefaultProfileInjector.java +++ /dev/null @@ -1,249 +0,0 @@ -package org.apache.maven.model.profile; - -/* - * 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.util.ArrayList; -import java.util.Collections; -import java.util.LinkedHashMap; -import java.util.List; -import java.util.Map; - -import org.apache.maven.model.Build; -import org.apache.maven.model.BuildBase; -import org.apache.maven.model.Model; -import org.apache.maven.model.ModelBase; -import org.apache.maven.model.Plugin; -import org.apache.maven.model.PluginContainer; -import org.apache.maven.model.PluginExecution; -import org.apache.maven.model.Profile; -import org.apache.maven.model.ReportPlugin; -import org.apache.maven.model.ReportSet; -import org.apache.maven.model.Reporting; -import org.apache.maven.model.building.ModelBuildingRequest; -import org.apache.maven.model.building.ModelProblemCollector; -import org.apache.maven.model.merge.MavenModelMerger; -import org.codehaus.plexus.component.annotations.Component; - -/** - * Handles profile injection into the model. - * - * @author Benjamin Bentmann - */ -@Component( role = ProfileInjector.class ) -public class DefaultProfileInjector - implements ProfileInjector -{ - - private ProfileModelMerger merger = new ProfileModelMerger(); - - @Override - public void injectProfile( Model model, Profile profile, ModelBuildingRequest request, - ModelProblemCollector problems ) - { - if ( profile != null ) - { - merger.mergeModelBase( model, profile ); - - if ( profile.getBuild() != null ) - { - if ( model.getBuild() == null ) - { - model.setBuild( new Build() ); - } - merger.mergeBuildBase( model.getBuild(), profile.getBuild() ); - } - } - } - - protected static class ProfileModelMerger - extends MavenModelMerger - { - - public void mergeModelBase( ModelBase target, ModelBase source ) - { - mergeModelBase( target, source, true, Collections.emptyMap() ); - } - - public void mergeBuildBase( BuildBase target, BuildBase source ) - { - mergeBuildBase( target, source, true, Collections.emptyMap() ); - } - - @Override - protected void mergePluginContainer_Plugins( PluginContainer target, PluginContainer source, - boolean sourceDominant, Map<Object, Object> context ) - { - List<Plugin> src = source.getPlugins(); - if ( !src.isEmpty() ) - { - List<Plugin> tgt = target.getPlugins(); - Map<Object, Plugin> master = new LinkedHashMap<Object, Plugin>( tgt.size() * 2 ); - - for ( Plugin element : tgt ) - { - Object key = getPluginKey( element ); - master.put( key, element ); - } - - Map<Object, List<Plugin>> predecessors = new LinkedHashMap<Object, List<Plugin>>(); - List<Plugin> pending = new ArrayList<Plugin>(); - for ( Plugin element : src ) - { - Object key = getPluginKey( element ); - Plugin existing = master.get( key ); - if ( existing != null ) - { - mergePlugin( existing, element, sourceDominant, context ); - - if ( !pending.isEmpty() ) - { - predecessors.put( key, pending ); - pending = new ArrayList<Plugin>(); - } - } - else - { - pending.add( element ); - } - } - - List<Plugin> result = new ArrayList<Plugin>( src.size() + tgt.size() ); - for ( Map.Entry<Object, Plugin> entry : master.entrySet() ) - { - List<Plugin> pre = predecessors.get( entry.getKey() ); - if ( pre != null ) - { - result.addAll( pre ); - } - result.add( entry.getValue() ); - } - result.addAll( pending ); - - target.setPlugins( result ); - } - } - - @Override - protected void mergePlugin_Executions( Plugin target, Plugin source, boolean sourceDominant, - Map<Object, Object> context ) - { - List<PluginExecution> src = source.getExecutions(); - if ( !src.isEmpty() ) - { - List<PluginExecution> tgt = target.getExecutions(); - Map<Object, PluginExecution> merged = - new LinkedHashMap<Object, PluginExecution>( ( src.size() + tgt.size() ) * 2 ); - - for ( PluginExecution element : tgt ) - { - Object key = getPluginExecutionKey( element ); - merged.put( key, element ); - } - - for ( PluginExecution element : src ) - { - Object key = getPluginExecutionKey( element ); - PluginExecution existing = merged.get( key ); - if ( existing != null ) - { - mergePluginExecution( existing, element, sourceDominant, context ); - } - else - { - merged.put( key, element ); - } - } - - target.setExecutions( new ArrayList<PluginExecution>( merged.values() ) ); - } - } - - @Override - protected void mergeReporting_Plugins( Reporting target, Reporting source, boolean sourceDominant, - Map<Object, Object> context ) - { - List<ReportPlugin> src = source.getPlugins(); - if ( !src.isEmpty() ) - { - List<ReportPlugin> tgt = target.getPlugins(); - Map<Object, ReportPlugin> merged = - new LinkedHashMap<Object, ReportPlugin>( ( src.size() + tgt.size() ) * 2 ); - - for ( ReportPlugin element : tgt ) - { - Object key = getReportPluginKey( element ); - merged.put( key, element ); - } - - for ( ReportPlugin element : src ) - { - Object key = getReportPluginKey( element ); - ReportPlugin existing = merged.get( key ); - if ( existing == null ) - { - merged.put( key, element ); - } - else - { - mergeReportPlugin( existing, element, sourceDominant, context ); - } - } - - target.setPlugins( new ArrayList<ReportPlugin>( merged.values() ) ); - } - } - - @Override - protected void mergeReportPlugin_ReportSets( ReportPlugin target, ReportPlugin source, boolean sourceDominant, - Map<Object, Object> context ) - { - List<ReportSet> src = source.getReportSets(); - if ( !src.isEmpty() ) - { - List<ReportSet> tgt = target.getReportSets(); - Map<Object, ReportSet> merged = new LinkedHashMap<Object, ReportSet>( ( src.size() + tgt.size() ) * 2 ); - - for ( ReportSet element : tgt ) - { - Object key = getReportSetKey( element ); - merged.put( key, element ); - } - - for ( ReportSet element : src ) - { - Object key = getReportSetKey( element ); - ReportSet existing = merged.get( key ); - if ( existing != null ) - { - mergeReportSet( existing, element, sourceDominant, context ); - } - else - { - merged.put( key, element ); - } - } - - target.setReportSets( new ArrayList<ReportSet>( merged.values() ) ); - } - } - - } - -} diff --git a/framework/src/maven/apache-maven-3.3.3/maven-model-builder/src/main/java/org/apache/maven/model/profile/DefaultProfileSelector.java b/framework/src/maven/apache-maven-3.3.3/maven-model-builder/src/main/java/org/apache/maven/model/profile/DefaultProfileSelector.java deleted file mode 100644 index 512476a1..00000000 --- a/framework/src/maven/apache-maven-3.3.3/maven-model-builder/src/main/java/org/apache/maven/model/profile/DefaultProfileSelector.java +++ /dev/null @@ -1,143 +0,0 @@ -package org.apache.maven.model.profile; - -/* - * 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.util.ArrayList; -import java.util.Collection; -import java.util.HashSet; -import java.util.List; - -import org.apache.maven.model.Activation; -import org.apache.maven.model.Profile; -import org.apache.maven.model.building.ModelProblemCollector; -import org.apache.maven.model.building.ModelProblem.Severity; -import org.apache.maven.model.building.ModelProblem.Version; -import org.apache.maven.model.building.ModelProblemCollectorRequest; -import org.apache.maven.model.profile.activation.ProfileActivator; -import org.codehaus.plexus.component.annotations.Component; -import org.codehaus.plexus.component.annotations.Requirement; - -/** - * Calculates the active profiles among a given collection of profiles. - * - * @author Benjamin Bentmann - */ -@Component( role = ProfileSelector.class ) -public class DefaultProfileSelector - implements ProfileSelector -{ - - @Requirement( role = ProfileActivator.class ) - private List<ProfileActivator> activators = new ArrayList<ProfileActivator>(); - - public DefaultProfileSelector addProfileActivator( ProfileActivator profileActivator ) - { - if ( profileActivator != null ) - { - activators.add( profileActivator ); - } - return this; - } - - @Override - public List<Profile> getActiveProfiles( Collection<Profile> profiles, ProfileActivationContext context, - ModelProblemCollector problems ) - { - Collection<String> activatedIds = new HashSet<String>( context.getActiveProfileIds() ); - Collection<String> deactivatedIds = new HashSet<String>( context.getInactiveProfileIds() ); - - List<Profile> activeProfiles = new ArrayList<Profile>( profiles.size() ); - List<Profile> activePomProfilesByDefault = new ArrayList<Profile>(); - boolean activatedPomProfileNotByDefault = false; - - for ( Profile profile : profiles ) - { - if ( !deactivatedIds.contains( profile.getId() ) ) - { - if ( activatedIds.contains( profile.getId() ) || isActive( profile, context, problems ) ) - { - activeProfiles.add( profile ); - - if ( Profile.SOURCE_POM.equals( profile.getSource() ) ) - { - activatedPomProfileNotByDefault = true; - } - } - else if ( isActiveByDefault( profile ) ) - { - if ( Profile.SOURCE_POM.equals( profile.getSource() ) ) - { - activePomProfilesByDefault.add( profile ); - } - else - { - activeProfiles.add( profile ); - } - } - - } - } - - if ( !activatedPomProfileNotByDefault ) - { - activeProfiles.addAll( activePomProfilesByDefault ); - } - - return activeProfiles; - } - - private boolean isActive( Profile profile, ProfileActivationContext context, ModelProblemCollector problems ) - { - boolean isActive = false; - for ( ProfileActivator activator : activators ) - { - if ( activator.presentInConfig( profile, context, problems ) ) - { - isActive = true; - } - } - for ( ProfileActivator activator : activators ) - { - try - { - if ( activator.presentInConfig( profile, context, problems ) ) - { - isActive &= activator.isActive( profile, context, problems ); - } - } - catch ( RuntimeException e ) - { - problems.add( new ModelProblemCollectorRequest( Severity.ERROR, Version.BASE ) - .setMessage( "Failed to determine activation for profile " + profile.getId() ) - .setLocation( profile.getLocation( "" ) ) - .setException( e ) ); - return false; - } - } - return isActive; - } - - private boolean isActiveByDefault( Profile profile ) - { - Activation activation = profile.getActivation(); - return activation != null && activation.isActiveByDefault(); - } - -} diff --git a/framework/src/maven/apache-maven-3.3.3/maven-model-builder/src/main/java/org/apache/maven/model/profile/ProfileActivationContext.java b/framework/src/maven/apache-maven-3.3.3/maven-model-builder/src/main/java/org/apache/maven/model/profile/ProfileActivationContext.java deleted file mode 100644 index d501e660..00000000 --- a/framework/src/maven/apache-maven-3.3.3/maven-model-builder/src/main/java/org/apache/maven/model/profile/ProfileActivationContext.java +++ /dev/null @@ -1,79 +0,0 @@ -package org.apache.maven.model.profile; - -/* - * 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 java.util.List; -import java.util.Map; - -/** - * Describes the environmental context used to determine the activation status of profiles. - * - * @author Benjamin Bentmann - */ -public interface ProfileActivationContext -{ - - /** - * Gets the identifiers of those profiles that should be activated by explicit demand. - * - * @return The identifiers of those profiles to activate, never {@code null}. - */ - List<String> getActiveProfileIds(); - - /** - * Gets the identifiers of those profiles that should be deactivated by explicit demand. - * - * @return The identifiers of those profiles to deactivate, never {@code null}. - */ - List<String> getInactiveProfileIds(); - - /** - * Gets the system properties to use for interpolation and profile activation. The system properties are collected - * from the runtime environment like {@link System#getProperties()} and environment variables. - * - * @return The execution properties, never {@code null}. - */ - Map<String, String> getSystemProperties(); - - /** - * Gets the user properties to use for interpolation and profile activation. The user properties have been - * configured directly by the user on his discretion, e.g. via the {@code -Dkey=value} parameter on the command - * line. - * - * @return The user properties, never {@code null}. - */ - Map<String, String> getUserProperties(); - - /** - * Gets the base directory of the current project (if any). - * - * @return The base directory of the current project or {@code null} if none. - */ - File getProjectDirectory(); - - /** - * Gets current calculated project properties - * - * @return The project properties, never {@code null}. - */ - Map<String, String> getProjectProperties(); - -} diff --git a/framework/src/maven/apache-maven-3.3.3/maven-model-builder/src/main/java/org/apache/maven/model/profile/ProfileInjector.java b/framework/src/maven/apache-maven-3.3.3/maven-model-builder/src/main/java/org/apache/maven/model/profile/ProfileInjector.java deleted file mode 100644 index fbd7ddf0..00000000 --- a/framework/src/maven/apache-maven-3.3.3/maven-model-builder/src/main/java/org/apache/maven/model/profile/ProfileInjector.java +++ /dev/null @@ -1,46 +0,0 @@ -package org.apache.maven.model.profile; - -/* - * 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 org.apache.maven.model.Model; -import org.apache.maven.model.Profile; -import org.apache.maven.model.building.ModelBuildingRequest; -import org.apache.maven.model.building.ModelProblemCollector; - -/** - * Handles profile injection into the model. - * - * @author Benjamin Bentmann - */ -public interface ProfileInjector -{ - - /** - * Merges values from the specified profile into the given model. Implementations are expected to keep the profile - * and model completely decoupled by injecting deep copies rather than the original objects from the profile. - * - * @param model The model into which to merge the values defined by the profile, must not be <code>null</code>. - * @param profile The (read-only) profile whose values should be injected, may be <code>null</code>. - * @param request The model building request that holds further settings, must not be {@code null}. - * @param problems The container used to collect problems that were encountered, must not be {@code null}. - */ - void injectProfile( Model model, Profile profile, ModelBuildingRequest request, ModelProblemCollector problems ); - -} diff --git a/framework/src/maven/apache-maven-3.3.3/maven-model-builder/src/main/java/org/apache/maven/model/profile/ProfileSelector.java b/framework/src/maven/apache-maven-3.3.3/maven-model-builder/src/main/java/org/apache/maven/model/profile/ProfileSelector.java deleted file mode 100644 index 53ea8d9c..00000000 --- a/framework/src/maven/apache-maven-3.3.3/maven-model-builder/src/main/java/org/apache/maven/model/profile/ProfileSelector.java +++ /dev/null @@ -1,49 +0,0 @@ -package org.apache.maven.model.profile; - -/* - * 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.util.Collection; -import java.util.List; - -import org.apache.maven.model.Profile; -import org.apache.maven.model.building.ModelProblemCollector; - -/** - * Calculates the active profiles among a given collection of profiles. - * - * @author Benjamin Bentmann - */ -public interface ProfileSelector -{ - - /** - * Determines the profiles which are active in the specified activation context. Active profiles will eventually be - * injected into the model. - * - * @param profiles The profiles whose activation status should be determined, must not be {@code null}. - * @param context The environmental context used to determine the activation status of a profile, must not be - * {@code null}. - * @param problems The container used to collect problems that were encountered, must not be {@code null}. - * @return The profiles that have been activated, never {@code null}. - */ - List<Profile> getActiveProfiles( Collection<Profile> profiles, ProfileActivationContext context, - ModelProblemCollector problems ); - -} diff --git a/framework/src/maven/apache-maven-3.3.3/maven-model-builder/src/main/java/org/apache/maven/model/profile/activation/FileProfileActivator.java b/framework/src/maven/apache-maven-3.3.3/maven-model-builder/src/main/java/org/apache/maven/model/profile/activation/FileProfileActivator.java deleted file mode 100644 index c0dcce23..00000000 --- a/framework/src/maven/apache-maven-3.3.3/maven-model-builder/src/main/java/org/apache/maven/model/profile/activation/FileProfileActivator.java +++ /dev/null @@ -1,192 +0,0 @@ -package org.apache.maven.model.profile.activation; - -/* - * 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.apache.maven.model.Activation; -import org.apache.maven.model.ActivationFile; -import org.apache.maven.model.Profile; -import org.apache.maven.model.building.ModelProblemCollector; -import org.apache.maven.model.building.ModelProblem.Severity; -import org.apache.maven.model.building.ModelProblem.Version; -import org.apache.maven.model.building.ModelProblemCollectorRequest; -import org.apache.maven.model.path.PathTranslator; -import org.apache.maven.model.profile.ProfileActivationContext; -import org.codehaus.plexus.component.annotations.Component; -import org.codehaus.plexus.component.annotations.Requirement; -import org.codehaus.plexus.interpolation.AbstractValueSource; -import org.codehaus.plexus.interpolation.MapBasedValueSource; -import org.codehaus.plexus.interpolation.RegexBasedInterpolator; -import org.codehaus.plexus.util.StringUtils; - -/** - * Determines profile activation based on the existence/absence of some file. - * File name interpolation support is limited to <code>${basedir}</code> (since Maven 3, - * see <a href="http://jira.codehaus.org/browse/MNG-2363">MNG-2363</a>), - * System properties and request properties. - * <code>${project.basedir}</code> is intentionally not supported as this form would suggest that other - * <code>${project.*}</code> expressions can be used, which is however beyond the design. - * - * @author Benjamin Bentmann - * @see ActivationFile - * @see org.apache.maven.model.validation.DefaultModelValidator#validateRawModel - */ -@Component( role = ProfileActivator.class, hint = "file" ) -public class FileProfileActivator - implements ProfileActivator -{ - - @Requirement - private PathTranslator pathTranslator; - - public FileProfileActivator setPathTranslator( PathTranslator pathTranslator ) - { - this.pathTranslator = pathTranslator; - return this; - } - - @Override - public boolean isActive( Profile profile, ProfileActivationContext context, ModelProblemCollector problems ) - { - Activation activation = profile.getActivation(); - - if ( activation == null ) - { - return false; - } - - ActivationFile file = activation.getFile(); - - if ( file == null ) - { - return false; - } - - String path; - boolean missing; - - if ( StringUtils.isNotEmpty( file.getExists() ) ) - { - path = file.getExists(); - missing = false; - } - else if ( StringUtils.isNotEmpty( file.getMissing() ) ) - { - path = file.getMissing(); - missing = true; - } - else - { - return false; - } - - RegexBasedInterpolator interpolator = new RegexBasedInterpolator(); - - final File basedir = context.getProjectDirectory(); - - if ( basedir != null ) - { - interpolator.addValueSource( new AbstractValueSource( false ) - { - @Override - public Object getValue( String expression ) - { - /* - * NOTE: We intentionally only support ${basedir} and not ${project.basedir} as the latter form - * would suggest that other project.* expressions can be used which is however beyond the design. - */ - if ( "basedir".equals( expression ) ) - { - return basedir.getAbsolutePath(); - } - return null; - } - } ); - } - else if ( path.contains( "${basedir}" ) ) - { - return false; - } - - interpolator.addValueSource( new MapBasedValueSource( context.getProjectProperties() ) ); - - interpolator.addValueSource( new MapBasedValueSource( context.getUserProperties() ) ); - - interpolator.addValueSource( new MapBasedValueSource( context.getSystemProperties() ) ); - - try - { - path = interpolator.interpolate( path, "" ); - } - catch ( Exception e ) - { - problems.add( new ModelProblemCollectorRequest( Severity.ERROR, Version.BASE ) - .setMessage( "Failed to interpolate file location " + path + " for profile " + profile.getId() - + ": " + e.getMessage() ) - .setLocation( file.getLocation( missing ? "missing" : "exists" ) ) - .setException( e ) ); - return false; - } - - path = pathTranslator.alignToBaseDirectory( path, basedir ); - - // replace activation value with interpolated value - if ( missing ) - { - file.setMissing( path ); - } - else - { - file.setExists( path ); - } - - File f = new File( path ); - - if ( !f.isAbsolute() ) - { - return false; - } - - boolean fileExists = f.exists(); - - return missing ? !fileExists : fileExists; - } - - @Override - public boolean presentInConfig( Profile profile, ProfileActivationContext context, ModelProblemCollector problems ) - { - Activation activation = profile.getActivation(); - - if ( activation == null ) - { - return false; - } - - ActivationFile file = activation.getFile(); - - if ( file == null ) - { - return false; - } - return true; - } - -} diff --git a/framework/src/maven/apache-maven-3.3.3/maven-model-builder/src/main/java/org/apache/maven/model/profile/activation/JdkVersionProfileActivator.java b/framework/src/maven/apache-maven-3.3.3/maven-model-builder/src/main/java/org/apache/maven/model/profile/activation/JdkVersionProfileActivator.java deleted file mode 100644 index e981bfd3..00000000 --- a/framework/src/maven/apache-maven-3.3.3/maven-model-builder/src/main/java/org/apache/maven/model/profile/activation/JdkVersionProfileActivator.java +++ /dev/null @@ -1,224 +0,0 @@ -package org.apache.maven.model.profile.activation; - -/* - * 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.util.ArrayList; -import java.util.Arrays; -import java.util.List; - -import org.apache.maven.model.Activation; -import org.apache.maven.model.Profile; -import org.apache.maven.model.building.ModelProblemCollector; -import org.apache.maven.model.building.ModelProblem.Severity; -import org.apache.maven.model.building.ModelProblem.Version; -import org.apache.maven.model.building.ModelProblemCollectorRequest; -import org.apache.maven.model.profile.ProfileActivationContext; -import org.codehaus.plexus.component.annotations.Component; - -/** - * Determines profile activation based on the version of the current Java runtime. - * - * @author Benjamin Bentmann - * @see Activation#getJdk() - */ -@Component( role = ProfileActivator.class, hint = "jdk-version" ) -public class JdkVersionProfileActivator - implements ProfileActivator -{ - - @Override - public boolean isActive( Profile profile, ProfileActivationContext context, ModelProblemCollector problems ) - { - Activation activation = profile.getActivation(); - - if ( activation == null ) - { - return false; - } - - String jdk = activation.getJdk(); - - if ( jdk == null ) - { - return false; - } - - String version = context.getSystemProperties().get( "java.version" ); - - if ( version == null || version.length() <= 0 ) - { - problems.add( new ModelProblemCollectorRequest( Severity.ERROR, Version.BASE ) - .setMessage( "Failed to determine Java version for profile " + profile.getId() ) - .setLocation( activation.getLocation( "jdk" ) ) ); - return false; - } - - if ( jdk.startsWith( "!" ) ) - { - return !version.startsWith( jdk.substring( 1 ) ); - } - else if ( isRange( jdk ) ) - { - return isInRange( version, getRange( jdk ) ); - } - else - { - return version.startsWith( jdk ); - } - } - - @Override - public boolean presentInConfig( Profile profile, ProfileActivationContext context, ModelProblemCollector problems ) - { - Activation activation = profile.getActivation(); - - if ( activation == null ) - { - return false; - } - - String jdk = activation.getJdk(); - - if ( jdk == null ) - { - return false; - } - return true; - } - - private static boolean isInRange( String value, List<RangeValue> range ) - { - int leftRelation = getRelationOrder( value, range.get( 0 ), true ); - - if ( leftRelation == 0 ) - { - return true; - } - - if ( leftRelation < 0 ) - { - return false; - } - - return getRelationOrder( value, range.get( 1 ), false ) <= 0; - } - - private static int getRelationOrder( String value, RangeValue rangeValue, boolean isLeft ) - { - if ( rangeValue.value.length() <= 0 ) - { - return isLeft ? 1 : -1; - } - - value = value.replaceAll( "[^0-9\\.\\-\\_]", "" ); - - List<String> valueTokens = new ArrayList<String>( Arrays.asList( value.split( "[\\.\\-\\_]" ) ) ); - List<String> rangeValueTokens = new ArrayList<String>( Arrays.asList( rangeValue.value.split( "\\." ) ) ); - - addZeroTokens( valueTokens, 3 ); - addZeroTokens( rangeValueTokens, 3 ); - - for ( int i = 0; i < 3; i++ ) - { - int x = Integer.parseInt( valueTokens.get( i ) ); - int y = Integer.parseInt( rangeValueTokens.get( i ) ); - if ( x < y ) - { - return -1; - } - else if ( x > y ) - { - return 1; - } - } - if ( !rangeValue.closed ) - { - return isLeft ? -1 : 1; - } - return 0; - } - - private static void addZeroTokens( List<String> tokens, int max ) - { - while ( tokens.size() < max ) - { - tokens.add( "0" ); - } - } - - private static boolean isRange( String value ) - { - return value.startsWith( "[" ) || value.startsWith( "(" ); - } - - private static List<RangeValue> getRange( String range ) - { - List<RangeValue> ranges = new ArrayList<RangeValue>(); - - for ( String token : range.split( "," ) ) - { - if ( token.startsWith( "[" ) ) - { - ranges.add( new RangeValue( token.replace( "[", "" ), true ) ); - } - else if ( token.startsWith( "(" ) ) - { - ranges.add( new RangeValue( token.replace( "(", "" ), false ) ); - } - else if ( token.endsWith( "]" ) ) - { - ranges.add( new RangeValue( token.replace( "]", "" ), true ) ); - } - else if ( token.endsWith( ")" ) ) - { - ranges.add( new RangeValue( token.replace( ")", "" ), false ) ); - } - else if ( token.length() <= 0 ) - { - ranges.add( new RangeValue( "", false ) ); - } - } - if ( ranges.size() < 2 ) - { - ranges.add( new RangeValue( "99999999", false ) ); - } - return ranges; - } - - private static class RangeValue - { - private String value; - - private boolean closed; - - RangeValue( String value, boolean closed ) - { - this.value = value.trim(); - this.closed = closed; - } - - @Override - public String toString() - { - return value; - } - } - -} diff --git a/framework/src/maven/apache-maven-3.3.3/maven-model-builder/src/main/java/org/apache/maven/model/profile/activation/OperatingSystemProfileActivator.java b/framework/src/maven/apache-maven-3.3.3/maven-model-builder/src/main/java/org/apache/maven/model/profile/activation/OperatingSystemProfileActivator.java deleted file mode 100644 index 30abb1fa..00000000 --- a/framework/src/maven/apache-maven-3.3.3/maven-model-builder/src/main/java/org/apache/maven/model/profile/activation/OperatingSystemProfileActivator.java +++ /dev/null @@ -1,168 +0,0 @@ -package org.apache.maven.model.profile.activation; - -/* - * 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 org.apache.maven.model.Activation; -import org.apache.maven.model.ActivationOS; -import org.apache.maven.model.Profile; -import org.apache.maven.model.building.ModelProblemCollector; -import org.apache.maven.model.profile.ProfileActivationContext; -import org.codehaus.plexus.component.annotations.Component; -import org.codehaus.plexus.util.Os; - -/** - * Determines profile activation based on the operating system of the current runtime platform. - * - * @author Benjamin Bentmann - * @see ActivationOS - */ -@Component( role = ProfileActivator.class, hint = "os" ) -public class OperatingSystemProfileActivator - implements ProfileActivator -{ - - @Override - public boolean isActive( Profile profile, ProfileActivationContext context, ModelProblemCollector problems ) - { - Activation activation = profile.getActivation(); - - if ( activation == null ) - { - return false; - } - - ActivationOS os = activation.getOs(); - - if ( os == null ) - { - return false; - } - - boolean active = ensureAtLeastOneNonNull( os ); - - if ( active && os.getFamily() != null ) - { - active = determineFamilyMatch( os.getFamily() ); - } - if ( active && os.getName() != null ) - { - active = determineNameMatch( os.getName() ); - } - if ( active && os.getArch() != null ) - { - active = determineArchMatch( os.getArch() ); - } - if ( active && os.getVersion() != null ) - { - active = determineVersionMatch( os.getVersion() ); - } - - return active; - } - - @Override - public boolean presentInConfig( Profile profile, ProfileActivationContext context, ModelProblemCollector problems ) - { - Activation activation = profile.getActivation(); - - if ( activation == null ) - { - return false; - } - - ActivationOS os = activation.getOs(); - - if ( os == null ) - { - return false; - } - return true; - } - - private boolean ensureAtLeastOneNonNull( ActivationOS os ) - { - return os.getArch() != null || os.getFamily() != null || os.getName() != null || os.getVersion() != null; - } - - private boolean determineVersionMatch( String version ) - { - String test = version; - boolean reverse = false; - - if ( test.startsWith( "!" ) ) - { - reverse = true; - test = test.substring( 1 ); - } - - boolean result = Os.isVersion( test ); - - return reverse ? !result : result; - } - - private boolean determineArchMatch( String arch ) - { - String test = arch; - boolean reverse = false; - - if ( test.startsWith( "!" ) ) - { - reverse = true; - test = test.substring( 1 ); - } - - boolean result = Os.isArch( test ); - - return reverse ? !result : result; - } - - private boolean determineNameMatch( String name ) - { - String test = name; - boolean reverse = false; - - if ( test.startsWith( "!" ) ) - { - reverse = true; - test = test.substring( 1 ); - } - - boolean result = Os.isName( test ); - - return reverse ? !result : result; - } - - private boolean determineFamilyMatch( String family ) - { - String test = family; - boolean reverse = false; - - if ( test.startsWith( "!" ) ) - { - reverse = true; - test = test.substring( 1 ); - } - - boolean result = Os.isFamily( test ); - - return reverse ? !result : result; - } - -} diff --git a/framework/src/maven/apache-maven-3.3.3/maven-model-builder/src/main/java/org/apache/maven/model/profile/activation/ProfileActivator.java b/framework/src/maven/apache-maven-3.3.3/maven-model-builder/src/main/java/org/apache/maven/model/profile/activation/ProfileActivator.java deleted file mode 100644 index 0547e742..00000000 --- a/framework/src/maven/apache-maven-3.3.3/maven-model-builder/src/main/java/org/apache/maven/model/profile/activation/ProfileActivator.java +++ /dev/null @@ -1,59 +0,0 @@ -package org.apache.maven.model.profile.activation; - -/* - * 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 org.apache.maven.model.Profile; -import org.apache.maven.model.building.ModelProblemCollector; -import org.apache.maven.model.profile.ProfileActivationContext; - -/** - * Determines whether a profile should be activated. - * - * @author Benjamin Bentmann - */ -public interface ProfileActivator -{ - - /** - * Determines whether the specified profile is active in the given activator context. - * - * @param profile The profile whose activation status should be determined, must not be {@code null}. - * @param context The environmental context used to determine the activation status of the profile, must not be - * {@code null}. - * @param problems The container used to collect problems (e.g. bad syntax) that were encountered, must not be - * {@code null}. - * @return {@code true} if the profile is active, {@code false} otherwise. - */ - boolean isActive( Profile profile, ProfileActivationContext context, ModelProblemCollector problems ); - - /** - * Determines whether specified activation method is present in configuration or not. It should help to have AND - * between activation conditions - * Need for solving http://jira.codehaus.org/browse/MNG-4565 - * @param profile The profile whose activation status should be determined, must not be {@code null}. - * @param context The environmental context used to determine the activation status of the profile, must not be - * {@code null}. - * @param problems The container used to collect problems (e.g. bad syntax) that were encountered, must not be - * {@code null}. - * @return {@code true} if the profile is active, {@code false} otherwise. - */ - boolean presentInConfig( Profile profile, ProfileActivationContext context, ModelProblemCollector problems ); - -} diff --git a/framework/src/maven/apache-maven-3.3.3/maven-model-builder/src/main/java/org/apache/maven/model/profile/activation/PropertyProfileActivator.java b/framework/src/maven/apache-maven-3.3.3/maven-model-builder/src/main/java/org/apache/maven/model/profile/activation/PropertyProfileActivator.java deleted file mode 100644 index ba7886f0..00000000 --- a/framework/src/maven/apache-maven-3.3.3/maven-model-builder/src/main/java/org/apache/maven/model/profile/activation/PropertyProfileActivator.java +++ /dev/null @@ -1,126 +0,0 @@ -package org.apache.maven.model.profile.activation; - -/* - * 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 org.apache.maven.model.Activation; -import org.apache.maven.model.ActivationProperty; -import org.apache.maven.model.Profile; -import org.apache.maven.model.building.ModelProblemCollector; -import org.apache.maven.model.building.ModelProblem.Severity; -import org.apache.maven.model.building.ModelProblem.Version; -import org.apache.maven.model.building.ModelProblemCollectorRequest; -import org.apache.maven.model.profile.ProfileActivationContext; -import org.codehaus.plexus.component.annotations.Component; -import org.codehaus.plexus.util.StringUtils; - -/** - * Determines profile activation based on the existence or value of some execution property. - * - * @author Benjamin Bentmann - * @see ActivationProperty - */ -@Component( role = ProfileActivator.class, hint = "property" ) -public class PropertyProfileActivator - implements ProfileActivator -{ - - @Override - public boolean isActive( Profile profile, ProfileActivationContext context, ModelProblemCollector problems ) - { - Activation activation = profile.getActivation(); - - if ( activation == null ) - { - return false; - } - - ActivationProperty property = activation.getProperty(); - - if ( property == null ) - { - return false; - } - - String name = property.getName(); - boolean reverseName = false; - - if ( name != null && name.startsWith( "!" ) ) - { - reverseName = true; - name = name.substring( 1 ); - } - - if ( name == null || name.length() <= 0 ) - { - problems.add( new ModelProblemCollectorRequest( Severity.ERROR, Version.BASE ) - .setMessage( "The property name is required to activate the profile " + profile.getId() ) - .setLocation( property.getLocation( "" ) ) ); - return false; - } - - String sysValue = context.getUserProperties().get( name ); - if ( sysValue == null ) - { - sysValue = context.getSystemProperties().get( name ); - } - - String propValue = property.getValue(); - if ( StringUtils.isNotEmpty( propValue ) ) - { - boolean reverseValue = false; - if ( propValue.startsWith( "!" ) ) - { - reverseValue = true; - propValue = propValue.substring( 1 ); - } - - // we have a value, so it has to match the system value... - boolean result = propValue.equals( sysValue ); - - return reverseValue ? !result : result; - } - else - { - boolean result = StringUtils.isNotEmpty( sysValue ); - - return reverseName ? !result : result; - } - } - - @Override - public boolean presentInConfig( Profile profile, ProfileActivationContext context, ModelProblemCollector problems ) - { - Activation activation = profile.getActivation(); - - if ( activation == null ) - { - return false; - } - - ActivationProperty property = activation.getProperty(); - - if ( property == null ) - { - return false; - } - return true; - } - -} |