Generates a URL[] with the project class path (can be used by a
URLClassLoader)

@return the array of classpath URL's
@throws MojoExecutionException
434143
private URL[] generateClassPathUrls() throws MojoExecutionException {
        List<URL> urls = new ArrayList<URL>();
        URL url;
        try {
            for (Object element : getCompileClasspath()) {
                String path = (String) element;
                if (path.endsWith(".jar")) {
                    url = new URL("jar:" + new File(path).toURI().toString() + "!/");
                } else {
                    url = new File(path).toURI().toURL();
                }
                urls.add(url);
            }
        } catch (MalformedURLException e) {
            throw new MojoExecutionException("Could not set up classpath", e);
        }
        return urls.toArray(new URL[urls.size()]);
    }
71107
private static URL getClassPathURL(String resourceName, URL resourceURL) {
    try {
      if ("file".equals(resourceURL.getProtocol())) {
        String path = resourceURL.getFile();
        // Compute the directory container the class.
        int endIdx = path.length() - resourceName.length();
        if (endIdx > 1) {
          // If it is not the root directory, return the end index to remove the trailing '/'.
          endIdx--;
        }
        return new URL("file", "", -1, path.substring(0, endIdx));
      }
      if ("jar".equals(resourceURL.getProtocol())) {
        String path = resourceURL.getFile();
        return URI.create(path.substring(0, path.indexOf("!/"))).toURL();
      }
    } catch (MalformedURLException e) {
      throw Throwables.propagate(e);
    }
    throw new IllegalStateException("Unsupported class URL: " + resourceURL);
  }
167185
public function getCompilerPasses(): array
    {
        $mappingBagProvider = $this->getMappingBagProvider();

        return $mappingBagProvider instanceof MappingBagProvider
            ? array_merge(
                parent::getCompilerPasses(),
                [new MappingCompilerPass($mappingBagProvider)]
            )
            : parent::getCompilerPasses();
    }
1284961
public static String[] getAllClassPathNotInJar() {
        String[] allClassPath = getAllClassPaths();
        List<String> allClassPathNotInJar = new ArrayList<String>();
        for (String classPath : allClassPath) {
            if (classPath.endsWith("jar")) {
                continue;
            }
            allClassPathNotInJar.add(classPath);
        }
        return allClassPathNotInJar.toArray(new String[allClassPathNotInJar.size()]);
    }
1336037
public void execute() throws MojoExecutionException {
        ClassLoader classloader;
        
        try {
            classloader= createClassLoader();
        } catch (Exception e) {
            throw new MojoExecutionException("could not create classloader from dependencies", e);
        }
        
        AbstractConfiguration[] configurations;
        
        try {
            configurations= ConfigurationGenerator.execute(generatedSourceDirectory, applicationDefinition, classloader, getSLF4JLogger());
        } catch (Exception e) {
            throw new MojoExecutionException("could not generate the configurator", e);
        }
        
        getPluginContext().put(GENERATED_CONFIGURATIONS_KEY, configurations);
        project.addCompileSourceRoot(generatedSourceDirectory.getPath());
    }
449966
@Override
	public String[][] getBootpathExt(ILaunchConfiguration configuration)
			throws CoreException {
		final String[][] bootpathInfo = new String[3][];
		final IRuntimeClasspathEntry[] entries = getOrComputeUnresolvedSARLRuntimeClasspath(configuration);
		final List<IRuntimeClasspathEntry> bootEntriesPrepend = new ArrayList<>();
		final IRuntimeClasspathEntry jreEntry;
		final int index;
		final Pair<IRuntimeClasspathEntry, Integer> pair = getJreEntry(entries, bootEntriesPrepend);
		jreEntry = pair.getKey();
		index = pair.getValue().intValue();
		final IRuntimeClasspathEntry[] bootEntriesPrep = JavaRuntime
				.resolveRuntimeClasspath(
						bootEntriesPrepend
						.toArray(new IRuntimeClasspathEntry[bootEntriesPrepend
						                                    .size()]), configuration);
		String[] entriesPrep = null;
		if (bootEntriesPrep.length > 0) {
			entriesPrep = new String[bootEntriesPrep.length];
			for (int i = 0; i < bootEntriesPrep.length; i++) {
				entriesPrep[i] = bootEntriesPrep[i].getLocation();
			}
		}
		if (jreEntry != null) {
			getBootpathExtForJRE(configuration, entries, jreEntry, index, entriesPrep, bootEntriesPrep, bootpathInfo);
		} else {
			if (entriesPrep == null) {
				bootpathInfo[1] = new String[0];
			} else {
				bootpathInfo[1] = entriesPrep;
			}
		}
		return bootpathInfo;
	}
1025780
private void addRelevantPluginDependenciesToClasspath(Set<URL> path) throws MojoExecutionException {
        if (hasCommandlineArgs()) {
            arguments = parseCommandlineArgs();
        }

        try {
            Iterator<Artifact> iter = this.determineRelevantPluginDependencies().iterator();
            while (iter.hasNext()) {
                Artifact classPathElement = iter.next();

                // we must skip org.osgi.core, otherwise we get a
                // java.lang.NoClassDefFoundError: org.osgi.vendor.framework property not set
                if (classPathElement.getArtifactId().equals("org.osgi.core")) {
                    getLog().debug("Skipping org.osgi.core -> " + classPathElement.getGroupId() + "/" + classPathElement.getArtifactId() + "/" + classPathElement.getVersion());
                    continue;
                }

                getLog().debug("Adding plugin dependency artifact: " + classPathElement.getArtifactId()
                    + " to classpath");
                path.add(classPathElement.getFile().toURI().toURL());
            }
        } catch (MalformedURLException e) {
            throw new MojoExecutionException("Error during setting up classpath", e);
        }

    }
812522
private void generateVersionXml( Set<ResolvedJarResource> jarResources )
            throws MojoExecutionException
    {

        VersionXmlGenerator generator = new VersionXmlGenerator( getEncoding() );
        generator.generate( getLibDirectory(), jarResources );
    }
1091137
private static Path[] provisionClassPath(FileSystem fs, String applicationName, String[] classPathExclusions){
		String genJarProperty = System.getProperty(TezConstants.GENERATE_JAR);
		boolean generateJar = genJarProperty != null && Boolean.parseBoolean(genJarProperty);
		List<Path> provisionedPaths = new ArrayList<Path>();
		List<File> generatedJars = new ArrayList<File>();

		boolean confFromHadoopConfDir = generateConfigJarFromHadoopConfDir(fs, applicationName, provisionedPaths, generatedJars);

		TezConfiguration tezConf = new TezConfiguration(fs.getConf());
		boolean provisionTez = true;
		if (tezConf.get("tez.lib.uris") != null){
			provisionTez = false;
		}
		URL[] classpath = ((URLClassLoader) ClassLoader.getSystemClassLoader()).getURLs();
		for (URL classpathUrl : classpath) {
			File f = new File(classpathUrl.getFile());
			if (f.isDirectory()) {
				if (generateJar){
					String jarFileName = ClassPathUtils.generateJarFileName("application");
					f = doGenerateJar(f, jarFileName, generatedJars, "application");
				}
				else if (f.getName().equals("conf") && !confFromHadoopConfDir){
					String jarFileName = ClassPathUtils.generateJarFileName("conf_application");
					f = doGenerateJar(f, jarFileName, generatedJars, "configuration");
				}
				else {
					f = null;
				}
			}
			if (f != null){
				if (f.getName().startsWith("tez-") && !provisionTez){
					logger.info("Skipping provisioning of " + f.getName() + " since Tez libraries are already provisioned");
					continue;
				}
				String destinationFilePath = applicationName + "/" + f.getName();
				Path provisionedPath = new Path(fs.getHomeDirectory(), destinationFilePath);
				if (shouldProvision(provisionedPath.getName(), classPathExclusions)){
					try {
						provisioinResourceToFs(fs, new Path(f.getAbsolutePath()), provisionedPath);
						provisionedPaths.add(provisionedPath);
					} catch (Exception e) {
						logger.warn("Failed to provision " + provisionedPath + "; " + e.getMessage());
						if (logger.isDebugEnabled()){
							logger.trace("Failed to provision " + provisionedPath, e);
						}
					}
				}
			}

		}

		for (File generatedJar : generatedJars) {
			try {
				generatedJar.delete();
			} catch (Exception e) {
				logger.warn("Failed to delete generated jars", e);
			}
		}
		return provisionedPaths.toArray(new Path[]{});
	}
476986
public static List<URL> getClasspathURLs(ClassLoader loader) {
        List<URL> urls = Lists.newArrayList();
        if (loader != null) {
            final Enumeration<URL> resources;
            try {
                resources = loader.getResources("");
            } catch (IOException e) {
                throw new RuntimeException(e);
            }
            while (resources.hasMoreElements()) {
                URL location = resources.nextElement();
                urls.add(location);
            }
        }
        return urls;
    }
571900
public function getClassFiles()
    {
        foreach ($this->getFlattenedAutoloadConfiguration() as $configuration) {
            $normalizedAutoloadPath = $this->normalizeAutoloadPath($configuration['mappingType'], $configuration['namespace'], $configuration['classPath']);
            if (!is_dir($normalizedAutoloadPath)) {
                continue;
            }
            foreach ($this->getClassesInNormalizedAutoloadPath($normalizedAutoloadPath, $configuration['namespace']) as $className => $classPath) {
                yield $className => $classPath;
            }
        }
    }
787351
static String[] getClasspathClassNames() throws ZipException, IOException {
        final String[] classes = getClasspathFileNamesWithExtension(".class");
        for (int i = 0; i < classes.length; i++) {
            classes[i] = classes[i].substring(0, classes[i].length() - 6).replace("/", ".");
        }
        return classes;
    }
1265361
protected CommandLine getDotCommandLine(Set<String> generatedFiles)
			throws MojoExecutionException {
		CommandLine cl = new CommandLine(command);
		if (isVerbose()) {
			cl.addArgument("-v");
		}
		cl.addArgument("-Tpng");
		cl.addArgument("-O");
		for (String generatedFile : generatedFiles) {
			if (generatedFile.endsWith(".dot")) {
				cl.addArgument(generatedFile);
			}
		}
		if (isVerbose()) {
			getLog().info("Commandline: " + cl);
		}
		return cl;
	}
678018
protected String[] getClassPath() {
        //workaround for Groovy-835
        URL[] urls = getURLs();
        String[] ret = new String[urls.length];
        for (int i = 0; i < ret.length; i++) {
            ret[i] = urls[i].getFile();
        }
        return ret;
    }
975109
public function createClasspath()
    {
        if ($this->isReference()) {
            throw $this->tooManyAttributes();
        }
        if ($this->classpath === null) {
            $this->classpath = new Path($this->project);
        }

        return $this->classpath->createPath();
    }
81425
public function getAllClassNames()
    {
        if (!$this->paths) {
            throw MappingException::pathRequired();
        }
        $classes = [];
        $includedFiles = [];
        foreach ($this->paths as $path) {
            if (!is_dir($path)) {
                $this->logger->warning(sprintf(
                    'The given path "%s" seems to be incorrect. You need to edit victoire_core.base_paths configuration.',
                    $path
                ));
                continue;
            }
            $iterator = new \RegexIterator(
                new \RecursiveIteratorIterator(
                    new \RecursiveDirectoryIterator($path, \FilesystemIterator::SKIP_DOTS),
                    \RecursiveIteratorIterator::LEAVES_ONLY
                ),
                $this->regex,
                \RecursiveRegexIterator::GET_MATCH
            );
            foreach ($iterator as $file) {
                $sourceFile = realpath($file[0]);
                $includedFiles[] = $sourceFile;
            }
        }

        foreach ($includedFiles as $fileName) {
            $class = $this->getClassNameFromFile($fileName);
            if (class_exists($class) && !$this->isTransient($class)) {
                $classes[] = $class;
            }
        }

        return $classes;
    }
1099412
private void processClassPath() {
    URL[] classLoaderUrls =
        ((URLClassLoader) Thread.currentThread().getContextClassLoader()).getURLs();
    for (URL url : classLoaderUrls) {
      String path = url.getFile();
      if (path.matches(config.getJarInferRegexStripModelJarName())) {
        String name = path.replaceAll(config.getJarInferRegexStripModelJarName(), "$1");
        LOG(DEBUG, "DEBUG", "model jar name: " + name + "\tjar path: " + path);
        if (!mapModelJarLocations.containsKey(name))
          mapModelJarLocations.put(name, new LinkedHashSet<>());
        mapModelJarLocations.get(name).add(path);
      }
    }
  }