liquibase-maven-plugin/src/main/java/org/liquibase/maven/plugins/MavenUtils.java
public static ClassLoader getArtifactClassloader(MavenProject project,
                                                   boolean includeArtifact,
                                                   boolean includeTestOutputDirectory,
                                                   Class clazz,
                                                   Log log,
                                                   boolean verbose)
          throws MalformedURLException {
    if (verbose) {
      log.info("Loading artifacts into URLClassLoader");
    }
    Set<URI> uris = new HashSet<>();
    // Find project dependencies, including the transitive ones.
    Set dependencies = project.getArtifacts();
    if ((dependencies != null) && !dependencies.isEmpty()) {
        for (Iterator it = dependencies.iterator(); it.hasNext();) {
            addArtifact(uris, (Artifact) it.next(), log, verbose);
        }
    } else {
      log.info("there are no resolved artifacts for the Maven project.");
    }

    // Include the artifact for the actual maven project if requested
    if (includeArtifact) {
      // If the actual artifact can be resolved, then use that, otherwise use the build
      // directory as that should contain the files for this project that we will need to
      // run against. It is possible that the build directly could be empty, but we cannot
      // directly include the source and resources as the resources may require filtering
      // to replace any placeholders in the resource files.
      Artifact a = project.getArtifact();
      if (a.getFile() != null) {
        addArtifact(uris, a, log, verbose);
      } else {
        addFile(uris, new File(project.getBuild().getOutputDirectory()), log, verbose);
      }
    }
     if (includeTestOutputDirectory) {
        addFile(uris, new File(project.getBuild().getTestOutputDirectory()), log, verbose);
    }
    if (verbose) {
      log.info(LOG_SEPARATOR);
    }

    List<URI> uriList = new ArrayList<>(uris);
    URL[] urlArray = new URL[uris.size()];
    for (int i=0; i<uris.size(); i++ ) {
        urlArray[i] = uriList.get(i).toURL();
    }
    return new URLClassLoader(urlArray, clazz.getClassLoader());
  }
public static ClassLoader getArtifactClassloader(MavenProject project,
                                                   boolean includeArtifact,
                                                   boolean includeTestOutputDirectory,
                                                   Class clazz,
                                                   Log log,
                                                   boolean verbose)
          throws MalformedURLException {
    if (verbose) {
      log.info("Loading artifacts into URLClassLoader");
    }
    Set<URI> uris = new HashSet<>();
    // Find project dependencies, including the transitive ones.
    Set dependencies = project.getArtifacts();
    if ((dependencies != null) && !dependencies.isEmpty()) {
        for (Iterator it = dependencies.iterator(); it.hasNext();) {
            addArtifact(uris, (Artifact) it.next(), log, verbose);
        }
    } else {
      log.info("there are no resolved artifacts for the Maven project.");
    }

    // Include the artifact for the actual maven project if requested
    if (includeArtifact) {
      // If the actual artifact can be resolved, then use that, otherwise use the build
      // directory as that should contain the files for this project that we will need to
      // run against. It is possible that the build directly could be empty, but we cannot
      // directly include the source and resources as the resources may require filtering
      // to replace any placeholders in the resource files.
      Artifact a = project.getArtifact();
      if (a.getFile() != null) {
        addArtifact(uris, a, log, verbose);
      } else {
        addFile(uris, new File(project.getBuild().getOutputDirectory()), log, verbose);
      }
    }
     if (includeTestOutputDirectory) {
        addFile(uris, new File(project.getBuild().getTestOutputDirectory()), log, verbose);
    }
    if (verbose) {
      log.info(LOG_SEPARATOR);
    }

    List<URI> uriList = new ArrayList<>(uris);
    URL[] urlArray = new URL[uris.size()];
    for (int i=0; i<uris.size(); i++ ) {
        urlArray[i] = uriList.get(i).toURL();
    }
    return new URLClassLoader(urlArray, clazz.getClassLoader());
  }
public static ClassLoader getArtifactClassloader ( MavenProject project , boolean includeArtifact , boolean includeTestOutputDirectory , Class clazz , Log log , boolean verbose ) throws MalformedURLException { if ( verbose ) { log . info ( "Loading artifacts into URLClassLoader" ) ; } Set < URI > uris = new HashSet <> ( ) ; // Find project dependencies, including the transitive ones. Set dependencies = project . getArtifacts ( ) ; if ( ( dependencies != null ) && ! dependencies . isEmpty ( ) ) { for ( Iterator it = dependencies . iterator ( ) ; it . hasNext ( ) ; ) { addArtifact ( uris , ( Artifact ) it . next ( ) , log , verbose ) ; } } else { log . info ( "there are no resolved artifacts for the Maven project." ) ; } // Include the artifact for the actual maven project if requested if ( includeArtifact ) { // If the actual artifact can be resolved, then use that, otherwise use the build // directory as that should contain the files for this project that we will need to // run against. It is possible that the build directly could be empty, but we cannot // directly include the source and resources as the resources may require filtering // to replace any placeholders in the resource files. Artifact a = project . getArtifact ( ) ; if ( a . getFile ( ) != null ) { addArtifact ( uris , a , log , verbose ) ; } else { addFile ( uris , new File ( project . getBuild ( ) . getOutputDirectory ( ) ) , log , verbose ) ; } } if ( includeTestOutputDirectory ) { addFile ( uris , new File ( project . getBuild ( ) . getTestOutputDirectory ( ) ) , log , verbose ) ; } if ( verbose ) { log . info ( LOG_SEPARATOR ) ; } List < URI > uriList = new ArrayList <> ( uris ) ; URL [ ] urlArray = new URL [ uris . size ( ) ] ; for ( int i = 0 ; i < uris . size ( ) ; i ++ ) { urlArray [ i ] = uriList . get ( i ) . toURL ( ) ; } return new URLClassLoader ( urlArray , clazz . getClassLoader ( ) ) ; }
Obtains a {@link ClassLoader} that can load from the Maven project dependencies. If
the dependencies have not be resolved (or there are none) then this will just end up
delegating to the parent {@link ClassLoader} of this class.
@return The ClassLoader that can load the resolved dependencies for the Maven
project.
@throws java.net.MalformedURLException If any of the dependencies cannot be resolved
into a URL.
Obtains a {