use of io.micronaut.starter.options.BuildTool in project micronaut-starter by micronaut-projects.
the class Gradle method apply.
@Override
public void apply(GeneratorContext generatorContext) {
ClassLoader classLoader = Thread.currentThread().getContextClassLoader();
generatorContext.addTemplate("gradleWrapperJar", new BinaryTemplate(WRAPPER_JAR, classLoader.getResource(WRAPPER_JAR)));
generatorContext.addTemplate("gradleWrapperProperties", new URLTemplate(WRAPPER_PROPS, classLoader.getResource(WRAPPER_PROPS)));
generatorContext.addTemplate("gradleWrapper", new URLTemplate("gradlew", classLoader.getResource("gradle/gradlew"), true));
generatorContext.addTemplate("gradleWrapperBat", new URLTemplate("gradlew.bat", classLoader.getResource("gradle/gradlew.bat"), true));
BuildTool buildTool = generatorContext.getBuildTool();
generatorContext.addTemplate("build", new RockerTemplate(buildTool.getBuildFileName(), buildGradle.template(generatorContext.getApplicationType(), generatorContext.getProject(), generatorContext.getFeatures(), buildTool == BuildTool.GRADLE_KOTLIN)));
generatorContext.addTemplate("gitignore", new RockerTemplate(".gitignore", gitignore.template()));
generatorContext.addTemplate("projectProperties", new RockerTemplate("gradle.properties", gradleProperties.template(generatorContext.getBuildProperties().getProperties())));
String settingsFile = buildTool == BuildTool.GRADLE ? "settings.gradle" : "settings.gradle.kts";
generatorContext.addTemplate("gradleSettings", new RockerTemplate(settingsFile, settingsGradle.template(generatorContext.getProject())));
}
use of io.micronaut.starter.options.BuildTool in project micronaut-starter by micronaut-projects.
the class AbstractFunctionFeature method applyFunction.
protected void applyFunction(GeneratorContext generatorContext, ApplicationType type) {
BuildTool buildTool = generatorContext.getBuildTool();
generatorContext.addHelpTemplate(new RockerWritable(readmeTemplate(generatorContext, generatorContext.getProject(), buildTool)));
if (type == ApplicationType.DEFAULT) {
final String className = StringUtils.capitalize(generatorContext.getProject().getPropertyName());
Project project = generatorContext.getProject().withClassName(className);
Language language = generatorContext.getLanguage();
String sourceFile = generatorContext.getSourcePath("/{packagePath}/" + className + "Controller");
switch(language) {
case GROOVY:
generatorContext.addTemplate("function", new RockerTemplate(sourceFile, groovyControllerTemplate(project)));
break;
case KOTLIN:
generatorContext.addTemplate("function", new RockerTemplate(sourceFile, kotlinControllerTemplate(project)));
break;
case JAVA:
default:
generatorContext.addTemplate("function", new RockerTemplate(sourceFile, javaControllerTemplate(project)));
break;
}
applyTestTemplate(generatorContext, project, className + getTestSuffix(type));
}
}
use of io.micronaut.starter.options.BuildTool in project micronaut-starter by micronaut-projects.
the class AbstractAzureFunction method apply.
@Override
public void apply(GeneratorContext generatorContext) {
ClassLoader classLoader = Thread.currentThread().getContextClassLoader();
ApplicationType type = generatorContext.getApplicationType();
generatorContext.addTemplate("host.json", new URLTemplate("host.json", classLoader.getResource("functions/azure/host.json")));
generatorContext.addTemplate("local.settings.json", new URLTemplate("local.settings.json", classLoader.getResource("functions/azure/local.settings.json")));
BuildTool buildTool = generatorContext.getBuildTool();
Project project = generatorContext.getProject();
if (buildTool == BuildTool.MAVEN) {
BuildProperties props = generatorContext.getBuildProperties();
props.put("functionAppName", project.getName());
props.put("functionAppRegion", "westus");
props.put("functionResourceGroup", "java-functions-group");
props.put("stagingDirectory", "${project.build.directory}/azure-functions/${functionAppName}");
}
addFunctionTemplate(generatorContext, project);
applyFunction(generatorContext, type);
}
Aggregations