Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

FIX: Cannot use multiple forkProperties #39

Merged
merged 1 commit into from
Feb 24, 2021
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
Expand Up @@ -36,7 +36,10 @@ open class OpenApiGradlePlugin : Plugin<Project> {
if (extension.forkProperties.isPresent) {
val element = extension.forkProperties.get()
if (element is String) {
command.add(element)
val elements = element
.split("-D")
.map { "-D${it.trim()}" }
command.addAll(elements)
} else if (element is Properties) {
element.toMap().map { r -> "-D${r.key}=${r.value}" }.forEach { p -> command.add(p) }
} else {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -126,7 +126,7 @@ class OpenApiGradlePluginTest {
fun `using forked properties`() {
buildFile.writeText("""$baseBuildGradle
openApi{
forkProperties = "-Dspring.profiles.active=multiple-endpoints"
forkProperties = "-Dspring.profiles.active=multiple-endpoints -Dsome.second.property=someValue"
}
""".trimMargin())

Expand All @@ -139,7 +139,7 @@ class OpenApiGradlePluginTest {
assertEquals(TaskOutcome.SUCCESS, getTaskByName(result, "generateOpenApiDocs")?.outcome)

val openApiJsonFile = File(projectBuildDir, DEFAULT_OPEN_API_FILE_NAME)
assertOpenApiJsonFileIsAsExpected(openApiJsonFile, 2)
assertOpenApiJsonFileIsAsExpected(openApiJsonFile, 3)
}

@Test
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
package com.example.demo.endpoints;

import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty;

@ConditionalOnProperty(value = {"some.second.property"}, havingValue = "someValue")
@RestController("/conditional")
public class ConditionalController {

@GetMapping("/conditional")
public String conditional(){
return "conditional";
}
}