
scala_maven.TychoUtilities Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of scala-maven-plugin Show documentation
Show all versions of scala-maven-plugin Show documentation
The scala-maven-plugin (previously maven-scala-plugin) is used for compiling/testing/running/documenting scala code of any maven project.
package scala_maven;
import java.io.File;
import java.lang.reflect.InvocationTargetException;
import java.lang.reflect.Method;
import java.security.AccessController;
import java.security.PrivilegedActionException;
import java.security.PrivilegedExceptionAction;
import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
import org.apache.maven.project.MavenProject;
/**
* Grossly hacky utility class which provides the fully unpacked OSGi classpath
* (ie. including nested .jars) when used in the context of Tycho and Maven 3.
* The use of reflection is required to avoid wiring in a dependency on either
* Tycho or Maven 3.
*
* @author miles.sabin
*/
public class TychoUtilities {
private static final String TychoConstants_CTX_ECLIPSE_PLUGIN_CLASSPATH = "org.codehaus.tycho.TychoConstants/eclipsePluginClasspath";
private static final Method getContextValueMethod;
private static final Method getLocationsMethod;
static {
Method getContextValueMethod0 = null;
Method getLocationsMethod0 = null;
try {
final Class> mpClazz = MavenProject.class;
getContextValueMethod0 = AccessController.doPrivileged(new PrivilegedExceptionAction() {
@Override
public Method run() throws Exception {
Method m = mpClazz.getDeclaredMethod("getContextValue", String.class);
m.setAccessible(true);
return m;
}
});
final Class> cpeClazz = Class.forName("org.codehaus.tycho.ClasspathEntry");
getLocationsMethod0 = AccessController.doPrivileged(new PrivilegedExceptionAction() {
@Override
public Method run() throws Exception {
Method m = cpeClazz.getDeclaredMethod("getLocations");
m.setAccessible(true);
return m;
}
});
} catch (ClassNotFoundException ex) {
} catch (PrivilegedActionException ex) {
}
getContextValueMethod = getContextValueMethod0;
getLocationsMethod = getLocationsMethod0;
}
@SuppressWarnings("unchecked")
public static List addOsgiClasspathElements(MavenProject project, List defaultClasspathElements) {
if (getLocationsMethod == null) {
return defaultClasspathElements;
}
List
© 2015 - 2025 Weber Informatics LLC | Privacy Policy