Start line:  
End line:  

Snippet Preview

Snippet HTML Code

Stack Overflow Questions
  /*
   * Copyright (c) 2002-2012 Alibaba Group Holding Limited.
   * All rights reserved.
   *
   * 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 com.alibaba.maven.plugin.springext;
 
 import java.io.File;
 import java.util.List;
 import java.util.Set;
 

Aggregator:
RequiresDependencyResolution:
test
 
 public abstract class AbstractSpringExtMojo extends AbstractMojo {
    
The maven project.

Parameter:
expression="${project}"
Required:
Readonly:
 
     private MavenProject project;

    

Parameter:
expression="${reactorProjects}"
Required:
Readonly:
 
     private Object projects;

    
If true, the <testOutputDirectory> and the dependencies of <scope>test<scope> will be put first on the runtime classpath.

Parameter:
expression="${noTestClasspath}" default-value="false"
 
     private boolean noTestClasspath;
 
     protected List<FilecreateClassPath() {
         return new DependencyLister().getDependencyFiles();
     }
 
     protected final MavenProject getCurrentProject() {
         return ;
     }
 
     protected final MavenProject[] getProjects() {
         if ( instanceof MavenProject[]) {
             return (MavenProject[]) // maven 3
         } else if ( instanceof Collection<?>) {
             Collection<MavenProjectmavenProjects = (Collection<MavenProject>) // maven 2
             return mavenProjects.toArray(new MavenProject[mavenProjects.size()]);
         } else {
             return new MavenProject[0];
         }
     }
 
     private class DependencyLister {
         private final Set<String>    dependencyFileNames = new HashSet<String>();
         private final List<File>     dependencyFiles     = new ArrayList<File>();
         private final String         currentDir          = new File("").getAbsolutePath() + .;
         private final List<String[]> displayClasspath    = new ArrayList<String[]>();
         private       int            width1              = -1;
         private       int            width2              = -1;
         private       int            width3              = -1;
 
         private List<FilegetDependencyFiles() {
             getLog().info("Setting up classpath ..."
                           + ( ? ""
                                              : "\n  (includes test files, " +
                                                "use \"-DnoTestClasspath\" to get rid of it)\n"));
 
             for (MavenProject project : getProjects()) {
                 String classesDirectory = project.getBuild().getOutputDirectory();
                 String testClassesDirectory = project.getBuild().getTestOutputDirectory();
 
                if (! && testClassesDirectory != null) {
                    addDependency(new File(testClassesDirectory), project.);
                }
                if (classesDirectory != null) {
                    addDependency(new File(classesDirectory), project.);
                }
            }
            .add(null);
            for (MavenProject project : getProjects()) {
                for (Iterator i = project.getArtifacts().iterator(); i.hasNext(); ) {
                    Artifact artifact = (Artifacti.next();
                    if (artifact != null && "jar".equals(artifact.getType())) {
                        String scope = artifact.getScope();
                        if (!artifact.isOptional() && !..equals(scope) && (! || !..equals(scope))) {
                            addDependency(artifact.getFile(), projectscope);
                        }
                    }
                }
            }
             += 2;
             += 2;
             += 2;
            String format = "%-" +  + "s %-" +  + "s %-" +  + "s";
            String sepLine = repeat('-') + " " + repeat('-') + " " + repeat('-');
            getLog().info(sepLine);
            getLog().info(String.format(format"Artifact""Project""Scope"));
            getLog().info(sepLine);
            for (String[] item : ) {
                if (item == null) {
                    getLog().info(sepLine);
                } else {
                    getLog().info(String.format(formatitem));
                }
            }
            getLog().info(sepLine);
            return ;
        }
        private String repeat(char cint count) {
            StringBuilder buf = new StringBuilder(count);
            for (int i = 0; i < counti++) {
                buf.append(c);
            }
            return buf.toString();
        }
        private void addDependency(File fileMavenProject projectString scope) {
            // file可能为null, unresolved
            if (file != null) {
                String fileName = file.getAbsolutePath();
                if (!.contains(fileName)) {
                    .add(file);
                    .add(fileName);
                    String displayName = fileName;
                    if (displayName.startsWith()) {
                        displayName = "." + . + displayName.substring(.length());
                    } else {
                        displayName = file.getName();
                    }
                    .add(new String[] { displayNameproject.getArtifactId(), scope });
                    if (displayName.length() > ) {
                         = displayName.length();
                    }
                    if (project.getArtifactId().length() > ) {
                         = project.getArtifactId().length();
                    }
                    if (scope.length() > ) {
                         = scope.length();
                    }
                }
            }
        }
    }
New to GrepCode? Check out our FAQ X