protected int addClasspathElements ( Collection < ? > elements , URL [ ] urls , int startPosition ) throws MojoExecutionException { for ( Object object : elements ) { try { if ( object instanceof Artifact ) { urls [ startPosition ] = ( ( Artifact ) object ) . getFile ( ) . toURI ( ) . toURL ( ) ; } else if ( object instanceof Resource ) { urls [ startPosition ] = new File ( ( ( Resource ) object ) . getDirectory ( ) ) . toURI ( ) . toURL ( ) ; } else { urls [ startPosition ] = new File ( ( String ) object ) . toURI ( ) . toURL ( ) ; } } catch ( MalformedURLException e ) { throw new MojoExecutionException ( "Failed to convert original classpath element " + object + " to URL." , e ) ; } startPosition ++ ; } return startPosition ; }
Add classpath elements to a classpath URL set