Skip to content

Commit 8df446b

Browse files
committed
Make Gradle dependencies sorted and grouped by scope and dependency
Closes gh-1283
1 parent badedbe commit 8df446b

File tree

2 files changed

+13
-3
lines changed

2 files changed

+13
-3
lines changed

grace-shell/src/main/groovy/org/grails/cli/profile/commands/CreateAppCommand.groovy

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1062,7 +1062,7 @@ class CreateAppCommand extends ArgumentCompletingCommand implements ProfileRepos
10621062
List<GradleDependency> gradleDependencies = convertToGradleDependencies(dependencies, grailsVersion)
10631063

10641064
String dependenciesString = gradleDependencies
1065-
.sort({ GradleDependency dep -> dep.scope })
1065+
.sort({ GradleDependency dep1, GradleDependency dep2 -> dep1 <=> dep2 })
10661066
.collect({ GradleDependency dep -> dep.toString(4) })
10671067
.unique()
10681068
.join(ln)

grace-shell/src/main/groovy/org/grails/cli/profile/commands/io/GradleDependency.groovy

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2017-2024 the original author or authors.
2+
* Copyright 2017-2025 the original author or authors.
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.
@@ -18,7 +18,7 @@ package org.grails.cli.profile.commands.io
1818
import org.eclipse.aether.artifact.Artifact
1919
import org.eclipse.aether.graph.Dependency
2020

21-
class GradleDependency {
21+
class GradleDependency implements Comparable<GradleDependency> {
2222

2323
static final Map<String, String> SCOPE_MAP = [
2424
console: 'console',
@@ -92,4 +92,14 @@ class GradleDependency {
9292
scope
9393
}
9494

95+
String getDependency() {
96+
dependency
97+
}
98+
99+
@Override
100+
int compareTo(GradleDependency d) {
101+
int s = this.scope <=> d.scope
102+
(s == 0) ? this.dependency <=> d.dependency : s
103+
}
104+
95105
}

0 commit comments

Comments
 (0)