use of io.crnk.gen.runtime.RuntimeClassLoaderFactory in project crnk-framework by crnk-project.
the class GenerateTypescriptTask method generate.
@TaskAction
public void generate() throws IOException {
Thread thread = Thread.currentThread();
ClassLoader contextClassLoader = thread.getContextClassLoader();
RuntimeClassLoaderFactory classLoaderFactory = new RuntimeClassLoaderFactory(getProject());
TSGeneratorConfig config = getConfig();
setupDefaultConfig(config);
URLClassLoader classloader = classLoaderFactory.createClassLoader(contextClassLoader);
try {
thread.setContextClassLoader(classloader);
runGeneration(classloader);
} finally {
// make sure to restore the classloader when leaving this task
thread.setContextClassLoader(contextClassLoader);
// dispose classloader
classloader.close();
}
}
use of io.crnk.gen.runtime.RuntimeClassLoaderFactory in project crnk-framework by crnk-project.
the class ForkedGenerateTypescriptTask method initClassPath.
private void initClassPath() {
RuntimeClassLoaderFactory classLoaderFactory = new RuntimeClassLoaderFactory(getProject());
Set<File> classpath = new HashSet<>();
classpath.addAll(classLoaderFactory.getProjectLibraries());
try {
classpath.add(Paths.get(classLoaderFactory.getPluginUrl().toURI()).toFile());
} catch (URISyntaxException e) {
throw new IllegalStateException(e);
}
Project project = getProject();
ConfigurableFileCollection files = project.files(classpath.toArray());
setClasspath(files);
}
use of io.crnk.gen.runtime.RuntimeClassLoaderFactory in project crnk-framework by crnk-project.
the class RuntimeClassoaderFactoryTest method setup.
@Before
public void setup() throws IOException {
// Deltaspike sometimes really wants to have a retarded JNDI context
System.setProperty(Context.INITIAL_CONTEXT_FACTORY, DummyInitialContextFactory.class.getName());
testProjectDir.newFolder("src", "main", "java");
File outputDir = testProjectDir.getRoot();
Project project = ProjectBuilder.builder().withName("crnk-gen-typescript-test").withProjectDir(outputDir).build();
project.setVersion("0.0.1");
project.getPluginManager().apply("com.moowork.node");
project.getPluginManager().apply(JavaPlugin.class);
project.getPluginManager().apply(TSGeneratorPlugin.class);
TSGeneratorExtension config = project.getExtensions().getByType(TSGeneratorExtension.class);
config.getRuntime().setConfiguration("test");
factory = new RuntimeClassLoaderFactory(project);
ClassLoader parentClassLoader = getClass().getClassLoader();
classLoader = factory.createClassLoader(parentClassLoader);
sharedClassLoader = (RuntimeClassLoaderFactory.SharedClassLoader) classLoader.getParent();
}
Aggregations