From 62a09335a0bf8219f28b295fc44bab3eaf728f98 Mon Sep 17 00:00:00 2001 From: Jason van Zyl <jvanzyl@apache.org> Date: Sun, 4 Mar 2007 00:47:12 +0000 Subject: [PATCH] o i have wrapped everything up into the embedder module, for the extra 60k it adds who cares and it lets me operate on the whole set of maven classes so that I can scramble the innards and have it work correctly and consistly for embedded uses and the CLI git-svn-id: https://svn.apache.org/repos/asf/maven/components/trunk@514295 13f79535-47bb-0310-9956-ffa450edef68 --- maven-cli/LICENSE.txt | 202 ------- maven-cli/NOTICE.txt | 11 - maven-cli/README.txt | 23 - maven-cli/checkstyle-license.txt | 18 - maven-cli/pom.xml | 88 ---- maven-cli/src/assemble/bin.xml | 98 ---- maven-cli/src/bin/m2.conf | 7 - maven-cli/src/bin/mvn | 165 ------ maven-cli/src/bin/mvn.bat | 156 ------ maven-cli/src/conf/settings.xml | 241 --------- .../cli/AbstractConsoleDownloadMonitor.java | 129 ----- .../maven/cli/BatchModeDownloadMonitor.java | 49 -- .../java/org/apache/maven/cli/CLIManager.java | 295 ----------- .../maven/cli/ConsoleDownloadMonitor.java | 66 --- .../java/org/apache/maven/cli/MavenCli.java | 497 ------------------ .../AbstractConsoleDownloadMonitorTest.java | 129 ----- .../cli/BatchModeDownloadMonitorTest.java | 38 -- .../maven/cli/ConsoleDownloadMonitorTest.java | 39 -- .../org/apache/maven/cli/MavenCliTest.java | 81 --- 19 files changed, 2332 deletions(-) delete mode 100644 maven-cli/LICENSE.txt delete mode 100644 maven-cli/NOTICE.txt delete mode 100644 maven-cli/README.txt delete mode 100644 maven-cli/checkstyle-license.txt delete mode 100644 maven-cli/pom.xml delete mode 100644 maven-cli/src/assemble/bin.xml delete mode 100644 maven-cli/src/bin/m2.conf delete mode 100755 maven-cli/src/bin/mvn delete mode 100644 maven-cli/src/bin/mvn.bat delete mode 100644 maven-cli/src/conf/settings.xml delete mode 100644 maven-cli/src/main/java/org/apache/maven/cli/AbstractConsoleDownloadMonitor.java delete mode 100644 maven-cli/src/main/java/org/apache/maven/cli/BatchModeDownloadMonitor.java delete mode 100644 maven-cli/src/main/java/org/apache/maven/cli/CLIManager.java delete mode 100644 maven-cli/src/main/java/org/apache/maven/cli/ConsoleDownloadMonitor.java delete mode 100644 maven-cli/src/main/java/org/apache/maven/cli/MavenCli.java delete mode 100644 maven-cli/src/test/java/org/apache/maven/cli/AbstractConsoleDownloadMonitorTest.java delete mode 100644 maven-cli/src/test/java/org/apache/maven/cli/BatchModeDownloadMonitorTest.java delete mode 100644 maven-cli/src/test/java/org/apache/maven/cli/ConsoleDownloadMonitorTest.java delete mode 100644 maven-cli/src/test/java/org/apache/maven/cli/MavenCliTest.java diff --git a/maven-cli/LICENSE.txt b/maven-cli/LICENSE.txt deleted file mode 100644 index d645695673..0000000000 --- a/maven-cli/LICENSE.txt +++ /dev/null @@ -1,202 +0,0 @@ - - Apache License - Version 2.0, January 2004 - http://www.apache.org/licenses/ - - TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION - - 1. Definitions. - - "License" shall mean the terms and conditions for use, reproduction, - and distribution as defined by Sections 1 through 9 of this document. - - "Licensor" shall mean the copyright owner or entity authorized by - the copyright owner that is granting the License. - - "Legal Entity" shall mean the union of the acting entity and all - other entities that control, are controlled by, or are under common - control with that entity. For the purposes of this definition, - "control" means (i) the power, direct or indirect, to cause the - direction or management of such entity, whether by contract or - otherwise, or (ii) ownership of fifty percent (50%) or more of the - outstanding shares, or (iii) beneficial ownership of such entity. - - "You" (or "Your") shall mean an individual or Legal Entity - exercising permissions granted by this License. - - "Source" form shall mean the preferred form for making modifications, - including but not limited to software source code, documentation - source, and configuration files. - - "Object" form shall mean any form resulting from mechanical - transformation or translation of a Source form, including but - not limited to compiled object code, generated documentation, - and conversions to other media types. - - "Work" shall mean the work of authorship, whether in Source or - Object form, made available under the License, as indicated by a - copyright notice that is included in or attached to the work - (an example is provided in the Appendix below). - - "Derivative Works" shall mean any work, whether in Source or Object - form, that is based on (or derived from) the Work and for which the - editorial revisions, annotations, elaborations, or other modifications - represent, as a whole, an original work of authorship. For the purposes - of this License, Derivative Works shall not include works that remain - separable from, or merely link (or bind by name) to the interfaces of, - the Work and Derivative Works thereof. - - "Contribution" shall mean any work of authorship, including - the original version of the Work and any modifications or additions - to that Work or Derivative Works thereof, that is intentionally - submitted to Licensor for inclusion in the Work by the copyright owner - or by an individual or Legal Entity authorized to submit on behalf of - the copyright owner. For the purposes of this definition, "submitted" - means any form of electronic, verbal, or written communication sent - to the Licensor or its representatives, including but not limited to - communication on electronic mailing lists, source code control systems, - and issue tracking systems that are managed by, or on behalf of, the - Licensor for the purpose of discussing and improving the Work, but - excluding communication that is conspicuously marked or otherwise - designated in writing by the copyright owner as "Not a Contribution." - - "Contributor" shall mean Licensor and any individual or Legal Entity - on behalf of whom a Contribution has been received by Licensor and - subsequently incorporated within the Work. - - 2. Grant of Copyright License. Subject to the terms and conditions of - this License, each Contributor hereby grants to You a perpetual, - worldwide, non-exclusive, no-charge, royalty-free, irrevocable - copyright license to reproduce, prepare Derivative Works of, - publicly display, publicly perform, sublicense, and distribute the - Work and such Derivative Works in Source or Object form. - - 3. Grant of Patent License. Subject to the terms and conditions of - this License, each Contributor hereby grants to You a perpetual, - worldwide, non-exclusive, no-charge, royalty-free, irrevocable - (except as stated in this section) patent license to make, have made, - use, offer to sell, sell, import, and otherwise transfer the Work, - where such license applies only to those patent claims licensable - by such Contributor that are necessarily infringed by their - Contribution(s) alone or by combination of their Contribution(s) - with the Work to which such Contribution(s) was submitted. If You - institute patent litigation against any entity (including a - cross-claim or counterclaim in a lawsuit) alleging that the Work - or a Contribution incorporated within the Work constitutes direct - or contributory patent infringement, then any patent licenses - granted to You under this License for that Work shall terminate - as of the date such litigation is filed. - - 4. Redistribution. You may reproduce and distribute copies of the - Work or Derivative Works thereof in any medium, with or without - modifications, and in Source or Object form, provided that You - meet the following conditions: - - (a) You must give any other recipients of the Work or - Derivative Works a copy of this License; and - - (b) You must cause any modified files to carry prominent notices - stating that You changed the files; and - - (c) You must retain, in the Source form of any Derivative Works - that You distribute, all copyright, patent, trademark, and - attribution notices from the Source form of the Work, - excluding those notices that do not pertain to any part of - the Derivative Works; and - - (d) If the Work includes a "NOTICE" text file as part of its - distribution, then any Derivative Works that You distribute must - include a readable copy of the attribution notices contained - within such NOTICE file, excluding those notices that do not - pertain to any part of the Derivative Works, in at least one - of the following places: within a NOTICE text file distributed - as part of the Derivative Works; within the Source form or - documentation, if provided along with the Derivative Works; or, - within a display generated by the Derivative Works, if and - wherever such third-party notices normally appear. The contents - of the NOTICE file are for informational purposes only and - do not modify the License. You may add Your own attribution - notices within Derivative Works that You distribute, alongside - or as an addendum to the NOTICE text from the Work, provided - that such additional attribution notices cannot be construed - as modifying the License. - - You may add Your own copyright statement to Your modifications and - may provide additional or different license terms and conditions - for use, reproduction, or distribution of Your modifications, or - for any such Derivative Works as a whole, provided Your use, - reproduction, and distribution of the Work otherwise complies with - the conditions stated in this License. - - 5. Submission of Contributions. Unless You explicitly state otherwise, - any Contribution intentionally submitted for inclusion in the Work - by You to the Licensor shall be under the terms and conditions of - this License, without any additional terms or conditions. - Notwithstanding the above, nothing herein shall supersede or modify - the terms of any separate license agreement you may have executed - with Licensor regarding such Contributions. - - 6. Trademarks. This License does not grant permission to use the trade - names, trademarks, service marks, or product names of the Licensor, - except as required for reasonable and customary use in describing the - origin of the Work and reproducing the content of the NOTICE file. - - 7. Disclaimer of Warranty. Unless required by applicable law or - agreed to in writing, Licensor provides the Work (and each - Contributor provides its Contributions) on an "AS IS" BASIS, - WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or - implied, including, without limitation, any warranties or conditions - of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A - PARTICULAR PURPOSE. You are solely responsible for determining the - appropriateness of using or redistributing the Work and assume any - risks associated with Your exercise of permissions under this License. - - 8. Limitation of Liability. In no event and under no legal theory, - whether in tort (including negligence), contract, or otherwise, - unless required by applicable law (such as deliberate and grossly - negligent acts) or agreed to in writing, shall any Contributor be - liable to You for damages, including any direct, indirect, special, - incidental, or consequential damages of any character arising as a - result of this License or out of the use or inability to use the - Work (including but not limited to damages for loss of goodwill, - work stoppage, computer failure or malfunction, or any and all - other commercial damages or losses), even if such Contributor - has been advised of the possibility of such damages. - - 9. Accepting Warranty or Additional Liability. While redistributing - the Work or Derivative Works thereof, You may choose to offer, - and charge a fee for, acceptance of support, warranty, indemnity, - or other liability obligations and/or rights consistent with this - License. However, in accepting such obligations, You may act only - on Your own behalf and on Your sole responsibility, not on behalf - of any other Contributor, and only if You agree to indemnify, - defend, and hold each Contributor harmless for any liability - incurred by, or claims asserted against, such Contributor by reason - of your accepting any such warranty or additional liability. - - END OF TERMS AND CONDITIONS - - APPENDIX: How to apply the Apache License to your work. - - To apply the Apache License to your work, attach the following - boilerplate notice, with the fields enclosed by brackets "[]" - replaced with your own identifying information. (Don't include - the brackets!) The text should be enclosed in the appropriate - comment syntax for the file format. We also recommend that a - file or class name and description of purpose be included on the - same "printed page" as the copyright notice for easier - identification within third-party archives. - - Copyright [yyyy] [name of copyright owner] - - Licensed 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. diff --git a/maven-cli/NOTICE.txt b/maven-cli/NOTICE.txt deleted file mode 100644 index d4dc4abfca..0000000000 --- a/maven-cli/NOTICE.txt +++ /dev/null @@ -1,11 +0,0 @@ -This product includes software developed by -The Apache Software Foundation (http://www.apache.org/). - -This product includes software (Plexus and Classworlds) developed by -The Codehaus Foundation (http://www.codehaus.org/). - -This product includes software (JSCH) developed by -JCraft Inc. (http://www.jcraft.com/). - -This product includes software (JTidy) developed by -SourceForge (http://www.sourceforge.net/). diff --git a/maven-cli/README.txt b/maven-cli/README.txt deleted file mode 100644 index 1ba98e0504..0000000000 --- a/maven-cli/README.txt +++ /dev/null @@ -1,23 +0,0 @@ -Installing Maven 2 -================== - -The following instructions show how to install Maven 2: - -1) Unpack the archive where you would like to store the binaries, eg: - tar zxvf maven-2.0.tar.gz -or - unzip maven-2.0.zip - -2) A directory called "maven-2.0" will be created. - -3) Add the bin directory to your PATH, eg: - export PATH=/usr/local/maven-2.0/bin:$PATH -or - set PATH="c:\program files\maven-2.0\bin";%PATH% - -4) Make sure JAVA_HOME is set to the location of your JDK - -5) Run "mvn --version" to verify that it is correctly installed. - -For more information, please see http://maven.apache.org - diff --git a/maven-cli/checkstyle-license.txt b/maven-cli/checkstyle-license.txt deleted file mode 100644 index af6d1c5814..0000000000 --- a/maven-cli/checkstyle-license.txt +++ /dev/null @@ -1,18 +0,0 @@ - - -/* ==================================================================== - * Copyright 2001-2004 The Apache Software Foundation. - * - * Licensed 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. - * ==================================================================== - */ diff --git a/maven-cli/pom.xml b/maven-cli/pom.xml deleted file mode 100644 index fb85525fee..0000000000 --- a/maven-cli/pom.xml +++ /dev/null @@ -1,88 +0,0 @@ -<?xml version="1.0" encoding="UTF-8"?> - -<!-- -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. ---> - -<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" - xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd"> - <parent> - <artifactId>maven</artifactId> - <groupId>org.apache.maven</groupId> - <version>2.1-SNAPSHOT</version> - </parent> - <modelVersion>4.0.0</modelVersion> - <artifactId>maven-cli</artifactId> - <name>Maven Core - CLI</name> - <build> - <plugins> - <plugin> - <artifactId>maven-assembly-plugin</artifactId> - <version>2.1</version> - <configuration> - <descriptors> - <descriptor>src/assemble/bin.xml</descriptor> - </descriptors> - <finalName>maven-${version}</finalName> - </configuration> - <executions> - <execution> - <phase>install</phase> - <goals> - <goal>attached</goal> - </goals> - </execution> - </executions> - </plugin> - </plugins> - </build> - <dependencies> - <dependency> - <groupId>org.codehaus.plexus</groupId> - <artifactId>plexus-classworlds</artifactId> - </dependency> - <dependency> - <groupId>org.codehaus.plexus</groupId> - <artifactId>plexus-utils</artifactId> - </dependency> - <dependency> - <groupId>org.apache.maven</groupId> - <artifactId>maven-embedder</artifactId> - <version>2.1-SNAPSHOT</version> - </dependency> - <dependency> - <groupId>commons-lang</groupId> - <artifactId>commons-lang</artifactId> - </dependency> - <dependency> - <groupId>commons-cli</groupId> - <artifactId>commons-cli</artifactId> - <version>1.0</version> - <exclusions> - <exclusion> - <artifactId>commons-lang</artifactId> - <groupId>commons-lang</groupId> - </exclusion> - <exclusion> - <artifactId>commons-logging</artifactId> - <groupId>commons-logging</groupId> - </exclusion> - </exclusions> - </dependency> - </dependencies> -</project> diff --git a/maven-cli/src/assemble/bin.xml b/maven-cli/src/assemble/bin.xml deleted file mode 100644 index 09febb427e..0000000000 --- a/maven-cli/src/assemble/bin.xml +++ /dev/null @@ -1,98 +0,0 @@ -<!-- -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. ---> - -<assembly> - <id>bin</id> - <formats> - <format>tar.gz</format> - <format>tar.bz2</format> - <format>zip</format> - </formats> - <fileSets> - <fileSet> - <includes> - <include>README*</include> - <include>LICENSE*</include> - <include>NOTICE*</include> - </includes> - </fileSet> - <fileSet> - <directory>src/bin</directory> - <outputDirectory>bin</outputDirectory> - <includes> - <include>*.bat</include> - <include>*.conf</include> - </includes> - <lineEnding>dos</lineEnding> - </fileSet> - <fileSet> - <directory>src/bin</directory> - <outputDirectory>bin</outputDirectory> - <includes> - <include>m2</include> - <include>mvn</include> - </includes> - <lineEnding>unix</lineEnding> - <fileMode>0755</fileMode> - </fileSet> - <fileSet> - <directory>src/conf</directory> - <outputDirectory>conf</outputDirectory> - </fileSet> - <fileSet> - <directory>target</directory> - <outputDirectory>lib</outputDirectory> - <includes> - <include>maven-cli-*.jar</include> - </includes> - <excludes> - <exclude>maven-cli-*-sources.jar</exclude> - </excludes> - </fileSet> - </fileSets> - <dependencySets> - <dependencySet> - <outputDirectory>core</outputDirectory> - <includes> - <include>org.codehaus.plexus:plexus-container-default</include> - <include>org.codehaus.plexus:plexus-component-api</include> - <include>org.codehaus.plexus:plexus-utils</include> - </includes> - </dependencySet> - <dependencySet> - <outputDirectory>core/boot</outputDirectory> - <includes> - <include>org.codehaus.plexus:plexus-classworlds</include> - </includes> - </dependencySet> - <dependencySet> - <outputDirectory>lib</outputDirectory> - <excludes> - <!-- Where is this coming from --> - <exclude>classworlds:classworlds</exclude> - <exclude>org.codehaus.plexus:plexus-container-default</exclude> - <exclude>org.codehaus.plexus:plexus-component-api</exclude> - <exclude>org.codehaus.plexus:plexus-classworlds</exclude> - <exclude>org.codehaus.plexus:plexus-utils</exclude> - <exclude>plexus:plexus-utils</exclude> - <exclude>junit:junit</exclude> - </excludes> - </dependencySet> - </dependencySets> -</assembly> diff --git a/maven-cli/src/bin/m2.conf b/maven-cli/src/bin/m2.conf deleted file mode 100644 index 1f1629d0f4..0000000000 --- a/maven-cli/src/bin/m2.conf +++ /dev/null @@ -1,7 +0,0 @@ -main is org.apache.maven.cli.MavenCli from plexus.core - -set maven.home default ${user.home}/m2 - -[plexus.core] -load ${maven.home}/core/*.jar -load ${maven.home}/lib/*.jar diff --git a/maven-cli/src/bin/mvn b/maven-cli/src/bin/mvn deleted file mode 100755 index af666aa8ad..0000000000 --- a/maven-cli/src/bin/mvn +++ /dev/null @@ -1,165 +0,0 @@ -#!/bin/sh -# ---------------------------------------------------------------------------- -# Copyright 2001-2004 The Apache Software Foundation. -# -# Licensed 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. -# ---------------------------------------------------------------------------- - -# Copyright (c) 2001-2002 The Apache Software Foundation. All rights -# reserved. - -# ---------------------------------------------------------------------------- -# Maven2 Start Up Batch script -# -# Required ENV vars: -# ------------------ -# JAVA_HOME - location of a JDK home dir -# -# Optional ENV vars -# ----------------- -# M2_HOME - location of maven2's installed home dir -# MAVEN_OPTS - parameters passed to the Java VM when running Maven -# e.g. to debug Maven itself, use -# set MAVEN_OPTS=-Xdebug -Xnoagent -Djava.compiler=NONE -Xrunjdwp:transport=dt_socket,server=y,suspend=y,address=8000 -# ---------------------------------------------------------------------------- - - -QUOTED_ARGS="" -while [ "$1" != "" ] ; do - - QUOTED_ARGS="$QUOTED_ARGS \"$1\"" - shift - -done - -if [ -f /etc/mavenrc ] ; then - . /etc/mavenrc -fi - -if [ -f "$HOME/.mavenrc" ] ; then - . "$HOME/.mavenrc" -fi - -# OS specific support. $var _must_ be set to either true or false. -cygwin=false; -darwin=false; -mingw=false -case "`uname`" in - CYGWIN*) cygwin=true ;; - MINGW*) mingw=true;; - Darwin*) darwin=true - if [ -z "$JAVA_VERSION" ] ; then - JAVA_VERSION="CurrentJDK" - else - echo "Using Java version: $JAVA_VERSION" - fi - if [ -z "$JAVA_HOME" ] ; then - JAVA_HOME=/System/Library/Frameworks/JavaVM.framework/Versions/${JAVA_VERSION}/Home - fi - ;; -esac - -if [ -z "$JAVA_HOME" ] ; then - if [ -r /etc/gentoo-release ] ; then - JAVA_HOME=`java-config --jre-home` - fi -fi - -if [ -z "$M2_HOME" ] ; then - ## resolve links - $0 may be a link to maven's home - PRG="$0" - - # need this for relative symlinks - while [ -h "$PRG" ] ; do - ls=`ls -ld "$PRG"` - link=`expr "$ls" : '.*-> \(.*\)$'` - if expr "$link" : '/.*' > /dev/null; then - PRG="$link" - else - PRG="`dirname "$PRG"`/$link" - fi - done - - saveddir=`pwd` - - M2_HOME=`dirname "$PRG"`/.. - - # make it fully qualified - M2_HOME=`cd "$M2_HOME" && pwd` - - cd "$saveddir" - # echo Using m2 at $M2_HOME -fi - -# For Cygwin, ensure paths are in UNIX format before anything is touched -if $cygwin ; then - [ -n "$M2_HOME" ] && - M2_HOME=`cygpath --unix "$M2_HOME"` - [ -n "$JAVA_HOME" ] && - JAVA_HOME=`cygpath --unix "$JAVA_HOME"` - [ -n "$CLASSPATH" ] && - CLASSPATH=`cygpath --path --unix "$CLASSPATH"` -fi - -# For Migwn, ensure paths are in UNIX format before anything is touched -if $mingw ; then - [ -n "$M2_HOME" ] && - M2_HOME="`(cd "$M2_HOME"; pwd)`" - [ -n "$JAVA_HOME" ] && - JAVA_HOME="`(cd "$JAVA_HOME"; pwd)`" - # TODO classpath? -fi - -if [ -z "$JAVACMD" ] ; then - if [ -n "$JAVA_HOME" ] ; then - if [ -x "$JAVA_HOME/jre/sh/java" ] ; then - # IBM's JDK on AIX uses strange locations for the executables - JAVACMD="$JAVA_HOME/jre/sh/java" - else - JAVACMD="$JAVA_HOME/bin/java" - fi - else - JAVACMD=java - fi -fi - -if [ ! -x "$JAVACMD" ] ; then - echo "Error: JAVA_HOME is not defined correctly." - echo " We cannot execute $JAVACMD" - exit 1 -fi - -if [ -z "$JAVA_HOME" ] ; then - echo "Warning: JAVA_HOME environment variable is not set." -fi - -CLASSWORLDS_LAUNCHER=org.codehaus.plexus.classworlds.launcher.Launcher - -# For Cygwin, switch paths to Windows format before running java -if $cygwin; then - [ -n "$M2_HOME" ] && - M2_HOME=`cygpath --path --windows "$M2_HOME"` - [ -n "$JAVA_HOME" ] && - JAVA_HOME=`cygpath --path --windows "$JAVA_HOME"` - [ -n "$HOME" ] && - HOME=`cygpath --path --windows "$HOME"` -fi - -exec "$JAVACMD" \ - $MAVEN_OPTS \ - -classpath "${M2_HOME}"/core/boot/plexus-classworlds-*.jar \ - "-Dclassworlds.conf=${M2_HOME}/bin/m2.conf" \ - "-Dmaven.home=${M2_HOME}" \ - ${CLASSWORLDS_LAUNCHER} $QUOTED_ARGS - - diff --git a/maven-cli/src/bin/mvn.bat b/maven-cli/src/bin/mvn.bat deleted file mode 100644 index 39ed99ca09..0000000000 --- a/maven-cli/src/bin/mvn.bat +++ /dev/null @@ -1,156 +0,0 @@ -@REM ---------------------------------------------------------------------------- -@REM Copyright 2001-2004 The Apache Software Foundation. -@REM -@REM Licensed under the Apache License, Version 2.0 (the "License"); -@REM you may not use this file except in compliance with the License. -@REM You may obtain a copy of the License at -@REM -@REM http://www.apache.org/licenses/LICENSE-2.0 -@REM -@REM Unless required by applicable law or agreed to in writing, software -@REM distributed under the License is distributed on an "AS IS" BASIS, -@REM WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -@REM See the License for the specific language governing permissions and -@REM limitations under the License. -@REM ---------------------------------------------------------------------------- -@REM - -@REM ---------------------------------------------------------------------------- -@REM Maven2 Start Up Batch script -@REM -@REM Required ENV vars: -@REM JAVA_HOME - location of a JDK home dir -@REM -@REM Optional ENV vars -@REM M2_HOME - location of maven2's installed home dir -@REM MAVEN_BATCH_ECHO - set to 'on' to enable the echoing of the batch commands -@REM MAVEN_BATCH_PAUSE - set to 'on' to wait for a key stroke before ending -@REM MAVEN_OPTS - parameters passed to the Java VM when running Maven -@REM e.g. to debug Maven itself, use -@REM set MAVEN_OPTS=-Xdebug -Xnoagent -Djava.compiler=NONE -Xrunjdwp:transport=dt_socket,server=y,suspend=y,address=8000 -@REM ---------------------------------------------------------------------------- - -@REM Begin all REM lines with '@' in case MAVEN_BATCH_ECHO is 'on' -@echo off -@REM enable echoing my setting MAVEN_BATCH_ECHO to 'on' -@if "%MAVEN_BATCH_ECHO%" == "on" echo %MAVEN_BATCH_ECHO% - -@REM Execute a user defined script before this one -if exist "%HOME%\mavenrc_pre.bat" call "%HOME%\mavenrc_pre.bat" - -set ERROR_CODE=0 - -@REM set local scope for the variables with windows NT shell -if "%OS%"=="Windows_NT" @setlocal - -@REM ==== START VALIDATION ==== -if not "%JAVA_HOME%" == "" goto OkJHome - -echo. -echo ERROR: JAVA_HOME not found in your environment. -echo Please set the JAVA_HOME variable in your environment to match the -echo location of your Java installation -echo. -goto error - -:OkJHome -if exist "%JAVA_HOME%\bin\java.exe" goto chkMHome - -echo. -echo ERROR: JAVA_HOME is set to an invalid directory. -echo JAVA_HOME = %JAVA_HOME% -echo Please set the JAVA_HOME variable in your environment to match the -echo location of your Java installation -echo. -goto error - -:chkMHome -if not "%M2_HOME%"=="" goto valMHome - -if "%OS%"=="Windows_NT" SET M2_HOME=%~dp0\.. -if not "%M2_HOME%"=="" goto valMHome - -echo. -echo ERROR: M2_HOME not found in your environment. -echo Please set the M2_HOME variable in your environment to match the -echo location of the Maven installation -echo. -goto error - -:valMHome -if exist "%M2_HOME%\bin\mvn.bat" goto init - -echo. -echo ERROR: M2_HOME is set to an invalid directory. -echo M2_HOME = %M2_HOME% -echo Please set the M2_HOME variable in your environment to match the -echo location of the Maven installation -echo. -goto error -@REM ==== END VALIDATION ==== - -:init -@REM Decide how to startup depending on the version of windows - -@REM -- Win98ME -if NOT "%OS%"=="Windows_NT" goto Win9xArg - -@REM -- 4NT shell -if "%eval[2+2]" == "4" goto 4NTArgs - -@REM -- Regular WinNT shell -set MAVEN_CMD_LINE_ARGS=%* -goto endInit - -@REM The 4NT Shell from jp software -:4NTArgs -set MAVEN_CMD_LINE_ARGS=%$ -goto endInit - -:Win9xArg -@REM Slurp the command line arguments. This loop allows for an unlimited number -@REM of agruments (up to the command line limit, anyway). -set MAVEN_CMD_LINE_ARGS= -:Win9xApp -if %1a==a goto endInit -set MAVEN_CMD_LINE_ARGS=%MAVEN_CMD_LINE_ARGS% %1 -shift -goto Win9xApp - -@REM Reaching here means variables are defined and arguments have been captured -:endInit -SET MAVEN_JAVA_EXE="%JAVA_HOME%\bin\java.exe" - -@REM Start MAVEN2 -for %%i in ("%M2_HOME%"\core\boot\plexus-classworlds-*) do set CLASSWORLDS_JAR="%%i" -%MAVEN_JAVA_EXE% %MAVEN_OPTS% -classpath %CLASSWORLDS_JAR% "-Dclassworlds.conf=%M2_HOME%\bin\m2.conf" "-Dmaven.home=%M2_HOME%" org.codehaus.plexus.classworlds.launcher.Launcher %MAVEN_CMD_LINE_ARGS% -if ERRORLEVEL 1 goto error -goto end - -:error -if "%OS%"=="Windows_NT" @endlocal -set ERROR_CODE=1 - -:end -@REM set local scope for the variables with windows NT shell -if "%OS%"=="Windows_NT" goto endNT - -@REM For old DOS remove the set variables from ENV - we assume they were not set -@REM before we started - at least we don't leave any baggage around -set MAVEN_JAVA_EXE= -set MAVEN_CMD_LINE_ARGS= -goto postExec - -:endNT -@endlocal - -:postExec -if exist "%HOME%\mavenrc_post.bat" call "%HOME%\mavenrc_post.bat" -@REM pause the batch file if MAVEN_BATCH_PAUSE is set to 'on' -if "%MAVEN_BATCH_PAUSE%" == "on" pause - -if "%MAVEN_TERMINATE_CMD%" == "on" exit %ERROR_CODE% - -exit /B %ERROR_CODE% - - diff --git a/maven-cli/src/conf/settings.xml b/maven-cli/src/conf/settings.xml deleted file mode 100644 index 84862915ee..0000000000 --- a/maven-cli/src/conf/settings.xml +++ /dev/null @@ -1,241 +0,0 @@ -<!-- -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. ---> - -<!-- - | This is the configuration file for Maven. It can be specified at two levels: - | - | 1. User Level. This settings.xml file provides configuration for a single user, - | and is normally provided in $HOME/.m2/settings.xml. - | - | NOTE: This location can be overridden with the system property: - | - | -Dorg.apache.maven.user-settings=/path/to/user/settings.xml - | - | 2. Global Level. This settings.xml file provides configuration for all maven - | users on a machine (assuming they're all using the same maven - | installation). It's normally provided in - | ${maven.home}/conf/settings.xml. - | - | NOTE: This location can be overridden with the system property: - | - | -Dorg.apache.maven.global-settings=/path/to/global/settings.xml - | - | The sections in this sample file are intended to give you a running start at - | getting the most out of your Maven installation. Where appropriate, the default - | values (values used when the setting is not specified) are provided. - | - |--> -<settings> - <!-- localRepository - | The path to the local repository maven will use to store artifacts. - | - | Default: ~/.m2/repository - <localRepository>/path/to/local/repo</localRepository> - --> - - <!-- interactiveMode - | This will determine whether maven prompts you when it needs input. If set to false, - | maven will use a sensible default value, perhaps based on some other setting, for - | the parameter in question. - | - | Default: true - <interactiveMode>true</interactiveMode> - --> - - <!-- offline - | Determines whether maven should attempt to connect to the network when executing a build. - | This will have an effect on artifact downloads, artifact deployment, and others. - | - | Default: false - <offline>false</offline> - --> - - <!-- proxies - | This is a list of proxies which can be used on this machine to connect to the network. - | Unless otherwise specified (by system property or command-line switch), the first proxy - | specification in this list marked as active will be used. - |--> - <proxies> - <!-- proxy - | Specification for one proxy, to be used in connecting to the network. - | - <proxy> - <id>optional</id> - <active>true</active> - <protocol>http</protocol> - <username>proxyuser</username> - <password>proxypass</password> - <host>proxy.host.net</host> - <port>80</port> - <nonProxyHosts>local.net,some.host.com</nonProxyHosts> - </proxy> - --> - </proxies> - - <!-- servers - | This is a list of authentication profiles, keyed by the server-id used within the system. - | Authentication profiles can be used whenever maven must make a connection to a remote server. - |--> - <servers> - <!-- server - | Specifies the authentication information to use when connecting to a particular server, identified by - | a unique name within the system (referred to by the 'id' attribute below). - | - | NOTE: You should either specify username/password OR privateKey/passphrase, since these pairings are - | used together. - | - <server> - <id>deploymentRepo</id> - <username>repouser</username> - <password>repopwd</password> - </server> - --> - - <!-- Another sample, using keys to authenticate. - <server> - <id>siteServer</id> - <privateKey>/path/to/private/key</privateKey> - <passphrase>optional; leave empty if not used.</passphrase> - </server> - --> - </servers> - - <!-- mirrors - | This is a list of mirrors to be used in downloading artifacts from remote repositories. - | - | It works like this: a POM may declare a repository to use in resolving certain artifacts. - | However, this repository may have problems with heavy traffic at times, so people have mirrored - | it to several places. - | - | That repository definition will have a unique id, so we can create a mirror reference for that - | repository, to be used as an alternate download site. The mirror site will be the preferred - | server for that repository. - |--> - <mirrors> - <!-- mirror - | Specifies a repository mirror site to use instead of a given repository. The repository that - | this mirror serves has an ID that matches the mirrorOf element of this mirror. IDs are used - | for inheritance and direct lookup purposes, and must be unique across the set of mirrors. - | - <mirror> - <id>mirrorId</id> - <mirrorOf>repositoryId</mirrorOf> - <name>Human Readable Name for this Mirror.</name> - <url>http://my.repository.com/repo/path</url> - </mirror> - --> - </mirrors> - - <!-- profiles - | This is a list of profiles which can be activated in a variety of ways, and which can modify - | the build process. Profiles provided in the settings.xml are intended to provide local machine- - | specific paths and repository locations which allow the build to work in the local environment. - | - | For example, if you have an integration testing plugin - like cactus - that needs to know where - | your Tomcat instance is installed, you can provide a variable here such that the variable is - | dereferenced during the build process to configure the cactus plugin. - | - | As noted above, profiles can be activated in a variety of ways. One way - the activeProfiles - | section of this document (settings.xml) - will be discussed later. Another way essentially - | relies on the detection of a system property, either matching a particular value for the property, - | or merely testing its existence. Profiles can also be activated by JDK version prefix, where a - | value of '1.4' might activate a profile when the build is executed on a JDK version of '1.4.2_07'. - | Finally, the list of active profiles can be specified directly from the command line. - | - | NOTE: For profiles defined in the settings.xml, you are restricted to specifying only artifact - | repositories, plugin repositories, and free-form properties to be used as configuration - | variables for plugins in the POM. - | - |--> - <profiles> - <!-- profile - | Specifies a set of introductions to the build process, to be activated using one or more of the - | mechanisms described above. For inheritance purposes, and to activate profiles via <activatedProfiles/> - | or the command line, profiles have to have an ID that is unique. - | - | An encouraged best practice for profile identification is to use a consistent naming convention - | for profiles, such as 'env-dev', 'env-test', 'env-production', 'user-jdcasey', 'user-brett', etc. - | This will make it more intuitive to understand what the set of introduced profiles is attempting - | to accomplish, particularly when you only have a list of profile id's for debug. - | - | This profile example uses the JDK version to trigger activation, and provides a JDK-specific repo. - <profile> - <id>jdk-1.4</id> - - <activation> - <jdk>1.4</jdk> - </activation> - - <repositories> - <repository> - <id>jdk14</id> - <name>Repository for JDK 1.4 builds</name> - <url>http://www.myhost.com/maven/jdk14</url> - <layout>default</layout> - <snapshotPolicy>always</snapshotPolicy> - </repository> - </repositories> - </profile> - --> - - <!-- - | Here is another profile, activated by the system property 'target-env' with a value of 'dev', - | which provides a specific path to the Tomcat instance. To use this, your plugin configuration - | might hypothetically look like: - | - | ... - | <plugin> - | <groupId>org.myco.myplugins</groupId> - | <artifactId>myplugin</artifactId> - | - | <configuration> - | <tomcatLocation>${tomcatPath}</tomcatLocation> - | </configuration> - | </plugin> - | ... - | - | NOTE: If you just wanted to inject this configuration whenever someone set 'target-env' to - | anything, you could just leave off the <value/> inside the activation-property. - | - <profile> - <id>env-dev</id> - - <activation> - <property> - <name>target-env</name> - <value>dev</value> - </property> - </activation> - - <properties> - <tomcatPath>/path/to/tomcat/instance</tomcatPath> - </properties> - </profile> - --> - </profiles> - - <!-- activeProfiles - | List of profiles that are active for all builds. - | - <activeProfiles> - <activeProfile>alwaysActiveProfile</activeProfile> - <activeProfile>anotherAlwaysActiveProfile</activeProfile> - </activeProfiles> - --> -</settings> diff --git a/maven-cli/src/main/java/org/apache/maven/cli/AbstractConsoleDownloadMonitor.java b/maven-cli/src/main/java/org/apache/maven/cli/AbstractConsoleDownloadMonitor.java deleted file mode 100644 index cf2c4537ff..0000000000 --- a/maven-cli/src/main/java/org/apache/maven/cli/AbstractConsoleDownloadMonitor.java +++ /dev/null @@ -1,129 +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 org.apache.commons.lang.StringUtils; -import org.apache.maven.MavenTransferListener; -import org.apache.maven.wagon.WagonConstants; -import org.apache.maven.wagon.events.TransferEvent; -import org.codehaus.plexus.logging.AbstractLogEnabled; - -/** - * Abstract console download progress meter. - * - * @author <a href="mailto:carlos@apache.org">Carlos Sanchez</a> - * @version $Id$ - * @since 2.0.5 - */ -public abstract class AbstractConsoleDownloadMonitor - extends AbstractLogEnabled - implements MavenTransferListener -{ - private boolean showChecksumEvents = false; - - protected boolean showEvent( TransferEvent event ) - { - if ( event.getResource() == null ) - { - return true; - } - - String resource = event.getResource().getName(); - - if ( StringUtils.isBlank( resource ) ) - { - return true; - } - - if ( resource.endsWith( ".sha1" ) || resource.endsWith( ".md5" ) ) - { - return showChecksumEvents; - } - - return true; - } - - public void transferInitiated( TransferEvent transferEvent ) - { - if ( !showEvent( transferEvent ) ) - { - return; - } - - String message = transferEvent.getRequestType() == TransferEvent.REQUEST_PUT ? "Uploading" : "Downloading"; - - String url = transferEvent.getWagon().getRepository().getUrl(); - - // TODO: can't use getLogger() because this isn't currently instantiated as a component - System.out.println( message + ": " + url + "/" + transferEvent.getResource().getName() ); - } - - /** - * Do nothing - */ - public void transferStarted( TransferEvent transferEvent ) - { - // This space left intentionally blank - } - - /** - * Do nothing - */ - public void transferProgress( TransferEvent transferEvent, byte[] buffer, int length ) - { - // This space left intentionally blank - } - - public void transferCompleted( TransferEvent transferEvent ) - { - long contentLength = transferEvent.getResource().getContentLength(); - if ( contentLength != WagonConstants.UNKNOWN_LENGTH ) - { - String type = ( transferEvent.getRequestType() == TransferEvent.REQUEST_PUT ? "uploaded" : "downloaded" ); - String l = contentLength >= 1024 ? ( contentLength / 1024 ) + "K" : contentLength + "b"; - System.out.println( l + " " + type ); - } - } - - public void transferError( TransferEvent transferEvent ) - { - // TODO: can't use getLogger() because this isn't currently instantiated as a component - transferEvent.getException().printStackTrace(); - } - - /** - * Do nothing - */ - public void debug( String message ) - { - // TODO: can't use getLogger() because this isn't currently instantiated as a component -// getLogger().debug( message ); - } - - public boolean isShowChecksumEvents() - { - return showChecksumEvents; - } - - public void setShowChecksumEvents( boolean showChecksumEvents ) - { - this.showChecksumEvents = showChecksumEvents; - } -} \ No newline at end of file diff --git a/maven-cli/src/main/java/org/apache/maven/cli/BatchModeDownloadMonitor.java b/maven-cli/src/main/java/org/apache/maven/cli/BatchModeDownloadMonitor.java deleted file mode 100644 index 4c897fadac..0000000000 --- a/maven-cli/src/main/java/org/apache/maven/cli/BatchModeDownloadMonitor.java +++ /dev/null @@ -1,49 +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 org.apache.maven.wagon.events.TransferEvent; - -/** - * Console download progress meter. - * - * @author <a href="mailto:brett@apache.org">Brett Porter</a> - * @version $Id$ - */ -public class BatchModeDownloadMonitor - extends AbstractConsoleDownloadMonitor -{ - public void transferInitiated( TransferEvent transferEvent ) - { - if ( !showEvent( transferEvent ) ) - { - return; - } - - String message = transferEvent.getRequestType() == TransferEvent.REQUEST_PUT ? "Uploading" : "Downloading"; - - String url = transferEvent.getWagon().getRepository().getUrl(); - - System.out.println( "url = " + url ); - - // TODO: can't use getLogger() because this isn't currently instantiated as a component - System.out.println( message + ": " + url + "/" + transferEvent.getResource().getName() ); - } -} diff --git a/maven-cli/src/main/java/org/apache/maven/cli/CLIManager.java b/maven-cli/src/main/java/org/apache/maven/cli/CLIManager.java deleted file mode 100644 index fd1401eac9..0000000000 --- a/maven-cli/src/main/java/org/apache/maven/cli/CLIManager.java +++ /dev/null @@ -1,295 +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 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; - -import java.util.ArrayList; -import java.util.List; - -/** - * @author Jason van Zyl - * @version $Revision: 381114 $ - */ -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 REACTOR = 'r'; - - 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 NON_RECURSIVE = 'N'; - - public static final char UPDATE_SNAPSHOTS = 'U'; - - public static final char ACTIVATE_PROFILES = 'P'; - - public static final String FORCE_PLUGIN_UPDATES = "cpu"; - - public static final String FORCE_PLUGIN_UPDATES2 = "up"; - - public static final String SUPPRESS_PLUGIN_UPDATES = "npu"; - - public static final String SUPPRESS_PLUGIN_REGISTRY = "npr"; - - 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 FAIL_FAST = "ff"; - - public static final String FAIL_AT_END = "fae"; - - public static final String FAIL_NEVER = "fn"; - - private Options options; - - public CLIManager() - { - options = new Options(); - - options.addOption( OptionBuilder.withLongOpt( "file" ).hasArg().withDescription( - "Force the use of an alternate POM file." ).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( "help" ).withDescription( "Display help information" ).create( HELP ) ); - 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( "reactor" ).withDescription( - "Execute goals for project found in the reactor" ).create( REACTOR ) ); - 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 updated releases and 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( "check-plugin-updates" ).withDescription( - "Force upToDate check for any relevant registered plugins" ).create( FORCE_PLUGIN_UPDATES ) ); - options.addOption( OptionBuilder.withLongOpt( "update-plugins" ).withDescription( - "Synonym for " + FORCE_PLUGIN_UPDATES ).create( FORCE_PLUGIN_UPDATES2 ) ); - options.addOption( OptionBuilder.withLongOpt( "no-plugin-updates" ).withDescription( - "Suppress upToDate check for any relevant registered plugins" ).create( SUPPRESS_PLUGIN_UPDATES ) ); - - options.addOption(OptionBuilder.withLongOpt("no-snapshot-updates") - .withDescription("Supress SNAPSHOT updates") - .create(SUPRESS_SNAPSHOT_UPDATES)); - - options.addOption( OptionBuilder.withLongOpt( "no-plugin-registry" ).withDescription( - "Don't use ~/.m2/plugin-registry.xml for plugin versions" ).create( SUPPRESS_PLUGIN_REGISTRY ) ); - - 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( "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 ) ); - } - - 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 cleaned = new ArrayList(); - - StringBuffer currentArg = null; - - for ( int i = 0; i < args.length; i++ ) - { - String arg = args[i]; - -// System.out.println( "Processing raw arg: " + arg ); - - 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 ) - { -// System.out.println( "Flushing last arg buffer: \'" + currentArg + "\' to cleaned list." ); - cleaned.add( currentArg.toString() ); - } - - // start building an argument here. - currentArg = new StringBuffer( 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 ) - { -// System.out.println( "Adjusting argument already appended to the arg buffer." ); - currentArg.setLength( currentArg.length() - 1 ); - } - // otherwise, we trim the trailing " and append to the buffer. - else - { -// System.out.println( "Appending arg part: \'" + cleanArgPart + "\' with preceding space to arg buffer." ); - // TODO: introducing a space here...not sure what else to do but collapse whitespace - currentArg.append( ' ' ).append( cleanArgPart ); - } - -// System.out.println( "Flushing completed arg buffer: \'" + currentArg + "\' to cleaned list." ); - - // we're done with this argument, so add it. - cleaned.add( currentArg.toString() ); - } - else - { -// System.out.println( "appending cleaned arg: \'" + cleanArgPart + "\' directly to cleaned list." ); - // this is a simple argument...just add it. - cleaned.add( cleanArgPart ); - } - -// System.out.println( "Clearing arg buffer." ); - // the currentArg MUST be finished when this completes. - 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 ) - { - // append to the argument we're building, collapsing whitespace to a single space. - if ( currentArg != null ) - { -// System.out.println( "Append unquoted arg part: \'" + arg + "\' to arg buffer." ); - currentArg.append( ' ' ).append( arg ); - } - // this is a loner, just add it directly. - else - { -// System.out.println( "Append unquoted arg part: \'" + arg + "\' directly to cleaned list." ); - cleaned.add( arg ); - } - } - } - - // clean up. - if ( currentArg != null ) - { -// System.out.println( "Adding unterminated arg buffer: \'" + currentArg + "\' to cleaned list." ); - cleaned.add( currentArg.toString() ); - } - - int cleanedSz = cleaned.size(); - String[] cleanArgs = null; - - if ( cleanedSz == 0 ) - { - // if we didn't have any arguments to clean, simply pass the original array through - cleanArgs = args; - } - else - { -// System.out.println( "Cleaned argument list:\n" + cleaned ); - cleanArgs = (String[]) cleaned.toArray( new String[cleanedSz] ); - } - - return cleanArgs; - } - - - public void displayHelp() - { - System.out.println(); - - HelpFormatter formatter = new HelpFormatter(); - - formatter.printHelp( "mvn [options] [<goal(s)>] [<phase(s)>]", "\nOptions:", options, "\n" ); - } -} diff --git a/maven-cli/src/main/java/org/apache/maven/cli/ConsoleDownloadMonitor.java b/maven-cli/src/main/java/org/apache/maven/cli/ConsoleDownloadMonitor.java deleted file mode 100644 index 7c0cc39a42..0000000000 --- a/maven-cli/src/main/java/org/apache/maven/cli/ConsoleDownloadMonitor.java +++ /dev/null @@ -1,66 +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 org.apache.maven.wagon.WagonConstants; -import org.apache.maven.wagon.events.TransferEvent; - -/** - * Console download progress meter. - * - * @author <a href="mailto:brett@apache.org">Brett Porter</a> - * @version $Id$ - */ -public class ConsoleDownloadMonitor - extends AbstractConsoleDownloadMonitor -{ - private long complete; - - public void transferInitiated( TransferEvent transferEvent ) - { - super.transferInitiated( transferEvent ); - - complete = 0; - } - - public void transferProgress( TransferEvent transferEvent, byte[] buffer, int length ) - { - long total = transferEvent.getResource().getContentLength(); - complete += length; - - if ( !showEvent( transferEvent ) ) - { - return; - } - - // TODO [BP]: Sys.out may no longer be appropriate, but will \r work with getLogger()? - if ( total >= 1024 ) - { - System.out.print( - ( complete / 1024 ) + "/" + ( total == WagonConstants.UNKNOWN_LENGTH ? "?" : ( total / 1024 ) + "K" ) + - "\r" ); - } - else - { - System.out.print( complete + "/" + ( total == WagonConstants.UNKNOWN_LENGTH ? "?" : total + "b" ) + "\r" ); - } - } -} - diff --git a/maven-cli/src/main/java/org/apache/maven/cli/MavenCli.java b/maven-cli/src/main/java/org/apache/maven/cli/MavenCli.java deleted file mode 100644 index 2c3a4a6503..0000000000 --- a/maven-cli/src/main/java/org/apache/maven/cli/MavenCli.java +++ /dev/null @@ -1,497 +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 org.apache.commons.cli.CommandLine; -import org.apache.commons.cli.ParseException; -import org.apache.maven.MavenTransferListener; -import org.apache.maven.embedder.Configuration; -import org.apache.maven.embedder.DefaultConfiguration; -import org.apache.maven.embedder.MavenEmbedder; -import org.apache.maven.embedder.MavenEmbedderException; -import org.apache.maven.execution.DefaultMavenExecutionRequest; -import org.apache.maven.execution.MavenExecutionRequest; -import org.apache.maven.execution.MavenExecutionResult; -import org.codehaus.plexus.classworlds.ClassWorld; - -import java.io.File; -import java.io.IOException; -import java.io.InputStream; -import java.util.ArrayList; -import java.util.List; -import java.util.Properties; -import java.util.StringTokenizer; - -/** - * @author jason van zyl - * @version $Id$ - * @noinspection UseOfSystemOutOrSystemErr,ACCESS_STATIC_VIA_INSTANCE - */ -public class MavenCli -{ - public static final String LOCAL_REPO_PROPERTY = "maven.repo.local"; - - public static void main( String[] args ) - { - ClassWorld classWorld = new ClassWorld( "plexus.core", Thread.currentThread().getContextClassLoader() ); - - int result = main( args, classWorld ); - - System.exit( result ); - } - - /** @noinspection ConfusingMainMethod */ - public static int main( String[] args, - ClassWorld classWorld ) - { - // ---------------------------------------------------------------------- - // Setup the command line parser - // ---------------------------------------------------------------------- - - CLIManager cliManager = new CLIManager(); - - CommandLine commandLine; - try - { - commandLine = cliManager.parse( args ); - } - catch ( ParseException e ) - { - System.err.println( "Unable to parse command line options: " + e.getMessage() ); - cliManager.displayHelp(); - return 1; - } - - // TODO: maybe classworlds could handle this requirement... - if ( "1.4".compareTo( System.getProperty( "java.specification.version" ) ) > 0 ) - { - System.err.println( - "Sorry, but JDK 1.4 or above is required to execute Maven. You appear to be using " + "Java:" ); - System.err.println( - "java version \"" + System.getProperty( "java.version", "<unknown java version>" ) + "\"" ); - System.err.println( System.getProperty( "java.runtime.name", "<unknown runtime name>" ) + " (build " + - System.getProperty( "java.runtime.version", "<unknown runtime version>" ) + ")" ); - System.err.println( System.getProperty( "java.vm.name", "<unknown vm name>" ) + " (build " + - System.getProperty( "java.vm.version", "<unknown vm version>" ) + ", " + - System.getProperty( "java.vm.info", "<unknown vm info>" ) + ")" ); - - return 1; - } - - boolean debug = commandLine.hasOption( CLIManager.DEBUG ); - - boolean quiet = !debug && commandLine.hasOption( CLIManager.QUIET ); - - boolean showErrors = debug || commandLine.hasOption( CLIManager.ERRORS ); - - if ( showErrors ) - { - System.out.println( "+ Error stacktraces are turned on." ); - } - - // ---------------------------------------------------------------------- - // Process particular command line options - // ---------------------------------------------------------------------- - - if ( commandLine.hasOption( CLIManager.HELP ) ) - { - cliManager.displayHelp(); - return 0; - } - - if ( commandLine.hasOption( CLIManager.VERSION ) ) - { - showVersion(); - - return 0; - } - else if ( debug ) - { - showVersion(); - } - - // ---------------------------------------------------------------------- - // Now that we have everything that we need we will fire up plexus and - // bring the maven component to life for use. - // ---------------------------------------------------------------------- - - boolean interactive = true; - - if ( commandLine.hasOption( CLIManager.BATCH_MODE ) ) - { - interactive = false; - } - - // This is now off by default and should just be removed as it causes too many problems and - // is turned off in 2.0.4. - boolean usePluginRegistry = false; - - if ( commandLine.hasOption( CLIManager.SUPPRESS_PLUGIN_REGISTRY ) ) - { - usePluginRegistry = false; - } - - boolean pluginUpdateOverride = false; - - if ( commandLine.hasOption( CLIManager.FORCE_PLUGIN_UPDATES ) || - commandLine.hasOption( CLIManager.FORCE_PLUGIN_UPDATES2 ) ) - { - pluginUpdateOverride = true; - } - else if ( commandLine.hasOption( CLIManager.SUPPRESS_PLUGIN_UPDATES ) ) - { - pluginUpdateOverride = false; - } - - boolean noSnapshotUpdates = false; - if ( commandLine.hasOption( CLIManager.SUPRESS_SNAPSHOT_UPDATES ) ) - { - noSnapshotUpdates = true; - } - - // ---------------------------------------------------------------------- - // - // ---------------------------------------------------------------------- - - List goals = commandLine.getArgList(); - - boolean recursive = true; - - String reactorFailureBehaviour = null; - - 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; - } - - boolean offline = false; - - if ( commandLine.hasOption( CLIManager.OFFLINE ) ) - { - offline = true; - } - - boolean updateSnapshots = false; - - if ( commandLine.hasOption( CLIManager.UPDATE_SNAPSHOTS ) ) - { - updateSnapshots = true; - } - - String globalChecksumPolicy = null; - - if ( commandLine.hasOption( CLIManager.CHECKSUM_FAILURE_POLICY ) ) - { - // todo; log - System.out.println( "+ Enabling strict checksum verification on all artifact downloads." ); - - globalChecksumPolicy = MavenExecutionRequest.CHECKSUM_POLICY_FAIL; - } - else if ( commandLine.hasOption( CLIManager.CHECKSUM_WARNING_POLICY ) ) - { - // todo: log - System.out.println( "+ Disabling strict checksum verification on all artifact downloads." ); - - globalChecksumPolicy = MavenExecutionRequest.CHECKSUM_POLICY_WARN; - } - - File baseDirectory = new File( System.getProperty( "user.dir" ) ); - - // ---------------------------------------------------------------------- - // Profile Activation - // ---------------------------------------------------------------------- - - List activeProfiles = new ArrayList(); - - List inactiveProfiles = new ArrayList(); - - if ( commandLine.hasOption( CLIManager.ACTIVATE_PROFILES ) ) - { - String profilesLine = commandLine.getOptionValue( CLIManager.ACTIVATE_PROFILES ); - - StringTokenizer profileTokens = new StringTokenizer( profilesLine, "," ); - - while ( profileTokens.hasMoreTokens() ) - { - String profileAction = profileTokens.nextToken().trim(); - - if ( profileAction.startsWith( "-" ) ) - { - activeProfiles.add( profileAction.substring( 1 ) ); - } - else if ( profileAction.startsWith( "+" ) ) - { - inactiveProfiles.add( profileAction.substring( 1 ) ); - } - else - { - // TODO: deprecate this eventually! - activeProfiles.add( profileAction ); - } - } - } - - MavenTransferListener transferListener; - - if ( interactive ) - { - transferListener = new ConsoleDownloadMonitor(); - } - else - { - transferListener = new BatchModeDownloadMonitor(); - } - - transferListener.setShowChecksumEvents( false ); - - // This means to scan a directory structure for POMs and process them. - boolean useReactor = false; - - if ( commandLine.hasOption( CLIManager.REACTOR ) ) - { - useReactor = true; - } - - String alternatePomFile = null; - if ( commandLine.hasOption( CLIManager.ALTERNATE_POM_FILE ) ) - { - alternatePomFile = commandLine.getOptionValue( CLIManager.ALTERNATE_POM_FILE ); - } - - int loggingLevel; - - if ( debug ) - { - loggingLevel = MavenExecutionRequest.LOGGING_LEVEL_DEBUG; - } - else if ( quiet ) - { - // TODO: we need to do some more work here. Some plugins use sys out or log errors at info level. - // Ideally, we could use Warn across the board - loggingLevel = MavenExecutionRequest.LOGGING_LEVEL_ERROR; - // TODO:Additionally, we can't change the mojo level because the component key includes the version and it isn't known ahead of time. This seems worth changing. - } - else - { - loggingLevel = MavenExecutionRequest.LOGGING_LEVEL_INFO; - } - - Properties executionProperties = getExecutionProperties( commandLine ); - - MavenExecutionRequest request = new DefaultMavenExecutionRequest() - .setBaseDirectory( baseDirectory ) - .setGoals( goals ) - .setProperties( executionProperties ) // optional - .setReactorFailureBehavior( reactorFailureBehaviour ) // default: fail fast - .setRecursive( recursive ) // default: true - .setUseReactor( useReactor ) // default: false - .setPomFile( alternatePomFile ) // optional - .setShowErrors( showErrors ) // default: false - .setInteractiveMode( interactive ) // default: false - .setUsePluginRegistry( usePluginRegistry ) - .setOffline( offline ) // default: false - .setUsePluginUpdateOverride( pluginUpdateOverride ) - .addActiveProfiles( activeProfiles ) // optional - .addInactiveProfiles( inactiveProfiles ) // optional - .setLoggingLevel( loggingLevel ) // default: info - .setTransferListener( transferListener ) // default: batch mode which goes along with interactive - .setUpdateSnapshots( updateSnapshots ) // default: false - .setNoSnapshotUpdates( noSnapshotUpdates ) // default: false - .setGlobalChecksumPolicy( globalChecksumPolicy ); // default: warn - - File userSettingsFile; - - if ( commandLine.getOptionValue( CLIManager.ALTERNATE_USER_SETTINGS ) != null ) - { - userSettingsFile = new File( commandLine.getOptionValue( CLIManager.ALTERNATE_USER_SETTINGS ) ); - } - else - { - userSettingsFile = MavenEmbedder.DEFAULT_USER_SETTINGS_FILE; - } - - Configuration configuration = new DefaultConfiguration() - .setUserSettingsFile( userSettingsFile ) - .setGlobalSettingsFile( MavenEmbedder.DEFAULT_GLOBAL_SETTINGS_FILE ) - .setClassWorld( classWorld ); - - String localRepoProperty = executionProperties.getProperty( LOCAL_REPO_PROPERTY ); - - if ( localRepoProperty != null ) - { - configuration.setLocalRepository( new File( localRepoProperty ) ); - } - - MavenEmbedder mavenEmbedder; - - try - { - mavenEmbedder = new MavenEmbedder( configuration ); - } - catch ( MavenEmbedderException e ) - { - showFatalError( "Unable to start the embedded plexus container", e, showErrors ); - - return 1; - } - - - MavenExecutionResult result = mavenEmbedder.execute( request ); - - if ( result.hasExceptions() ) - { - showFatalError( "Unable to configure the Maven application", (Exception) result.getExceptions().get( 0 ), showErrors ); - - return 1; - } - - return 0; - } - - private static void showFatalError( String message, - Exception e, - boolean show ) - { - System.err.println( "FATAL ERROR: " + message ); - if ( show ) - { - System.err.println( "Error stacktrace:" ); - - e.printStackTrace(); - } - else - { - System.err.println( "For more information, run with the -e flag" ); - } - } - - private static void showError( String message, - Exception e, - boolean show ) - { - System.err.println( message ); - if ( show ) - { - System.err.println( "Error stacktrace:" ); - - e.printStackTrace(); - } - } - - private static void showVersion() - { - InputStream resourceAsStream; - try - { - Properties properties = new Properties(); - resourceAsStream = MavenCli.class.getClassLoader().getResourceAsStream( - "META-INF/maven/org.apache.maven/maven-core/pom.properties" ); - properties.load( resourceAsStream ); - - if ( properties.getProperty( "builtOn" ) != null ) - { - System.out.println( "Maven version: " + properties.getProperty( "version", "unknown" ) + " built on " + - properties.getProperty( "builtOn" ) ); - } - else - { - System.out.println( "Maven version: " + properties.getProperty( "version", "unknown" ) ); - } - } - catch ( IOException e ) - { - System.err.println( "Unable determine version from JAR file: " + e.getMessage() ); - } - } - - // ---------------------------------------------------------------------- - // System properties handling - // ---------------------------------------------------------------------- - - private static Properties getExecutionProperties( CommandLine commandLine ) - { - Properties executionProperties = new Properties(); - - // ---------------------------------------------------------------------- - // 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 ); - - for ( int i = 0; i < defStrs.length; ++i ) - { - setCliProperty( defStrs[i], executionProperties ); - } - } - - executionProperties.putAll( System.getProperties() ); - - return executionProperties; - } - - private static void setCliProperty( String property, - Properties executionProperties ) - { - 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 ).trim(); - } - - executionProperties.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 ); - } -} diff --git a/maven-cli/src/test/java/org/apache/maven/cli/AbstractConsoleDownloadMonitorTest.java b/maven-cli/src/test/java/org/apache/maven/cli/AbstractConsoleDownloadMonitorTest.java deleted file mode 100644 index a1df559ae9..0000000000 --- a/maven-cli/src/test/java/org/apache/maven/cli/AbstractConsoleDownloadMonitorTest.java +++ /dev/null @@ -1,129 +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 junit.framework.TestCase; -import org.apache.maven.MavenTransferListener; -import org.apache.maven.wagon.ConnectionException; -import org.apache.maven.wagon.authentication.AuthenticationException; -import org.apache.maven.wagon.events.TransferEvent; -import org.apache.maven.wagon.providers.file.FileWagon; -import org.apache.maven.wagon.repository.Repository; -import org.apache.maven.wagon.resource.Resource; - -import java.io.File; - -/** - * Test for {@link AbstractConsoleDownloadMonitor} - * - * @author <a href="mailto:carlos@apache.org">Carlos Sanchez</a> - * @version $Id$ - */ -public abstract class AbstractConsoleDownloadMonitorTest - extends TestCase -{ - private MavenTransferListener monitor; - - public AbstractConsoleDownloadMonitorTest() - { - super(); - } - - public void setMonitor( MavenTransferListener monitor ) - { - this.monitor = monitor; - } - - public MavenTransferListener getMonitor() - { - return monitor; - } - - public void testTransferInitiated() - throws Exception - { - monitor.transferInitiated( new TransferEventMock() ); - } - - public void testTransferStarted() - throws Exception - { - monitor.transferStarted( new TransferEventMock() ); - } - - public void testTransferProgress() - throws Exception - { - byte[] buffer = new byte[1000]; - monitor.transferProgress( new TransferEventMock(), buffer, 1000 ); - } - - public void testTransferCompleted() - throws Exception - { - monitor.transferCompleted( new TransferEventMock() ); - } - - public void testTransferError() - throws Exception - { - monitor.transferError( new TransferEventMock( new RuntimeException() ) ); - } - - public void testDebug() - throws Exception - { - monitor.debug( "msg" ); - } - - private class RepositoryMock - extends Repository - { - public RepositoryMock() - { - super(); - setId("mock"); - File basedir = new File(System.getProperty( "basedir", "." )); - setUrl( "file://" + basedir.getAbsolutePath() + "/target/" ); - } - } - - private class TransferEventMock - extends TransferEvent - { - public TransferEventMock() - throws ConnectionException, AuthenticationException - { - super( new FileWagon(), new RepositoryMock(), new Resource(), TransferEvent.TRANSFER_INITIATED, TransferEvent.REQUEST_GET ); - getResource().setContentLength( 100000 ); - getWagon().setRepository( new RepositoryMock() ); - getWagon().connect(); - } - - public TransferEventMock( Exception exception ) - throws ConnectionException, AuthenticationException - { - super( new FileWagon(), new RepositoryMock(), new Resource(), exception, TransferEvent.REQUEST_GET ); - getResource().setContentLength( 100000 ); - getWagon().setRepository( new RepositoryMock() ); - getWagon().connect(); - } - } -} \ No newline at end of file diff --git a/maven-cli/src/test/java/org/apache/maven/cli/BatchModeDownloadMonitorTest.java b/maven-cli/src/test/java/org/apache/maven/cli/BatchModeDownloadMonitorTest.java deleted file mode 100644 index 80b85f5c9a..0000000000 --- a/maven-cli/src/test/java/org/apache/maven/cli/BatchModeDownloadMonitorTest.java +++ /dev/null @@ -1,38 +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. - */ - -/** - * Test for {@link BatchModeDownloadMonitor} - * - * @author <a href="mailto:carlos@apache.org">Carlos Sanchez</a> - * @version $Id$ - */ -public class BatchModeDownloadMonitorTest - extends AbstractConsoleDownloadMonitorTest -{ - protected void setUp() - throws Exception - { - super.setMonitor( new BatchModeDownloadMonitor() ); - - super.setUp(); - } -} diff --git a/maven-cli/src/test/java/org/apache/maven/cli/ConsoleDownloadMonitorTest.java b/maven-cli/src/test/java/org/apache/maven/cli/ConsoleDownloadMonitorTest.java deleted file mode 100644 index 3e18731900..0000000000 --- a/maven-cli/src/test/java/org/apache/maven/cli/ConsoleDownloadMonitorTest.java +++ /dev/null @@ -1,39 +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. - */ - -/** - * Test for {@link ConsoleDownloadMonitor} - * - * @author <a href="mailto:carlos@apache.org">Carlos Sanchez</a> - * @version $Id$ - */ -public class ConsoleDownloadMonitorTest - extends AbstractConsoleDownloadMonitorTest -{ - - protected void setUp() - throws Exception - { - super.setMonitor( new ConsoleDownloadMonitor() ); - - super.setUp(); - } -} diff --git a/maven-cli/src/test/java/org/apache/maven/cli/MavenCliTest.java b/maven-cli/src/test/java/org/apache/maven/cli/MavenCliTest.java deleted file mode 100644 index b5be6c8744..0000000000 --- a/maven-cli/src/test/java/org/apache/maven/cli/MavenCliTest.java +++ /dev/null @@ -1,81 +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 junit.framework.TestCase; -import org.codehaus.plexus.classworlds.ClassWorld; -import org.codehaus.plexus.util.StringOutputStream; - -import java.io.OutputStream; -import java.io.PrintStream; - -/** - * Test method for 'org.apache.maven.cli.MavenCli.main(String[], ClassWorld)' - * - * @author <a href="mailto:vincent.siveton@gmail.com">Vincent Siveton</a> - * @version $Id$ - */ -public class MavenCliTest - extends TestCase -{ - /** - * Test that JDK 1.4 or above is required to execute MavenCli - * - * @throws Exception - */ - public void testMain() - throws Exception - { - ClassWorld classWorld = new ClassWorld(); - - PrintStream oldErr = System.err; - PrintStream oldOut = System.out; - - OutputStream errOS = new StringOutputStream(); - PrintStream err = new PrintStream( errOS ); - System.setErr( err ); - OutputStream outOS = new StringOutputStream(); - PrintStream out = new PrintStream( outOS ); - System.setOut( out ); - - try - { - System.setProperty( "java.specification.version", "1.0" ); - assertEquals( 1, MavenCli.main( new String[] { "-h" }, classWorld ) ); - System.setProperty( "java.specification.version", "1.1" ); - assertEquals( 1, MavenCli.main( new String[] { "-h" }, classWorld ) ); - System.setProperty( "java.specification.version", "1.2" ); - assertEquals( 1, MavenCli.main( new String[] { "-h" }, classWorld ) ); - System.setProperty( "java.specification.version", "1.3" ); - assertEquals( 1, MavenCli.main( new String[] { "-h" }, classWorld ) ); - System.setProperty( "java.specification.version", "1.4" ); - assertEquals( 0, MavenCli.main( new String[] { "-h" }, classWorld ) ); - System.setProperty( "java.specification.version", "1.5" ); - assertEquals( 0, MavenCli.main( new String[] { "-h" }, classWorld ) ); - System.setProperty( "java.specification.version", "1.6" ); - assertEquals( 0, MavenCli.main( new String[] { "-h" }, classWorld ) ); - } - finally - { - System.setErr( oldErr ); - System.setErr( oldOut ); - } - } -}