Search in sources :

Example 1 with LintCheckPluginException

use of uk.gov.justice.raml.maven.lintchecker.LintCheckPluginException in project microservice_framework by CJSCommonPlatform.

the class HandlerScanner method getHandlesActions.

public Collection<String> getHandlesActions(final MavenProject project) throws LintCheckPluginException {
    final ClassLoader originalClassLoader = Thread.currentThread().getContextClassLoader();
    try {
        final Set<URL> urls = new HashSet<>();
        for (String element : project.getRuntimeClasspathElements()) {
            urls.add(new File(element).toURI().toURL());
        }
        final ClassLoader contextClassLoader = URLClassLoader.newInstance(urls.toArray(new URL[0]), originalClassLoader);
        Thread.currentThread().setContextClassLoader(contextClassLoader);
    } catch (DependencyResolutionRequiredException | MalformedURLException e) {
        throw new LintCheckPluginException("Could not set up class loader", e);
    }
    final List<String> actions = scanForActions(configureReflections());
    Thread.currentThread().setContextClassLoader(originalClassLoader);
    return actions;
}
Also used : MalformedURLException(java.net.MalformedURLException) DependencyResolutionRequiredException(org.apache.maven.artifact.DependencyResolutionRequiredException) URLClassLoader(java.net.URLClassLoader) File(java.io.File) URL(java.net.URL) HashSet(java.util.HashSet) LintCheckPluginException(uk.gov.justice.raml.maven.lintchecker.LintCheckPluginException)

Aggregations

File (java.io.File)1 MalformedURLException (java.net.MalformedURLException)1 URL (java.net.URL)1 URLClassLoader (java.net.URLClassLoader)1 HashSet (java.util.HashSet)1 DependencyResolutionRequiredException (org.apache.maven.artifact.DependencyResolutionRequiredException)1 LintCheckPluginException (uk.gov.justice.raml.maven.lintchecker.LintCheckPluginException)1