diff options
Diffstat (limited to 'framework/src/maven/apache-maven-3.3.3/maven-embedder/src/main/java/org/apache')
24 files changed, 0 insertions, 4469 deletions
diff --git a/framework/src/maven/apache-maven-3.3.3/maven-embedder/src/main/java/org/apache/maven/cli/CLIManager.java b/framework/src/maven/apache-maven-3.3.3/maven-embedder/src/main/java/org/apache/maven/cli/CLIManager.java deleted file mode 100644 index a78e11dc..00000000 --- a/framework/src/maven/apache-maven-3.3.3/maven-embedder/src/main/java/org/apache/maven/cli/CLIManager.java +++ /dev/null @@ -1,271 +0,0 @@ -package org.apache.maven.cli; - -/* - * 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.PrintStream; -import java.io.PrintWriter; -import java.util.ArrayList; -import java.util.List; - -import org.apache.commons.cli.CommandLine; -import org.apache.commons.cli.CommandLineParser; -import org.apache.commons.cli.GnuParser; -import org.apache.commons.cli.HelpFormatter; -import org.apache.commons.cli.OptionBuilder; -import org.apache.commons.cli.Options; -import org.apache.commons.cli.ParseException; - -/** - * @author Jason van Zyl - */ -public class CLIManager -{ - public static final char ALTERNATE_POM_FILE = 'f'; - - public static final char BATCH_MODE = 'B'; - - public static final char SET_SYSTEM_PROPERTY = 'D'; - - public static final char OFFLINE = 'o'; - - public static final char QUIET = 'q'; - - public static final char DEBUG = 'X'; - - public static final char ERRORS = 'e'; - - public static final char HELP = 'h'; - - public static final char VERSION = 'v'; - - public static final char SHOW_VERSION = 'V'; - - public static final char NON_RECURSIVE = 'N'; - - public static final char UPDATE_SNAPSHOTS = 'U'; - - public static final char ACTIVATE_PROFILES = 'P'; - - public static final String SUPRESS_SNAPSHOT_UPDATES = "nsu"; - - public static final char CHECKSUM_FAILURE_POLICY = 'C'; - - public static final char CHECKSUM_WARNING_POLICY = 'c'; - - public static final char ALTERNATE_USER_SETTINGS = 's'; - - public static final String ALTERNATE_GLOBAL_SETTINGS = "gs"; - - public static final char ALTERNATE_USER_TOOLCHAINS = 't'; - - public static final String ALTERNATE_GLOBAL_TOOLCHAINS = "gt"; - - public static final String FAIL_FAST = "ff"; - - public static final String FAIL_AT_END = "fae"; - - public static final String FAIL_NEVER = "fn"; - - public static final String RESUME_FROM = "rf"; - - public static final String PROJECT_LIST = "pl"; - - public static final String ALSO_MAKE = "am"; - - public static final String ALSO_MAKE_DEPENDENTS = "amd"; - - public static final String LOG_FILE = "l"; - - public static final String ENCRYPT_MASTER_PASSWORD = "emp"; - - public static final String ENCRYPT_PASSWORD = "ep"; - - public static final String THREADS = "T"; - - public static final String LEGACY_LOCAL_REPOSITORY = "llr"; - - public static final String BUILDER = "b"; - - protected Options options; - - @SuppressWarnings( { "static-access", "checkstyle:linelength" } ) - public CLIManager() - { - options = new Options(); - options.addOption( OptionBuilder.withLongOpt( "help" ).withDescription( "Display help information" ).create( HELP ) ); - options.addOption( OptionBuilder.withLongOpt( "file" ).hasArg().withDescription( "Force the use of an alternate POM file (or directory with pom.xml)." ).create( ALTERNATE_POM_FILE ) ); - options.addOption( OptionBuilder.withLongOpt( "define" ).hasArg().withDescription( "Define a system property" ).create( SET_SYSTEM_PROPERTY ) ); - options.addOption( OptionBuilder.withLongOpt( "offline" ).withDescription( "Work offline" ).create( OFFLINE ) ); - options.addOption( OptionBuilder.withLongOpt( "version" ).withDescription( "Display version information" ).create( VERSION ) ); - options.addOption( OptionBuilder.withLongOpt( "quiet" ).withDescription( "Quiet output - only show errors" ).create( QUIET ) ); - options.addOption( OptionBuilder.withLongOpt( "debug" ).withDescription( "Produce execution debug output" ).create( DEBUG ) ); - options.addOption( OptionBuilder.withLongOpt( "errors" ).withDescription( "Produce execution error messages" ).create( ERRORS ) ); - options.addOption( OptionBuilder.withLongOpt( "non-recursive" ).withDescription( "Do not recurse into sub-projects" ).create( NON_RECURSIVE ) ); - options.addOption( OptionBuilder.withLongOpt( "update-snapshots" ).withDescription( "Forces a check for missing releases and updated snapshots on remote repositories" ).create( UPDATE_SNAPSHOTS ) ); - options.addOption( OptionBuilder.withLongOpt( "activate-profiles" ).withDescription( "Comma-delimited list of profiles to activate" ).hasArg().create( ACTIVATE_PROFILES ) ); - options.addOption( OptionBuilder.withLongOpt( "batch-mode" ).withDescription( "Run in non-interactive (batch) mode" ).create( BATCH_MODE ) ); - options.addOption( OptionBuilder.withLongOpt( "no-snapshot-updates" ).withDescription( "Suppress SNAPSHOT updates" ).create( SUPRESS_SNAPSHOT_UPDATES ) ); - options.addOption( OptionBuilder.withLongOpt( "strict-checksums" ).withDescription( "Fail the build if checksums don't match" ).create( CHECKSUM_FAILURE_POLICY ) ); - options.addOption( OptionBuilder.withLongOpt( "lax-checksums" ).withDescription( "Warn if checksums don't match" ).create( CHECKSUM_WARNING_POLICY ) ); - options.addOption( OptionBuilder.withLongOpt( "settings" ).withDescription( "Alternate path for the user settings file" ).hasArg().create( ALTERNATE_USER_SETTINGS ) ); - options.addOption( OptionBuilder.withLongOpt( "global-settings" ).withDescription( "Alternate path for the global settings file" ).hasArg().create( ALTERNATE_GLOBAL_SETTINGS ) ); - options.addOption( OptionBuilder.withLongOpt( "toolchains" ).withDescription( "Alternate path for the user toolchains file" ).hasArg().create( ALTERNATE_USER_TOOLCHAINS ) ); - options.addOption( OptionBuilder.withLongOpt( "global-toolchains" ).withDescription( "Alternate path for the global toolchains file" ).hasArg().create( ALTERNATE_GLOBAL_TOOLCHAINS ) ); - options.addOption( OptionBuilder.withLongOpt( "fail-fast" ).withDescription( "Stop at first failure in reactorized builds" ).create( FAIL_FAST ) ); - options.addOption( OptionBuilder.withLongOpt( "fail-at-end" ).withDescription( "Only fail the build afterwards; allow all non-impacted builds to continue" ).create( FAIL_AT_END ) ); - options.addOption( OptionBuilder.withLongOpt( "fail-never" ).withDescription( "NEVER fail the build, regardless of project result" ).create( FAIL_NEVER ) ); - options.addOption( OptionBuilder.withLongOpt( "resume-from" ).hasArg().withDescription( "Resume reactor from specified project" ).create( RESUME_FROM ) ); - options.addOption( OptionBuilder.withLongOpt( "projects" ).withDescription( "Comma-delimited list of specified reactor projects to build instead of all projects. A project can be specified by [groupId]:artifactId or by its relative path." ).hasArg().create( PROJECT_LIST ) ); - options.addOption( OptionBuilder.withLongOpt( "also-make" ).withDescription( "If project list is specified, also build projects required by the list" ).create( ALSO_MAKE ) ); - options.addOption( OptionBuilder.withLongOpt( "also-make-dependents" ).withDescription( "If project list is specified, also build projects that depend on projects on the list" ).create( ALSO_MAKE_DEPENDENTS ) ); - options.addOption( OptionBuilder.withLongOpt( "log-file" ).hasArg().withDescription( "Log file to where all build output will go." ).create( LOG_FILE ) ); - options.addOption( OptionBuilder.withLongOpt( "show-version" ).withDescription( "Display version information WITHOUT stopping build" ).create( SHOW_VERSION ) ); - options.addOption( OptionBuilder.withLongOpt( "encrypt-master-password" ).hasOptionalArg().withDescription( "Encrypt master security password" ).create( ENCRYPT_MASTER_PASSWORD ) ); - options.addOption( OptionBuilder.withLongOpt( "encrypt-password" ).hasOptionalArg().withDescription( "Encrypt server password" ).create( ENCRYPT_PASSWORD ) ); - options.addOption( OptionBuilder.withLongOpt( "threads" ).hasArg().withDescription( "Thread count, for instance 2.0C where C is core multiplied" ).create( THREADS ) ); - options.addOption( OptionBuilder.withLongOpt( "legacy-local-repository" ).withDescription( "Use Maven 2 Legacy Local Repository behaviour, ie no use of _remote.repositories. Can also be activated by using -Dmaven.legacyLocalRepo=true" ).create( LEGACY_LOCAL_REPOSITORY ) ); - options.addOption( OptionBuilder.withLongOpt( "builder" ).hasArg().withDescription( "The id of the build strategy to use." ).create( BUILDER ) ); - - // Adding this back in for compatibility with the verifier that hard codes this option. - options.addOption( OptionBuilder.withLongOpt( "no-plugin-registry" ).withDescription( "Ineffective, only kept for backward compatibility" ).create( "npr" ) ); - options.addOption( OptionBuilder.withLongOpt( "check-plugin-updates" ).withDescription( "Ineffective, only kept for backward compatibility" ).create( "cpu" ) ); - options.addOption( OptionBuilder.withLongOpt( "update-plugins" ).withDescription( "Ineffective, only kept for backward compatibility" ).create( "up" ) ); - options.addOption( OptionBuilder.withLongOpt( "no-plugin-updates" ).withDescription( "Ineffective, only kept for backward compatibility" ).create( "npu" ) ); - } - - public CommandLine parse( String[] args ) - throws ParseException - { - // We need to eat any quotes surrounding arguments... - String[] cleanArgs = cleanArgs( args ); - - CommandLineParser parser = new GnuParser(); - - return parser.parse( options, cleanArgs ); - } - - private String[] cleanArgs( String[] args ) - { - List<String> cleaned = new ArrayList<String>(); - - StringBuilder currentArg = null; - - for ( String arg : args ) - { - boolean addedToBuffer = false; - - if ( arg.startsWith( "\"" ) ) - { - // if we're in the process of building up another arg, push it and start over. - // this is for the case: "-Dfoo=bar "-Dfoo2=bar two" (note the first unterminated quote) - if ( currentArg != null ) - { - cleaned.add( currentArg.toString() ); - } - - // start building an argument here. - currentArg = new StringBuilder( arg.substring( 1 ) ); - addedToBuffer = true; - } - - // this has to be a separate "if" statement, to capture the case of: "-Dfoo=bar" - if ( arg.endsWith( "\"" ) ) - { - String cleanArgPart = arg.substring( 0, arg.length() - 1 ); - - // if we're building an argument, keep doing so. - if ( currentArg != null ) - { - // if this is the case of "-Dfoo=bar", then we need to adjust the buffer. - if ( addedToBuffer ) - { - currentArg.setLength( currentArg.length() - 1 ); - } - // otherwise, we trim the trailing " and append to the buffer. - else - { - // TODO: introducing a space here...not sure what else to do but collapse whitespace - currentArg.append( ' ' ).append( cleanArgPart ); - } - - cleaned.add( currentArg.toString() ); - } - else - { - cleaned.add( cleanArgPart ); - } - - currentArg = null; - - continue; - } - - // if we haven't added this arg to the buffer, and we ARE building an argument - // buffer, then append it with a preceding space...again, not sure what else to - // do other than collapse whitespace. - // NOTE: The case of a trailing quote is handled by nullifying the arg buffer. - if ( !addedToBuffer ) - { - if ( currentArg != null ) - { - currentArg.append( ' ' ).append( arg ); - } - else - { - cleaned.add( arg ); - } - } - } - - if ( currentArg != null ) - { - cleaned.add( currentArg.toString() ); - } - - int cleanedSz = cleaned.size(); - - String[] cleanArgs; - - if ( cleanedSz == 0 ) - { - cleanArgs = args; - } - else - { - cleanArgs = cleaned.toArray( new String[cleanedSz] ); - } - - return cleanArgs; - } - - public void displayHelp( PrintStream stdout ) - { - stdout.println(); - - PrintWriter pw = new PrintWriter( stdout ); - - HelpFormatter formatter = new HelpFormatter(); - - formatter.printHelp( pw, HelpFormatter.DEFAULT_WIDTH, "mvn [options] [<goal(s)>] [<phase(s)>]", "\nOptions:", - options, HelpFormatter.DEFAULT_LEFT_PAD, HelpFormatter.DEFAULT_DESC_PAD, "\n", false ); - - pw.flush(); - } -} diff --git a/framework/src/maven/apache-maven-3.3.3/maven-embedder/src/main/java/org/apache/maven/cli/CLIReportingUtils.java b/framework/src/maven/apache-maven-3.3.3/maven-embedder/src/main/java/org/apache/maven/cli/CLIReportingUtils.java deleted file mode 100644 index 07863b72..00000000 --- a/framework/src/maven/apache-maven-3.3.3/maven-embedder/src/main/java/org/apache/maven/cli/CLIReportingUtils.java +++ /dev/null @@ -1,205 +0,0 @@ -package org.apache.maven.cli; - -/* - * 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.IOException; -import java.io.InputStream; -import java.util.Date; -import java.util.Locale; -import java.util.Properties; -import java.util.TimeZone; - -import org.codehaus.plexus.util.IOUtil; -import org.codehaus.plexus.util.Os; -import org.slf4j.Logger; - -/** - * Utility class used to report errors, statistics, application version info, etc. - * - * @author jdcasey - * - */ -public final class CLIReportingUtils -{ - // CHECKSTYLE_OFF: MagicNumber - public static final long MB = 1024 * 1024; - - private static final long ONE_SECOND = 1000L; - private static final long ONE_MINUTE = 60 * ONE_SECOND; - private static final long ONE_HOUR = 60 * ONE_MINUTE; - private static final long ONE_DAY = 24 * ONE_HOUR; - // CHECKSTYLE_ON: MagicNumber - - public static final String BUILD_VERSION_PROPERTY = "version"; - - public static String showVersion() - { - final String ls = System.getProperty( "line.separator" ); - Properties properties = getBuildProperties(); - StringBuilder version = new StringBuilder(); - version.append( createMavenVersionString( properties ) ).append( ls ); - version.append( reduce( properties.getProperty( "distributionShortName" ) + " home: " - + System.getProperty( "maven.home", "<unknown maven home>" ) ) ).append( ls ); - version.append( "Java version: " ).append( - System.getProperty( "java.version", "<unknown java version>" ) ).append( ", vendor: " ).append( - System.getProperty( "java.vendor", "<unknown vendor>" ) ).append( ls ); - version.append( "Java home: " ).append( System.getProperty( "java.home", "<unknown java home>" ) ).append( ls ); - version.append( "Default locale: " ).append( Locale.getDefault() ).append( ", platform encoding: " ).append( - System.getProperty( "file.encoding", "<unknown encoding>" ) ).append( ls ); - version.append( "OS name: \"" ).append( Os.OS_NAME ).append( "\", version: \"" ).append( Os.OS_VERSION ).append( - "\", arch: \"" ).append( Os.OS_ARCH ).append( "\", family: \"" ).append( Os.OS_FAMILY ).append( "\"" ); - return version.toString(); - } - - /** - * Create a human readable string containing the Maven version, buildnumber, and time of build - * - * @param buildProperties The build properties - * @return Readable build info - */ - static String createMavenVersionString( Properties buildProperties ) - { - String timestamp = reduce( buildProperties.getProperty( "timestamp" ) ); - String version = reduce( buildProperties.getProperty( BUILD_VERSION_PROPERTY ) ); - String rev = reduce( buildProperties.getProperty( "buildNumber" ) ); - String distributionName = reduce( buildProperties.getProperty( "distributionName" ) ); - - String msg = distributionName + " "; - msg += ( version != null ? version : "<version unknown>" ); - if ( rev != null || timestamp != null ) - { - msg += " ("; - msg += ( rev != null ? rev : "" ); - if ( timestamp != null ) - { - String ts = formatTimestamp( Long.valueOf( timestamp ) ); - msg += ( rev != null ? "; " : "" ) + ts; - } - msg += ")"; - } - return msg; - } - - private static String reduce( String s ) - { - return ( s != null ? ( s.startsWith( "${" ) && s.endsWith( "}" ) ? null : s ) : null ); - } - - static Properties getBuildProperties() - { - Properties properties = new Properties(); - InputStream resourceAsStream = null; - try - { - resourceAsStream = MavenCli.class.getResourceAsStream( "/org/apache/maven/messages/build.properties" ); - - if ( resourceAsStream != null ) - { - properties.load( resourceAsStream ); - } - } - catch ( IOException e ) - { - System.err.println( "Unable determine version from JAR file: " + e.getMessage() ); - } - finally - { - IOUtil.close( resourceAsStream ); - } - - return properties; - } - - public static void showError( Logger logger, String message, Throwable e, boolean showStackTrace ) - { - if ( showStackTrace ) - { - logger.error( message, e ); - } - else - { - logger.error( message ); - - if ( e != null ) - { - logger.error( e.getMessage() ); - - for ( Throwable cause = e.getCause(); cause != null; cause = cause.getCause() ) - { - logger.error( "Caused by: " + cause.getMessage() ); - } - } - } - } - - public static String formatTimestamp( long timestamp ) - { - // Manual construction of the tz offset because only Java 7 is aware of ISO 8601 time zones - TimeZone tz = TimeZone.getDefault(); - int offset = tz.getRawOffset(); - - // Raw offset ignores DST, so check if we are in DST now and add the offset - if ( tz.inDaylightTime( new Date( timestamp ) ) ) - { - offset += tz.getDSTSavings(); - } - - // CHECKSTYLE_OFF: MagicNumber - long m = Math.abs( ( offset / ONE_MINUTE ) % 60 ); - long h = Math.abs( ( offset / ONE_HOUR ) % 24 ); - // CHECKSTYLE_ON: MagicNumber - - int offsetDir = (int) Math.signum( (float) offset ); - char offsetSign = offsetDir >= 0 ? '+' : '-'; - return String.format( "%tFT%<tT%s%02d:%02d", timestamp, offsetSign, h, m ); - } - - public static String formatDuration( long duration ) - { - // CHECKSTYLE_OFF: MagicNumber - long ms = duration % 1000; - long s = ( duration / ONE_SECOND ) % 60; - long m = ( duration / ONE_MINUTE ) % 60; - long h = ( duration / ONE_HOUR ) % 24; - long d = duration / ONE_DAY; - // CHECKSTYLE_ON: MagicNumber - - String format; - if ( d > 0 ) - { - format = "%d d %02d:%02d h"; - } - else if ( h > 0 ) - { - format = "%2$02d:%3$02d h"; - } - else if ( m > 0 ) - { - format = "%3$02d:%4$02d min"; - } - else - { - format = "%4$d.%5$03d s"; - } - - return String.format( format, d, h, m, s, ms ); - } - -} diff --git a/framework/src/maven/apache-maven-3.3.3/maven-embedder/src/main/java/org/apache/maven/cli/CliRequest.java b/framework/src/maven/apache-maven-3.3.3/maven-embedder/src/main/java/org/apache/maven/cli/CliRequest.java deleted file mode 100644 index 4656dd37..00000000 --- a/framework/src/maven/apache-maven-3.3.3/maven-embedder/src/main/java/org/apache/maven/cli/CliRequest.java +++ /dev/null @@ -1,120 +0,0 @@ -package org.apache.maven.cli; - -/* - * 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.Properties; - -import org.apache.commons.cli.CommandLine; -import org.apache.maven.execution.DefaultMavenExecutionRequest; -import org.apache.maven.execution.MavenExecutionRequest; -import org.codehaus.plexus.classworlds.ClassWorld; - -public class CliRequest -{ - String[] args; - - CommandLine commandLine; - - ClassWorld classWorld; - - String workingDirectory; - - File multiModuleProjectDirectory; - - boolean debug; - - boolean quiet; - - boolean showErrors = true; - - Properties userProperties = new Properties(); - - Properties systemProperties = new Properties(); - - MavenExecutionRequest request; - - CliRequest( String[] args, ClassWorld classWorld ) - { - this.args = args; - this.classWorld = classWorld; - this.request = new DefaultMavenExecutionRequest(); - } - - public String[] getArgs() - { - return args; - } - - public CommandLine getCommandLine() - { - return commandLine; - } - - public ClassWorld getClassWorld() - { - return classWorld; - } - - public String getWorkingDirectory() - { - return workingDirectory; - } - - public File getMultiModuleProjectDirectory() - { - return multiModuleProjectDirectory; - } - - public boolean isDebug() - { - return debug; - } - - public boolean isQuiet() - { - return quiet; - } - - public boolean isShowErrors() - { - return showErrors; - } - - public Properties getUserProperties() - { - return userProperties; - } - - public Properties getSystemProperties() - { - return systemProperties; - } - - public MavenExecutionRequest getRequest() - { - return request; - } - - public void setUserProperties( Properties properties ) - { - this.userProperties.putAll( properties ); - } -}
\ No newline at end of file diff --git a/framework/src/maven/apache-maven-3.3.3/maven-embedder/src/main/java/org/apache/maven/cli/MavenCli.java b/framework/src/maven/apache-maven-3.3.3/maven-embedder/src/main/java/org/apache/maven/cli/MavenCli.java deleted file mode 100644 index 39660956..00000000 --- a/framework/src/maven/apache-maven-3.3.3/maven-embedder/src/main/java/org/apache/maven/cli/MavenCli.java +++ /dev/null @@ -1,1610 +0,0 @@ -package org.apache.maven.cli; - -/* - * 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.BufferedInputStream; -import java.io.Console; -import java.io.File; -import java.io.FileInputStream; -import java.io.FileNotFoundException; -import java.io.FileOutputStream; -import java.io.IOException; -import java.io.InputStream; -import java.io.PrintStream; -import java.util.ArrayList; -import java.util.Arrays; -import java.util.Collections; -import java.util.HashSet; -import java.util.LinkedHashMap; -import java.util.List; -import java.util.Map; -import java.util.Map.Entry; -import java.util.Properties; -import java.util.Set; -import java.util.StringTokenizer; - -import org.apache.commons.cli.CommandLine; -import org.apache.commons.cli.ParseException; -import org.apache.commons.cli.UnrecognizedOptionException; -import org.apache.maven.BuildAbort; -import org.apache.maven.InternalErrorException; -import org.apache.maven.Maven; -import org.apache.maven.building.FileSource; -import org.apache.maven.building.Problem; -import org.apache.maven.building.Source; -import org.apache.maven.cli.configuration.ConfigurationProcessor; -import org.apache.maven.cli.configuration.SettingsXmlConfigurationProcessor; -import org.apache.maven.cli.event.DefaultEventSpyContext; -import org.apache.maven.cli.event.ExecutionEventLogger; -import org.apache.maven.cli.internal.BootstrapCoreExtensionManager; -import org.apache.maven.cli.internal.extension.model.CoreExtension; -import org.apache.maven.cli.internal.extension.model.io.xpp3.CoreExtensionsXpp3Reader; -import org.apache.maven.cli.logging.Slf4jConfiguration; -import org.apache.maven.cli.logging.Slf4jConfigurationFactory; -import org.apache.maven.cli.logging.Slf4jLoggerManager; -import org.apache.maven.cli.logging.Slf4jStdoutLogger; -import org.apache.maven.cli.transfer.ConsoleMavenTransferListener; -import org.apache.maven.cli.transfer.QuietMavenTransferListener; -import org.apache.maven.cli.transfer.Slf4jMavenTransferListener; -import org.apache.maven.eventspy.internal.EventSpyDispatcher; -import org.apache.maven.exception.DefaultExceptionHandler; -import org.apache.maven.exception.ExceptionHandler; -import org.apache.maven.exception.ExceptionSummary; -import org.apache.maven.execution.DefaultMavenExecutionRequest; -import org.apache.maven.execution.ExecutionListener; -import org.apache.maven.execution.MavenExecutionRequest; -import org.apache.maven.execution.MavenExecutionRequestPopulationException; -import org.apache.maven.execution.MavenExecutionRequestPopulator; -import org.apache.maven.execution.MavenExecutionResult; -import org.apache.maven.extension.internal.CoreExports; -import org.apache.maven.extension.internal.CoreExtensionEntry; -import org.apache.maven.lifecycle.LifecycleExecutionException; -import org.apache.maven.model.building.ModelProcessor; -import org.apache.maven.project.MavenProject; -import org.apache.maven.properties.internal.EnvironmentUtils; -import org.apache.maven.properties.internal.SystemProperties; -import org.apache.maven.toolchain.building.DefaultToolchainsBuildingRequest; -import org.apache.maven.toolchain.building.ToolchainsBuilder; -import org.apache.maven.toolchain.building.ToolchainsBuildingResult; -import org.codehaus.plexus.ContainerConfiguration; -import org.codehaus.plexus.DefaultContainerConfiguration; -import org.codehaus.plexus.DefaultPlexusContainer; -import org.codehaus.plexus.PlexusConstants; -import org.codehaus.plexus.PlexusContainer; -import org.codehaus.plexus.classworlds.ClassWorld; -import org.codehaus.plexus.classworlds.realm.ClassRealm; -import org.codehaus.plexus.classworlds.realm.NoSuchRealmException; -import org.codehaus.plexus.component.repository.exception.ComponentLookupException; -import org.codehaus.plexus.logging.LoggerManager; -import org.codehaus.plexus.util.IOUtil; -import org.codehaus.plexus.util.StringUtils; -import org.codehaus.plexus.util.xml.pull.XmlPullParserException; -import org.eclipse.aether.transfer.TransferListener; -import org.slf4j.ILoggerFactory; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; -import org.sonatype.plexus.components.cipher.DefaultPlexusCipher; -import org.sonatype.plexus.components.sec.dispatcher.DefaultSecDispatcher; -import org.sonatype.plexus.components.sec.dispatcher.SecDispatcher; -import org.sonatype.plexus.components.sec.dispatcher.SecUtil; -import org.sonatype.plexus.components.sec.dispatcher.model.SettingsSecurity; - -import com.google.common.base.Charsets; -import com.google.common.io.Files; -import com.google.inject.AbstractModule; - -// TODO: push all common bits back to plexus cli and prepare for transition to Guice. We don't need 50 ways to make CLIs - -/** - * @author Jason van Zyl - * @noinspection UseOfSystemOutOrSystemErr,ACCESS_STATIC_VIA_INSTANCE - */ -public class MavenCli -{ - public static final String LOCAL_REPO_PROPERTY = "maven.repo.local"; - - public static final String THREADS_DEPRECATED = "maven.threads.experimental"; - - public static final String MULTIMODULE_PROJECT_DIRECTORY = "maven.multiModuleProjectDirectory"; - - @SuppressWarnings( "checkstyle:constantname" ) - public static final String userHome = System.getProperty( "user.home" ); - - @SuppressWarnings( "checkstyle:constantname" ) - public static final File userMavenConfigurationHome = new File( userHome, ".m2" ); - - /** - * @deprecated use {@link SettingsXmlConfigurationProcessor#DEFAULT_USER_SETTINGS_FILE} - */ - public static final File DEFAULT_USER_SETTINGS_FILE = SettingsXmlConfigurationProcessor.DEFAULT_USER_SETTINGS_FILE; - - /** - * @deprecated use {@link SettingsXmlConfigurationProcessor#DEFAULT_GLOBAL_SETTINGS_FILE} - */ - public static final File DEFAULT_GLOBAL_SETTINGS_FILE = - SettingsXmlConfigurationProcessor.DEFAULT_GLOBAL_SETTINGS_FILE; - - public static final File DEFAULT_USER_TOOLCHAINS_FILE = new File( userMavenConfigurationHome, "toolchains.xml" ); - - public static final File DEFAULT_GLOBAL_TOOLCHAINS_FILE = - new File( System.getProperty( "maven.home", System.getProperty( "user.dir", "" ) ), "conf/toolchains.xml" ); - - private static final String EXT_CLASS_PATH = "maven.ext.class.path"; - - private static final String EXTENSIONS_FILENAME = ".mvn/extensions.xml"; - - private ClassWorld classWorld; - - private LoggerManager plexusLoggerManager; - - private ILoggerFactory slf4jLoggerFactory; - - private Logger slf4jLogger; - - private EventSpyDispatcher eventSpyDispatcher; - - private ModelProcessor modelProcessor; - - private Maven maven; - - private MavenExecutionRequestPopulator executionRequestPopulator; - - private ToolchainsBuilder toolchainsBuilder; - - private DefaultSecDispatcher dispatcher; - - private Map<String, ConfigurationProcessor> configurationProcessors; - - public MavenCli() - { - this( null ); - } - - // This supports painless invocation by the Verifier during embedded execution of the core ITs - public MavenCli( ClassWorld classWorld ) - { - this.classWorld = classWorld; - } - - public static void main( String[] args ) - { - int result = main( args, null ); - - System.exit( result ); - } - - /** @noinspection ConfusingMainMethod */ - public static int main( String[] args, ClassWorld classWorld ) - { - MavenCli cli = new MavenCli(); - return cli.doMain( new CliRequest( args, classWorld ) ); - } - - // TODO: need to externalize CliRequest - public static int doMain( String[] args, ClassWorld classWorld ) - { - MavenCli cli = new MavenCli(); - return cli.doMain( new CliRequest( args, classWorld ) ); - } - - // This supports painless invocation by the Verifier during embedded execution of the core ITs - public int doMain( String[] args, String workingDirectory, PrintStream stdout, PrintStream stderr ) - { - PrintStream oldout = System.out; - PrintStream olderr = System.err; - - final Set<String> realms; - if ( classWorld != null ) - { - realms = new HashSet<String>(); - for ( ClassRealm realm : classWorld.getRealms() ) - { - realms.add( realm.getId() ); - } - } - else - { - realms = Collections.emptySet(); - } - - try - { - if ( stdout != null ) - { - System.setOut( stdout ); - } - if ( stderr != null ) - { - System.setErr( stderr ); - } - - CliRequest cliRequest = new CliRequest( args, classWorld ); - cliRequest.workingDirectory = workingDirectory; - - return doMain( cliRequest ); - } - finally - { - if ( classWorld != null ) - { - for ( ClassRealm realm : new ArrayList<ClassRealm>( classWorld.getRealms() ) ) - { - String realmId = realm.getId(); - if ( !realms.contains( realmId ) ) - { - try - { - classWorld.disposeRealm( realmId ); - } - catch ( NoSuchRealmException ignored ) - { - // can't happen - } - } - } - } - System.setOut( oldout ); - System.setErr( olderr ); - } - } - - // TODO: need to externalize CliRequest - public int doMain( CliRequest cliRequest ) - { - PlexusContainer localContainer = null; - try - { - initialize( cliRequest ); - cli( cliRequest ); - logging( cliRequest ); - version( cliRequest ); - properties( cliRequest ); - localContainer = container( cliRequest ); - commands( cliRequest ); - configure( cliRequest ); - toolchains( cliRequest ); - populateRequest( cliRequest ); - encryption( cliRequest ); - repository( cliRequest ); - return execute( cliRequest ); - } - catch ( ExitException e ) - { - return e.exitCode; - } - catch ( UnrecognizedOptionException e ) - { - // pure user error, suppress stack trace - return 1; - } - catch ( BuildAbort e ) - { - CLIReportingUtils.showError( slf4jLogger, "ABORTED", e, cliRequest.showErrors ); - - return 2; - } - catch ( Exception e ) - { - CLIReportingUtils.showError( slf4jLogger, "Error executing Maven.", e, cliRequest.showErrors ); - - return 1; - } - finally - { - if ( localContainer != null ) - { - localContainer.dispose(); - } - } - } - - void initialize( CliRequest cliRequest ) - throws ExitException - { - if ( cliRequest.workingDirectory == null ) - { - cliRequest.workingDirectory = System.getProperty( "user.dir" ); - } - - if ( cliRequest.multiModuleProjectDirectory == null ) - { - String basedirProperty = System.getProperty( MULTIMODULE_PROJECT_DIRECTORY ); - if ( basedirProperty == null ) - { - System.err.format( "-D%s system propery is not set." - + " Check $M2_HOME environment variable and mvn script match.", MULTIMODULE_PROJECT_DIRECTORY ); - throw new ExitException( 1 ); - } - File basedir = basedirProperty != null ? new File( basedirProperty ) : new File( "" ); - try - { - cliRequest.multiModuleProjectDirectory = basedir.getCanonicalFile(); - } - catch ( IOException e ) - { - cliRequest.multiModuleProjectDirectory = basedir.getAbsoluteFile(); - } - } - - // - // Make sure the Maven home directory is an absolute path to save us from confusion with say drive-relative - // Windows paths. - // - String mavenHome = System.getProperty( "maven.home" ); - - if ( mavenHome != null ) - { - System.setProperty( "maven.home", new File( mavenHome ).getAbsolutePath() ); - } - } - - void cli( CliRequest cliRequest ) - throws Exception - { - // - // Parsing errors can happen during the processing of the arguments and we prefer not having to check if - // the logger is null and construct this so we can use an SLF4J logger everywhere. - // - slf4jLogger = new Slf4jStdoutLogger(); - - CLIManager cliManager = new CLIManager(); - - List<String> args = new ArrayList<String>(); - - try - { - File configFile = new File( cliRequest.multiModuleProjectDirectory, ".mvn/maven.config" ); - - if ( configFile.isFile() ) - { - for ( String arg : Files.toString( configFile, Charsets.UTF_8 ).split( "\\s+" ) ) - { - args.add( arg ); - } - - CommandLine config = cliManager.parse( args.toArray( new String[args.size()] ) ); - List<?> unrecongized = config.getArgList(); - if ( !unrecongized.isEmpty() ) - { - throw new ParseException( "Unrecognized maven.config entries: " + unrecongized ); - } - } - } - catch ( ParseException e ) - { - System.err.println( "Unable to parse maven.config: " + e.getMessage() ); - cliManager.displayHelp( System.out ); - throw e; - } - - try - { - args.addAll( 0, Arrays.asList( cliRequest.args ) ); - cliRequest.commandLine = cliManager.parse( args.toArray( new String[args.size()] ) ); - } - catch ( ParseException e ) - { - System.err.println( "Unable to parse command line options: " + e.getMessage() ); - cliManager.displayHelp( System.out ); - throw e; - } - - if ( cliRequest.commandLine.hasOption( CLIManager.HELP ) ) - { - cliManager.displayHelp( System.out ); - throw new ExitException( 0 ); - } - - if ( cliRequest.commandLine.hasOption( CLIManager.VERSION ) ) - { - System.out.println( CLIReportingUtils.showVersion() ); - throw new ExitException( 0 ); - } - } - - /** - * configure logging - */ - private void logging( CliRequest cliRequest ) - { - cliRequest.debug = cliRequest.commandLine.hasOption( CLIManager.DEBUG ); - cliRequest.quiet = !cliRequest.debug && cliRequest.commandLine.hasOption( CLIManager.QUIET ); - cliRequest.showErrors = cliRequest.debug || cliRequest.commandLine.hasOption( CLIManager.ERRORS ); - - slf4jLoggerFactory = LoggerFactory.getILoggerFactory(); - Slf4jConfiguration slf4jConfiguration = Slf4jConfigurationFactory.getConfiguration( slf4jLoggerFactory ); - - if ( cliRequest.debug ) - { - cliRequest.request.setLoggingLevel( MavenExecutionRequest.LOGGING_LEVEL_DEBUG ); - slf4jConfiguration.setRootLoggerLevel( Slf4jConfiguration.Level.DEBUG ); - } - else if ( cliRequest.quiet ) - { - cliRequest.request.setLoggingLevel( MavenExecutionRequest.LOGGING_LEVEL_ERROR ); - slf4jConfiguration.setRootLoggerLevel( Slf4jConfiguration.Level.ERROR ); - } - // else fall back to default log level specified in conf - // see http://jira.codehaus.org/browse/MNG-2570 - - if ( cliRequest.commandLine.hasOption( CLIManager.LOG_FILE ) ) - { - File logFile = new File( cliRequest.commandLine.getOptionValue( CLIManager.LOG_FILE ) ); - logFile = resolveFile( logFile, cliRequest.workingDirectory ); - - // redirect stdout and stderr to file - try - { - PrintStream ps = new PrintStream( new FileOutputStream( logFile ) ); - System.setOut( ps ); - System.setErr( ps ); - } - catch ( FileNotFoundException e ) - { - // - // Ignore - // - } - } - - slf4jConfiguration.activate(); - - plexusLoggerManager = new Slf4jLoggerManager(); - slf4jLogger = slf4jLoggerFactory.getLogger( this.getClass().getName() ); - } - - private void version( CliRequest cliRequest ) - { - if ( cliRequest.debug || cliRequest.commandLine.hasOption( CLIManager.SHOW_VERSION ) ) - { - System.out.println( CLIReportingUtils.showVersion() ); - } - } - - private void commands( CliRequest cliRequest ) - { - if ( cliRequest.showErrors ) - { - slf4jLogger.info( "Error stacktraces are turned on." ); - } - - if ( MavenExecutionRequest.CHECKSUM_POLICY_WARN.equals( cliRequest.request.getGlobalChecksumPolicy() ) ) - { - slf4jLogger.info( "Disabling strict checksum verification on all artifact downloads." ); - } - else if ( MavenExecutionRequest.CHECKSUM_POLICY_FAIL.equals( cliRequest.request.getGlobalChecksumPolicy() ) ) - { - slf4jLogger.info( "Enabling strict checksum verification on all artifact downloads." ); - } - } - - private void properties( CliRequest cliRequest ) - { - populateProperties( cliRequest.commandLine, cliRequest.systemProperties, cliRequest.userProperties ); - } - - private PlexusContainer container( CliRequest cliRequest ) - throws Exception - { - if ( cliRequest.classWorld == null ) - { - cliRequest.classWorld = new ClassWorld( "plexus.core", Thread.currentThread().getContextClassLoader() ); - } - - ClassRealm coreRealm = cliRequest.classWorld.getClassRealm( "plexus.core" ); - if ( coreRealm == null ) - { - coreRealm = cliRequest.classWorld.getRealms().iterator().next(); - } - - List<File> extClassPath = parseExtClasspath( cliRequest ); - - CoreExtensionEntry coreEntry = CoreExtensionEntry.discoverFrom( coreRealm ); - List<CoreExtensionEntry> extensions = - loadCoreExtensions( cliRequest, coreRealm, coreEntry.getExportedArtifacts() ); - - ClassRealm containerRealm = setupContainerRealm( cliRequest.classWorld, coreRealm, extClassPath, extensions ); - - ContainerConfiguration cc = new DefaultContainerConfiguration() - .setClassWorld( cliRequest.classWorld ) - .setRealm( containerRealm ) - .setClassPathScanning( PlexusConstants.SCANNING_INDEX ) - .setAutoWiring( true ) - .setName( "maven" ); - - Set<String> exportedArtifacts = new HashSet<String>( coreEntry.getExportedArtifacts() ); - Set<String> exportedPackages = new HashSet<String>( coreEntry.getExportedPackages() ); - for ( CoreExtensionEntry extension : extensions ) - { - exportedArtifacts.addAll( extension.getExportedArtifacts() ); - exportedPackages.addAll( extension.getExportedPackages() ); - } - - final CoreExports exports = new CoreExports( containerRealm, exportedArtifacts, exportedPackages ); - - DefaultPlexusContainer container = new DefaultPlexusContainer( cc, new AbstractModule() - { - @Override - protected void configure() - { - bind( ILoggerFactory.class ).toInstance( slf4jLoggerFactory ); - bind( CoreExports.class ).toInstance( exports ); - } - } ); - - // NOTE: To avoid inconsistencies, we'll use the TCCL exclusively for lookups - container.setLookupRealm( null ); - - container.setLoggerManager( plexusLoggerManager ); - - for ( CoreExtensionEntry extension : extensions ) - { - container.discoverComponents( extension.getClassRealm() ); - } - - customizeContainer( container ); - - container.getLoggerManager().setThresholds( cliRequest.request.getLoggingLevel() ); - - Thread.currentThread().setContextClassLoader( container.getContainerRealm() ); - - eventSpyDispatcher = container.lookup( EventSpyDispatcher.class ); - - DefaultEventSpyContext eventSpyContext = new DefaultEventSpyContext(); - Map<String, Object> data = eventSpyContext.getData(); - data.put( "plexus", container ); - data.put( "workingDirectory", cliRequest.workingDirectory ); - data.put( "systemProperties", cliRequest.systemProperties ); - data.put( "userProperties", cliRequest.userProperties ); - data.put( "versionProperties", CLIReportingUtils.getBuildProperties() ); - eventSpyDispatcher.init( eventSpyContext ); - - // refresh logger in case container got customized by spy - slf4jLogger = slf4jLoggerFactory.getLogger( this.getClass().getName() ); - - maven = container.lookup( Maven.class ); - - executionRequestPopulator = container.lookup( MavenExecutionRequestPopulator.class ); - - modelProcessor = createModelProcessor( container ); - - configurationProcessors = container.lookupMap( ConfigurationProcessor.class ); - - toolchainsBuilder = container.lookup( ToolchainsBuilder.class ); - - dispatcher = (DefaultSecDispatcher) container.lookup( SecDispatcher.class, "maven" ); - - return container; - } - - private List<CoreExtensionEntry> loadCoreExtensions( CliRequest cliRequest, ClassRealm containerRealm, - Set<String> providedArtifacts ) - { - if ( cliRequest.multiModuleProjectDirectory == null ) - { - return Collections.emptyList(); - } - - File extensionsFile = new File( cliRequest.multiModuleProjectDirectory, EXTENSIONS_FILENAME ); - if ( !extensionsFile.isFile() ) - { - return Collections.emptyList(); - } - - try - { - List<CoreExtension> extensions = readCoreExtensionsDescriptor( extensionsFile ); - if ( extensions.isEmpty() ) - { - return Collections.emptyList(); - } - - ContainerConfiguration cc = new DefaultContainerConfiguration() // - .setClassWorld( cliRequest.classWorld ) // - .setRealm( containerRealm ) // - .setClassPathScanning( PlexusConstants.SCANNING_INDEX ) // - .setAutoWiring( true ) // - .setName( "maven" ); - - DefaultPlexusContainer container = new DefaultPlexusContainer( cc, new AbstractModule() - { - @Override - protected void configure() - { - bind( ILoggerFactory.class ).toInstance( slf4jLoggerFactory ); - } - } ); - - try - { - container.setLookupRealm( null ); - - container.setLoggerManager( plexusLoggerManager ); - - container.getLoggerManager().setThresholds( cliRequest.request.getLoggingLevel() ); - - Thread.currentThread().setContextClassLoader( container.getContainerRealm() ); - - executionRequestPopulator = container.lookup( MavenExecutionRequestPopulator.class ); - - configurationProcessors = container.lookupMap( ConfigurationProcessor.class ); - - configure( cliRequest ); - - MavenExecutionRequest request = DefaultMavenExecutionRequest.copy( cliRequest.request ); - - request = populateRequest( cliRequest, request ); - - request = executionRequestPopulator.populateDefaults( request ); - - BootstrapCoreExtensionManager resolver = container.lookup( BootstrapCoreExtensionManager.class ); - - return resolver.loadCoreExtensions( request, providedArtifacts, extensions ); - } - finally - { - executionRequestPopulator = null; - container.dispose(); - } - } - catch ( RuntimeException e ) - { - // runtime exceptions are most likely bugs in maven, let them bubble up to the user - throw e; - } - catch ( Exception e ) - { - slf4jLogger.warn( "Failed to read extensions descriptor " + extensionsFile + ": " + e.getMessage() ); - } - return Collections.emptyList(); - } - - private List<CoreExtension> readCoreExtensionsDescriptor( File extensionsFile ) - throws IOException, XmlPullParserException - { - CoreExtensionsXpp3Reader parser = new CoreExtensionsXpp3Reader(); - InputStream is = null; - try - { - is = new BufferedInputStream( new FileInputStream( extensionsFile ) ); - return parser.read( is ).getExtensions(); - } - finally - { - IOUtil.close( is ); - } - } - - private ClassRealm setupContainerRealm( ClassWorld classWorld, ClassRealm coreRealm, List<File> extClassPath, - List<CoreExtensionEntry> extensions ) - throws Exception - { - if ( !extClassPath.isEmpty() || !extensions.isEmpty() ) - { - ClassRealm extRealm = classWorld.newRealm( "maven.ext", null ); - - extRealm.setParentRealm( coreRealm ); - - slf4jLogger.debug( "Populating class realm " + extRealm.getId() ); - - for ( File file : extClassPath ) - { - slf4jLogger.debug( " Included " + file ); - - extRealm.addURL( file.toURI().toURL() ); - } - - for ( CoreExtensionEntry entry : reverse( extensions ) ) - { - Set<String> exportedPackages = entry.getExportedPackages(); - ClassRealm realm = entry.getClassRealm(); - for ( String exportedPackage : exportedPackages ) - { - extRealm.importFrom( realm, exportedPackage ); - } - if ( exportedPackages.isEmpty() ) - { - // sisu uses realm imports to establish component visibility - extRealm.importFrom( realm, realm.getId() ); - } - } - - return extRealm; - } - - return coreRealm; - } - - private static <T> List<T> reverse( List<T> list ) - { - List<T> copy = new ArrayList<T>( list ); - Collections.reverse( copy ); - return copy; - } - - private List<File> parseExtClasspath( CliRequest cliRequest ) - { - String extClassPath = cliRequest.userProperties.getProperty( EXT_CLASS_PATH ); - if ( extClassPath == null ) - { - extClassPath = cliRequest.systemProperties.getProperty( EXT_CLASS_PATH ); - } - - List<File> jars = new ArrayList<File>(); - - if ( StringUtils.isNotEmpty( extClassPath ) ) - { - for ( String jar : StringUtils.split( extClassPath, File.pathSeparator ) ) - { - File file = resolveFile( new File( jar ), cliRequest.workingDirectory ); - - slf4jLogger.debug( " Included " + file ); - - jars.add( file ); - } - } - - return jars; - } - - // - // This should probably be a separate tool and not be baked into Maven. - // - private void encryption( CliRequest cliRequest ) - throws Exception - { - if ( cliRequest.commandLine.hasOption( CLIManager.ENCRYPT_MASTER_PASSWORD ) ) - { - String passwd = cliRequest.commandLine.getOptionValue( CLIManager.ENCRYPT_MASTER_PASSWORD ); - - if ( passwd == null ) - { - Console cons = System.console(); - char[] password = ( cons == null ) ? null : cons.readPassword( "Master password: " ); - if ( password != null ) - { - // Cipher uses Strings - passwd = String.copyValueOf( password ); - - // Sun/Oracle advises to empty the char array - java.util.Arrays.fill( password, ' ' ); - } - } - - DefaultPlexusCipher cipher = new DefaultPlexusCipher(); - - System.out.println( cipher.encryptAndDecorate( passwd, - DefaultSecDispatcher.SYSTEM_PROPERTY_SEC_LOCATION ) ); - - throw new ExitException( 0 ); - } - else if ( cliRequest.commandLine.hasOption( CLIManager.ENCRYPT_PASSWORD ) ) - { - String passwd = cliRequest.commandLine.getOptionValue( CLIManager.ENCRYPT_PASSWORD ); - - if ( passwd == null ) - { - Console cons = System.console(); - char[] password = ( cons == null ) ? null : cons.readPassword( "Password: " ); - if ( password != null ) - { - // Cipher uses Strings - passwd = String.copyValueOf( password ); - - // Sun/Oracle advises to empty the char array - java.util.Arrays.fill( password, ' ' ); - } - } - - String configurationFile = dispatcher.getConfigurationFile(); - - if ( configurationFile.startsWith( "~" ) ) - { - configurationFile = System.getProperty( "user.home" ) + configurationFile.substring( 1 ); - } - - String file = System.getProperty( DefaultSecDispatcher.SYSTEM_PROPERTY_SEC_LOCATION, configurationFile ); - - String master = null; - - SettingsSecurity sec = SecUtil.read( file, true ); - if ( sec != null ) - { - master = sec.getMaster(); - } - - if ( master == null ) - { - throw new IllegalStateException( "Master password is not set in the setting security file: " + file ); - } - - DefaultPlexusCipher cipher = new DefaultPlexusCipher(); - String masterPasswd = cipher.decryptDecorated( master, DefaultSecDispatcher.SYSTEM_PROPERTY_SEC_LOCATION ); - System.out.println( cipher.encryptAndDecorate( passwd, masterPasswd ) ); - - throw new ExitException( 0 ); - } - } - - private void repository( CliRequest cliRequest ) - throws Exception - { - if ( cliRequest.commandLine.hasOption( CLIManager.LEGACY_LOCAL_REPOSITORY ) - || Boolean.getBoolean( "maven.legacyLocalRepo" ) ) - { - cliRequest.request.setUseLegacyLocalRepository( true ); - } - } - - private int execute( CliRequest cliRequest ) throws MavenExecutionRequestPopulationException - { - MavenExecutionRequest request = executionRequestPopulator.populateDefaults( cliRequest.request ); - - eventSpyDispatcher.onEvent( request ); - - MavenExecutionResult result = maven.execute( request ); - - eventSpyDispatcher.onEvent( result ); - - eventSpyDispatcher.close(); - - if ( result.hasExceptions() ) - { - ExceptionHandler handler = new DefaultExceptionHandler(); - - Map<String, String> references = new LinkedHashMap<String, String>(); - - MavenProject project = null; - - for ( Throwable exception : result.getExceptions() ) - { - ExceptionSummary summary = handler.handleException( exception ); - - logSummary( summary, references, "", cliRequest.showErrors ); - - if ( project == null && exception instanceof LifecycleExecutionException ) - { - project = ( (LifecycleExecutionException) exception ).getProject(); - } - } - - slf4jLogger.error( "" ); - - if ( !cliRequest.showErrors ) - { - slf4jLogger.error( "To see the full stack trace of the errors, re-run Maven with the -e switch." ); - } - if ( !slf4jLogger.isDebugEnabled() ) - { - slf4jLogger.error( "Re-run Maven using the -X switch to enable full debug logging." ); - } - - if ( !references.isEmpty() ) - { - slf4jLogger.error( "" ); - slf4jLogger.error( "For more information about the errors and possible solutions" - + ", please read the following articles:" ); - - for ( Map.Entry<String, String> entry : references.entrySet() ) - { - slf4jLogger.error( entry.getValue() + " " + entry.getKey() ); - } - } - - if ( project != null && !project.equals( result.getTopologicallySortedProjects().get( 0 ) ) ) - { - slf4jLogger.error( "" ); - slf4jLogger.error( "After correcting the problems, you can resume the build with the command" ); - slf4jLogger.error( " mvn <goals> -rf :" + project.getArtifactId() ); - } - - if ( MavenExecutionRequest.REACTOR_FAIL_NEVER.equals( cliRequest.request.getReactorFailureBehavior() ) ) - { - slf4jLogger.info( "Build failures were ignored." ); - - return 0; - } - else - { - return 1; - } - } - else - { - return 0; - } - } - - private void logSummary( ExceptionSummary summary, Map<String, String> references, String indent, - boolean showErrors ) - { - String referenceKey = ""; - - if ( StringUtils.isNotEmpty( summary.getReference() ) ) - { - referenceKey = references.get( summary.getReference() ); - if ( referenceKey == null ) - { - referenceKey = "[Help " + ( references.size() + 1 ) + "]"; - references.put( summary.getReference(), referenceKey ); - } - } - - String msg = summary.getMessage(); - - if ( StringUtils.isNotEmpty( referenceKey ) ) - { - if ( msg.indexOf( '\n' ) < 0 ) - { - msg += " -> " + referenceKey; - } - else - { - msg += "\n-> " + referenceKey; - } - } - - String[] lines = msg.split( "(\r\n)|(\r)|(\n)" ); - - for ( int i = 0; i < lines.length; i++ ) - { - String line = indent + lines[i].trim(); - - if ( ( i == lines.length - 1 ) - && ( showErrors || ( summary.getException() instanceof InternalErrorException ) ) ) - { - slf4jLogger.error( line, summary.getException() ); - } - else - { - slf4jLogger.error( line ); - } - } - - indent += " "; - - for ( ExceptionSummary child : summary.getChildren() ) - { - logSummary( child, references, indent, showErrors ); - } - } - - @SuppressWarnings( "checkstyle:methodlength" ) - private void configure( CliRequest cliRequest ) - throws Exception - { - // - // This is not ideal but there are events specifically for configuration from the CLI which I don't - // believe are really valid but there are ITs which assert the right events are published so this - // needs to be supported so the EventSpyDispatcher needs to be put in the CliRequest so that - // it can be accessed by configuration processors. - // - cliRequest.request.setEventSpyDispatcher( eventSpyDispatcher ); - - // - // We expect at most 2 implementations to be available. The SettingsXmlConfigurationProcessor implementation - // is always available in the core and likely always will be, but we may have another ConfigurationProcessor - // present supplied by the user. The rule is that we only allow the execution of one ConfigurationProcessor. - // If there is more than one then we execute the one supplied by the user, otherwise we execute the - // the default SettingsXmlConfigurationProcessor. - // - int userSuppliedConfigurationProcessorCount = configurationProcessors.size() - 1; - - if ( userSuppliedConfigurationProcessorCount == 0 ) - { - // - // Our settings.xml source is historically how we have configured Maven from the CLI so we are going to - // have to honour its existence forever. So let's run it. - // - configurationProcessors.get( SettingsXmlConfigurationProcessor.HINT ).process( cliRequest ); - } - else if ( userSuppliedConfigurationProcessorCount == 1 ) - { - // - // Run the user supplied ConfigurationProcessor - // - for ( Entry<String, ConfigurationProcessor> entry : configurationProcessors.entrySet() ) - { - String hint = entry.getKey(); - if ( !hint.equals( SettingsXmlConfigurationProcessor.HINT ) ) - { - ConfigurationProcessor configurationProcessor = entry.getValue(); - configurationProcessor.process( cliRequest ); - } - } - } - else if ( userSuppliedConfigurationProcessorCount > 1 ) - { - // - // There are too many ConfigurationProcessors so we don't know which one to run so report the error. - // - StringBuffer sb = new StringBuffer( - String.format( "\nThere can only be one user supplied ConfigurationProcessor, there are %s:\n\n", - userSuppliedConfigurationProcessorCount ) ); - for ( Entry<String, ConfigurationProcessor> entry : configurationProcessors.entrySet() ) - { - String hint = entry.getKey(); - if ( !hint.equals( SettingsXmlConfigurationProcessor.HINT ) ) - { - ConfigurationProcessor configurationProcessor = entry.getValue(); - sb.append( String.format( "%s\n", configurationProcessor.getClass().getName() ) ); - } - } - sb.append( String.format( "\n" ) ); - throw new Exception( sb.toString() ); - } - } - - @SuppressWarnings( "checkstyle:methodlength" ) - private void toolchains( CliRequest cliRequest ) - throws Exception - { - File userToolchainsFile; - - if ( cliRequest.commandLine.hasOption( CLIManager.ALTERNATE_USER_TOOLCHAINS ) ) - { - userToolchainsFile = - new File( cliRequest.commandLine.getOptionValue( CLIManager.ALTERNATE_USER_TOOLCHAINS ) ); - userToolchainsFile = resolveFile( userToolchainsFile, cliRequest.workingDirectory ); - - if ( !userToolchainsFile.isFile() ) - { - throw new FileNotFoundException( "The specified user toolchains file does not exist: " - + userToolchainsFile ); - } - } - else - { - userToolchainsFile = DEFAULT_USER_TOOLCHAINS_FILE; - } - - File globalToolchainsFile; - - if ( cliRequest.commandLine.hasOption( CLIManager.ALTERNATE_GLOBAL_TOOLCHAINS ) ) - { - globalToolchainsFile = - new File( cliRequest.commandLine.getOptionValue( CLIManager.ALTERNATE_GLOBAL_TOOLCHAINS ) ); - globalToolchainsFile = resolveFile( globalToolchainsFile, cliRequest.workingDirectory ); - - if ( !globalToolchainsFile.isFile() ) - { - throw new FileNotFoundException( "The specified global toolchains file does not exist: " - + globalToolchainsFile ); - } - } - else - { - globalToolchainsFile = DEFAULT_GLOBAL_TOOLCHAINS_FILE; - } - - cliRequest.request.setGlobalToolchainsFile( globalToolchainsFile ); - cliRequest.request.setUserToolchainsFile( userToolchainsFile ); - - DefaultToolchainsBuildingRequest toolchainsRequest = new DefaultToolchainsBuildingRequest(); - if ( globalToolchainsFile.isFile() ) - { - toolchainsRequest.setGlobalToolchainsSource( new FileSource( globalToolchainsFile ) ); - } - if ( userToolchainsFile.isFile() ) - { - toolchainsRequest.setUserToolchainsSource( new FileSource( userToolchainsFile ) ); - } - - eventSpyDispatcher.onEvent( toolchainsRequest ); - - slf4jLogger.debug( "Reading global toolchains from " - + getLocation( toolchainsRequest.getGlobalToolchainsSource(), globalToolchainsFile ) ); - slf4jLogger.debug( "Reading user toolchains from " - + getLocation( toolchainsRequest.getUserToolchainsSource(), userToolchainsFile ) ); - - ToolchainsBuildingResult toolchainsResult = toolchainsBuilder.build( toolchainsRequest ); - - eventSpyDispatcher.onEvent( toolchainsRequest ); - - executionRequestPopulator.populateFromToolchains( cliRequest.request, - toolchainsResult.getEffectiveToolchains() ); - - if ( !toolchainsResult.getProblems().isEmpty() && slf4jLogger.isWarnEnabled() ) - { - slf4jLogger.warn( "" ); - slf4jLogger.warn( "Some problems were encountered while building the effective toolchains" ); - - for ( Problem problem : toolchainsResult.getProblems() ) - { - slf4jLogger.warn( problem.getMessage() + " @ " + problem.getLocation() ); - } - - slf4jLogger.warn( "" ); - } - } - - private Object getLocation( Source source, File defaultLocation ) - { - if ( source != null ) - { - return source.getLocation(); - } - return defaultLocation; - } - - private MavenExecutionRequest populateRequest( CliRequest cliRequest ) - { - return populateRequest( cliRequest, cliRequest.request ); - } - - private MavenExecutionRequest populateRequest( CliRequest cliRequest, MavenExecutionRequest request ) - { - CommandLine commandLine = cliRequest.commandLine; - String workingDirectory = cliRequest.workingDirectory; - boolean quiet = cliRequest.quiet; - boolean showErrors = cliRequest.showErrors; - - String[] deprecatedOptions = { "up", "npu", "cpu", "npr" }; - for ( String deprecatedOption : deprecatedOptions ) - { - if ( commandLine.hasOption( deprecatedOption ) ) - { - slf4jLogger.warn( "Command line option -" + deprecatedOption - + " is deprecated and will be removed in future Maven versions." ); - } - } - - // ---------------------------------------------------------------------- - // Now that we have everything that we need we will fire up plexus and - // bring the maven component to life for use. - // ---------------------------------------------------------------------- - - if ( commandLine.hasOption( CLIManager.BATCH_MODE ) ) - { - request.setInteractiveMode( false ); - } - - boolean noSnapshotUpdates = false; - if ( commandLine.hasOption( CLIManager.SUPRESS_SNAPSHOT_UPDATES ) ) - { - noSnapshotUpdates = true; - } - - // ---------------------------------------------------------------------- - // - // ---------------------------------------------------------------------- - - @SuppressWarnings( "unchecked" ) - List<String> goals = commandLine.getArgList(); - - boolean recursive = true; - - // this is the default behavior. - String reactorFailureBehaviour = MavenExecutionRequest.REACTOR_FAIL_FAST; - - if ( commandLine.hasOption( CLIManager.NON_RECURSIVE ) ) - { - recursive = false; - } - - if ( commandLine.hasOption( CLIManager.FAIL_FAST ) ) - { - reactorFailureBehaviour = MavenExecutionRequest.REACTOR_FAIL_FAST; - } - else if ( commandLine.hasOption( CLIManager.FAIL_AT_END ) ) - { - reactorFailureBehaviour = MavenExecutionRequest.REACTOR_FAIL_AT_END; - } - else if ( commandLine.hasOption( CLIManager.FAIL_NEVER ) ) - { - reactorFailureBehaviour = MavenExecutionRequest.REACTOR_FAIL_NEVER; - } - - if ( commandLine.hasOption( CLIManager.OFFLINE ) ) - { - request.setOffline( true ); - } - - boolean updateSnapshots = false; - - if ( commandLine.hasOption( CLIManager.UPDATE_SNAPSHOTS ) ) - { - updateSnapshots = true; - } - - String globalChecksumPolicy = null; - - if ( commandLine.hasOption( CLIManager.CHECKSUM_FAILURE_POLICY ) ) - { - globalChecksumPolicy = MavenExecutionRequest.CHECKSUM_POLICY_FAIL; - } - else if ( commandLine.hasOption( CLIManager.CHECKSUM_WARNING_POLICY ) ) - { - globalChecksumPolicy = MavenExecutionRequest.CHECKSUM_POLICY_WARN; - } - - File baseDirectory = new File( workingDirectory, "" ).getAbsoluteFile(); - - // ---------------------------------------------------------------------- - // Profile Activation - // ---------------------------------------------------------------------- - - List<String> activeProfiles = new ArrayList<String>(); - - List<String> inactiveProfiles = new ArrayList<String>(); - - if ( commandLine.hasOption( CLIManager.ACTIVATE_PROFILES ) ) - { - String[] profileOptionValues = commandLine.getOptionValues( CLIManager.ACTIVATE_PROFILES ); - if ( profileOptionValues != null ) - { - for ( String profileOptionValue : profileOptionValues ) - { - StringTokenizer profileTokens = new StringTokenizer( profileOptionValue, "," ); - - while ( profileTokens.hasMoreTokens() ) - { - String profileAction = profileTokens.nextToken().trim(); - - if ( profileAction.startsWith( "-" ) || profileAction.startsWith( "!" ) ) - { - inactiveProfiles.add( profileAction.substring( 1 ) ); - } - else if ( profileAction.startsWith( "+" ) ) - { - activeProfiles.add( profileAction.substring( 1 ) ); - } - else - { - activeProfiles.add( profileAction ); - } - } - } - } - } - - TransferListener transferListener; - - if ( quiet ) - { - transferListener = new QuietMavenTransferListener(); - } - else if ( request.isInteractiveMode() && !cliRequest.commandLine.hasOption( CLIManager.LOG_FILE ) ) - { - // - // If we're logging to a file then we don't want the console transfer listener as it will spew - // download progress all over the place - // - transferListener = getConsoleTransferListener(); - } - else - { - transferListener = getBatchTransferListener(); - } - - ExecutionListener executionListener = new ExecutionEventLogger(); - if ( eventSpyDispatcher != null ) - { - executionListener = eventSpyDispatcher.chainListener( executionListener ); - } - - String alternatePomFile = null; - if ( commandLine.hasOption( CLIManager.ALTERNATE_POM_FILE ) ) - { - alternatePomFile = commandLine.getOptionValue( CLIManager.ALTERNATE_POM_FILE ); - } - - File userToolchainsFile; - if ( commandLine.hasOption( CLIManager.ALTERNATE_USER_TOOLCHAINS ) ) - { - userToolchainsFile = new File( commandLine.getOptionValue( CLIManager.ALTERNATE_USER_TOOLCHAINS ) ); - userToolchainsFile = resolveFile( userToolchainsFile, workingDirectory ); - } - else - { - userToolchainsFile = MavenCli.DEFAULT_USER_TOOLCHAINS_FILE; - } - - request.setBaseDirectory( baseDirectory ).setGoals( goals ) - .setSystemProperties( cliRequest.systemProperties ) - .setUserProperties( cliRequest.userProperties ) - .setReactorFailureBehavior( reactorFailureBehaviour ) // default: fail fast - .setRecursive( recursive ) // default: true - .setShowErrors( showErrors ) // default: false - .addActiveProfiles( activeProfiles ) // optional - .addInactiveProfiles( inactiveProfiles ) // optional - .setExecutionListener( executionListener ) - .setTransferListener( transferListener ) // default: batch mode which goes along with interactive - .setUpdateSnapshots( updateSnapshots ) // default: false - .setNoSnapshotUpdates( noSnapshotUpdates ) // default: false - .setGlobalChecksumPolicy( globalChecksumPolicy ) // default: warn - .setMultiModuleProjectDirectory( cliRequest.multiModuleProjectDirectory ); - - if ( alternatePomFile != null ) - { - File pom = resolveFile( new File( alternatePomFile ), workingDirectory ); - if ( pom.isDirectory() ) - { - pom = new File( pom, "pom.xml" ); - } - - request.setPom( pom ); - } - else if ( modelProcessor != null ) - { - File pom = modelProcessor.locatePom( baseDirectory ); - - if ( pom.isFile() ) - { - request.setPom( pom ); - } - } - - if ( ( request.getPom() != null ) && ( request.getPom().getParentFile() != null ) ) - { - request.setBaseDirectory( request.getPom().getParentFile() ); - } - - if ( commandLine.hasOption( CLIManager.RESUME_FROM ) ) - { - request.setResumeFrom( commandLine.getOptionValue( CLIManager.RESUME_FROM ) ); - } - - if ( commandLine.hasOption( CLIManager.PROJECT_LIST ) ) - { - String[] projectOptionValues = commandLine.getOptionValues( CLIManager.PROJECT_LIST ); - - List<String> inclProjects = new ArrayList<String>(); - List<String> exclProjects = new ArrayList<String>(); - - if ( projectOptionValues != null ) - { - for ( String projectOptionValue : projectOptionValues ) - { - StringTokenizer projectTokens = new StringTokenizer( projectOptionValue, "," ); - - while ( projectTokens.hasMoreTokens() ) - { - String projectAction = projectTokens.nextToken().trim(); - - if ( projectAction.startsWith( "-" ) || projectAction.startsWith( "!" ) ) - { - exclProjects.add( projectAction.substring( 1 ) ); - } - else if ( projectAction.startsWith( "+" ) ) - { - inclProjects.add( projectAction.substring( 1 ) ); - } - else - { - inclProjects.add( projectAction ); - } - } - } - } - - request.setSelectedProjects( inclProjects ); - request.setExcludedProjects( exclProjects ); - } - - if ( commandLine.hasOption( CLIManager.ALSO_MAKE ) - && !commandLine.hasOption( CLIManager.ALSO_MAKE_DEPENDENTS ) ) - { - request.setMakeBehavior( MavenExecutionRequest.REACTOR_MAKE_UPSTREAM ); - } - else if ( !commandLine.hasOption( CLIManager.ALSO_MAKE ) - && commandLine.hasOption( CLIManager.ALSO_MAKE_DEPENDENTS ) ) - { - request.setMakeBehavior( MavenExecutionRequest.REACTOR_MAKE_DOWNSTREAM ); - } - else if ( commandLine.hasOption( CLIManager.ALSO_MAKE ) - && commandLine.hasOption( CLIManager.ALSO_MAKE_DEPENDENTS ) ) - { - request.setMakeBehavior( MavenExecutionRequest.REACTOR_MAKE_BOTH ); - } - - String localRepoProperty = request.getUserProperties().getProperty( MavenCli.LOCAL_REPO_PROPERTY ); - - if ( localRepoProperty == null ) - { - localRepoProperty = request.getSystemProperties().getProperty( MavenCli.LOCAL_REPO_PROPERTY ); - } - - if ( localRepoProperty != null ) - { - request.setLocalRepositoryPath( localRepoProperty ); - } - - request.setCacheNotFound( true ); - request.setCacheTransferError( false ); - - // - // Builder, concurrency and parallelism - // - // We preserve the existing methods for builder selection which is to look for various inputs in the threading - // configuration. We don't have an easy way to allow a pluggable builder to provide its own configuration - // parameters but this is sufficient for now. Ultimately we want components like Builders to provide a way to - // extend the command line to accept its own configuration parameters. - // - final String threadConfiguration = commandLine.hasOption( CLIManager.THREADS ) - ? commandLine.getOptionValue( CLIManager.THREADS ) - : request.getSystemProperties().getProperty( - MavenCli.THREADS_DEPRECATED ); // TODO: Remove this setting. Note that the int-tests use it - - if ( threadConfiguration != null ) - { - // - // Default to the standard multithreaded builder - // - request.setBuilderId( "multithreaded" ); - - if ( threadConfiguration.contains( "C" ) ) - { - request.setDegreeOfConcurrency( calculateDegreeOfConcurrencyWithCoreMultiplier( threadConfiguration ) ); - } - else - { - request.setDegreeOfConcurrency( Integer.valueOf( threadConfiguration ) ); - } - } - - // - // Allow the builder to be overriden by the user if requested. The builders are now pluggable. - // - if ( commandLine.hasOption( CLIManager.BUILDER ) ) - { - request.setBuilderId( commandLine.getOptionValue( CLIManager.BUILDER ) ); - } - - return request; - } - - int calculateDegreeOfConcurrencyWithCoreMultiplier( String threadConfiguration ) - { - int procs = Runtime.getRuntime().availableProcessors(); - return (int) ( Float.valueOf( threadConfiguration.replace( "C", "" ) ) * procs ); - } - - static File resolveFile( File file, String workingDirectory ) - { - if ( file == null ) - { - return null; - } - else if ( file.isAbsolute() ) - { - return file; - } - else if ( file.getPath().startsWith( File.separator ) ) - { - // drive-relative Windows path - return file.getAbsoluteFile(); - } - else - { - return new File( workingDirectory, file.getPath() ).getAbsoluteFile(); - } - } - - // ---------------------------------------------------------------------- - // System properties handling - // ---------------------------------------------------------------------- - - static void populateProperties( CommandLine commandLine, Properties systemProperties, Properties userProperties ) - { - EnvironmentUtils.addEnvVars( systemProperties ); - - // ---------------------------------------------------------------------- - // Options that are set on the command line become system properties - // and therefore are set in the session properties. System properties - // are most dominant. - // ---------------------------------------------------------------------- - - if ( commandLine.hasOption( CLIManager.SET_SYSTEM_PROPERTY ) ) - { - String[] defStrs = commandLine.getOptionValues( CLIManager.SET_SYSTEM_PROPERTY ); - - if ( defStrs != null ) - { - for ( String defStr : defStrs ) - { - setCliProperty( defStr, userProperties ); - } - } - } - - SystemProperties.addSystemProperties( systemProperties ); - - // ---------------------------------------------------------------------- - // Properties containing info about the currently running version of Maven - // These override any corresponding properties set on the command line - // ---------------------------------------------------------------------- - - Properties buildProperties = CLIReportingUtils.getBuildProperties(); - - String mavenVersion = buildProperties.getProperty( CLIReportingUtils.BUILD_VERSION_PROPERTY ); - systemProperties.setProperty( "maven.version", mavenVersion ); - - String mavenBuildVersion = CLIReportingUtils.createMavenVersionString( buildProperties ); - systemProperties.setProperty( "maven.build.version", mavenBuildVersion ); - } - - private static void setCliProperty( String property, Properties properties ) - { - String name; - - String value; - - int i = property.indexOf( "=" ); - - if ( i <= 0 ) - { - name = property.trim(); - - value = "true"; - } - else - { - name = property.substring( 0, i ).trim(); - - value = property.substring( i + 1 ); - } - - properties.setProperty( name, value ); - - // ---------------------------------------------------------------------- - // I'm leaving the setting of system properties here as not to break - // the SystemPropertyProfileActivator. This won't harm embedding. jvz. - // ---------------------------------------------------------------------- - - System.setProperty( name, value ); - } - - static class ExitException - extends Exception - { - @SuppressWarnings( "checkstyle:visibilitymodifier" ) - public int exitCode; - - public ExitException( int exitCode ) - { - this.exitCode = exitCode; - } - } - - // - // Customizations available via the CLI - // - - protected TransferListener getConsoleTransferListener() - { - return new ConsoleMavenTransferListener( System.out ); - } - - protected TransferListener getBatchTransferListener() - { - return new Slf4jMavenTransferListener(); - } - - protected void customizeContainer( PlexusContainer container ) - { - } - - protected ModelProcessor createModelProcessor( PlexusContainer container ) - throws ComponentLookupException - { - return container.lookup( ModelProcessor.class ); - } -} diff --git a/framework/src/maven/apache-maven-3.3.3/maven-embedder/src/main/java/org/apache/maven/cli/configuration/ConfigurationProcessor.java b/framework/src/maven/apache-maven-3.3.3/maven-embedder/src/main/java/org/apache/maven/cli/configuration/ConfigurationProcessor.java deleted file mode 100644 index 75fb9b91..00000000 --- a/framework/src/maven/apache-maven-3.3.3/maven-embedder/src/main/java/org/apache/maven/cli/configuration/ConfigurationProcessor.java +++ /dev/null @@ -1,28 +0,0 @@ -package org.apache.maven.cli.configuration; - -/* - * 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.cli.CliRequest; - -public interface ConfigurationProcessor -{ - void process( CliRequest request ) - throws Exception; -} diff --git a/framework/src/maven/apache-maven-3.3.3/maven-embedder/src/main/java/org/apache/maven/cli/configuration/SettingsXmlConfigurationProcessor.java b/framework/src/maven/apache-maven-3.3.3/maven-embedder/src/main/java/org/apache/maven/cli/configuration/SettingsXmlConfigurationProcessor.java deleted file mode 100644 index 791a2267..00000000 --- a/framework/src/maven/apache-maven-3.3.3/maven-embedder/src/main/java/org/apache/maven/cli/configuration/SettingsXmlConfigurationProcessor.java +++ /dev/null @@ -1,290 +0,0 @@ -package org.apache.maven.cli.configuration; - -/* - * 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.io.FileNotFoundException; -import java.util.List; - -import org.apache.commons.cli.CommandLine; -import org.apache.maven.artifact.InvalidRepositoryException; -import org.apache.maven.bridge.MavenRepositorySystem; -import org.apache.maven.building.Source; -import org.apache.maven.cli.CLIManager; -import org.apache.maven.cli.CliRequest; -import org.apache.maven.execution.MavenExecutionRequest; -import org.apache.maven.execution.MavenExecutionRequestPopulationException; -import org.apache.maven.settings.Mirror; -import org.apache.maven.settings.Proxy; -import org.apache.maven.settings.Repository; -import org.apache.maven.settings.Server; -import org.apache.maven.settings.Settings; -import org.apache.maven.settings.SettingsUtils; -import org.apache.maven.settings.building.DefaultSettingsBuildingRequest; -import org.apache.maven.settings.building.SettingsBuilder; -import org.apache.maven.settings.building.SettingsBuildingRequest; -import org.apache.maven.settings.building.SettingsBuildingResult; -import org.apache.maven.settings.building.SettingsProblem; -import org.apache.maven.settings.crypto.SettingsDecrypter; -import org.codehaus.plexus.component.annotations.Component; -import org.codehaus.plexus.component.annotations.Requirement; -import org.slf4j.Logger; - -@Component( role = ConfigurationProcessor.class, hint = SettingsXmlConfigurationProcessor.HINT ) -public class SettingsXmlConfigurationProcessor - implements ConfigurationProcessor -{ - public static final String HINT = "settings"; - - public static final String USER_HOME = System.getProperty( "user.home" ); - - public static final File USER_MAVEN_CONFIGURATION_HOME = new File( USER_HOME, ".m2" ); - - public static final File DEFAULT_USER_SETTINGS_FILE = new File( USER_MAVEN_CONFIGURATION_HOME, "settings.xml" ); - - public static final File DEFAULT_GLOBAL_SETTINGS_FILE = new File( System.getProperty( "maven.home", System - .getProperty( "user.dir", "" ) ), "conf/settings.xml" ); - - @Requirement - private Logger logger; - - @Requirement - private SettingsBuilder settingsBuilder; - - @Requirement - private SettingsDecrypter settingsDecrypter; - - @Override - public void process( CliRequest cliRequest ) - throws Exception - { - CommandLine commandLine = cliRequest.getCommandLine(); - String workingDirectory = cliRequest.getWorkingDirectory(); - MavenExecutionRequest request = cliRequest.getRequest(); - - File userSettingsFile; - - if ( commandLine.hasOption( CLIManager.ALTERNATE_USER_SETTINGS ) ) - { - userSettingsFile = new File( commandLine.getOptionValue( CLIManager.ALTERNATE_USER_SETTINGS ) ); - userSettingsFile = resolveFile( userSettingsFile, workingDirectory ); - - if ( !userSettingsFile.isFile() ) - { - throw new FileNotFoundException( "The specified user settings file does not exist: " - + userSettingsFile ); - } - } - else - { - userSettingsFile = DEFAULT_USER_SETTINGS_FILE; - } - - File globalSettingsFile; - - if ( commandLine.hasOption( CLIManager.ALTERNATE_GLOBAL_SETTINGS ) ) - { - globalSettingsFile = new File( commandLine.getOptionValue( CLIManager.ALTERNATE_GLOBAL_SETTINGS ) ); - globalSettingsFile = resolveFile( globalSettingsFile, workingDirectory ); - - if ( !globalSettingsFile.isFile() ) - { - throw new FileNotFoundException( "The specified global settings file does not exist: " - + globalSettingsFile ); - } - } - else - { - globalSettingsFile = DEFAULT_GLOBAL_SETTINGS_FILE; - } - - request.setGlobalSettingsFile( globalSettingsFile ); - request.setUserSettingsFile( userSettingsFile ); - - SettingsBuildingRequest settingsRequest = new DefaultSettingsBuildingRequest(); - settingsRequest.setGlobalSettingsFile( globalSettingsFile ); - settingsRequest.setUserSettingsFile( userSettingsFile ); - settingsRequest.setSystemProperties( cliRequest.getSystemProperties() ); - settingsRequest.setUserProperties( cliRequest.getUserProperties() ); - - if ( request.getEventSpyDispatcher() != null ) - { - request.getEventSpyDispatcher().onEvent( settingsRequest ); - } - - logger.debug( "Reading global settings from " - + getLocation( settingsRequest.getGlobalSettingsSource(), settingsRequest.getGlobalSettingsFile() ) ); - logger.debug( "Reading user settings from " - + getLocation( settingsRequest.getUserSettingsSource(), settingsRequest.getUserSettingsFile() ) ); - - SettingsBuildingResult settingsResult = settingsBuilder.build( settingsRequest ); - - if ( request.getEventSpyDispatcher() != null ) - { - request.getEventSpyDispatcher().onEvent( settingsResult ); - } - - populateFromSettings( request, settingsResult.getEffectiveSettings() ); - - if ( !settingsResult.getProblems().isEmpty() && logger.isWarnEnabled() ) - { - logger.warn( "" ); - logger.warn( "Some problems were encountered while building the effective settings" ); - - for ( SettingsProblem problem : settingsResult.getProblems() ) - { - logger.warn( problem.getMessage() + " @ " + problem.getLocation() ); - } - logger.warn( "" ); - } - } - - private MavenExecutionRequest populateFromSettings( MavenExecutionRequest request, Settings settings ) - throws MavenExecutionRequestPopulationException - { - if ( settings == null ) - { - return request; - } - - request.setOffline( settings.isOffline() ); - - request.setInteractiveMode( settings.isInteractiveMode() ); - - request.setPluginGroups( settings.getPluginGroups() ); - - request.setLocalRepositoryPath( settings.getLocalRepository() ); - - for ( Server server : settings.getServers() ) - { - server = server.clone(); - - request.addServer( server ); - } - - // <proxies> - // <proxy> - // <active>true</active> - // <protocol>http</protocol> - // <host>proxy.somewhere.com</host> - // <port>8080</port> - // <username>proxyuser</username> - // <password>somepassword</password> - // <nonProxyHosts>www.google.com|*.somewhere.com</nonProxyHosts> - // </proxy> - // </proxies> - - for ( Proxy proxy : settings.getProxies() ) - { - if ( !proxy.isActive() ) - { - continue; - } - - proxy = proxy.clone(); - - request.addProxy( proxy ); - } - - // <mirrors> - // <mirror> - // <id>nexus</id> - // <mirrorOf>*</mirrorOf> - // <url>http://repository.sonatype.org/content/groups/public</url> - // </mirror> - // </mirrors> - - for ( Mirror mirror : settings.getMirrors() ) - { - mirror = mirror.clone(); - - request.addMirror( mirror ); - } - - request.setActiveProfiles( settings.getActiveProfiles() ); - - for ( org.apache.maven.settings.Profile rawProfile : settings.getProfiles() ) - { - request.addProfile( SettingsUtils.convertFromSettingsProfile( rawProfile ) ); - - if ( settings.getActiveProfiles().contains( rawProfile.getId() ) ) - { - List<Repository> remoteRepositories = rawProfile.getRepositories(); - for ( Repository remoteRepository : remoteRepositories ) - { - try - { - request.addRemoteRepository( - MavenRepositorySystem.buildArtifactRepository( remoteRepository ) ); - } - catch ( InvalidRepositoryException e ) - { - // do nothing for now - } - } - - List<Repository> pluginRepositories = rawProfile.getPluginRepositories(); - for ( Repository pluginRepository : pluginRepositories ) - { - try - { - request.addPluginArtifactRepository( - MavenRepositorySystem.buildArtifactRepository( pluginRepository ) ); - } - catch ( InvalidRepositoryException e ) - { - // do nothing for now - } - } - } - } - return request; - } - - private Object getLocation( Source source, File defaultLocation ) - { - if ( source != null ) - { - return source.getLocation(); - } - return defaultLocation; - } - - static File resolveFile( File file, String workingDirectory ) - { - if ( file == null ) - { - return null; - } - else if ( file.isAbsolute() ) - { - return file; - } - else if ( file.getPath().startsWith( File.separator ) ) - { - // drive-relative Windows path - return file.getAbsoluteFile(); - } - else - { - return new File( workingDirectory, file.getPath() ).getAbsoluteFile(); - } - } -} diff --git a/framework/src/maven/apache-maven-3.3.3/maven-embedder/src/main/java/org/apache/maven/cli/event/DefaultEventSpyContext.java b/framework/src/maven/apache-maven-3.3.3/maven-embedder/src/main/java/org/apache/maven/cli/event/DefaultEventSpyContext.java deleted file mode 100644 index 7c7976ab..00000000 --- a/framework/src/maven/apache-maven-3.3.3/maven-embedder/src/main/java/org/apache/maven/cli/event/DefaultEventSpyContext.java +++ /dev/null @@ -1,38 +0,0 @@ -package org.apache.maven.cli.event; - -/* - * 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.HashMap; -import java.util.Map; - -import org.apache.maven.eventspy.EventSpy; - -public class DefaultEventSpyContext - implements EventSpy.Context -{ - - private final Map<String, Object> data = new HashMap<String, Object>(); - - public Map<String, Object> getData() - { - return data; - } - -} diff --git a/framework/src/maven/apache-maven-3.3.3/maven-embedder/src/main/java/org/apache/maven/cli/event/ExecutionEventLogger.java b/framework/src/maven/apache-maven-3.3.3/maven-embedder/src/main/java/org/apache/maven/cli/event/ExecutionEventLogger.java deleted file mode 100644 index ad3ad3a4..00000000 --- a/framework/src/maven/apache-maven-3.3.3/maven-embedder/src/main/java/org/apache/maven/cli/event/ExecutionEventLogger.java +++ /dev/null @@ -1,381 +0,0 @@ -package org.apache.maven.cli.event; - -/* - * 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 static org.apache.maven.cli.CLIReportingUtils.formatDuration; -import static org.apache.maven.cli.CLIReportingUtils.formatTimestamp; - -import org.apache.maven.execution.AbstractExecutionListener; -import org.apache.maven.execution.BuildFailure; -import org.apache.maven.execution.BuildSuccess; -import org.apache.maven.execution.BuildSummary; -import org.apache.maven.execution.ExecutionEvent; -import org.apache.maven.execution.MavenExecutionResult; -import org.apache.maven.execution.MavenSession; -import org.apache.maven.plugin.MojoExecution; -import org.apache.maven.plugin.descriptor.MojoDescriptor; -import org.apache.maven.project.MavenProject; -import org.codehaus.plexus.util.StringUtils; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; - -/** - * Logs execution events to logger, eventually user-supplied. - * - * @author Benjamin Bentmann - */ -public class ExecutionEventLogger - extends AbstractExecutionListener -{ - private final Logger logger; - - private static final int LINE_LENGTH = 72; - private static final int MAX_PADDED_BUILD_TIME_DURATION_LENGTH = 9; - private static final int MAX_PROJECT_NAME_LENGTH = 52; - - public ExecutionEventLogger() - { - logger = LoggerFactory.getLogger( ExecutionEventLogger.class ); - } - - // TODO should we deprecate? - public ExecutionEventLogger( Logger logger ) - { - if ( logger == null ) - { - throw new IllegalArgumentException( "logger missing" ); - } - - this.logger = logger; - } - - private static String chars( char c, int count ) - { - StringBuilder buffer = new StringBuilder( count ); - - for ( int i = count; i > 0; i-- ) - { - buffer.append( c ); - } - - return buffer.toString(); - } - - @Override - public void projectDiscoveryStarted( ExecutionEvent event ) - { - if ( logger.isInfoEnabled() ) - { - logger.info( "Scanning for projects..." ); - } - } - - @Override - public void sessionStarted( ExecutionEvent event ) - { - if ( logger.isInfoEnabled() && event.getSession().getProjects().size() > 1 ) - { - logger.info( chars( '-', LINE_LENGTH ) ); - - logger.info( "Reactor Build Order:" ); - - logger.info( "" ); - - for ( MavenProject project : event.getSession().getProjects() ) - { - logger.info( project.getName() ); - } - } - } - - @Override - public void sessionEnded( ExecutionEvent event ) - { - if ( logger.isInfoEnabled() ) - { - if ( event.getSession().getProjects().size() > 1 ) - { - logReactorSummary( event.getSession() ); - } - - logResult( event.getSession() ); - - logStats( event.getSession() ); - - logger.info( chars( '-', LINE_LENGTH ) ); - } - } - - private void logReactorSummary( MavenSession session ) - { - logger.info( chars( '-', LINE_LENGTH ) ); - - logger.info( "Reactor Summary:" ); - - logger.info( "" ); - - MavenExecutionResult result = session.getResult(); - - for ( MavenProject project : session.getProjects() ) - { - StringBuilder buffer = new StringBuilder( 128 ); - - buffer.append( project.getName() ); - buffer.append( ' ' ); - - if ( buffer.length() <= MAX_PROJECT_NAME_LENGTH ) - { - while ( buffer.length() < MAX_PROJECT_NAME_LENGTH ) - { - buffer.append( '.' ); - } - buffer.append( ' ' ); - } - - BuildSummary buildSummary = result.getBuildSummary( project ); - - if ( buildSummary == null ) - { - buffer.append( "SKIPPED" ); - } - else if ( buildSummary instanceof BuildSuccess ) - { - buffer.append( "SUCCESS [" ); - String buildTimeDuration = formatDuration( buildSummary.getTime() ); - int padSize = MAX_PADDED_BUILD_TIME_DURATION_LENGTH - buildTimeDuration.length(); - if ( padSize > 0 ) - { - buffer.append( chars( ' ', padSize ) ); - } - buffer.append( buildTimeDuration ); - buffer.append( "]" ); - } - else if ( buildSummary instanceof BuildFailure ) - { - buffer.append( "FAILURE [" ); - String buildTimeDuration = formatDuration( buildSummary.getTime() ); - int padSize = MAX_PADDED_BUILD_TIME_DURATION_LENGTH - buildTimeDuration.length(); - if ( padSize > 0 ) - { - buffer.append( chars( ' ', padSize ) ); - } - buffer.append( buildTimeDuration ); - buffer.append( "]" ); - } - - logger.info( buffer.toString() ); - } - } - - private void logResult( MavenSession session ) - { - logger.info( chars( '-', LINE_LENGTH ) ); - - if ( session.getResult().hasExceptions() ) - { - logger.info( "BUILD FAILURE" ); - } - else - { - logger.info( "BUILD SUCCESS" ); - } - } - - private void logStats( MavenSession session ) - { - logger.info( chars( '-', LINE_LENGTH ) ); - - long finish = System.currentTimeMillis(); - - long time = finish - session.getRequest().getStartTime().getTime(); - - String wallClock = session.getRequest().getDegreeOfConcurrency() > 1 ? " (Wall Clock)" : ""; - - logger.info( "Total time: " + formatDuration( time ) + wallClock ); - - logger.info( "Finished at: " + formatTimestamp( finish ) ); - - System.gc(); - - Runtime r = Runtime.getRuntime(); - - long mb = 1024 * 1024; - - logger.info( "Final Memory: " + ( r.totalMemory() - r.freeMemory() ) / mb + "M/" + r.totalMemory() / mb + "M" ); - } - - @Override - public void projectSkipped( ExecutionEvent event ) - { - if ( logger.isInfoEnabled() ) - { - logger.info( chars( ' ', LINE_LENGTH ) ); - logger.info( chars( '-', LINE_LENGTH ) ); - - logger.info( "Skipping " + event.getProject().getName() ); - logger.info( "This project has been banned from the build due to previous failures." ); - - logger.info( chars( '-', LINE_LENGTH ) ); - } - } - - @Override - public void projectStarted( ExecutionEvent event ) - { - if ( logger.isInfoEnabled() ) - { - logger.info( chars( ' ', LINE_LENGTH ) ); - logger.info( chars( '-', LINE_LENGTH ) ); - - logger.info( "Building " + event.getProject().getName() + " " + event.getProject().getVersion() ); - - logger.info( chars( '-', LINE_LENGTH ) ); - } - } - - @Override - public void mojoSkipped( ExecutionEvent event ) - { - if ( logger.isWarnEnabled() ) - { - logger.warn( "Goal " + event.getMojoExecution().getGoal() - + " requires online mode for execution but Maven is currently offline, skipping" ); - } - } - - /** - * <pre>--- mojo-artifactId:version:goal (mojo-executionId) @ project-artifactId ---</pre> - */ - @Override - public void mojoStarted( ExecutionEvent event ) - { - if ( logger.isInfoEnabled() ) - { - StringBuilder buffer = new StringBuilder( 128 ); - - buffer.append( "--- " ); - append( buffer, event.getMojoExecution() ); - append( buffer, event.getProject() ); - buffer.append( " ---" ); - - logger.info( "" ); - logger.info( buffer.toString() ); - } - } - - /** - * <pre>>>> mojo-artifactId:version:goal (mojo-executionId) > :forked-goal @ project-artifactId >>></pre> - * <pre>>>> mojo-artifactId:version:goal (mojo-executionId) > [lifecycle]phase @ project-artifactId >>></pre> - */ - @Override - public void forkStarted( ExecutionEvent event ) - { - if ( logger.isInfoEnabled() ) - { - StringBuilder buffer = new StringBuilder( 128 ); - - buffer.append( ">>> " ); - append( buffer, event.getMojoExecution() ); - buffer.append( " > " ); - appendForkInfo( buffer, event.getMojoExecution().getMojoDescriptor() ); - append( buffer, event.getProject() ); - buffer.append( " >>>" ); - - logger.info( "" ); - logger.info( buffer.toString() ); - } - } - - // CHECKSTYLE_OFF: LineLength - /** - * <pre><<< mojo-artifactId:version:goal (mojo-executionId) < :forked-goal @ project-artifactId <<<</pre> - * <pre><<< mojo-artifactId:version:goal (mojo-executionId) < [lifecycle]phase @ project-artifactId <<<</pre> - */ - // CHECKSTYLE_ON: LineLength - @Override - public void forkSucceeded( ExecutionEvent event ) - { - if ( logger.isInfoEnabled() ) - { - StringBuilder buffer = new StringBuilder( 128 ); - - buffer.append( "<<< " ); - append( buffer, event.getMojoExecution() ); - buffer.append( " < " ); - appendForkInfo( buffer, event.getMojoExecution().getMojoDescriptor() ); - append( buffer, event.getProject() ); - buffer.append( " <<<" ); - - logger.info( "" ); - logger.info( buffer.toString() ); - } - } - - private void append( StringBuilder buffer, MojoExecution me ) - { - buffer.append( me.getArtifactId() ).append( ':' ).append( me.getVersion() ); - buffer.append( ':' ).append( me.getGoal() ); - if ( me.getExecutionId() != null ) - { - buffer.append( " (" ).append( me.getExecutionId() ).append( ')' ); - } - } - - private void appendForkInfo( StringBuilder buffer, MojoDescriptor md ) - { - if ( StringUtils.isNotEmpty( md.getExecutePhase() ) ) - { - // forked phase - if ( StringUtils.isNotEmpty( md.getExecuteLifecycle() ) ) - { - buffer.append( '[' ); - buffer.append( md.getExecuteLifecycle() ); - buffer.append( ']' ); - } - buffer.append( md.getExecutePhase() ); - } - else - { - // forked goal - buffer.append( ':' ); - buffer.append( md.getExecuteGoal() ); - } - } - - private void append( StringBuilder buffer, MavenProject project ) - { - buffer.append( " @ " ).append( project.getArtifactId() ); - } - - @Override - public void forkedProjectStarted( ExecutionEvent event ) - { - if ( logger.isInfoEnabled() && event.getMojoExecution().getForkedExecutions().size() > 1 ) - { - logger.info( chars( ' ', LINE_LENGTH ) ); - logger.info( chars( '>', LINE_LENGTH ) ); - - logger.info( "Forking " + event.getProject().getName() + " " + event.getProject().getVersion() ); - - logger.info( chars( '>', LINE_LENGTH ) ); - } - } - -} diff --git a/framework/src/maven/apache-maven-3.3.3/maven-embedder/src/main/java/org/apache/maven/cli/internal/BootstrapCoreExtensionManager.java b/framework/src/maven/apache-maven-3.3.3/maven-embedder/src/main/java/org/apache/maven/cli/internal/BootstrapCoreExtensionManager.java deleted file mode 100644 index a431bded..00000000 --- a/framework/src/maven/apache-maven-3.3.3/maven-embedder/src/main/java/org/apache/maven/cli/internal/BootstrapCoreExtensionManager.java +++ /dev/null @@ -1,143 +0,0 @@ -package org.apache.maven.cli.internal; - -/* - * 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.ArrayList; -import java.util.Collections; -import java.util.List; -import java.util.Set; - -import javax.inject.Inject; -import javax.inject.Named; - -import org.apache.maven.RepositoryUtils; -import org.apache.maven.cli.internal.extension.model.CoreExtension; -import org.apache.maven.execution.MavenExecutionRequest; -import org.apache.maven.extension.internal.CoreExtensionEntry; -import org.apache.maven.internal.aether.DefaultRepositorySystemSessionFactory; -import org.apache.maven.model.Plugin; -import org.apache.maven.plugin.PluginResolutionException; -import org.apache.maven.plugin.internal.DefaultPluginDependenciesResolver; -import org.codehaus.plexus.DefaultPlexusContainer; -import org.codehaus.plexus.PlexusContainer; -import org.codehaus.plexus.classworlds.ClassWorld; -import org.codehaus.plexus.classworlds.realm.ClassRealm; -import org.codehaus.plexus.logging.Logger; -import org.eclipse.aether.RepositorySystemSession; -import org.eclipse.aether.artifact.Artifact; -import org.eclipse.aether.graph.DependencyFilter; -import org.eclipse.aether.graph.DependencyNode; -import org.eclipse.aether.repository.RemoteRepository; -import org.eclipse.aether.util.filter.ExclusionsDependencyFilter; -import org.eclipse.aether.util.graph.visitor.PreorderNodeListGenerator; - -@Named -public class BootstrapCoreExtensionManager -{ - private final Logger log; - - private final DefaultPluginDependenciesResolver pluginDependenciesResolver; - - private final DefaultRepositorySystemSessionFactory repositorySystemSessionFactory; - - private final ClassWorld classWorld; - - private final ClassRealm parentRealm; - - @Inject - public BootstrapCoreExtensionManager( Logger log, DefaultPluginDependenciesResolver pluginDependenciesResolver, - DefaultRepositorySystemSessionFactory repositorySystemSessionFactory, - PlexusContainer container ) - { - this.log = log; - this.pluginDependenciesResolver = pluginDependenciesResolver; - this.repositorySystemSessionFactory = repositorySystemSessionFactory; - this.classWorld = ( (DefaultPlexusContainer) container ).getClassWorld(); - this.parentRealm = container.getContainerRealm(); - } - - public List<CoreExtensionEntry> loadCoreExtensions( MavenExecutionRequest request, Set<String> providedArtifacts, - List<CoreExtension> extensions ) - throws Exception - { - RepositorySystemSession repoSession = repositorySystemSessionFactory.newRepositorySession( request ); - List<RemoteRepository> repositories = RepositoryUtils.toRepos( request.getPluginArtifactRepositories() ); - - return resolveCoreExtensions( repoSession, repositories, providedArtifacts, extensions ); - } - - private List<CoreExtensionEntry> resolveCoreExtensions( RepositorySystemSession repoSession, - List<RemoteRepository> repositories, - Set<String> providedArtifacts, - List<CoreExtension> configuration ) - throws Exception - { - List<CoreExtensionEntry> extensions = new ArrayList<CoreExtensionEntry>(); - - DependencyFilter dependencyFilter = new ExclusionsDependencyFilter( providedArtifacts ); - - for ( CoreExtension extension : configuration ) - { - List<Artifact> artifacts = resolveExtension( extension, repoSession, repositories, dependencyFilter ); - if ( !artifacts.isEmpty() ) - { - extensions.add( createExtension( extension, artifacts ) ); - } - } - - return Collections.unmodifiableList( extensions ); - } - - private CoreExtensionEntry createExtension( CoreExtension extension, List<Artifact> artifacts ) - throws Exception - { - String realmId = - "coreExtension>" + extension.getGroupId() + ":" + extension.getArtifactId() + ":" + extension.getVersion(); - ClassRealm realm = classWorld.newRealm( realmId, null ); - log.debug( "Populating class realm " + realm.getId() ); - realm.setParentRealm( parentRealm ); - for ( Artifact artifact : artifacts ) - { - File file = artifact.getFile(); - log.debug( " Included " + file ); - realm.addURL( file.toURI().toURL() ); - } - return CoreExtensionEntry.discoverFrom( realm, Collections.singleton( artifacts.get( 0 ).getFile() ) ); - } - - private List<Artifact> resolveExtension( CoreExtension extension, RepositorySystemSession repoSession, - List<RemoteRepository> repositories, DependencyFilter dependencyFilter ) - throws PluginResolutionException - { - Plugin plugin = new Plugin(); - plugin.setGroupId( extension.getGroupId() ); - plugin.setArtifactId( extension.getArtifactId() ); - plugin.setVersion( extension.getVersion() ); - - DependencyNode root = - pluginDependenciesResolver.resolveCoreExtension( plugin, dependencyFilter, repositories, repoSession ); - PreorderNodeListGenerator nlg = new PreorderNodeListGenerator(); - root.accept( nlg ); - List<Artifact> artifacts = nlg.getArtifacts( false ); - - return artifacts; - } -} diff --git a/framework/src/maven/apache-maven-3.3.3/maven-embedder/src/main/java/org/apache/maven/cli/logging/BaseSlf4jConfiguration.java b/framework/src/maven/apache-maven-3.3.3/maven-embedder/src/main/java/org/apache/maven/cli/logging/BaseSlf4jConfiguration.java deleted file mode 100644 index 33e9920e..00000000 --- a/framework/src/maven/apache-maven-3.3.3/maven-embedder/src/main/java/org/apache/maven/cli/logging/BaseSlf4jConfiguration.java +++ /dev/null @@ -1,45 +0,0 @@ -package org.apache.maven.cli.logging; - -/* - * 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.slf4j.Logger; -import org.slf4j.LoggerFactory; - -/** - * Abstract implementation. - * - * @author Hervé Boutemy - * @since 3.1.0 - */ -public class BaseSlf4jConfiguration - implements Slf4jConfiguration -{ - private final Logger logger = LoggerFactory.getLogger( BaseSlf4jConfiguration.class ); - - public void setRootLoggerLevel( Level level ) - { - logger.warn( "setRootLoggerLevel: operation not supported" ); - } - - public void activate() - { - logger.warn( "reset(): operation not supported" ); - } -} diff --git a/framework/src/maven/apache-maven-3.3.3/maven-embedder/src/main/java/org/apache/maven/cli/logging/Slf4jConfiguration.java b/framework/src/maven/apache-maven-3.3.3/maven-embedder/src/main/java/org/apache/maven/cli/logging/Slf4jConfiguration.java deleted file mode 100644 index 5f4b64d3..00000000 --- a/framework/src/maven/apache-maven-3.3.3/maven-embedder/src/main/java/org/apache/maven/cli/logging/Slf4jConfiguration.java +++ /dev/null @@ -1,47 +0,0 @@ -package org.apache.maven.cli.logging; - -/* - * 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. - */ - -/** - * Interface for configuration operations on loggers, which are not available in slf4j, then require per-slf4f-binding - * implementation. - * - * @author Hervé Boutemy - * @since 3.1.0 - */ -public interface Slf4jConfiguration -{ - public static enum Level - { - DEBUG, INFO, ERROR - } - - /** - * Set root logging level. - * - * @param level the level - */ - void setRootLoggerLevel( Level level ); - - /** - * Activate logging implementation configuration (if necessary). - */ - void activate(); -} diff --git a/framework/src/maven/apache-maven-3.3.3/maven-embedder/src/main/java/org/apache/maven/cli/logging/Slf4jConfigurationFactory.java b/framework/src/maven/apache-maven-3.3.3/maven-embedder/src/main/java/org/apache/maven/cli/logging/Slf4jConfigurationFactory.java deleted file mode 100644 index b50d9442..00000000 --- a/framework/src/maven/apache-maven-3.3.3/maven-embedder/src/main/java/org/apache/maven/cli/logging/Slf4jConfigurationFactory.java +++ /dev/null @@ -1,91 +0,0 @@ -package org.apache.maven.cli.logging; - -/* - * 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.IOException; -import java.net.URL; -import java.util.Enumeration; -import java.util.LinkedHashMap; -import java.util.Map; -import java.util.Properties; -import java.util.Set; - -import org.apache.maven.cli.logging.impl.UnsupportedSlf4jBindingConfiguration; -import org.codehaus.plexus.util.PropertyUtils; -import org.slf4j.ILoggerFactory; - -/** - * Slf4jConfiguration factory, loading implementations from <code>META-INF/maven/slf4j-configuration.properties</code> - * configuration files in class loader: key is the class name of the ILoggerFactory, value is the class name of - * the corresponding Slf4jConfiguration. - * - * @author Hervé Boutemy - * @since 3.1.0 - */ -public class Slf4jConfigurationFactory -{ - public static final String RESOURCE = "META-INF/maven/slf4j-configuration.properties"; - - public static Slf4jConfiguration getConfiguration( ILoggerFactory loggerFactory ) - { - Map<URL, Set<Object>> supported = new LinkedHashMap<URL, Set<Object>>(); - - String slf4jBinding = loggerFactory.getClass().getCanonicalName(); - - try - { - Enumeration<URL> resources = Slf4jConfigurationFactory.class.getClassLoader().getResources( RESOURCE ); - - while ( resources.hasMoreElements() ) - { - URL resource = resources.nextElement(); - - Properties conf = PropertyUtils.loadProperties( resource.openStream() ); - - String impl = conf.getProperty( slf4jBinding ); - - if ( impl != null ) - { - return (Slf4jConfiguration) Class.forName( impl ).newInstance(); - } - - supported.put( resource, conf.keySet() ); - } - } - catch ( IOException e ) - { - e.printStackTrace(); - } - catch ( InstantiationException e ) - { - e.printStackTrace(); - } - catch ( IllegalAccessException e ) - { - e.printStackTrace(); - } - catch ( ClassNotFoundException e ) - { - e.printStackTrace(); - } - - return new UnsupportedSlf4jBindingConfiguration( slf4jBinding, supported ); - } -} diff --git a/framework/src/maven/apache-maven-3.3.3/maven-embedder/src/main/java/org/apache/maven/cli/logging/Slf4jLogger.java b/framework/src/maven/apache-maven-3.3.3/maven-embedder/src/main/java/org/apache/maven/cli/logging/Slf4jLogger.java deleted file mode 100644 index 39574642..00000000 --- a/framework/src/maven/apache-maven-3.3.3/maven-embedder/src/main/java/org/apache/maven/cli/logging/Slf4jLogger.java +++ /dev/null @@ -1,145 +0,0 @@ -package org.apache.maven.cli.logging; - -/* - * 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.codehaus.plexus.logging.Logger; - -/** - * Adapt an SLF4J logger to a Plexus logger, ignoring Plexus logger API parts that are not classical and - * probably not really used. - * - * @author Jason van Zyl - * @since 3.1.0 - */ -public class Slf4jLogger - implements Logger -{ - - private org.slf4j.Logger logger; - - public Slf4jLogger( org.slf4j.Logger logger ) - { - this.logger = logger; - } - - public void debug( String message ) - { - logger.debug( message ); - } - - public void debug( String message, Throwable throwable ) - { - logger.debug( message, throwable ); - } - - public boolean isDebugEnabled() - { - return logger.isDebugEnabled(); - } - - public void info( String message ) - { - logger.info( message ); - } - - public void info( String message, Throwable throwable ) - { - logger.info( message, throwable ); - } - - public boolean isInfoEnabled() - { - return logger.isInfoEnabled(); - } - - public void warn( String message ) - { - logger.warn( message ); - } - - public void warn( String message, Throwable throwable ) - { - logger.warn( message, throwable ); - } - - public boolean isWarnEnabled() - { - return logger.isWarnEnabled(); - } - - public void error( String message ) - { - logger.error( message ); - } - - public void error( String message, Throwable throwable ) - { - logger.error( message, throwable ); - } - - public boolean isErrorEnabled() - { - return logger.isErrorEnabled(); - } - - public void fatalError( String message ) - { - logger.error( message ); - } - - public void fatalError( String message, Throwable throwable ) - { - logger.error( message, throwable ); - } - - public boolean isFatalErrorEnabled() - { - return logger.isErrorEnabled(); - } - - /** - * <b>Warning</b>: ignored (always return <code>0 == Logger.LEVEL_DEBUG</code>). - */ - public int getThreshold() - { - return 0; - } - - /** - * <b>Warning</b>: ignored. - */ - public void setThreshold( int threshold ) - { - } - - /** - * <b>Warning</b>: ignored (always return <code>null</code>). - */ - public Logger getChildLogger( String name ) - { - return null; - } - - public String getName() - { - return logger.getName(); - } - -} diff --git a/framework/src/maven/apache-maven-3.3.3/maven-embedder/src/main/java/org/apache/maven/cli/logging/Slf4jLoggerManager.java b/framework/src/maven/apache-maven-3.3.3/maven-embedder/src/main/java/org/apache/maven/cli/logging/Slf4jLoggerManager.java deleted file mode 100644 index 529f19eb..00000000 --- a/framework/src/maven/apache-maven-3.3.3/maven-embedder/src/main/java/org/apache/maven/cli/logging/Slf4jLoggerManager.java +++ /dev/null @@ -1,111 +0,0 @@ -package org.apache.maven.cli.logging; - -/* - * 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.codehaus.plexus.logging.Logger; -import org.codehaus.plexus.logging.LoggerManager; -import org.slf4j.ILoggerFactory; -import org.slf4j.LoggerFactory; - -/** - * Use an SLF4J {@link org.slf4j.ILoggerFactory} as a backing for a Plexus - * {@link org.codehaus.plexus.logging.LoggerManager}, - * ignoring Plexus logger API parts that are not classical and probably not really used. - * - * @author Jason van Zyl - * @since 3.1 - */ -public class Slf4jLoggerManager - implements LoggerManager -{ - - private ILoggerFactory loggerFactory; - - public Slf4jLoggerManager() - { - loggerFactory = LoggerFactory.getILoggerFactory(); - } - - public Logger getLoggerForComponent( String role ) - { - return new Slf4jLogger( loggerFactory.getLogger( role ) ); - } - - /** - * The logger name for a component with a non-null hint is <code>role.hint</code>. - * <b>Warning</b>: this does not conform to logger name as class name convention. - * (and what about <code>null</code> and <code>default</code> hint equivalence?) - */ - public Logger getLoggerForComponent( String role, String hint ) - { - return ( null == hint - ? getLoggerForComponent( role ) - : new Slf4jLogger( loggerFactory.getLogger( role + '.' + hint ) ) ); - } - - // - // Trying to give loggers back is a bad idea. Ceki said so :-) - // notice to self: what was this method supposed to do? - // - /** - * <b>Warning</b>: ignored. - */ - public void returnComponentLogger( String role ) - { - } - - /** - * <b>Warning</b>: ignored. - */ - public void returnComponentLogger( String role, String hint ) - { - } - - /** - * <b>Warning</b>: ignored (always return <code>0</code>). - */ - public int getThreshold() - { - return 0; - } - - /** - * <b>Warning</b>: ignored. - */ - public void setThreshold( int threshold ) - { - } - - /** - * <b>Warning</b>: ignored. - */ - public void setThresholds( int threshold ) - { - } - - /** - * <b>Warning</b>: ignored (always return <code>0</code>). - */ - public int getActiveLoggerCount() - { - return 0; - } - -} diff --git a/framework/src/maven/apache-maven-3.3.3/maven-embedder/src/main/java/org/apache/maven/cli/logging/Slf4jStdoutLogger.java b/framework/src/maven/apache-maven-3.3.3/maven-embedder/src/main/java/org/apache/maven/cli/logging/Slf4jStdoutLogger.java deleted file mode 100644 index 64b9bfde..00000000 --- a/framework/src/maven/apache-maven-3.3.3/maven-embedder/src/main/java/org/apache/maven/cli/logging/Slf4jStdoutLogger.java +++ /dev/null @@ -1,306 +0,0 @@ -package org.apache.maven.cli.logging; - -/* - * 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.PrintStream; - -import org.slf4j.Logger; -import org.slf4j.Marker; - -/** - * @since 3.1.0 - */ -public class Slf4jStdoutLogger - implements Logger -{ - private static final String ERROR = "[ERROR] "; - - private PrintStream out = System.out; - - // - // These are the only methods we need in our primordial logger - // - public void error( String msg ) - { - out.print( ERROR ); - out.println( msg ); - } - - public void error( String msg, Throwable t ) - { - error( msg ); - - if ( null != t ) - { - t.printStackTrace( out ); - } - } - - // - // Don't need any of this - // - public String getName() - { - return null; - } - - public boolean isTraceEnabled() - { - return false; - } - - public void trace( String msg ) - { - } - - public void trace( String format, Object arg ) - { - } - - public void trace( String format, Object arg1, Object arg2 ) - { - } - - public void trace( String format, Object... arguments ) - { - } - - public void trace( String msg, Throwable t ) - { - } - - public boolean isTraceEnabled( Marker marker ) - { - return false; - } - - public void trace( Marker marker, String msg ) - { - } - - public void trace( Marker marker, String format, Object arg ) - { - } - - public void trace( Marker marker, String format, Object arg1, Object arg2 ) - { - } - - public void trace( Marker marker, String format, Object... argArray ) - { - } - - public void trace( Marker marker, String msg, Throwable t ) - { - } - - public boolean isDebugEnabled() - { - return false; - } - - public void debug( String msg ) - { - } - - public void debug( String format, Object arg ) - { - } - - public void debug( String format, Object arg1, Object arg2 ) - { - } - - public void debug( String format, Object... arguments ) - { - } - - public void debug( String msg, Throwable t ) - { - } - - public boolean isDebugEnabled( Marker marker ) - { - return false; - } - - public void debug( Marker marker, String msg ) - { - } - - public void debug( Marker marker, String format, Object arg ) - { - } - - public void debug( Marker marker, String format, Object arg1, Object arg2 ) - { - } - - public void debug( Marker marker, String format, Object... arguments ) - { - } - - public void debug( Marker marker, String msg, Throwable t ) - { - } - - public boolean isInfoEnabled() - { - return false; - } - - public void info( String msg ) - { - } - - public void info( String format, Object arg ) - { - } - - public void info( String format, Object arg1, Object arg2 ) - { - } - - public void info( String format, Object... arguments ) - { - } - - public void info( String msg, Throwable t ) - { - } - - public boolean isInfoEnabled( Marker marker ) - { - return false; - } - - public void info( Marker marker, String msg ) - { - } - - public void info( Marker marker, String format, Object arg ) - { - } - - public void info( Marker marker, String format, Object arg1, Object arg2 ) - { - } - - public void info( Marker marker, String format, Object... arguments ) - { - } - - public void info( Marker marker, String msg, Throwable t ) - { - } - - public boolean isWarnEnabled() - { - return false; - } - - public void warn( String msg ) - { - } - - public void warn( String format, Object arg ) - { - } - - public void warn( String format, Object... arguments ) - { - } - - public void warn( String format, Object arg1, Object arg2 ) - { - } - - public void warn( String msg, Throwable t ) - { - } - - public boolean isWarnEnabled( Marker marker ) - { - return false; - } - - public void warn( Marker marker, String msg ) - { - } - - public void warn( Marker marker, String format, Object arg ) - { - } - - public void warn( Marker marker, String format, Object arg1, Object arg2 ) - { - } - - public void warn( Marker marker, String format, Object... arguments ) - { - } - - public void warn( Marker marker, String msg, Throwable t ) - { - } - - public boolean isErrorEnabled() - { - return false; - } - - public void error( String format, Object arg ) - { - } - - public void error( String format, Object arg1, Object arg2 ) - { - } - - public void error( String format, Object... arguments ) - { - } - - public boolean isErrorEnabled( Marker marker ) - { - return false; - } - - public void error( Marker marker, String msg ) - { - } - - public void error( Marker marker, String format, Object arg ) - { - } - - public void error( Marker marker, String format, Object arg1, Object arg2 ) - { - } - - public void error( Marker marker, String format, Object... arguments ) - { - } - - public void error( Marker marker, String msg, Throwable t ) - { - } - -} diff --git a/framework/src/maven/apache-maven-3.3.3/maven-embedder/src/main/java/org/apache/maven/cli/logging/impl/Log4j2Configuration.java b/framework/src/maven/apache-maven-3.3.3/maven-embedder/src/main/java/org/apache/maven/cli/logging/impl/Log4j2Configuration.java deleted file mode 100644 index b24ea9cf..00000000 --- a/framework/src/maven/apache-maven-3.3.3/maven-embedder/src/main/java/org/apache/maven/cli/logging/impl/Log4j2Configuration.java +++ /dev/null @@ -1,59 +0,0 @@ -package org.apache.maven.cli.logging.impl; - -/* - * 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.cli.logging.BaseSlf4jConfiguration; - -/** - * Configuration for slf4j-log4j2. - * - * @author Hervé Boutemy - * @since 3.1.0 - */ -public class Log4j2Configuration - extends BaseSlf4jConfiguration -{ - @Override - public void setRootLoggerLevel( Level level ) - { - String value; - switch ( level ) - { - case DEBUG: - value = "debug"; - break; - - case INFO: - value = "info"; - break; - - default: - value = "error"; - break; - } - System.setProperty( "maven.logging.root.level", value ); - } - - @Override - public void activate() - { - // no op - } -} diff --git a/framework/src/maven/apache-maven-3.3.3/maven-embedder/src/main/java/org/apache/maven/cli/logging/impl/LogbackConfiguration.java b/framework/src/maven/apache-maven-3.3.3/maven-embedder/src/main/java/org/apache/maven/cli/logging/impl/LogbackConfiguration.java deleted file mode 100644 index 5d9fab74..00000000 --- a/framework/src/maven/apache-maven-3.3.3/maven-embedder/src/main/java/org/apache/maven/cli/logging/impl/LogbackConfiguration.java +++ /dev/null @@ -1,61 +0,0 @@ -package org.apache.maven.cli.logging.impl; - -/* - * 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.cli.logging.BaseSlf4jConfiguration; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; - -/** - * Configuration for slf4j-logback. - * - * @author Hervé Boutemy - * @since 3.1.0 - */ -public class LogbackConfiguration - extends BaseSlf4jConfiguration -{ - @Override - public void setRootLoggerLevel( Level level ) - { - ch.qos.logback.classic.Level value; - switch ( level ) - { - case DEBUG: - value = ch.qos.logback.classic.Level.DEBUG; - break; - - case INFO: - value = ch.qos.logback.classic.Level.INFO; - break; - - default: - value = ch.qos.logback.classic.Level.ERROR; - break; - } - ( (ch.qos.logback.classic.Logger) LoggerFactory.getLogger( Logger.ROOT_LOGGER_NAME ) ).setLevel( value ); - } - - @Override - public void activate() - { - // no op - } -} diff --git a/framework/src/maven/apache-maven-3.3.3/maven-embedder/src/main/java/org/apache/maven/cli/logging/impl/Slf4jSimpleConfiguration.java b/framework/src/maven/apache-maven-3.3.3/maven-embedder/src/main/java/org/apache/maven/cli/logging/impl/Slf4jSimpleConfiguration.java deleted file mode 100644 index 3961059d..00000000 --- a/framework/src/maven/apache-maven-3.3.3/maven-embedder/src/main/java/org/apache/maven/cli/logging/impl/Slf4jSimpleConfiguration.java +++ /dev/null @@ -1,63 +0,0 @@ -package org.apache.maven.cli.logging.impl; - -/* - * 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.cli.logging.BaseSlf4jConfiguration; -import org.slf4j.MavenSlf4jFriend; -import org.slf4j.impl.MavenSlf4jSimpleFriend; - -/** - * Configuration for slf4j-simple. - * - * @author Hervé Boutemy - * @since 3.1.0 - */ -public class Slf4jSimpleConfiguration - extends BaseSlf4jConfiguration -{ - @Override - public void setRootLoggerLevel( Level level ) - { - String value; - switch ( level ) - { - case DEBUG: - value = "debug"; - break; - - case INFO: - value = "info"; - break; - - default: - value = "error"; - break; - } - System.setProperty( "org.slf4j.simpleLogger.defaultLogLevel", value ); - } - - @Override - public void activate() - { - // property for root logger level or System.out redirection need to be taken into account - MavenSlf4jFriend.reset(); - MavenSlf4jSimpleFriend.init(); - } -} diff --git a/framework/src/maven/apache-maven-3.3.3/maven-embedder/src/main/java/org/apache/maven/cli/logging/impl/UnsupportedSlf4jBindingConfiguration.java b/framework/src/maven/apache-maven-3.3.3/maven-embedder/src/main/java/org/apache/maven/cli/logging/impl/UnsupportedSlf4jBindingConfiguration.java deleted file mode 100644 index 2e91b251..00000000 --- a/framework/src/maven/apache-maven-3.3.3/maven-embedder/src/main/java/org/apache/maven/cli/logging/impl/UnsupportedSlf4jBindingConfiguration.java +++ /dev/null @@ -1,72 +0,0 @@ -package org.apache.maven.cli.logging.impl; - -/* - * 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.net.URL; -import java.util.Map; -import java.util.Set; - -import org.apache.maven.cli.logging.BaseSlf4jConfiguration; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; - -/** - * Pseudo-configuration for unsupported slf4j binding. - * - * @author Hervé Boutemy - * @since 3.2.4 - */ -public class UnsupportedSlf4jBindingConfiguration - extends BaseSlf4jConfiguration -{ - private final Logger logger = LoggerFactory.getLogger( UnsupportedSlf4jBindingConfiguration.class ); - - private String slf4jBinding; - - private Map<URL, Set<Object>> supported; - - public UnsupportedSlf4jBindingConfiguration( String slf4jBinding, Map<URL, Set<Object>> supported ) - { - this.slf4jBinding = slf4jBinding; - this.supported = supported; - } - - @Override - public void activate() - { - logger.warn( "The SLF4J binding actually used is not supported by Maven: " + slf4jBinding ); - logger.warn( "Maven supported bindings are:" ); - - String ls = System.getProperty( "line.separator" ); - - for ( Map.Entry<URL, Set<Object>> entry : supported.entrySet() ) - { - StringBuilder sb = new StringBuilder(); - sb.append( "(from " ).append( entry.getKey().toExternalForm() ).append( ")" ); - - for ( Object binding : entry.getValue() ) - { - sb.append( ls ).append( "- " ).append( binding ); - } - - logger.warn( sb.toString() ); - } - } -} diff --git a/framework/src/maven/apache-maven-3.3.3/maven-embedder/src/main/java/org/apache/maven/cli/transfer/AbstractMavenTransferListener.java b/framework/src/maven/apache-maven-3.3.3/maven-embedder/src/main/java/org/apache/maven/cli/transfer/AbstractMavenTransferListener.java deleted file mode 100644 index 58b1a5dc..00000000 --- a/framework/src/maven/apache-maven-3.3.3/maven-embedder/src/main/java/org/apache/maven/cli/transfer/AbstractMavenTransferListener.java +++ /dev/null @@ -1,90 +0,0 @@ -package org.apache.maven.cli.transfer; - -/* - * 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.PrintStream; -import java.text.DecimalFormat; -import java.text.DecimalFormatSymbols; -import java.util.Locale; - -import org.eclipse.aether.transfer.AbstractTransferListener; -import org.eclipse.aether.transfer.TransferCancelledException; -import org.eclipse.aether.transfer.TransferEvent; -import org.eclipse.aether.transfer.TransferResource; - -public abstract class AbstractMavenTransferListener - extends AbstractTransferListener -{ - - protected PrintStream out; - - protected AbstractMavenTransferListener( PrintStream out ) - { - this.out = out; - } - - @Override - public void transferInitiated( TransferEvent event ) - { - String message = event.getRequestType() == TransferEvent.RequestType.PUT ? "Uploading" : "Downloading"; - - out.println( message + ": " + event.getResource().getRepositoryUrl() + event.getResource().getResourceName() ); - } - - @Override - public void transferCorrupted( TransferEvent event ) - throws TransferCancelledException - { - TransferResource resource = event.getResource(); - - out.println( "[WARNING] " + event.getException().getMessage() + " for " + resource.getRepositoryUrl() - + resource.getResourceName() ); - } - - @Override - public void transferSucceeded( TransferEvent event ) - { - TransferResource resource = event.getResource(); - long contentLength = event.getTransferredBytes(); - if ( contentLength >= 0 ) - { - String type = ( event.getRequestType() == TransferEvent.RequestType.PUT ? "Uploaded" : "Downloaded" ); - String len = contentLength >= 1024 ? toKB( contentLength ) + " KB" : contentLength + " B"; - - String throughput = ""; - long duration = System.currentTimeMillis() - resource.getTransferStartTime(); - if ( duration > 0 ) - { - DecimalFormat format = new DecimalFormat( "0.0", new DecimalFormatSymbols( Locale.ENGLISH ) ); - double kbPerSec = ( contentLength / 1024.0 ) / ( duration / 1000.0 ); - throughput = " at " + format.format( kbPerSec ) + " KB/sec"; - } - - out.println( type + ": " + resource.getRepositoryUrl() + resource.getResourceName() + " (" + len - + throughput + ")" ); - } - } - - protected long toKB( long bytes ) - { - return ( bytes + 1023 ) / 1024; - } - -} diff --git a/framework/src/maven/apache-maven-3.3.3/maven-embedder/src/main/java/org/apache/maven/cli/transfer/BatchModeMavenTransferListener.java b/framework/src/maven/apache-maven-3.3.3/maven-embedder/src/main/java/org/apache/maven/cli/transfer/BatchModeMavenTransferListener.java deleted file mode 100644 index 0e20f17f..00000000 --- a/framework/src/maven/apache-maven-3.3.3/maven-embedder/src/main/java/org/apache/maven/cli/transfer/BatchModeMavenTransferListener.java +++ /dev/null @@ -1,32 +0,0 @@ -package org.apache.maven.cli.transfer; - -/* - * 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.PrintStream; - -public class BatchModeMavenTransferListener - extends AbstractMavenTransferListener -{ - public BatchModeMavenTransferListener( PrintStream out ) - { - super( out ); - } - -} diff --git a/framework/src/maven/apache-maven-3.3.3/maven-embedder/src/main/java/org/apache/maven/cli/transfer/ConsoleMavenTransferListener.java b/framework/src/maven/apache-maven-3.3.3/maven-embedder/src/main/java/org/apache/maven/cli/transfer/ConsoleMavenTransferListener.java deleted file mode 100644 index 46725024..00000000 --- a/framework/src/maven/apache-maven-3.3.3/maven-embedder/src/main/java/org/apache/maven/cli/transfer/ConsoleMavenTransferListener.java +++ /dev/null @@ -1,133 +0,0 @@ -package org.apache.maven.cli.transfer; - -/* - * 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.PrintStream; -import java.util.Map; -import java.util.concurrent.ConcurrentHashMap; - -import org.eclipse.aether.transfer.TransferCancelledException; -import org.eclipse.aether.transfer.TransferEvent; -import org.eclipse.aether.transfer.TransferResource; - -/** - * Console download progress meter. - * - * @author <a href="mailto:brett@apache.org">Brett Porter</a> - */ -public class ConsoleMavenTransferListener - extends AbstractMavenTransferListener -{ - - private Map<TransferResource, Long> downloads = new ConcurrentHashMap<TransferResource, Long>(); - - private int lastLength; - - public ConsoleMavenTransferListener( PrintStream out ) - { - super( out ); - } - - @Override - public void transferProgressed( TransferEvent event ) - throws TransferCancelledException - { - TransferResource resource = event.getResource(); - downloads.put( resource, event.getTransferredBytes() ); - - StringBuilder buffer = new StringBuilder( 64 ); - - for ( Map.Entry<TransferResource, Long> entry : downloads.entrySet() ) - { - long total = entry.getKey().getContentLength(); - Long complete = entry.getValue(); - // NOTE: This null check guards against http://bugs.sun.com/bugdatabase/view_bug.do?bug_id=6312056 - if ( complete != null ) - { - buffer.append( getStatus( complete, total ) ).append( " " ); - } - } - - int pad = lastLength - buffer.length(); - lastLength = buffer.length(); - pad( buffer, pad ); - buffer.append( '\r' ); - - out.print( buffer.toString() ); - } - - private String getStatus( long complete, long total ) - { - if ( total >= 1024 ) - { - return toKB( complete ) + "/" + toKB( total ) + " KB "; - } - else if ( total >= 0 ) - { - return complete + "/" + total + " B "; - } - else if ( complete >= 1024 ) - { - return toKB( complete ) + " KB "; - } - else - { - return complete + " B "; - } - } - - private void pad( StringBuilder buffer, int spaces ) - { - String block = " "; - while ( spaces > 0 ) - { - int n = Math.min( spaces, block.length() ); - buffer.append( block, 0, n ); - spaces -= n; - } - } - - @Override - public void transferSucceeded( TransferEvent event ) - { - transferCompleted( event ); - - super.transferSucceeded( event ); - } - - @Override - public void transferFailed( TransferEvent event ) - { - transferCompleted( event ); - - super.transferFailed( event ); - } - - private void transferCompleted( TransferEvent event ) - { - downloads.remove( event.getResource() ); - - StringBuilder buffer = new StringBuilder( 64 ); - pad( buffer, lastLength ); - buffer.append( '\r' ); - out.print( buffer.toString() ); - } - -} diff --git a/framework/src/maven/apache-maven-3.3.3/maven-embedder/src/main/java/org/apache/maven/cli/transfer/QuietMavenTransferListener.java b/framework/src/maven/apache-maven-3.3.3/maven-embedder/src/main/java/org/apache/maven/cli/transfer/QuietMavenTransferListener.java deleted file mode 100644 index fd9f52cf..00000000 --- a/framework/src/maven/apache-maven-3.3.3/maven-embedder/src/main/java/org/apache/maven/cli/transfer/QuietMavenTransferListener.java +++ /dev/null @@ -1,31 +0,0 @@ -package org.apache.maven.cli.transfer; - -/* - * 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.eclipse.aether.transfer.AbstractTransferListener; - -/** - * @author Benjamin Bentmann - */ -public class QuietMavenTransferListener - extends AbstractTransferListener -{ - -} diff --git a/framework/src/maven/apache-maven-3.3.3/maven-embedder/src/main/java/org/apache/maven/cli/transfer/Slf4jMavenTransferListener.java b/framework/src/maven/apache-maven-3.3.3/maven-embedder/src/main/java/org/apache/maven/cli/transfer/Slf4jMavenTransferListener.java deleted file mode 100644 index bb72db36..00000000 --- a/framework/src/maven/apache-maven-3.3.3/maven-embedder/src/main/java/org/apache/maven/cli/transfer/Slf4jMavenTransferListener.java +++ /dev/null @@ -1,97 +0,0 @@ -package org.apache.maven.cli.transfer; - -/* - * 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.text.DecimalFormat; -import java.text.DecimalFormatSymbols; -import java.util.Locale; - -import org.eclipse.aether.transfer.AbstractTransferListener; -import org.eclipse.aether.transfer.TransferCancelledException; -import org.eclipse.aether.transfer.TransferEvent; -import org.eclipse.aether.transfer.TransferResource; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; - -public class Slf4jMavenTransferListener - extends AbstractTransferListener -{ - - protected final Logger out; - - public Slf4jMavenTransferListener() - { - this.out = LoggerFactory.getLogger( Slf4jMavenTransferListener.class ); - } - - // TODO should we deprecate? - public Slf4jMavenTransferListener( Logger out ) - { - this.out = out; - } - - @Override - public void transferInitiated( TransferEvent event ) - { - String message = event.getRequestType() == TransferEvent.RequestType.PUT ? "Uploading" : "Downloading"; - - out.info( message + ": " + event.getResource().getRepositoryUrl() + event.getResource().getResourceName() ); - } - - @Override - public void transferCorrupted( TransferEvent event ) - throws TransferCancelledException - { - TransferResource resource = event.getResource(); - - out.warn( event.getException().getMessage() + " for " + resource.getRepositoryUrl() - + resource.getResourceName() ); - } - - @Override - public void transferSucceeded( TransferEvent event ) - { - TransferResource resource = event.getResource(); - long contentLength = event.getTransferredBytes(); - if ( contentLength >= 0 ) - { - String type = ( event.getRequestType() == TransferEvent.RequestType.PUT ? "Uploaded" : "Downloaded" ); - String len = contentLength >= 1024 ? toKB( contentLength ) + " KB" : contentLength + " B"; - - String throughput = ""; - long duration = System.currentTimeMillis() - resource.getTransferStartTime(); - if ( duration > 0 ) - { - DecimalFormat format = new DecimalFormat( "0.0", new DecimalFormatSymbols( Locale.ENGLISH ) ); - double kbPerSec = ( contentLength / 1024.0 ) / ( duration / 1000.0 ); - throughput = " at " + format.format( kbPerSec ) + " KB/sec"; - } - - out.info( type + ": " + resource.getRepositoryUrl() + resource.getResourceName() + " (" + len - + throughput + ")" ); - } - } - - protected long toKB( long bytes ) - { - return ( bytes + 1023 ) / 1024; - } - -} |