[hg] main-silver: have a faster method of extracting at least on...

  • From: Milos Kleint < >
  • To: ,
  • Subject: [hg] main-silver: have a faster method of extracting at least on...
  • Date: Fri, 10 May 2013 09:39:56 -0700

changeset f613e19343f5 in main-silver ((none))
details: http://hg.netbeans.org/main-silver/rev/f613e19343f5
description:
        have a faster method of extracting at least one non-snapshot version 
in netbeans module related archetypes

diffstat:

 maven.apisupport/manifest.mf                                                 
        |    2 +-
 maven.apisupport/nbproject/project.xml                                       
        |    2 +-
 
maven.apisupport/src/org/netbeans/modules/maven/apisupport/NbmWizardPanelVisual.java
 |   73 +++-
 maven/manifest.mf                                                            
        |    2 +-
 maven/src/org/netbeans/modules/maven/api/archetype/Archetype.java            
        |  201 ++++++++++
 maven/src/org/netbeans/modules/maven/newproject/ArchetypeWizardUtils.java    
        |   52 +--
 maven/src/org/netbeans/modules/maven/newproject/BasicPanelVisual.java        
        |   94 +----
 7 files changed, 280 insertions(+), 146 deletions(-)

diffs (632 lines):

diff --git a/maven.apisupport/manifest.mf b/maven.apisupport/manifest.mf
--- a/maven.apisupport/manifest.mf
+++ b/maven.apisupport/manifest.mf
@@ -2,5 +2,5 @@
 OpenIDE-Module: org.netbeans.modules.maven.apisupport/1
 OpenIDE-Module-Localizing-Bundle: 
org/netbeans/modules/maven/apisupport/Bundle.properties
 AutoUpdate-Show-In-Client: false
-OpenIDE-Module-Specification-Version: 1.42
+OpenIDE-Module-Specification-Version: 1.43
 
diff --git a/maven.apisupport/nbproject/project.xml 
b/maven.apisupport/nbproject/project.xml
--- a/maven.apisupport/nbproject/project.xml
+++ b/maven.apisupport/nbproject/project.xml
@@ -152,7 +152,7 @@
                     <compile-dependency/>
                     <run-dependency>
                         <release-version>2</release-version>
-                        <specification-version>2.76</specification-version>
+                        <specification-version>2.81</specification-version>
                     </run-dependency>
                 </dependency>
                 <dependency>
diff --git 
a/maven.apisupport/src/org/netbeans/modules/maven/apisupport/NbmWizardPanelVisual.java
 
b/maven.apisupport/src/org/netbeans/modules/maven/apisupport/NbmWizardPanelVisual.java
--- 
a/maven.apisupport/src/org/netbeans/modules/maven/apisupport/NbmWizardPanelVisual.java
+++ 
b/maven.apisupport/src/org/netbeans/modules/maven/apisupport/NbmWizardPanelVisual.java
@@ -47,10 +47,18 @@
 import java.util.ArrayList;
 import java.util.Collections;
 import java.util.List;
+import java.util.Map;
 import javax.swing.DefaultComboBoxModel;
 import javax.swing.SwingUtilities;
+import org.apache.maven.artifact.resolver.ArtifactNotFoundException;
+import org.apache.maven.artifact.resolver.ArtifactResolutionException;
+import org.netbeans.api.progress.aggregate.AggregateProgressFactory;
+import org.netbeans.api.progress.aggregate.AggregateProgressHandle;
+import org.netbeans.api.progress.aggregate.ProgressContributor;
 import org.netbeans.modules.maven.api.MavenValidators;
+import org.netbeans.modules.maven.api.archetype.Archetype;
 import static org.netbeans.modules.maven.apisupport.Bundle.*;
+import org.netbeans.modules.maven.embedder.exec.ProgressTransferListener;
 import org.netbeans.modules.maven.indexer.api.NBVersionInfo;
 import org.netbeans.modules.maven.indexer.api.RepositoryInfo;
 import org.netbeans.modules.maven.indexer.api.RepositoryPreferences;
@@ -64,6 +72,7 @@
 import org.netbeans.validation.api.ui.ValidationGroup;
 import org.netbeans.validation.api.ui.swing.SwingValidationGroup;
 import org.openide.WizardDescriptor;
+import org.openide.util.Exceptions;
 import org.openide.util.NbBundle;
 import org.openide.util.NbBundle.Messages;
 import org.openide.util.RequestProcessor;
@@ -83,13 +92,18 @@
     private ValidationGroup vgEnabled = ValidationGroup.create();
     boolean isApp = false;
     private boolean isLoaded = false;
+    private AggregateProgressHandle handle;
+    private final Object HANDLE_LOCK = new Object();
+    
 
     @SuppressWarnings("unchecked") // SIMPLEVALIDATION-48
-    @Messages("ADD_Module_Name=NetBeans Module ArtifactId")
+    @Messages({"ADD_Module_Name=NetBeans Module ArtifactId", 
+             "Handle_Download=Downloading Archetype"})
     public NbmWizardPanelVisual(NbmWizardPanel panel) {
         this.panel = panel;
         initComponents();
-        isApp = NbmWizardIterator.NB_APP_ARCH.equals(panel.getArchetype());
+        final Archetype arch = panel.getArchetype();
+        isApp = NbmWizardIterator.NB_APP_ARCH.equals(arch);
         if (isApp) {
             vg.add(txtAddModule, ValidatorUtils.merge(
                     MavenValidators.createArtifactIdValidators(),
@@ -138,6 +152,47 @@
                         versions.add(version.getVersion());
                     }
                     versions.add("SNAPSHOT"); // NOI18N
+                    if (result.isPartial() || versions.size() == 1) {
+                        RP.post(new Runnable() {
+                            //download archetype to figure the default value 
of the netbeansVersion parameter.
+                            @Override
+                            public void run() {
+                                AggregateProgressHandle hndl = 
AggregateProgressFactory.createHandle(Handle_Download(),
+                                        new ProgressContributor[]{
+                                            
AggregateProgressFactory.createProgressContributor("zaloha")}, //NOI18N
+                                        
ProgressTransferListener.cancellable(), null);
+                                synchronized (HANDLE_LOCK) {
+                                    handle = hndl;
+                                }
+
+                                try {
+                                    arch.resolveArtifacts(hndl);
+                                    Map<String, String> props = 
arch.loadRequiredProperties();
+                                    String def = 
props.get("netbeansVersion");
+                                    final List<String> versions3 = new 
ArrayList<String>();
+                                    if (def != null) {
+                                        versions3.add(def);
+                                    }
+                                    versions3.add("SNAPSHOT");
+                                    if (result.isPartial()) {
+                                        versions3.add(SEARCHING);
+                                    }
+                                    EventQueue.invokeLater(new Runnable() {
+                                        public @Override
+                                        void run() {
+                                            versionCombo.setModel(new 
DefaultComboBoxModel(versions3.toArray()));
+                                            
versionComboActionPerformed(null);
+                                        }
+                                    });
+                                } catch (ArtifactResolutionException ex) {
+                                    Exceptions.printStackTrace(ex);
+                                } catch (ArtifactNotFoundException ex) {
+                                    Exceptions.printStackTrace(ex);
+                                } finally {
+                                }
+                            }
+                        });
+                    }
                     if (result.isPartial()) {
                         versions.add(SEARCHING);
                         //we return the values we have and schedule 
retrieval of the rest.
@@ -289,6 +344,13 @@
 
 
      void store(WizardDescriptor d) {
+        synchronized (HANDLE_LOCK) {
+            if (handle != null) {
+                handle.finish();
+                handle = null;
+            }
+        }        
+         
         d.putProperty(NbmWizardIterator.OSGIDEPENDENCIES, 
Boolean.valueOf(cbOsgiDeps.isSelected()));
          if (isApp) {
              if (cbAddModule.isSelected()) {
@@ -313,6 +375,13 @@
     }
 
     void read(WizardDescriptor d) {
+        synchronized (HANDLE_LOCK) {
+            if (handle != null) {
+                handle.finish();
+                handle = null;
+            }
+        }        
+        
         Boolean b = (Boolean) 
d.getProperty(NbmWizardIterator.OSGIDEPENDENCIES);
         if (b != null) {
             cbOsgiDeps.setSelected(b.booleanValue());
diff --git a/maven/manifest.mf b/maven/manifest.mf
--- a/maven/manifest.mf
+++ b/maven/manifest.mf
@@ -1,6 +1,6 @@
 Manifest-Version: 1.0
 OpenIDE-Module: org.netbeans.modules.maven/2
-OpenIDE-Module-Specification-Version: 2.80
+OpenIDE-Module-Specification-Version: 2.81
 OpenIDE-Module-Localizing-Bundle: 
org/netbeans/modules/maven/Bundle.properties
 OpenIDE-Module-Layer: org/netbeans/modules/maven/layer.xml
 AutoUpdate-Show-In-Client: false
diff --git 
a/maven/src/org/netbeans/modules/maven/api/archetype/Archetype.java 
b/maven/src/org/netbeans/modules/maven/api/archetype/Archetype.java
--- a/maven/src/org/netbeans/modules/maven/api/archetype/Archetype.java
+++ b/maven/src/org/netbeans/modules/maven/api/archetype/Archetype.java
@@ -42,7 +42,37 @@
 
 package org.netbeans.modules.maven.api.archetype;
 
+import java.io.File;
+import java.io.IOException;
+import java.io.InputStream;
+import java.util.Collections;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+import java.util.jar.JarFile;
+import java.util.logging.Level;
+import java.util.logging.Logger;
+import java.util.zip.ZipEntry;
+import org.apache.maven.artifact.Artifact;
+import org.apache.maven.artifact.handler.ArtifactHandler;
+import org.apache.maven.artifact.repository.ArtifactRepository;
+import org.apache.maven.artifact.resolver.ArtifactNotFoundException;
+import org.apache.maven.artifact.resolver.ArtifactResolutionException;
+import org.apache.maven.repository.RepositorySystem;
 import org.netbeans.api.annotations.common.NonNull;
+import org.netbeans.api.progress.aggregate.AggregateProgressHandle;
+import org.netbeans.modules.maven.embedder.EmbedderFactory;
+import org.netbeans.modules.maven.embedder.MavenEmbedder;
+import org.netbeans.modules.maven.embedder.exec.ProgressTransferListener;
+import org.netbeans.modules.maven.indexer.api.RepositoryInfo;
+import org.netbeans.modules.maven.indexer.api.RepositoryPreferences;
+import org.openide.util.Exceptions;
+import org.openide.xml.XMLUtil;
+import org.w3c.dom.Document;
+import org.w3c.dom.Element;
+import org.w3c.dom.NodeList;
+import org.xml.sax.InputSource;
+import org.xml.sax.SAXException;
 
 /**
  * Simple model class to describe a Maven archetype. To be created by 
ArchetypeProvider 
@@ -51,6 +81,8 @@
  */
 public final class Archetype {
     
+    private static final Logger LOG = 
Logger.getLogger(Archetype.class.getName());
+    
     private String artifactId;
     private String groupId;
     private String version;
@@ -58,6 +90,9 @@
     private String description;
     private String repository;
     public final boolean deletable;
+    private Artifact artifact;
+    private Artifact pomArtifact;
+
     
     public Archetype(boolean deletable) {
         this.deletable = deletable;
@@ -120,6 +155,7 @@
     
     /**
      * optional property.
+     * @param repo
      */ 
     public void setRepository(String repo) {
         repository = repo;
@@ -133,6 +169,171 @@
         return repository;
     }
     
+    /**
+     * initially non resolved artifact, need to call resolveArtifacts() 
before getArtifact().getFile() can be used.
+     * @return 
+     */
+    public synchronized Artifact getArtifact() {
+        if (artifact == null) {
+            MavenEmbedder online = EmbedderFactory.getOnlineEmbedder();
+            artifact = online.createArtifact(
+                    getGroupId(),
+                    getArtifactId(),
+                    getVersion(),
+                    "jar", //NOI18N
+                    "maven-archetype"); //NOI18N
+
+            //hack to get the right extension for the right packaging 
without the plugin.
+            artifact.setArtifactHandler(new ArtifactHandler() {
+                @Override
+                public String getExtension() {
+                    return "jar"; //NOI18N
+                }
+
+                @Override
+                public String getDirectory() {
+                    return null;
+                }
+
+                @Override
+                public String getClassifier() {
+                    return null;
+                }
+
+                @Override
+                public String getPackaging() {
+                    return "maven-archetype"; //NOI18N
+                }
+
+                @Override
+                public boolean isIncludesDependencies() {
+                    return false;
+                }
+
+                @Override
+                public String getLanguage() {
+                    return "java"; //NOI18N
+                }
+
+                @Override
+                public boolean isAddedToClasspath() {
+                    return false;
+                }
+            });
+        }
+        return artifact;
+    }
+
+    /**
+     * initially non resolved artifact, need to call resolveArtifacts() 
before getArtifact().getFile() can be used.
+     * @return 
+     */
+    public synchronized Artifact getPomArtifact() {
+        if (pomArtifact == null) {
+            MavenEmbedder online = EmbedderFactory.getOnlineEmbedder();
+            pomArtifact = online.createArtifact(
+                    getGroupId(),
+                    getArtifactId(),
+                    getVersion(),
+                    "pom", //NOI18N
+                    "pom"); //NOI18N
+        }
+        return pomArtifact;
+    }
+    
+    /**
+     * resolve the artifacts associated with the archetype (ideally 
downloads them to the local repository)
+     * @param hndl
+     * @throws ArtifactResolutionException
+     * @throws ArtifactNotFoundException 
+     */
+    public void resolveArtifacts(AggregateProgressHandle hndl) throws 
ArtifactResolutionException, ArtifactNotFoundException {
+        MavenEmbedder online = EmbedderFactory.getOnlineEmbedder();
+        
+        List<ArtifactRepository> repos;
+        if (getRepository() == null) {
+            repos = 
Collections.<ArtifactRepository>singletonList(online.createRemoteRepository(RepositorySystem.DEFAULT_REMOTE_REPO_URL,
 RepositorySystem.DEFAULT_REMOTE_REPO_ID));
+        } else {
+           repos = 
Collections.<ArtifactRepository>singletonList(online.createRemoteRepository(getRepository(),
 "custom-repo"));//NOI18N
+           for (RepositoryInfo info : 
RepositoryPreferences.getInstance().getRepositoryInfos()) {
+                if (getRepository().equals(info.getRepositoryUrl())) {
+                    repos = 
Collections.<ArtifactRepository>singletonList(online.createRemoteRepository(getRepository(),
 info.getId()));//NOI18N
+                    break;
+                }
+            }
+        }
+        try {
+            ProgressTransferListener.setAggregateHandle(hndl);
+            
+            hndl.start();
+
+//TODO how to rewrite to track progress?
+//            try {
+//                WagonManager wagon = 
online.getPlexusContainer().lookup(WagonManager.class);
+//                wagon.setDownloadMonitor(new ProgressTransferListener());
+//            } catch (ComponentLookupException ex) {
+//                Exceptions.printStackTrace(ex);
+//            }
+            online.resolve(getPomArtifact(), repos, 
online.getLocalRepository());
+            online.resolve(getArtifact(), repos, 
online.getLocalRepository());
+        } catch (ThreadDeath d) { // download interrupted
+        } catch (IllegalStateException ise) { //download interrupted in 
dependent thread. #213812
+            if (!(ise.getCause() instanceof ThreadDeath)) {
+                throw ise;
+            }
+        } finally {
+            ProgressTransferListener.clearAggregateHandle();
+            hndl.finish();
+        }
+    } 
+    
+    /**
+     * parses the META-INF/maven/archetype-metadata.xml file within the 
archetype's jar
+     * to get the additional required properties. Assumes resolveArtifacts() 
was called beforehand
+     * @return required property name as key and default value as map value
+     */
+    public Map<String, String> loadRequiredProperties() {
+        HashMap<String, String> map = new HashMap<String, String>();
+        File fil = getArtifact().getFile();
+        assert fil != null : "requires a resolved artifact";
+        JarFile jf = null;
+        try {
+            jf = new JarFile(fil);
+            ZipEntry entry = 
jf.getJarEntry("META-INF/maven/archetype-metadata.xml");
+            if (entry == null) {
+                entry = jf.getJarEntry("META-INF/maven/archetype.xml");
+            }
+            if (entry != null) {
+                InputStream in = jf.getInputStream(entry);
+                try {
+                    Document doc = XMLUtil.parse(new InputSource(in), false, 
false, XMLUtil.defaultErrorHandler(), null);
+                    NodeList nl = 
doc.getElementsByTagName("requiredProperty");
+                    for (int i = 0; i < nl.getLength(); i++) {
+                        Element rP = (Element) nl.item(i);
+                        Element dV = XMLUtil.findElement(rP, "defaultValue", 
null);
+                        map.put(rP.getAttribute("key"), dV != null ? 
XMLUtil.findText(dV) : null);
+                    }
+                } finally {
+                    in.close();
+                }
+            }
+        } catch (IOException ex) {
+            LOG.log(Level.INFO, ex.getMessage(), ex);
+        } catch (SAXException ex) {
+            LOG.log(Level.INFO, ex.getMessage(), ex);
+        } finally {
+            if (jf != null) {
+                try {
+                    jf.close();
+                } catch (IOException ex) {
+                    Exceptions.printStackTrace(ex);
+                }
+            }
+        }
+        return map;
+    }
+    
+    
     @Override
     public int hashCode() {
         return getGroupId().trim().hashCode() + 13 * 
getArtifactId().trim().hashCode() + 23 * getVersion().trim().hashCode();
diff --git 
a/maven/src/org/netbeans/modules/maven/newproject/ArchetypeWizardUtils.java 
b/maven/src/org/netbeans/modules/maven/newproject/ArchetypeWizardUtils.java
--- 
a/maven/src/org/netbeans/modules/maven/newproject/ArchetypeWizardUtils.java
+++ 
b/maven/src/org/netbeans/modules/maven/newproject/ArchetypeWizardUtils.java
@@ -44,7 +44,6 @@
 
 import java.io.File;
 import java.io.IOException;
-import java.io.InputStream;
 import java.util.ArrayList;
 import java.util.Collections;
 import java.util.Enumeration;
@@ -53,12 +52,9 @@
 import java.util.List;
 import java.util.Map;
 import java.util.Set;
-import java.util.jar.JarFile;
 import java.util.logging.Level;
 import java.util.logging.LogRecord;
 import java.util.logging.Logger;
-import java.util.zip.ZipEntry;
-import org.apache.maven.artifact.Artifact;
 import org.apache.maven.repository.RepositorySystem;
 import org.netbeans.api.annotations.common.NullAllowed;
 import org.netbeans.api.project.Project;
@@ -82,12 +78,6 @@
 import org.openide.filesystems.FileUtil;
 import org.openide.util.Exceptions;
 import org.openide.util.NbBundle.Messages;
-import org.openide.xml.XMLUtil;
-import org.w3c.dom.Document;
-import org.w3c.dom.Element;
-import org.w3c.dom.NodeList;
-import org.xml.sax.InputSource;
-import org.xml.sax.SAXException;
 
 /**
  * @author mkleint
@@ -156,47 +146,7 @@
         task.result();
     }
 
-    static Map<String, String> getAdditionalProperties(Artifact art) {
-        HashMap<String, String> map = new HashMap<String, String>();
-        File fil = art.getFile();
-        JarFile jf = null;
-        try {
-            jf = new JarFile(fil);
-            ZipEntry entry = 
jf.getJarEntry("META-INF/maven/archetype-metadata.xml");//NOI18N
-            if (entry == null) {
-                entry = 
jf.getJarEntry("META-INF/maven/archetype.xml");//NOI18N
-            }
-            if (entry != null) {
-                // 
http://maven.apache.org/archetype/maven-archetype-plugin/specification/archetype-metadata.html
-                InputStream in = jf.getInputStream(entry);
-                try {
-                    Document doc = XMLUtil.parse(new InputSource(in), false, 
false, XMLUtil.defaultErrorHandler(), null);
-                    NodeList nl = 
doc.getElementsByTagName("requiredProperty"); // NOI18N
-                    for (int i = 0; i < nl.getLength(); i++) {
-                        Element rP = (Element) nl.item(i);
-                        Element dV = XMLUtil.findElement(rP, "defaultValue", 
null); // NOI18N
-                        map.put(rP.getAttribute("key"), dV != null ? 
XMLUtil.findText(dV) : null); // NOI18N
-                    }
-                } finally {
-                    in.close();
-                }
-            }
-        } catch (IOException ex) {
-            LOG.log(Level.INFO, ex.getMessage(), ex);
-            //TODO should we do someting like delete the non-zip file? with 
the exception thrown the download failed?
-        } catch (SAXException ex) {
-            LOG.log(Level.INFO, ex.getMessage(), ex);
-        } finally {
-            if (jf != null) {
-                try {
-                    jf.close();
-                } catch (IOException ex) {
-                    Exceptions.printStackTrace(ex);
-                }
-            }
-        }
-        return map;
-    }
+   
 
     /**
      * Instantiates archetype stored in given wizard descriptor.
diff --git 
a/maven/src/org/netbeans/modules/maven/newproject/BasicPanelVisual.java 
b/maven/src/org/netbeans/modules/maven/newproject/BasicPanelVisual.java
--- a/maven/src/org/netbeans/modules/maven/newproject/BasicPanelVisual.java
+++ b/maven/src/org/netbeans/modules/maven/newproject/BasicPanelVisual.java
@@ -48,7 +48,6 @@
 import java.io.File;
 import java.util.Collections;
 import java.util.HashMap;
-import java.util.List;
 import java.util.Map;
 import java.util.logging.Level;
 import java.util.logging.Logger;
@@ -62,25 +61,18 @@
 import javax.swing.table.TableModel;
 import javax.swing.text.Document;
 import org.apache.maven.artifact.Artifact;
-import org.apache.maven.artifact.handler.ArtifactHandler;
-import org.apache.maven.artifact.repository.ArtifactRepository;
 import org.apache.maven.artifact.resolver.ArtifactNotFoundException;
 import org.apache.maven.artifact.resolver.ArtifactResolutionException;
 import org.apache.maven.artifact.versioning.ArtifactVersion;
 import org.apache.maven.artifact.versioning.DefaultArtifactVersion;
-import org.apache.maven.repository.RepositorySystem;
 import org.netbeans.api.options.OptionsDisplayer;
 import org.netbeans.api.progress.aggregate.AggregateProgressFactory;
 import org.netbeans.api.progress.aggregate.AggregateProgressHandle;
 import org.netbeans.api.progress.aggregate.ProgressContributor;
-import org.netbeans.modules.java.api.common.util.CommonProjectUtils;
 import org.netbeans.modules.maven.api.MavenValidators;
 import org.netbeans.modules.maven.api.archetype.Archetype;
-import org.netbeans.modules.maven.embedder.EmbedderFactory;
-import org.netbeans.modules.maven.embedder.MavenEmbedder;
 import org.netbeans.modules.maven.embedder.exec.ProgressTransferListener;
 import org.netbeans.modules.maven.indexer.api.RepositoryIndexer;
-import org.netbeans.modules.maven.indexer.api.RepositoryInfo;
 import org.netbeans.modules.maven.indexer.api.RepositoryPreferences;
 import static org.netbeans.modules.maven.newproject.Bundle.*;
 import org.netbeans.modules.maven.options.MavenOptionController;
@@ -637,7 +629,7 @@
             Artifact art = downloadArchetype(arch);
             File fil = art.getFile();
             if (fil.exists()) {
-                Map<String, String> props = 
ArchetypeWizardUtils.getAdditionalProperties(art);
+                Map<String, String> props = arch.loadRequiredProperties();
                 for (String key : props.keySet()) {
                     String defVal = props.get(key);
                     if ("groupId".equals(key) || "artifactId".equals(key) || 
"version".equals(key)) {
@@ -684,96 +676,18 @@
 
     @Messages("Handle_Download=Downloading Archetype")
     private Artifact downloadArchetype(Archetype arch) throws 
ArtifactResolutionException, ArtifactNotFoundException {
-        MavenEmbedder online = EmbedderFactory.getOnlineEmbedder();
-        Artifact art = online.createArtifact(
-                arch.getGroupId(), 
-                arch.getArtifactId(), 
-                arch.getVersion(), 
-                "jar", //NOI18N
-                "maven-archetype"); //NOI18N
-        Artifact pom = online.createArtifact(
-                arch.getGroupId(), 
-                arch.getArtifactId(), 
-                arch.getVersion(), 
-                "pom", //NOI18N
-                "pom"); //NOI18N
         
-        //hack to get the right extension for the right packaging without 
the plugin.
-        art.setArtifactHandler(new ArtifactHandler() {
-            @Override
-            public String getExtension() {
-                return "jar"; //NOI18N
-            }
-            @Override
-            public String getDirectory() {
-                return null;
-            }
-            @Override
-            public String getClassifier() {
-                return null;
-            }
-            @Override
-            public String getPackaging() {
-                return "maven-archetype"; //NOI18N
-            }
-            @Override
-            public boolean isIncludesDependencies() {
-                return false;
-            }
-            @Override
-            public String getLanguage() {
-                return "java"; //NOI18N
-            }
-            @Override
-            public boolean isAddedToClasspath() {
-                return false;
-            }
-        });
-        List<ArtifactRepository> repos;
-        if (arch.getRepository() == null) {
-            repos = 
Collections.<ArtifactRepository>singletonList(online.createRemoteRepository(RepositorySystem.DEFAULT_REMOTE_REPO_URL,
 RepositorySystem.DEFAULT_REMOTE_REPO_ID));
-        } else {
-           repos = 
Collections.<ArtifactRepository>singletonList(online.createRemoteRepository(arch.getRepository(),
 "custom-repo"));//NOI18N
-           for (RepositoryInfo info : 
RepositoryPreferences.getInstance().getRepositoryInfos()) {
-                if (arch.getRepository().equals(info.getRepositoryUrl())) {
-                    repos = 
Collections.<ArtifactRepository>singletonList(online.createRemoteRepository(arch.getRepository(),
 info.getId()));//NOI18N
-                    break;
-                }
-            }
-        }
         AggregateProgressHandle hndl = 
AggregateProgressFactory.createHandle(Handle_Download(),
                 new ProgressContributor[] {
                     
AggregateProgressFactory.createProgressContributor("zaloha") },  //NOI18N
                 ProgressTransferListener.cancellable(), null);
-        ProgressTransferListener.setAggregateHandle(hndl);
-
-        try {
-            hndl.start();
-
             synchronized (HANDLE_LOCK) {
                handle = hndl;
             }            
-//TODO how to rewrite to track progress?
-//            try {
-//                WagonManager wagon = 
online.getPlexusContainer().lookup(WagonManager.class);
-//                wagon.setDownloadMonitor(new ProgressTransferListener());
-//            } catch (ComponentLookupException ex) {
-//                Exceptions.printStackTrace(ex);
-//            }
-            online.resolve(pom, repos, online.getLocalRepository());
-            online.resolve(art, repos, online.getLocalRepository());
-        } catch (ThreadDeath d) { // download interrupted
-        } catch (IllegalStateException ise) { //download interrupted in 
dependent thread. #213812
-            if (!(ise.getCause() instanceof ThreadDeath)) {
-                throw ise;
-            }
-        } finally {
-            hndl.finish();
-            ProgressTransferListener.clearAggregateHandle();
-        }
+        arch.resolveArtifacts(hndl);
         //#154913
-        
RepositoryIndexer.updateIndexWithArtifacts(RepositoryPreferences.getInstance().getLocalRepository(),
 Collections.singletonList(art));
-        return art;
+        
RepositoryIndexer.updateIndexWithArtifacts(RepositoryPreferences.getInstance().getLocalRepository(),
 Collections.singletonList(arch.getArtifact()));
+        return arch.getArtifact();
     }
     
     private TableModel createPropModel() {

[hg] main-silver: have a faster method of extracting at least on...

Milos Kleint 05/10/2013

Project Features

About this Project

APIsupport was started in November 2009, is owned by Antonin Nebuzelsky, and has 43 members.
By use of this website, you agree to the NetBeans Policies and Terms of Use (revision 20140418.2d69abc). © 2013, Oracle Corporation and/or its affiliates. Sponsored by Oracle logo
 
 
Close
loading
Please Confirm
Close