Skip to content

Commit 99564d3

Browse files
committed
feature: #14017 - add micronaut feature to forge
1 parent 9a1bd98 commit 99564d3

File tree

3 files changed

+87
-1
lines changed

3 files changed

+87
-1
lines changed
Lines changed: 72 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,72 @@
1+
/*
2+
* Licensed to the Apache Software Foundation (ASF) under one
3+
* or more contributor license agreements. See the NOTICE file
4+
* distributed with this work for additional information
5+
* regarding copyright ownership. The ASF licenses this file
6+
* to you under the Apache License, Version 2.0 (the
7+
* "License"); you may not use this file except in compliance
8+
* with the License. You may obtain a copy of the License at
9+
*
10+
* https://www.apache.org/licenses/LICENSE-2.0
11+
*
12+
* Unless required by applicable law or agreed to in writing,
13+
* software distributed under the License is distributed on an
14+
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
15+
* KIND, either express or implied. See the License for the
16+
* specific language governing permissions and limitations
17+
* under the License.
18+
*/
19+
package org.grails.forge.feature.micronaut;
20+
21+
import io.micronaut.core.annotation.NonNull;
22+
import jakarta.inject.Singleton;
23+
import org.grails.forge.application.ApplicationType;
24+
import org.grails.forge.application.generator.GeneratorContext;
25+
import org.grails.forge.build.dependencies.Dependency;
26+
import org.grails.forge.feature.Category;
27+
import org.grails.forge.feature.Feature;
28+
29+
@Singleton
30+
public class GrailsMicronaut implements Feature {
31+
32+
@Override
33+
@NonNull
34+
public String getName() {
35+
return "grails-micronaut";
36+
}
37+
38+
@Override
39+
public String getTitle() {
40+
return "Micronaut Support";
41+
}
42+
43+
@Override
44+
public String getDescription() {
45+
return "Adds support for Micronaut to Grails using the Spring Starter";
46+
}
47+
48+
@Override
49+
public boolean supports(ApplicationType applicationType) {
50+
return true;
51+
}
52+
53+
@Override
54+
public String getCategory() {
55+
return Category.SPRING;
56+
}
57+
58+
@Override
59+
public String getDocumentation() {
60+
return "https://micronaut-projects.github.io/micronaut-spring/latest/guide/#springBootStarter";
61+
}
62+
63+
@Override
64+
public void apply(GeneratorContext generatorContext) {
65+
generatorContext.addDependency(Dependency.builder()
66+
.groupId("org.apache.grails")
67+
.artifactId("grails-micronaut")
68+
.implementation());
69+
70+
generatorContext.getBuildProperties().put("micronautPlatformVersion", "4.9.2");
71+
}
72+
}
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@
1616
* specific language governing permissions and limitations
1717
* under the License.
1818
*/
19-
package org.grails.forge.feature.other;
19+
package org.grails.forge.feature.micronaut;
2020

2121
import io.micronaut.core.annotation.NonNull;
2222
import jakarta.inject.Singleton;

grails-forge/test-core/src/test/groovy/org/grails/forge/create/CreateAppSpec.groovy

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -81,6 +81,20 @@ class CreateAppSpec extends CommandSpec {
8181
'''.stripIndent(8)
8282
}
8383

84+
void "test create-app with micronaut feature"() {
85+
given:
86+
generateProject(OperatingSystem.MACOS_ARCH64, ['grails-micronaut'], ApplicationType.WEB)
87+
88+
def gradleProperties = new File(dir, 'gradle.properties')
89+
def gradleBuildFile = new File(dir, 'build.gradle')
90+
91+
expect:
92+
gradleProperties.exists()
93+
gradleProperties.text.contains('micronautPlatformVersion=4.9.2')
94+
gradleBuildFile.exists()
95+
gradleBuildFile.text.contains('implementation "org.apache.grails:grails-micronaut"')
96+
}
97+
8498
void "test create-app web-plugin creates a correct Application.groovy"() {
8599
given:
86100
generateProject(OperatingSystem.MACOS_ARCH64, [], ApplicationType.WEB_PLUGIN)

0 commit comments

Comments
 (0)