Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -0,0 +1,82 @@
/*
* Copyright 2017-2025 original authors
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* https://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package io.micronaut.starter.feature.other;

import io.micronaut.context.annotation.Requires;
import io.micronaut.starter.application.ApplicationType;
import io.micronaut.starter.application.generator.GeneratorContext;
import io.micronaut.starter.build.dependencies.Dependency;
import io.micronaut.starter.feature.Feature;
import jakarta.annotation.Nullable;
import jakarta.inject.Singleton;

import static io.micronaut.core.util.StringUtils.TRUE;
import static io.micronaut.starter.feature.Category.VALIDATION;

@Requires(property = "micronaut.starter.feature.jspecify.enabled", value = TRUE, defaultValue = TRUE)
@Singleton
public class Jspecify implements Feature {

public static final String NAME = "jspecify";
private static final Dependency JSPECIFY_DEPENDENCY =
Dependency.builder()
.groupId("org.jspecify")
.artifactId("jspecify")
.compile()
.build();

@Override
public String getName() {
return NAME;
}

@Override
public String getTitle() {
return "JSpecify Nullability Annotations";
}

@Override
public String getDescription() {
return "It adds the JSpecify Nullability Annotations dependency.";
}

@Nullable
@Override
public String getMicronautDocumentation() {
return "https://docs.micronaut.io/latest/guide/#jspecify";
}

@Nullable
@Override
public String getThirdPartyDocumentation() {
return "https://jspecify.dev/docs/start-here/";
}

@Override
public boolean supports(ApplicationType applicationType) {
return true;
}

@Override
public String getCategory() {
return VALIDATION;
}

@Override
public void apply(GeneratorContext generatorContext) {
generatorContext.addDependency(JSPECIFY_DEPENDENCY);
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
package io.micronaut.starter.feature.other

import io.micronaut.starter.ApplicationContextSpec
import io.micronaut.starter.BuildBuilder
import io.micronaut.starter.application.ApplicationType
import io.micronaut.starter.build.BuildTestVerifier
import io.micronaut.starter.fixture.CommandOutputFixture
import io.micronaut.starter.build.BuildTestUtil
import io.micronaut.starter.options.BuildTool
import spock.lang.Shared
import spock.lang.Subject

class JspecifySpec extends ApplicationContextSpec implements CommandOutputFixture{

@Shared
@Subject
Jspecify jspecify = beanContext.getBean(Jspecify)

void "jspecify supports application type #appType"(ApplicationType appType) {
expect:
jspecify.supports(appType)

where:
appType << ApplicationType.values()
}

void "jspecify dependencies #buildTool"(BuildTool buildTool) {
when:
String template = new BuildBuilder(beanContext, buildTool)
.features(['jspecify'])
.render()
BuildTestVerifier verifier = BuildTestUtil.verifier(buildTool, template)

then:
verifier.hasDependency("jspecify")

where:
buildTool << BuildTool.values()
}

void 'test README.md with feature jspecify contains links to docs'() {
when:
def output = generate(['jspecify'])
def readme = output["README.md"]

then:
readme
readme.contains("https://docs.micronaut.io/latest/guide/#jspecify")
readme.contains("https://jspecify.dev/docs/start-here/")
}

}
Loading