This is an automated email from the ASF dual-hosted git repository.

mbien pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/netbeans.git


The following commit(s) were added to refs/heads/master by this push:
     new a9845e3070 Update maven mirror generator action.
     new ea7b98a59b Merge pull request #6766 from 
mbien/update-maven-mirror-utils
a9845e3070 is described below

commit a9845e3070f96255d000963ef7039e4a5b3165ad
Author: Michael Bien <[email protected]>
AuthorDate: Wed Nov 29 19:30:32 2023 +0100

    Update maven mirror generator action.
    
    None of the preset mirrors for maven central exist anymore, this
    updates the preset to the last known public mirrors and tweaks the UI
    a bit.
    
    Fixed possible NPE when the central list is checked before
    NotificationLineSupport was attached.
---
 .../modules/maven/codegen/Bundle.properties        |  6 +-
 .../modules/maven/codegen/MirrorGenerator.java     |  2 +-
 .../modules/maven/codegen/NewMirrorPanel.form      | 37 +++++-----
 .../modules/maven/codegen/NewMirrorPanel.java      | 85 ++++++++++------------
 4 files changed, 58 insertions(+), 72 deletions(-)

diff --git 
a/java/maven.grammar/src/org/netbeans/modules/maven/codegen/Bundle.properties 
b/java/maven.grammar/src/org/netbeans/modules/maven/codegen/Bundle.properties
index 418507d7b4..bd6cbb4899 100644
--- 
a/java/maven.grammar/src/org/netbeans/modules/maven/codegen/Bundle.properties
+++ 
b/java/maven.grammar/src/org/netbeans/modules/maven/codegen/Bundle.properties
@@ -30,9 +30,9 @@ NewMirrorPanel.lblUrl.text=Mirror &URL:
 NewMirrorPanel.btnLink.text=<html><a href="">See Apache Maven documentation 
for details.</a></html>
 LBL_Central=Central Repository
 LBL_All=All repositories, you have Repository Manager installed
-LBL_NonLocal=All non local repositories (Maven 2.0.9+)
-LBL_AllButFoo=All repositories, with exception of 'foo' (Maven 2.0.9+)
-LBL_List=List of repositories (Maven 2.0.9+)
+LBL_NonLocal=All non local repositories
+LBL_AllButFoo=All repositories, with exception of 'foo'
+LBL_List=List of repositories
 NewPluginPanel.chkConfig.text=Configuration Skeleton
 NewPluginPanel.lblQuery.text=Name Query:
 NewPluginPanel.tfQuery.text=
diff --git 
a/java/maven.grammar/src/org/netbeans/modules/maven/codegen/MirrorGenerator.java
 
b/java/maven.grammar/src/org/netbeans/modules/maven/codegen/MirrorGenerator.java
index 2182d71834..c123120ba2 100644
--- 
a/java/maven.grammar/src/org/netbeans/modules/maven/codegen/MirrorGenerator.java
+++ 
b/java/maven.grammar/src/org/netbeans/modules/maven/codegen/MirrorGenerator.java
@@ -45,7 +45,7 @@ public class MirrorGenerator extends 
AbstractGenerator<SettingsModel> {
         
         @Override
         public List<? extends CodeGenerator> create(Lookup context) {
-            ArrayList<CodeGenerator> toRet = new ArrayList<CodeGenerator>();
+            ArrayList<CodeGenerator> toRet = new ArrayList<>();
             SettingsModel model = context.lookup(SettingsModel.class);
             JTextComponent component = context.lookup(JTextComponent.class);
             if (model != null) {
diff --git 
a/java/maven.grammar/src/org/netbeans/modules/maven/codegen/NewMirrorPanel.form 
b/java/maven.grammar/src/org/netbeans/modules/maven/codegen/NewMirrorPanel.form
index abb779e3bb..2e999a7790 100644
--- 
a/java/maven.grammar/src/org/netbeans/modules/maven/codegen/NewMirrorPanel.form
+++ 
b/java/maven.grammar/src/org/netbeans/modules/maven/codegen/NewMirrorPanel.form
@@ -1,4 +1,4 @@
-<?xml version="1.1" encoding="UTF-8" ?>
+<?xml version="1.0" encoding="UTF-8" ?>
 
 <!--
 
@@ -37,29 +37,26 @@
   <Layout>
     <DimensionLayout dim="0">
       <Group type="103" groupAlignment="0" attributes="0">
-          <Group type="102" attributes="0">
+          <Group type="102" alignment="1" attributes="0">
               <EmptySpace max="-2" attributes="0"/>
-              <Group type="103" groupAlignment="0" attributes="0">
-                  <Group type="102" alignment="0" attributes="0">
+              <Group type="103" groupAlignment="1" attributes="0">
+                  <Group type="102" attributes="0">
+                      <EmptySpace min="0" pref="108" max="32767" 
attributes="0"/>
+                      <Component id="btnLink" min="-2" max="-2" 
attributes="0"/>
+                  </Group>
+                  <Group type="102" attributes="0">
                       <Group type="103" groupAlignment="0" attributes="0">
-                          <Component id="lblMirrorOf" alignment="0" min="-2" 
max="-2" attributes="0"/>
                           <Component id="lblId" alignment="0" min="-2" 
max="-2" attributes="0"/>
+                          <Component id="lblMirrorOf" alignment="0" min="-2" 
max="-2" attributes="0"/>
+                          <Component id="lblUrl" alignment="0" min="-2" 
max="-2" attributes="0"/>
                       </Group>
-                      <EmptySpace min="-2" max="-2" attributes="0"/>
+                      <EmptySpace max="-2" attributes="0"/>
                       <Group type="103" groupAlignment="0" attributes="0">
-                          <Group type="102" alignment="0" attributes="0">
-                              <Component id="txtId" pref="159" max="32767" 
attributes="0"/>
-                              <EmptySpace min="145" pref="145" max="145" 
attributes="0"/>
-                          </Group>
-                          <Component id="comMirrorOf" alignment="0" pref="304" 
max="32767" attributes="0"/>
+                          <Component id="comUrl" max="32767" attributes="0"/>
+                          <Component id="txtId" max="32767" attributes="0"/>
+                          <Component id="comMirrorOf" max="32767" 
attributes="0"/>
                       </Group>
                   </Group>
-                  <Group type="102" alignment="0" attributes="0">
-                      <Component id="lblUrl" min="-2" max="-2" attributes="0"/>
-                      <EmptySpace type="unrelated" max="-2" attributes="0"/>
-                      <Component id="comUrl" pref="303" max="32767" 
attributes="0"/>
-                  </Group>
-                  <Component id="btnLink" alignment="0" pref="400" max="32767" 
attributes="0"/>
               </Group>
               <EmptySpace max="-2" attributes="0"/>
           </Group>
@@ -73,19 +70,19 @@
                   <Component id="lblId" alignment="3" min="-2" max="-2" 
attributes="0"/>
                   <Component id="txtId" alignment="3" min="-2" max="-2" 
attributes="0"/>
               </Group>
-              <EmptySpace max="-2" attributes="0"/>
+              <EmptySpace type="unrelated" max="-2" attributes="0"/>
               <Group type="103" groupAlignment="3" attributes="0">
                   <Component id="lblMirrorOf" alignment="3" min="-2" max="-2" 
attributes="0"/>
                   <Component id="comMirrorOf" alignment="3" min="-2" max="-2" 
attributes="0"/>
               </Group>
-              <EmptySpace max="-2" attributes="0"/>
+              <EmptySpace type="unrelated" max="-2" attributes="0"/>
               <Group type="103" groupAlignment="3" attributes="0">
                   <Component id="lblUrl" alignment="3" min="-2" max="-2" 
attributes="0"/>
                   <Component id="comUrl" alignment="3" min="-2" max="-2" 
attributes="0"/>
               </Group>
               <EmptySpace type="separate" max="-2" attributes="0"/>
               <Component id="btnLink" min="-2" max="-2" attributes="0"/>
-              <EmptySpace pref="36" max="32767" attributes="0"/>
+              <EmptySpace max="32767" attributes="0"/>
           </Group>
       </Group>
     </DimensionLayout>
diff --git 
a/java/maven.grammar/src/org/netbeans/modules/maven/codegen/NewMirrorPanel.java 
b/java/maven.grammar/src/org/netbeans/modules/maven/codegen/NewMirrorPanel.java
index b9e9d9e881..0d26e1d11c 100644
--- 
a/java/maven.grammar/src/org/netbeans/modules/maven/codegen/NewMirrorPanel.java
+++ 
b/java/maven.grammar/src/org/netbeans/modules/maven/codegen/NewMirrorPanel.java
@@ -21,8 +21,6 @@ package org.netbeans.modules.maven.codegen;
 
 import java.awt.Component;
 import java.awt.Cursor;
-import java.awt.event.ActionEvent;
-import java.awt.event.ActionListener;
 import java.net.MalformedURLException;
 import java.net.URL;
 import javax.swing.DefaultComboBoxModel;
@@ -56,10 +54,10 @@ public class NewMirrorPanel extends javax.swing.JPanel {
     private SettingsModel model;
     private NotificationLineSupport nls;
 
-    private static final String ALL = "*"; //2.0.5+ //NOI18N
-    private static final String ALL_NON_LOCAL = "external:*"; //2.0.9+ //NOI18N
-    private static final String ALL_BUT_FOO = "*,!foo"; //2.0.9+ //NOI18N
-    private static final String LIST = "foo,bar"; //2.0.9+ //NOI18N
+    private static final String ALL = "*"; //NOI18N
+    private static final String ALL_NON_LOCAL = "external:*"; //NOI18N
+    private static final String ALL_BUT_FOO = "*,!foo"; //NOI18N
+    private static final String LIST = "foo,bar"; //NOI18N
 
     private final String[] MIRROROFS = new String[] {
         RepositorySystem.DEFAULT_REMOTE_REPO_ID,
@@ -68,7 +66,7 @@ public class NewMirrorPanel extends javax.swing.JPanel {
         ALL_BUT_FOO,
         LIST
     };
-    private DefaultComboBoxModel<String> urlmodel;
+    private final DefaultComboBoxModel<String> urlmodel;
 
 
     public NewMirrorPanel(SettingsModel model) {
@@ -135,18 +133,14 @@ public class NewMirrorPanel extends javax.swing.JPanel {
         comUrl.setModel(urlmodel);
 
         btnLink.setCursor(Cursor.getPredefinedCursor(Cursor.HAND_CURSOR));
-        btnLink.addActionListener(new ActionListener() {
-            @Override
-            public void actionPerformed(ActionEvent e) {
-                try {
-                    URL link = new 
URL("http://maven.apache.org/guides/mini/guide-mirror-settings.html";); //NOI18N
-                    HtmlBrowser.URLDisplayer.getDefault().showURL(link);
-                } catch (MalformedURLException ex) {
-                    Exceptions.printStackTrace(ex);
-                }
+        btnLink.addActionListener(e -> {
+            try {
+                URL link = new 
URL("http://maven.apache.org/guides/mini/guide-mirror-settings.html";); //NOI18N
+                HtmlBrowser.URLDisplayer.getDefault().showURL(link);
+            } catch (MalformedURLException ex) {
+                Exceptions.printStackTrace(ex);
             }
         });
-        checkCentral();
     }
 
     /** For gaining access to DialogDisplayer instance to manage
@@ -163,6 +157,7 @@ public class NewMirrorPanel extends javax.swing.JPanel {
     public void addNotify() {
         super.addNotify();
         assert nls != null : " The notificationLineSupport was not attached to 
the panel."; //NOI18N
+        checkCentral();
     }
 
     private void checkId() {
@@ -179,21 +174,19 @@ public class NewMirrorPanel extends javax.swing.JPanel {
         String sel = (String)comMirrorOf.getSelectedItem();
         urlmodel.removeAllElements();
         if (RepositorySystem.DEFAULT_REMOTE_REPO_ID.equals(sel)) {
-            //see 
http://docs.codehaus.org/display/MAVENUSER/Mirrors+Repositories
-            // for a list of central mirrors.
-            //TODO might be worth to externalize somehow.
-            
urlmodel.addElement("http://mirrors.ibiblio.org/pub/mirrors/maven2";); //NOI18N
-            
urlmodel.addElement("http://www.ibiblio.net/pub/packages/maven2";);//NOI18N
-            urlmodel.addElement("http://ftp.cica.es/mirrors/maven2";);//NOI18N
-            urlmodel.addElement("http://repo1.sonatype.net/maven2";);//NOI18N
-            urlmodel.addElement("http://repo.exist.com/maven2";);//NOI18N
-            urlmodel.addElement("http://mirrors.redv.com/maven2";);//NOI18N
-            urlmodel.addElement("http://mirrors.dotsrc.org/maven2";);//NOI18N
+            // according to devs involved with maven and maven central, these 
are the only public mirrors left for central at this time
+            // see 
https://repo.maven.apache.org/maven2/.meta/repository-metadata.xml (which 
should be kept up2date now - hopefully)
+            
urlmodel.addElement("https://maven-central.storage-download.googleapis.com/maven2";);
 //NOI18N
+            
urlmodel.addElement("https://maven-central-eu.storage-download.googleapis.com/maven2";);
 //NOI18N
+            
urlmodel.addElement("https://maven-central-asia.storage-download.googleapis.com/maven2";);
 //NOI18N
+            if (txtId.getText() == null || txtId.getText().isEmpty()) {
+                
txtId.setText(RepositorySystem.DEFAULT_REMOTE_REPO_ID+"-mirror"); //NOI18N
+            }
+        } else if 
((RepositorySystem.DEFAULT_REMOTE_REPO_ID+"-mirror").equals(txtId.getText())) {
+            txtId.setText(""); //NOI18N
         }
     }
 
-
-
     /** This method is called from within the constructor to
      * initialize the form.
      * WARNING: Do NOT modify this code. The content of this method is
@@ -234,46 +227,42 @@ public class NewMirrorPanel extends javax.swing.JPanel {
 
         GroupLayout layout = new GroupLayout(this);
         this.setLayout(layout);
-        layout.setHorizontalGroup(
-            layout.createParallelGroup(Alignment.LEADING)
-            .addGroup(layout.createSequentialGroup()
+        layout.setHorizontalGroup(layout.createParallelGroup(Alignment.LEADING)
+            .addGroup(Alignment.TRAILING, layout.createSequentialGroup()
                 .addContainerGap()
-                .addGroup(layout.createParallelGroup(Alignment.LEADING)
+                .addGroup(layout.createParallelGroup(Alignment.TRAILING)
+                    .addGroup(layout.createSequentialGroup()
+                        .addGap(0, 108, Short.MAX_VALUE)
+                        .addComponent(btnLink, GroupLayout.PREFERRED_SIZE, 
GroupLayout.DEFAULT_SIZE, GroupLayout.PREFERRED_SIZE))
                     .addGroup(layout.createSequentialGroup()
                         .addGroup(layout.createParallelGroup(Alignment.LEADING)
+                            .addComponent(lblId)
                             .addComponent(lblMirrorOf)
-                            .addComponent(lblId))
+                            .addComponent(lblUrl))
                         .addPreferredGap(ComponentPlacement.RELATED)
                         .addGroup(layout.createParallelGroup(Alignment.LEADING)
-                            .addGroup(layout.createSequentialGroup()
-                                .addComponent(txtId, GroupLayout.DEFAULT_SIZE, 
159, Short.MAX_VALUE)
-                                .addGap(145, 145, 145))
-                            .addComponent(comMirrorOf, 0, 304, 
Short.MAX_VALUE)))
-                    .addGroup(layout.createSequentialGroup()
-                        .addComponent(lblUrl)
-                        .addPreferredGap(ComponentPlacement.UNRELATED)
-                        .addComponent(comUrl, 0, 303, Short.MAX_VALUE))
-                    .addComponent(btnLink, GroupLayout.DEFAULT_SIZE, 400, 
Short.MAX_VALUE))
+                            .addComponent(comUrl, 0, GroupLayout.DEFAULT_SIZE, 
Short.MAX_VALUE)
+                            .addComponent(txtId)
+                            .addComponent(comMirrorOf, 0, 
GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))))
                 .addContainerGap())
         );
-        layout.setVerticalGroup(
-            layout.createParallelGroup(Alignment.LEADING)
+        layout.setVerticalGroup(layout.createParallelGroup(Alignment.LEADING)
             .addGroup(layout.createSequentialGroup()
                 .addContainerGap()
                 .addGroup(layout.createParallelGroup(Alignment.BASELINE)
                     .addComponent(lblId)
                     .addComponent(txtId, GroupLayout.PREFERRED_SIZE, 
GroupLayout.DEFAULT_SIZE, GroupLayout.PREFERRED_SIZE))
-                .addPreferredGap(ComponentPlacement.RELATED)
+                .addPreferredGap(ComponentPlacement.UNRELATED)
                 .addGroup(layout.createParallelGroup(Alignment.BASELINE)
                     .addComponent(lblMirrorOf)
                     .addComponent(comMirrorOf, GroupLayout.PREFERRED_SIZE, 
GroupLayout.DEFAULT_SIZE, GroupLayout.PREFERRED_SIZE))
-                .addPreferredGap(ComponentPlacement.RELATED)
+                .addPreferredGap(ComponentPlacement.UNRELATED)
                 .addGroup(layout.createParallelGroup(Alignment.BASELINE)
                     .addComponent(lblUrl)
                     .addComponent(comUrl, GroupLayout.PREFERRED_SIZE, 
GroupLayout.DEFAULT_SIZE, GroupLayout.PREFERRED_SIZE))
                 .addGap(18, 18, 18)
                 .addComponent(btnLink, GroupLayout.PREFERRED_SIZE, 
GroupLayout.DEFAULT_SIZE, GroupLayout.PREFERRED_SIZE)
-                .addContainerGap(36, Short.MAX_VALUE))
+                .addContainerGap(GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
         );
     }// </editor-fold>//GEN-END:initComponents
 


---------------------------------------------------------------------
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

Reply via email to