You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@netbeans.apache.org by "matthiasblaesing (via GitHub)" <gi...@apache.org> on 2023/12/07 17:46:28 UTC
Re: [PR] Centralize internal maven artifact version queries. [netbeans]
matthiasblaesing commented on code in PR #6751:
URL: https://github.com/apache/netbeans/pull/6751#discussion_r1419346012
##########
java/maven/src/org/netbeans/modules/maven/options/MavenVersionSettings.java:
##########
@@ -1,76 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-package org.netbeans.modules.maven.options;
-
-import java.util.prefs.Preferences;
-import org.openide.util.NbPreferences;
-
-/**
- * Preferences class for externalizing the hardwired plugin versions to
- * allow changes by advanced users?
- * @author mkleint
- */
-public final class MavenVersionSettings {
Review Comment:
I don't understand the rename here, but ok, as long as it is not API.
##########
java/maven/src/org/netbeans/modules/maven/options/NbArtifactVersionPreferences.java:
##########
@@ -0,0 +1,124 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.netbeans.modules.maven.options;
+
+import java.util.Map;
+import java.util.prefs.Preferences;
+import org.apache.maven.artifact.versioning.ComparableVersion;
+import org.netbeans.modules.maven.api.Constants;
+import org.netbeans.modules.maven.indexer.api.NBVersionInfo;
+import org.netbeans.modules.maven.indexer.api.RepositoryQueries;
+import org.openide.util.NbPreferences;
+
+import static java.util.Map.entry;
+
+/**
+ * Preferences class for internal artifact version queries.
+ *
+ * Generally returns the latest known version unless overwritten by preference storage.
+ *
+ * @author mkleint
+ */
+public final class NbArtifactVersionPreferences {
+
+ private static final Map<String, String> fallback;
+
+ static {
+ // TODO update periodically - modifications might require test updates
+ String nb_version = "RELEASE200";
+ String nb_utilities_version = "14.0";
+ fallback = Map.ofEntries(
+ entry(key("org.netbeans.api", "org-netbeans-modules-editor"), nb_version), // represents all other nb artifacts
+ entry(key(Constants.GROUP_APACHE_PLUGINS, Constants.PLUGIN_COMPILER), "3.11.0"),
+ entry(key(Constants.GROUP_APACHE_PLUGINS, Constants.PLUGIN_RESOURCES), "3.3.1"),
+ entry(key(Constants.GROUP_APACHE_PLUGINS, Constants.PLUGIN_FAILSAFE), "3.2.2"),
+ entry(key(Constants.GROUP_APACHE_PLUGINS, Constants.PLUGIN_SUREFIRE), "3.2.2"),
+ entry(key("org.apache.netbeans.utilities", "utilities-parent"), nb_utilities_version),
+ entry(key("org.apache.netbeans.utilities", "nbm-maven-harness"), nb_utilities_version),
+ entry(key("org.apache.netbeans.utilities", "nbm-shared"), nb_utilities_version),
+ entry(key("org.apache.netbeans.utilities", "nbm-repository-plugin"), nb_utilities_version),
+ entry(key("org.apache.netbeans.utilities", "nbm-maven-plugin"), nb_utilities_version),
+ entry(key("org.apache.netbeans.archetypes", "nbm-archetype"), "1.18"),
+ entry(key("org.apache.netbeans.archetypes", "netbeans-platform-app-archetype"), "1.23")
+ );
+ }
+
+ private static final NbArtifactVersionPreferences INSTANCE = new NbArtifactVersionPreferences();
+
+ private NbArtifactVersionPreferences() {}
+
+ public static NbArtifactVersionPreferences getDefault() {
+ return INSTANCE;
+ }
+
+ protected final Preferences getPreferences() {
+ return NbPreferences.root().node("org/netbeans/modules/maven/artifactVersions");
+ }
+
+ protected final String putProperty(String key, String value) {
+ String retval = getProperty(key);
+ if (value != null) {
+ getPreferences().put(key, value);
+ } else {
+ getPreferences().remove(key);
+ }
+ return retval;
+ }
+
+ protected final String getProperty(String key) {
+ return getPreferences().get(key, null);
+ }
+
+ public String getNBVersion() {
+ return getVersion("org.netbeans.api", "org-netbeans-modules-editor");
+ }
+
+ public String getVersion(String aid) {
+ return getVersion(Constants.GROUP_APACHE_PLUGINS, aid);
+ }
+
+ public String getVersion(String gid, String aid) {
Review Comment:
You can guess what `gid` and `aid` means, but `groupId` and `artifactId` would make this much easier.
##########
java/maven/src/org/netbeans/modules/maven/options/NbArtifactVersionPreferences.java:
##########
@@ -0,0 +1,124 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.netbeans.modules.maven.options;
+
+import java.util.Map;
+import java.util.prefs.Preferences;
+import org.apache.maven.artifact.versioning.ComparableVersion;
+import org.netbeans.modules.maven.api.Constants;
+import org.netbeans.modules.maven.indexer.api.NBVersionInfo;
+import org.netbeans.modules.maven.indexer.api.RepositoryQueries;
+import org.openide.util.NbPreferences;
+
+import static java.util.Map.entry;
+
+/**
+ * Preferences class for internal artifact version queries.
+ *
+ * Generally returns the latest known version unless overwritten by preference storage.
+ *
+ * @author mkleint
+ */
+public final class NbArtifactVersionPreferences {
+
+ private static final Map<String, String> fallback;
+
+ static {
+ // TODO update periodically - modifications might require test updates
+ String nb_version = "RELEASE200";
+ String nb_utilities_version = "14.0";
+ fallback = Map.ofEntries(
+ entry(key("org.netbeans.api", "org-netbeans-modules-editor"), nb_version), // represents all other nb artifacts
+ entry(key(Constants.GROUP_APACHE_PLUGINS, Constants.PLUGIN_COMPILER), "3.11.0"),
+ entry(key(Constants.GROUP_APACHE_PLUGINS, Constants.PLUGIN_RESOURCES), "3.3.1"),
+ entry(key(Constants.GROUP_APACHE_PLUGINS, Constants.PLUGIN_FAILSAFE), "3.2.2"),
+ entry(key(Constants.GROUP_APACHE_PLUGINS, Constants.PLUGIN_SUREFIRE), "3.2.2"),
+ entry(key("org.apache.netbeans.utilities", "utilities-parent"), nb_utilities_version),
+ entry(key("org.apache.netbeans.utilities", "nbm-maven-harness"), nb_utilities_version),
+ entry(key("org.apache.netbeans.utilities", "nbm-shared"), nb_utilities_version),
+ entry(key("org.apache.netbeans.utilities", "nbm-repository-plugin"), nb_utilities_version),
+ entry(key("org.apache.netbeans.utilities", "nbm-maven-plugin"), nb_utilities_version),
+ entry(key("org.apache.netbeans.archetypes", "nbm-archetype"), "1.18"),
+ entry(key("org.apache.netbeans.archetypes", "netbeans-platform-app-archetype"), "1.23")
+ );
+ }
+
+ private static final NbArtifactVersionPreferences INSTANCE = new NbArtifactVersionPreferences();
+
+ private NbArtifactVersionPreferences() {}
+
+ public static NbArtifactVersionPreferences getDefault() {
+ return INSTANCE;
+ }
+
+ protected final Preferences getPreferences() {
Review Comment:
`protected` on a `final` class? This is effectively package private and thus just remove the access modifier.
--
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.
To unsubscribe, e-mail: notifications-unsubscribe@netbeans.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@netbeans.apache.org
For additional commands, e-mail: notifications-help@netbeans.apache.org
For further information about the NetBeans mailing lists, visit:
https://cwiki.apache.org/confluence/display/NETBEANS/Mailing+lists