Search in sources :

Example 1 with TSGeneratorConfig

use of io.crnk.gen.typescript.TSGeneratorConfig in project crnk-framework by crnk-project.

the class RuntimeClassLoaderFactory method getProjectLibraries.

public Set<File> getProjectLibraries() {
    Set<File> classpath = new HashSet<>();
    SourceSetContainer sourceSets = (SourceSetContainer) project.getProperties().get("sourceSets");
    if (sourceSets != null) {
        SortedSet<String> availableSourceSetNames = sourceSets.getNames();
        for (String sourceSetName : Arrays.asList("main", "test", "integrationTest")) {
            if (availableSourceSetNames.contains(sourceSetName)) {
                SourceSet sourceSet = sourceSets.getByName(sourceSetName);
                classpath.add(sourceSet.getOutput().getClassesDir());
            }
        }
    }
    // add  dependencies from configured gradle configuration to url (usually test or integrationTest)
    TSGeneratorConfig generatorConfiguration = project.getExtensions().getByType(TSGeneratorConfig.class);
    String configurationName = generatorConfiguration.getRuntime().getConfiguration();
    ConfigurationContainer configurations = project.getConfigurations();
    Configuration runtimeConfiguration = configurations.findByName(configurationName + "Runtime");
    if (runtimeConfiguration == null) {
        runtimeConfiguration = configurations.getByName(configurationName);
    }
    classpath.addAll(runtimeConfiguration.getFiles());
    for (File file : classpath) {
        LOGGER.debug("classpath entry: {}", file);
    }
    return classpath;
}
Also used : SourceSet(org.gradle.api.tasks.SourceSet) TSNpmConfiguration(io.crnk.gen.typescript.TSNpmConfiguration) Configuration(org.gradle.api.artifacts.Configuration) TSRuntimeConfiguration(io.crnk.gen.typescript.TSRuntimeConfiguration) TSGeneratorConfig(io.crnk.gen.typescript.TSGeneratorConfig) ConfigurationContainer(org.gradle.api.artifacts.ConfigurationContainer) File(java.io.File) SourceSetContainer(org.gradle.api.tasks.SourceSetContainer) HashSet(java.util.HashSet)

Example 2 with TSGeneratorConfig

use of io.crnk.gen.typescript.TSGeneratorConfig in project crnk-framework by crnk-project.

the class GeneratorExecutor method run.

public void run(File outputDir) {
    TSGeneratorConfig config = new TSGeneratorConfig();
    config.setGenerateExpressions(true);
    config.getNpm().setPackagingEnabled(false);
    config.getNpm().setPackageName("@crnk/angular-ngrx");
    config.getNpm().getPackageMapping().put(MetaElement.class.getPackage().getName(), "@crnk/angular-ngrx/meta");
    MetaModule metaModule = MetaModule.create();
    metaModule.addMetaProvider(new ResourceMetaProvider());
    CrnkBoot boot = new CrnkBoot();
    boot.setServiceDiscovery(new EmptyServiceDiscovery());
    boot.addModule(metaModule);
    boot.boot();
    TSGenerator generator = new TSGenerator(outputDir, metaModule.getLookup(), config);
    try {
        generator.run();
    } catch (IOException e) {
        throw new IllegalStateException(e);
    }
}
Also used : CrnkBoot(io.crnk.core.boot.CrnkBoot) TSGenerator(io.crnk.gen.typescript.internal.TSGenerator) TSGeneratorConfig(io.crnk.gen.typescript.TSGeneratorConfig) ResourceMetaProvider(io.crnk.meta.provider.resource.ResourceMetaProvider) IOException(java.io.IOException) MetaModule(io.crnk.meta.MetaModule) EmptyServiceDiscovery(io.crnk.core.module.discovery.EmptyServiceDiscovery)

Aggregations

TSGeneratorConfig (io.crnk.gen.typescript.TSGeneratorConfig)2 CrnkBoot (io.crnk.core.boot.CrnkBoot)1 EmptyServiceDiscovery (io.crnk.core.module.discovery.EmptyServiceDiscovery)1 TSNpmConfiguration (io.crnk.gen.typescript.TSNpmConfiguration)1 TSRuntimeConfiguration (io.crnk.gen.typescript.TSRuntimeConfiguration)1 TSGenerator (io.crnk.gen.typescript.internal.TSGenerator)1 MetaModule (io.crnk.meta.MetaModule)1 ResourceMetaProvider (io.crnk.meta.provider.resource.ResourceMetaProvider)1 File (java.io.File)1 IOException (java.io.IOException)1 HashSet (java.util.HashSet)1 Configuration (org.gradle.api.artifacts.Configuration)1 ConfigurationContainer (org.gradle.api.artifacts.ConfigurationContainer)1 SourceSet (org.gradle.api.tasks.SourceSet)1 SourceSetContainer (org.gradle.api.tasks.SourceSetContainer)1