Skip to content

Commit eb54e1e

Browse files
committed
All parameters are optional
1 parent 52df3e9 commit eb54e1e

File tree

1 file changed

+16
-5
lines changed

1 file changed

+16
-5
lines changed

src/main/java/org/openrewrite/java/dependencies/DependencyList.java

Lines changed: 16 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -45,21 +45,28 @@ public class DependencyList extends Recipe {
4545
transient MavenMetadataFailures metadataFailures = new MavenMetadataFailures(this);
4646

4747
@Option(displayName = "Scope",
48-
description = "The scope of the dependencies to include in the report.",
48+
description = "The scope of the dependencies to include in the report." +
49+
"Defaults to \"Compile\"",
4950
valid = {"Compile", "Runtime", "TestRuntime"},
51+
required = false,
5052
example = "Compile")
53+
@Nullable
5154
Scope scope;
5255

5356
@Option(displayName = "Include transitive dependencies",
5457
description = "Whether or not to include transitive dependencies in the report. " +
55-
"Defaults to including only direct dependencies.",
58+
"Defaults to including only direct dependencies." +
59+
"Defaults to false.",
60+
required = false,
5661
example = "true")
5762
boolean includeTransitive;
5863

5964
@Option(displayName = "Validate dependencies are resolvable",
6065
description = "When enabled the recipe will attempt to download every dependency it encounters, reporting on any failures. " +
61-
"This can be useful for identifying dependencies that have become unavailable since an LST was produced.",
66+
"This can be useful for identifying dependencies that have become unavailable since an LST was produced." +
67+
"Defaults to false.",
6268
valid = {"true", "false"},
69+
required = false,
6370
example = "true")
6471
boolean validateResolvable;
6572

@@ -93,7 +100,7 @@ public TreeVisitor<?, ExecutionContext> getVisitor() {
93100
m.findFirst(GradleProject.class)
94101
.filter(gradle -> seenGradleProjects.add(new GroupArtifactVersion(gradle.getGroup(), gradle.getName(), gradle.getVersion())))
95102
.ifPresent(gradle -> {
96-
GradleDependencyConfiguration conf = gradle.getConfiguration(scope.asGradleConfigurationName());
103+
GradleDependencyConfiguration conf = gradle.getConfiguration(scope().asGradleConfigurationName());
97104
if (conf != null) {
98105
for (ResolvedDependency dep : conf.getResolved()) {
99106
if (dep.getDepth() > 0) {
@@ -104,7 +111,7 @@ public TreeVisitor<?, ExecutionContext> getVisitor() {
104111
}
105112
});
106113
m.findFirst(MavenResolutionResult.class).ifPresent(maven -> {
107-
for (ResolvedDependency dep : maven.getDependencies().get(scope.asMavenScope())) {
114+
for (ResolvedDependency dep : maven.getDependencies().get(scope().asMavenScope())) {
108115
if (dep.getDepth() > 0) {
109116
continue;
110117
}
@@ -116,6 +123,10 @@ public TreeVisitor<?, ExecutionContext> getVisitor() {
116123
};
117124
}
118125

126+
private Scope scope() {
127+
return scope == null ? Scope.Compile : scope;
128+
}
129+
119130
private void insertDependency(ExecutionContext ctx, GradleProject gradle, Set<ResolvedGroupArtifactVersion> seen, ResolvedDependency dep, boolean direct) {
120131
if (!seen.add(dep.getGav())) {
121132
return;

0 commit comments

Comments
 (0)