View Javadoc

1   package org.apache.maven.cli.compat;
2   
3   /*
4    * Licensed to the Apache Software Foundation (ASF) under one
5    * or more contributor license agreements.  See the NOTICE file
6    * distributed with this work for additional information
7    * regarding copyright ownership.  The ASF licenses this file
8    * to you under the Apache License, Version 2.0 (the
9    * "License"); you may not use this file except in compliance
10   * with the License.  You may obtain a copy of the License at
11   *
12   *   http://www.apache.org/licenses/LICENSE-2.0
13   *
14   * Unless required by applicable law or agreed to in writing,
15   * software distributed under the License is distributed on an
16   * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
17   * KIND, either express or implied.  See the License for the
18   * specific language governing permissions and limitations
19   * under the License.
20   */
21  
22  import org.apache.maven.cli.MavenCli;
23  import org.codehaus.classworlds.ClassWorld;
24  
25  /**
26   * Main class used to shield the user from the rest of Maven in the event the user is using JDK < 1.5.
27   * 
28   * @since 2.2.0
29   */
30  public class CompatibleMain
31  {
32  
33      public static void main( String[] args )
34      {
35          ClassWorld classWorld = new ClassWorld( "plexus.core", Thread.currentThread().getContextClassLoader() );
36  
37          int result = main( args, classWorld );
38  
39          System.exit( result );
40      }
41  
42      /**
43       * @noinspection ConfusingMainMethod
44       */
45      public static int main( String[] args, ClassWorld classWorld )
46      {
47          // ----------------------------------------------------------------------
48          // Setup the command line parser
49          // ----------------------------------------------------------------------
50          
51          String javaVersion = System.getProperty( "java.specification.version", "1.5" );
52          if ( "1.4".equals( javaVersion ) || "1.3".equals( javaVersion ) 
53               || "1.2".equals( javaVersion )  || "1.1".equals( javaVersion ) )
54          {
55  	        System.out.println( "Java specification version: " + javaVersion );
56              System.err.println( "This release of Maven requires Java version 1.5 or greater." );
57              return 1;
58          }
59          
60          return MavenCli.main( args, classWorld );
61      }
62  }