You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@netbeans.apache.org by lk...@apache.org on 2019/03/07 05:04:11 UTC
[incubator-netbeans] branch master updated: [NETBEANS-2179] Fixed
sub-project serialization and display name improvements.
This is an automated email from the ASF dual-hosted git repository.
lkishalmi pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/incubator-netbeans.git
The following commit(s) were added to refs/heads/master by this push:
new 6a49eec [NETBEANS-2179] Fixed sub-project serialization and display name improvements.
6a49eec is described below
commit 6a49eec9a165803b344ee0c7f6da7ad38ab0f6aa
Author: Laszlo Kishalmi <la...@gmail.com>
AuthorDate: Sun Mar 3 12:30:02 2019 -0800
[NETBEANS-2179] Fixed sub-project serialization and display name improvements.
---
.../gradle/tooling/NbProjectInfoBuilder.groovy | 5 +-
.../modules/gradle/GradleProjectCache.java | 2 +-
.../modules/gradle/api/GradleBaseProject.java | 60 ++++++++++++++++------
.../gradle/api/GradleBaseProjectBuilder.java | 3 +-
.../modules/gradle/nodes/SubProjectsNode.java | 4 +-
.../org/netbeans/modules/gradle/queries/Info.java | 8 +--
6 files changed, 57 insertions(+), 25 deletions(-)
diff --git a/groovy/gradle/netbeans-gradle-tooling/src/main/groovy/org/netbeans/modules/gradle/tooling/NbProjectInfoBuilder.groovy b/groovy/gradle/netbeans-gradle-tooling/src/main/groovy/org/netbeans/modules/gradle/tooling/NbProjectInfoBuilder.groovy
index 885b5e1..3ac906a 100644
--- a/groovy/gradle/netbeans-gradle-tooling/src/main/groovy/org/netbeans/modules/gradle/tooling/NbProjectInfoBuilder.groovy
+++ b/groovy/gradle/netbeans-gradle-tooling/src/main/groovy/org/netbeans/modules/gradle/tooling/NbProjectInfoBuilder.groovy
@@ -105,7 +105,7 @@ class NbProjectInfoBuilder {
Map<String, File> sp = new HashMap<>();
for(Project p: project.subprojects) {
- sp.put(p.name, p.projectDir);
+ sp.put(p.path, p.projectDir);
}
model.info.project_subProjects = sp;
@@ -119,6 +119,9 @@ class NbProjectInfoBuilder {
}
model.info.project_includedBuilds = ib;
+ if (gradleVersion.compareTo(VersionNumber.parse('3.3')) >= 0) {
+ model.info.project_display_name = project.displayName;
+ }
try {
model.info.buildClassPath = storeSet(project.buildscript.configurations.classpath.files)
} catch (Exception e) {
diff --git a/groovy/gradle/src/org/netbeans/modules/gradle/GradleProjectCache.java b/groovy/gradle/src/org/netbeans/modules/gradle/GradleProjectCache.java
index 7c14f3d..df5a962 100644
--- a/groovy/gradle/src/org/netbeans/modules/gradle/GradleProjectCache.java
+++ b/groovy/gradle/src/org/netbeans/modules/gradle/GradleProjectCache.java
@@ -97,7 +97,7 @@ public final class GradleProjectCache {
private static final Map<File, Set<File>> SUB_PROJECT_DIR_CACHE = new ConcurrentHashMap<>();
// Increase this number if new info is gathered from the projects.
- private static final int COMPATIBLE_CACHE_VERSION = 10;
+ private static final int COMPATIBLE_CACHE_VERSION = 11;
/**
* Loads a physical GradleProject either from Gradle or Cache. As project retrieval can be time consuming using
diff --git a/groovy/gradle/src/org/netbeans/modules/gradle/api/GradleBaseProject.java b/groovy/gradle/src/org/netbeans/modules/gradle/api/GradleBaseProject.java
index 33b996f..8c16759 100644
--- a/groovy/gradle/src/org/netbeans/modules/gradle/api/GradleBaseProject.java
+++ b/groovy/gradle/src/org/netbeans/modules/gradle/api/GradleBaseProject.java
@@ -23,6 +23,7 @@ import org.netbeans.modules.gradle.spi.GradleFiles;
import org.netbeans.modules.gradle.api.execute.RunUtils;
import java.io.File;
import java.io.Serializable;
+import java.nio.file.Path;
import java.util.ArrayList;
import java.util.Collections;
import java.util.HashMap;
@@ -31,6 +32,7 @@ import java.util.List;
import java.util.Map;
import java.util.Set;
import org.netbeans.api.project.Project;
+import org.openide.filesystems.FileUtil;
/**
* This object holds the basic information of the Gradle project.
@@ -52,6 +54,7 @@ public final class GradleBaseProject implements Serializable, ModuleSearchSuppor
String path;
String status;
String parentName;
+ String displayName;
File buildDir;
File projectDir;
@@ -75,10 +78,10 @@ public final class GradleBaseProject implements Serializable, ModuleSearchSuppor
}
/**
- * This Gradle project name.
- *
- *
- *
+ * This Gradle project name.
+ *
+ *
+ *
* @return the name of the project
*/
public String getName() {
@@ -105,6 +108,10 @@ public final class GradleBaseProject implements Serializable, ModuleSearchSuppor
return description;
}
+ public String getDisplayName() {
+ return displayName;
+ }
+
public String getVersion() {
return version;
}
@@ -123,8 +130,8 @@ public final class GradleBaseProject implements Serializable, ModuleSearchSuppor
/**
* The set of Gradle plugin ids used applied in this project.
- *
- * @return the set of applied plugins
+ *
+ * @return the set of applied plugins
*/
public Set<String> getPlugins() {
return plugins;
@@ -139,8 +146,8 @@ public final class GradleBaseProject implements Serializable, ModuleSearchSuppor
}
/**
- * The classpath used to
- * @return
+ * The classpath used to
+ * @return
*/
public Set<File> getGradleClassPath() {
return gradleClassPath;
@@ -153,11 +160,11 @@ public final class GradleBaseProject implements Serializable, ModuleSearchSuppor
public Map<String, File> getIncludedBuilds() {
return includedBuilds;
}
-
+
/**
* Returns true if the project directory is the same as the root project's
* project directory, in short if this project is a root project.
- *
+ *
* @return true for root Gradle projects
*/
public boolean isRoot() {
@@ -166,8 +173,8 @@ public final class GradleBaseProject implements Serializable, ModuleSearchSuppor
/**
* Return the value of the property defined {@code netbeans.<key>} as
- * in this Gradle project or inherited from the root project.
- *
+ * in this Gradle project or inherited from the root project.
+ *
* @param key the property name after the {@code netbeans.} prefix.
* @return the property value or {@code null} if it is not defined.
*/
@@ -187,6 +194,13 @@ public final class GradleBaseProject implements Serializable, ModuleSearchSuppor
return license != null ? license : "default"; //NOI18N
}
+ /**
+ * Returns the sub-project of this project, in a map as Gradle project path
+ * and project directory pairs. In the current Gradle implementation only
+ * root project can have sub-projects.
+ *
+ * @return the map of sub-projects.
+ */
public Map<String, File> getSubProjects() {
return subProjects;
}
@@ -294,13 +308,13 @@ public final class GradleBaseProject implements Serializable, ModuleSearchSuppor
}
/**
- * Retrieve the actual GradleBaseProject from the given NetBeans
- * {@link Project project} lookup. If the project is not a Gradle project it
+ * Retrieve the actual GradleBaseProject from the given NetBeans
+ * {@link Project project} lookup. If the project is not a Gradle project it
* returns {@code null}. It always returns a non-null value for a Gradle
* project.
- *
+ *
* @see org.netbeans.modules.gradle.api.NbGradleProject.Quality
- *
+ *
* @param project a NetBeans project
* @return the basic Gradle project info stored for the given project or
* {@code null} for non-Gradle projects.
@@ -318,7 +332,19 @@ public final class GradleBaseProject implements Serializable, ModuleSearchSuppor
ret.buildDir = new File(files.getProjectDir(), "build");
ret.rootDir = files.getRootDir();
ret.version = "unspecified";
- ret.path = files.isRootProject() ? ":" : ":" + ret.name;
+ StringBuilder path = new StringBuilder(":"); //NOI18N
+ if (!files.isRootProject()) {
+ Path prjPath = files.getProjectDir().toPath();
+ Path rootPath = files.getRootDir().toPath();
+ String separator = "";
+ Path relPath = rootPath.relativize(prjPath);
+ for(int i = 0; i < relPath.getNameCount() ; i++) {
+ path.append(separator);
+ path.append(relPath.getName(i));
+ separator = ":"; //NOI18N
+ }
+ }
+ ret.path = path.toString();
ret.status = "release";
ret.parentName = files.isRootProject() ? null : files.getRootDir().getName();
diff --git a/groovy/gradle/src/org/netbeans/modules/gradle/api/GradleBaseProjectBuilder.java b/groovy/gradle/src/org/netbeans/modules/gradle/api/GradleBaseProjectBuilder.java
index eb14433..7cdfed9 100644
--- a/groovy/gradle/src/org/netbeans/modules/gradle/api/GradleBaseProjectBuilder.java
+++ b/groovy/gradle/src/org/netbeans/modules/gradle/api/GradleBaseProjectBuilder.java
@@ -39,7 +39,7 @@ import org.openide.util.lookup.ServiceProvider;
/**
* This is the de-serialization support class for GradleBaseProject.
- *
+ *
* @author Laszlo Kishalmi
*/
@SuppressWarnings("unchecked")
@@ -81,6 +81,7 @@ class GradleBaseProjectBuilder implements ProjectInfoExtractor.Result {
prj.path = (String) info.get("project_path");
prj.status = (String) info.get("project_status");
prj.parentName = (String) info.get("project_parent_name");
+ prj.displayName = (String) info.get("project_display_name");
prj.description = (String) info.get("project_description");
prj.group = (String) info.get("project_group");
prj.buildDir = (File) info.get("project_buildDir");
diff --git a/groovy/gradle/src/org/netbeans/modules/gradle/nodes/SubProjectsNode.java b/groovy/gradle/src/org/netbeans/modules/gradle/nodes/SubProjectsNode.java
index 715af43..3b25ef5 100644
--- a/groovy/gradle/src/org/netbeans/modules/gradle/nodes/SubProjectsNode.java
+++ b/groovy/gradle/src/org/netbeans/modules/gradle/nodes/SubProjectsNode.java
@@ -117,8 +117,8 @@ public class SubProjectsNode extends AbstractNode {
@Override
protected boolean createKeys(final List<NbGradleProjectImpl> modules) {
Map<String, File> subProjects = project.getGradleProject().getBaseProject().getSubProjects();
- for (String name : subProjects.keySet()) {
- File projDir = subProjects.get(name);
+ for (String path : subProjects.keySet()) {
+ File projDir = subProjects.get(path);
FileObject fo = FileUtil.toFileObject(projDir);
if (fo != null) {
try {
diff --git a/groovy/gradle/src/org/netbeans/modules/gradle/queries/Info.java b/groovy/gradle/src/org/netbeans/modules/gradle/queries/Info.java
index 5062262..b9cfe26 100644
--- a/groovy/gradle/src/org/netbeans/modules/gradle/queries/Info.java
+++ b/groovy/gradle/src/org/netbeans/modules/gradle/queries/Info.java
@@ -73,8 +73,7 @@ public final class Info implements ProjectInformation, PropertyChangeListener {
public String getName() {
GradleBaseProject prj = GradleBaseProject.get(project);
- String ret = prj.getParentName() != null ? prj.getParentName() + ":" : ""; //NOI18N
- ret += prj.getName(); //NOI18N
+ String ret = prj.isRoot() ? prj.getName() : prj.getRootDir().getName() + prj.getPath();
return ret;
}
@@ -92,6 +91,9 @@ public final class Info implements ProjectInformation, PropertyChangeListener {
&& !prj.getDescription().isEmpty()) {
ret = prj.getDescription();
} else {
+ // The current implementation of Gradle's displayName is kind of ugly
+ // and cannot be configured.
+ //ret = prj.getDisplayName() != null ? prj.getDisplayName() : getName();
ret = getName();
}
return ret;
@@ -124,7 +126,7 @@ public final class Info implements ProjectInformation, PropertyChangeListener {
if (prefChangeListenerSet.compareAndSet(false, true)) {
Preferences prefs = GradleSettings.getDefault().getPreferences();
prefs.addPreferenceChangeListener(WeakListeners.create(
- PreferenceChangeListener.class, preferenceChangeListener, prefs));
+ PreferenceChangeListener.class, preferenceChangeListener, prefs));
}
if (!pcs.hasListeners(null)) {
project.getLookup().lookup(NbGradleProject.class).addPropertyChangeListener(this);
---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@netbeans.apache.org
For additional commands, e-mail: commits-help@netbeans.apache.org
For further information about the NetBeans mailing lists, visit:
https://cwiki.apache.org/confluence/display/NETBEANS/Mailing+lists