Skip to content

Commit 1fa3852

Browse files
committed
do not automatically add the snapshot repository
1 parent 2c2495d commit 1fa3852

File tree

2 files changed

+63
-1
lines changed

2 files changed

+63
-1
lines changed

src/main/groovy/io/openapiprocessor/gradle/OpenApiProcessorPlugin.groovy

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,8 @@ class OpenApiProcessorPlugin implements Plugin<Project> {
4949

5050
private void addOpenApiProcessorRepository (Project project) {
5151
def snapshots = project.findProperty ("openapi-processor-gradle.snapshots")
52-
if (snapshots != null && snapshots == false) {
52+
if (snapshots == null || snapshots != "true") {
53+
project.logger.debug("openapi-processor: snapshot repository disabled")
5354
return
5455
}
5556

@@ -61,6 +62,7 @@ class OpenApiProcessorPlugin implements Plugin<Project> {
6162
}
6263
}
6364
}
65+
project.logger.debug("openapi-processor: snapshot repository enabled")
6466
}
6567

6668
/**
Lines changed: 60 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,60 @@
1+
/*
2+
* Copyright 2023 https://github.com/openapi-processor/openapi-processor-gradle
3+
* PDX-License-Identifier: Apache-2.0
4+
*/
5+
6+
package io.openapiprocessor.gradle
7+
8+
9+
import io.openapiprocessor.gradle.support.PluginSpec
10+
11+
class SnapshotsRepositorySpec extends PluginSpec {
12+
13+
@Override
14+
String getBuildFileName () {
15+
'build.gradle'
16+
}
17+
18+
@Override
19+
String getBuildFile (String projectDir) {
20+
"""\
21+
plugins {
22+
id("io.openapiprocessor.openapi-processor")
23+
}
24+
""".stripIndent ()
25+
}
26+
27+
@Override
28+
List<String> getGradleArguments () {
29+
['--stacktrace', '--debug']
30+
}
31+
32+
void "does not add snapshot repository if ot enabled or disabled" () {
33+
when:
34+
def result = build("8.5", """\
35+
""".stripIndent())
36+
37+
then:
38+
result.output.contains("snapshot repository disabled")
39+
}
40+
41+
void "does not add snapshot repository if disabled" () {
42+
when:
43+
def result = build("8.5", """\
44+
openapi-processor-gradle.snapshots = false
45+
""".stripIndent())
46+
47+
then:
48+
result.output.contains("snapshot repository disabled")
49+
}
50+
51+
void "adds snapshot repository" () {
52+
when:
53+
def result = build("8.5", """\
54+
openapi-processor-gradle.snapshots = true
55+
""".stripIndent())
56+
57+
then:
58+
result.output.contains("snapshot repository enabled")
59+
}
60+
}

0 commit comments

Comments
 (0)