Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update maven mirror generator action. #6766

Merged
merged 1 commit into from
Dec 8, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -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=
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ public static class Factory implements CodeGenerator.Factory {

@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) {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
<?xml version="1.1" encoding="UTF-8" ?>
<?xml version="1.0" encoding="UTF-8" ?>

<!--

Expand Down Expand Up @@ -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>
Expand All @@ -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>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,6 @@

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;
Expand Down Expand Up @@ -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,
Expand All @@ -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) {
Expand Down Expand Up @@ -135,18 +133,14 @@ public void changedUpdate(DocumentEvent e) {
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();
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@sdedic to answer your question from the other PR, the NPE was here:

nls.setErrorMessage(NbBundle.getMessage(NewProfilePanel.class, "ERR_SameMirrorId"));

nls was null. This can happen when the mirror already exists and the user opens the dialog again, the check will run right from the constructor, nls is set post-construction and is therefore still null. By moving the check into addNotify() this is avoided.

}

/** For gaining access to DialogDisplayer instance to manage
Expand All @@ -163,6 +157,7 @@ public void attachDialogDisplayer(DialogDescriptor dd) {
public void addNotify() {
super.addNotify();
assert nls != null : " The notificationLineSupport was not attached to the panel."; //NOI18N
checkCentral();
}

private void checkId() {
Expand All @@ -179,21 +174,19 @@ private void checkCentral() {
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
mbien marked this conversation as resolved.
Show resolved Hide resolved
// 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
Expand Down Expand Up @@ -234,46 +227,42 @@ private void initComponents() {

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

Expand Down
Loading