sdedic commented on a change in pull request #2879:
URL: https://github.com/apache/netbeans/pull/2879#discussion_r613265981
##########
File path:
extide/gradle/src/org/netbeans/modules/gradle/api/execute/GradleDistributionManager.java
##########
@@ -308,6 +313,46 @@ public GradleDistribution defaultDistribution() {
return ret;
}
+ /**
+ * Lists all the {@link GradleDistribution}s available on the Gradle Home
+ * of this distribution manager. It looks for the
<code>$GRADLE_HOME/wrapper/dists</code>
+ * directory for already downloaded distributions.
+ * @return the list of available Gradle distributions from the Gradle Home.
+ * @since 2.10
+ */
+ public List<GradleDistribution> availableLocalDistributions() {
+ List<GradleDistribution> ret = new ArrayList<>();
+ File dists = new File(gradleUserHome, "wrapper/dists"); //NOI18N
+ if (dists.isDirectory()) {
+ try {
+ Files.walkFileTree(dists.toPath(), new
SimpleFileVisitor<Path>() {
Review comment:
Is it necessary to walk the tree to the depth - are the dists sometimes
nested ? Otherwise `Files.list(dists.toPath).forEach()` could be faster.
##########
File path:
extide/gradle/src/org/netbeans/modules/gradle/api/execute/GradleDistributionManager.java
##########
@@ -308,6 +313,46 @@ public GradleDistribution defaultDistribution() {
return ret;
}
+ /**
+ * Lists all the {@link GradleDistribution}s available on the Gradle Home
+ * of this distribution manager. It looks for the
<code>$GRADLE_HOME/wrapper/dists</code>
+ * directory for already downloaded distributions.
+ * @return the list of available Gradle distributions from the Gradle Home.
+ * @since 2.10
+ */
+ public List<GradleDistribution> availableLocalDistributions() {
+ List<GradleDistribution> ret = new ArrayList<>();
+ File dists = new File(gradleUserHome, "wrapper/dists"); //NOI18N
Review comment:
I'd avoid `/` (possible troubles on Windows). Given Path is needed
later, better could be `Paths.get(gradleUserName, "wrapper", "dists")`.
##########
File path:
extide/gradle/src/org/netbeans/modules/gradle/api/execute/GradleDistributionManager.java
##########
@@ -308,6 +313,46 @@ public GradleDistribution defaultDistribution() {
return ret;
}
+ /**
+ * Lists all the {@link GradleDistribution}s available on the Gradle Home
+ * of this distribution manager. It looks for the
<code>$GRADLE_HOME/wrapper/dists</code>
+ * directory for already downloaded distributions.
+ * @return the list of available Gradle distributions from the Gradle Home.
+ * @since 2.10
+ */
+ public List<GradleDistribution> availableLocalDistributions() {
+ List<GradleDistribution> ret = new ArrayList<>();
+ File dists = new File(gradleUserHome, "wrapper/dists"); //NOI18N
+ if (dists.isDirectory()) {
+ try {
+ Files.walkFileTree(dists.toPath(), new
SimpleFileVisitor<Path>() {
+ @Override
+ public FileVisitResult visitFile(Path f,
BasicFileAttributes attrs) throws IOException {
+ String fname = f.getFileName().toString();
+ Matcher m = DIST_VERSION_PATTERN.matcher(fname);
+ if (m.matches()) {
+ Path dist = f.getParent().resolve(m.group(1));
Review comment:
Can use `f.resolveSibling()`
##########
File path:
extide/gradle/src/org/netbeans/modules/gradle/api/execute/GradleDistributionManager.java
##########
@@ -308,6 +313,46 @@ public GradleDistribution defaultDistribution() {
return ret;
}
+ /**
+ * Lists all the {@link GradleDistribution}s available on the Gradle Home
+ * of this distribution manager. It looks for the
<code>$GRADLE_HOME/wrapper/dists</code>
+ * directory for already downloaded distributions.
+ * @return the list of available Gradle distributions from the Gradle Home.
+ * @since 2.10
+ */
+ public List<GradleDistribution> availableLocalDistributions() {
+ List<GradleDistribution> ret = new ArrayList<>();
+ File dists = new File(gradleUserHome, "wrapper/dists"); //NOI18N
+ if (dists.isDirectory()) {
+ try {
+ Files.walkFileTree(dists.toPath(), new
SimpleFileVisitor<Path>() {
+ @Override
+ public FileVisitResult visitFile(Path f,
BasicFileAttributes attrs) throws IOException {
+ String fname = f.getFileName().toString();
+ Matcher m = DIST_VERSION_PATTERN.matcher(fname);
+ if (m.matches()) {
Review comment:
this looks for `xxxx-gradle-version.zip` in `~/.gradle/wrapper/dists`,
and uses its unpacked form, right ?
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:
[email protected]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]
For further information about the NetBeans mailing lists, visit:
https://cwiki.apache.org/confluence/display/NETBEANS/Mailing+lists