/*-
 * Copyright (c) 2012-2013 Red Hat, Inc.
 *
 * 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.
 */
package org.fedoraproject.maven.tools.resolver;

import java.io.File;
import java.util.LinkedList;
import java.util.List;
import java.util.Map;
import java.util.TreeMap;

import org.fedoraproject.maven.resolver.DefaultResolver;
import org.fedoraproject.maven.resolver.Resolver;
import org.fedoraproject.maven.resolver.SystemResolver;
import org.fedoraproject.maven.utils.StringSplitter;

import com.beust.jcommander.DynamicParameter;
import com.beust.jcommander.JCommander;
import com.beust.jcommander.Parameter;
import com.beust.jcommander.ParameterException;

public class ResolverCli
{
    @Parameter
    public List<String> parameters = new LinkedList<>();

    @Parameter( names = { "-h", "--help" }, help = true, description = "Display usage information" )
    private boolean help;

    @Parameter( names = { "-X", "--debug" }, description = "Display debugging information" )
    public boolean debug = false;

    @DynamicParameter( names = "-D", description = "Define system property" )
    public Map<String, String> defines = new TreeMap<>();

    public ResolverCli( String[] args )
    {
        try
        {
            JCommander jcomm = new JCommander( this, args );
            jcomm.setProgramName( "xmvn-resolve" );

            if ( help )
            {
                System.out.println( "xmvn-resolve: Resolve artifacts from system repository" );
                System.out.println();
                jcomm.usage();
                System.exit( 0 );
            }

            for ( String param : defines.keySet() )
                System.setProperty( param, defines.get( param ) );
            if ( debug )
                System.setProperty( "xmvn.debug", "true" );
        }
        catch ( ParameterException e )
        {
            System.err.println( e.getMessage() + ". Specify -h for usage." );
            System.exit( 1 );
        }
    }

    public void run()
    {
        Resolver resolver = new DefaultResolver();

        for ( String s : parameters )
        {
            String[] tok = StringSplitter.split( s, 4, ':' );
            File file = resolver.resolve( tok[0], tok[1], tok[2], tok[3] );
            System.out.println( file );
        }

        SystemResolver.printInvolvedPackages();
    }

    public static void main( String[] args )
    {
        ResolverCli cli = new ResolverCli( args );
        cli.run();
    }
}

@@ -670,16 +670,71 @@
 o.File;%0A
+import java.util.ArrayList;%0Aimport java.util.Iterator;%0A
 import j
@@ -750,24 +750,24 @@
 LinkedList;%0A
-
 import java.
@@ -1573,16 +1573,183 @@
 false;%0A%0A
+    @Parameter( names = %7B %22-c%22, %22--classpath%22 %7D, description = %22Use colon instead of new line to separate resolved artifacts%22 )%0A    public boolean classpath = false;%0A%0A
     @Dyn
@@ -2691,32 +2691,529 @@
        %7D%0A    %7D%0A%0A
+    private void printResult( List%3CFile%3E result )%0A    %7B%0A        if ( classpath )%0A        %7B%0A            Iterator%3CFile%3E it = result.iterator();%0A            System.out.print( it.next() );%0A            while ( it.hasNext() )%0A            %7B%0A                System.out.print( ':' );%0A                System.out.print( it.next() );%0A            %7D%0A            System.out.println();%0A        %7D%0A        else%0A        %7B%0A            for ( File f : result )%0A                System.out.println( f );%0A        %7D%0A    %7D%0A%0A
     public void 
@@ -3274,16 +3274,63 @@
 olver();
+%0A        List%3CFile%3E result = new ArrayList%3C%3E();
 %0A%0A      
@@ -3521,34 +3521,26 @@
         
-System.out.println
+result.add
 ( file )
@@ -3544,32 +3544,101 @@
 e );%0A        %7D%0A%0A
+        if ( !result.isEmpty() )%0A            printResult( result );%0A%0A
         SystemRe

Add option for xmvn-resolve to use colon as result separator