Lines 53-58
Link Here
|
53 |
import java.util.List; |
53 |
import java.util.List; |
54 |
import java.util.Map; |
54 |
import java.util.Map; |
55 |
import java.util.Set; |
55 |
import java.util.Set; |
|
|
56 |
import java.util.concurrent.CountDownLatch; |
57 |
import java.util.concurrent.TimeUnit; |
58 |
import java.util.concurrent.atomic.AtomicBoolean; |
56 |
import java.util.jar.JarFile; |
59 |
import java.util.jar.JarFile; |
57 |
import java.util.logging.Level; |
60 |
import java.util.logging.Level; |
58 |
import java.util.logging.LogRecord; |
61 |
import java.util.logging.LogRecord; |
Lines 67-72
Link Here
|
67 |
import org.netbeans.api.progress.ProgressHandle; |
70 |
import org.netbeans.api.progress.ProgressHandle; |
68 |
import org.netbeans.api.project.Project; |
71 |
import org.netbeans.api.project.Project; |
69 |
import org.netbeans.api.project.ProjectManager; |
72 |
import org.netbeans.api.project.ProjectManager; |
|
|
73 |
import org.netbeans.api.project.ui.OpenProjects; |
70 |
import org.netbeans.modules.maven.api.ModelUtils; |
74 |
import org.netbeans.modules.maven.api.ModelUtils; |
71 |
import org.netbeans.modules.maven.api.NbMavenProject; |
75 |
import org.netbeans.modules.maven.api.NbMavenProject; |
72 |
import org.netbeans.modules.maven.api.archetype.ProjectInfo; |
76 |
import org.netbeans.modules.maven.api.archetype.ProjectInfo; |
Lines 83-88
Link Here
|
83 |
import org.openide.filesystems.FileUtil; |
87 |
import org.openide.filesystems.FileUtil; |
84 |
import org.openide.util.Exceptions; |
88 |
import org.openide.util.Exceptions; |
85 |
import org.openide.util.NbBundle; |
89 |
import org.openide.util.NbBundle; |
|
|
90 |
import org.openide.util.Task; |
91 |
import org.openide.util.TaskListener; |
86 |
import org.openide.xml.XMLUtil; |
92 |
import org.openide.xml.XMLUtil; |
87 |
import org.w3c.dom.Document; |
93 |
import org.w3c.dom.Document; |
88 |
import org.w3c.dom.Element; |
94 |
import org.w3c.dom.Element; |
Lines 199-205
Link Here
|
199 |
EA_ARCH.setArtifactId("pom-root"); //NOI18N |
205 |
EA_ARCH.setArtifactId("pom-root"); //NOI18N |
200 |
} |
206 |
} |
201 |
|
207 |
|
202 |
private static void runArchetype(File directory, ProjectInfo vi, Archetype arch, @NullAllowed Map<String,String> additional) throws IOException { |
208 |
private static void runArchetype(final File projDir, ProjectInfo vi, Archetype arch, @NullAllowed Map<String,String> additional) throws IOException { |
|
|
209 |
File directory = projDir.getParentFile(); |
203 |
BeanRunConfig config = new BeanRunConfig(); |
210 |
BeanRunConfig config = new BeanRunConfig(); |
204 |
config.setProperty("archetypeGroupId", arch.getGroupId()); //NOI18N |
211 |
config.setProperty("archetypeGroupId", arch.getGroupId()); //NOI18N |
205 |
config.setProperty("archetypeArtifactId", arch.getArtifactId()); //NOI18N |
212 |
config.setProperty("archetypeArtifactId", arch.getArtifactId()); //NOI18N |
Lines 235-241
Link Here
|
235 |
|
242 |
|
236 |
config.setTaskDisplayName(NbBundle.getMessage(ArchetypeWizardUtils.class, "RUN_Maven")); |
243 |
config.setTaskDisplayName(NbBundle.getMessage(ArchetypeWizardUtils.class, "RUN_Maven")); |
237 |
ExecutorTask task = RunUtils.executeMaven(config); //NOI18N |
244 |
ExecutorTask task = RunUtils.executeMaven(config); //NOI18N |
238 |
task.result(); |
245 |
final AtomicBoolean stoppedWaiting = new AtomicBoolean(); |
|
|
246 |
final CountDownLatch latch = new CountDownLatch(1); |
247 |
task.addTaskListener(new TaskListener() { |
248 |
@Override public void taskFinished(Task task) { |
249 |
boolean openLater = stoppedWaiting.get(); |
250 |
latch.countDown(); |
251 |
if (openLater) { |
252 |
// #191951: took too long and wizard closed early, try to open created projects now |
253 |
try { |
254 |
for (FileObject d : openProjects(projDir, null)) { |
255 |
Project p = ProjectManager.getDefault().findProject(d); |
256 |
if (p != null) { |
257 |
OpenProjects.getDefault().open(new Project[] {p}, false); |
258 |
} |
259 |
} |
260 |
} catch (IOException x) { |
261 |
LOG.log(Level.INFO, "could not find/load projects in " + projDir, x); |
262 |
} |
263 |
} |
264 |
} |
265 |
}); |
266 |
try { |
267 |
latch.await(10, TimeUnit.SECONDS); |
268 |
} catch (InterruptedException x) { |
269 |
LOG.log(Level.INFO, null, x); |
270 |
} |
271 |
stoppedWaiting.set(true); |
239 |
} |
272 |
} |
240 |
|
273 |
|
241 |
static Map<String, String> getAdditionalProperties(Artifact art) { |
274 |
static Map<String, String> getAdditionalProperties(Artifact art) { |
Lines 360-366
Link Here
|
360 |
} |
393 |
} |
361 |
handle.progress(NbBundle.getMessage(MavenWizardIterator.class, "PRG_Processing_Archetype"), ++progressCounter); |
394 |
handle.progress(NbBundle.getMessage(MavenWizardIterator.class, "PRG_Processing_Archetype"), ++progressCounter); |
362 |
|
395 |
|
363 |
runArchetype(parent, vi, arch, additional); |
396 |
runArchetype(projDir, vi, arch, additional); |
364 |
|
397 |
|
365 |
handle.progress(++progressCounter); |
398 |
handle.progress(++progressCounter); |
366 |
} |
399 |
} |