--- a/api.maven/nbproject/project.properties Fri Sep 16 11:20:45 2016 +0200
+++ a/api.maven/nbproject/project.properties Tue Oct 25 15:27:53 2016 +0200
@@ -39,7 +39,7 @@
# Portions Copyrighted 2008 Sun Microsystems, Inc.
is.autoload=true
-javac.source=1.6
+javac.source=1.8
javac.compilerargs=-Xlint -Xlint:-serial
javadoc.apichanges=${basedir}/apichanges.xml
javadoc.arch=${basedir}/arch.xml
--- a/api.maven/nbproject/project.xml Fri Sep 16 11:20:45 2016 +0200
+++ a/api.maven/nbproject/project.xml Tue Oct 25 15:27:53 2016 +0200
@@ -59,6 +59,23 @@
+ org.netbeans.api.templates
+
+
+
+ 1.0
+
+
+
+ org.netbeans.core.multiview
+
+
+
+ 1
+ 1.44
+
+
+
org.netbeans.modules.maven
@@ -68,6 +85,14 @@
+ org.openide.awt
+
+
+
+ 7.67
+
+
+
org.openide.dialogs
@@ -92,11 +117,19 @@
- org.netbeans.api.templates
+ org.openide.nodes
- 1.0
+ 7.45
+
+
+
+ org.openide.util
+
+
+
+ 9.7
@@ -107,6 +140,22 @@
8.0
+
+ org.openide.util.ui
+
+
+
+ 9.6
+
+
+
+ org.openide.windows
+
+
+
+ 6.75
+
+
--- a/maven/nbproject/project.xml Fri Sep 16 11:20:45 2016 +0200
+++ a/maven/nbproject/project.xml Tue Oct 25 15:27:53 2016 +0200
@@ -572,6 +572,11 @@
+ org.netbeans.modules.templatesui
+
+
+
+
org.netbeans.modules.xml.xdm
@@ -581,12 +586,13 @@
- org.openide.util.ui
+ org.openide.util.lookup
- org.openide.util.lookup
+ org.openide.util.ui
+
--- a/maven/src/org/netbeans/modules/maven/api/archetype/ArchetypeWizards.java Fri Sep 16 11:20:45 2016 +0200
+++ a/maven/src/org/netbeans/modules/maven/api/archetype/ArchetypeWizards.java Tue Oct 25 15:27:53 2016 +0200
@@ -47,6 +47,7 @@
import java.util.Map;
import java.util.Set;
import org.netbeans.api.annotations.common.NullAllowed;
+import org.netbeans.api.project.Project;
import org.netbeans.api.templates.TemplateRegistration;
import org.netbeans.modules.maven.model.ModelOperation;
import org.netbeans.modules.maven.model.pom.POMModel;
@@ -54,6 +55,7 @@
import org.netbeans.modules.maven.newproject.BasicWizardPanel;
import org.netbeans.modules.maven.newproject.MavenWizardIterator;
import org.netbeans.validation.api.ui.ValidationGroup;
+import org.netbeans.validation.api.ui.ValidationGroupProvider;
import org.openide.WizardDescriptor;
import org.openide.filesystems.FileObject;
@@ -107,6 +109,10 @@
return new BasicWizardPanel(vg, archetype, isFinish, false);
}
+ static WizardDescriptor.Panel basicWizardPanel(Object p, String type) {
+ return basicWizardPanel(ValidationGroup.create(), false, null);
+ }
+
/**
* Wizard iterator using a predetermined archetype.
* @since 2.28
--- a/maven/src/org/netbeans/modules/maven/execute/MavenCommandLineExecutor.java Fri Sep 16 11:20:45 2016 +0200
+++ a/maven/src/org/netbeans/modules/maven/execute/MavenCommandLineExecutor.java Tue Oct 25 15:27:53 2016 +0200
@@ -67,7 +67,6 @@
import java.util.zip.ZipInputStream;
import javax.swing.AbstractAction;
import org.apache.maven.artifact.Artifact;
-import org.apache.maven.artifact.versioning.ArtifactVersion;
import org.apache.maven.artifact.versioning.DefaultArtifactVersion;
import org.apache.maven.artifact.versioning.InvalidVersionSpecificationException;
import org.apache.maven.artifact.versioning.VersionRange;
@@ -78,7 +77,6 @@
import org.codehaus.plexus.util.IOUtil;
import org.codehaus.plexus.util.cli.CommandLineUtils;
import org.codehaus.plexus.util.xml.Xpp3Dom;
-import org.netbeans.api.extexecution.ExternalProcessSupport;
import org.netbeans.api.extexecution.base.Processes;
import org.netbeans.api.progress.ProgressHandle;
import org.netbeans.api.progress.ProgressHandleFactory;
@@ -604,10 +602,12 @@
}
//#195039
- builder.environment().put("M2_HOME", mavenHome.getAbsolutePath());
- if (!mavenHome.equals(EmbedderFactory.getDefaultMavenHome())) {
- //only relevant display when using the non-default maven installation.
- display.append(Utilities.escapeParameters(new String[] {"M2_HOME=" + mavenHome.getAbsolutePath()})).append(' '); // NOI18N
+ if (mavenHome != null) {
+ builder.environment().put("M2_HOME", mavenHome.getAbsolutePath());
+ if (!mavenHome.equals(EmbedderFactory.getDefaultMavenHome())) {
+ //only relevant display when using the non-default maven installation.
+ display.append(Utilities.escapeParameters(new String[] {"M2_HOME=" + mavenHome.getAbsolutePath()})).append(' '); // NOI18N
+ }
}
//very hacky here.. have a way to remove
@@ -709,7 +709,9 @@
mavenPath = delimiter + mavenPath;
}
//netbeans-eventspy.jar comes first on classpath
- mavenPath = jar.getAbsolutePath() + mavenPath;
+ if (jar != null) {
+ mavenPath = jar.getAbsolutePath() + mavenPath;
+ }
clonedConfig.setProperty(CosChecker.MAVENEXTCLASSPATH, mavenPath);
}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ e66070a74aa4 Tue Oct 25 15:27:53 2016 +0200
@@ -0,0 +1,174 @@
+/*
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
+ *
+ * Copyright (c) 2016 Oracle and/or its affiliates. All rights reserved.
+ *
+ * Oracle and Java are registered trademarks of Oracle and/or its affiliates.
+ * Other names may be trademarks of their respective owners.
+ *
+ * The contents of this file are subject to the terms of either the GNU
+ * General Public License Version 2 only ("GPL") or the Common
+ * Development and Distribution License("CDDL") (collectively, the
+ * "License"). You may not use this file except in compliance with the
+ * License. You can obtain a copy of the License at
+ * http://www.netbeans.org/cddl-gplv2.html
+ * or nbbuild/licenses/CDDL-GPL-2-CP. See the License for the
+ * specific language governing permissions and limitations under the
+ * License. When distributing the software, include this License Header
+ * Notice in each file and include the License file at
+ * nbbuild/licenses/CDDL-GPL-2-CP. Oracle designates this
+ * particular file as subject to the "Classpath" exception as provided
+ * by Oracle in the GPL Version 2 section of the License file that
+ * accompanied this code. If applicable, add the following below the
+ * License Header, with the fields enclosed by brackets [] replaced by
+ * your own identifying information:
+ * "Portions Copyrighted [year] [name of copyright owner]"
+ *
+ * If you wish your version of this file to be governed by only the CDDL
+ * or only the GPL Version 2, indicate your decision by adding
+ * "[Contributor] elects to include this software in this distribution
+ * under the [CDDL or GPL Version 2] license." If you do not indicate a
+ * single choice of license, a recipient has the option to distribute
+ * your version of this file under either the CDDL, the GPL Version 2 or
+ * to extend the choice of license to its licensees as provided above.
+ * However, if you add GPL Version 2 code and therefore, elected the GPL
+ * Version 2 license, then the option applies only if the new code is
+ * made subject to such option by the copyright holder.
+ *
+ * Contributor(s):
+ */
+package org.netbeans.modules.maven.newproject;
+
+import java.io.File;
+import java.io.IOException;
+import java.io.InputStream;
+import java.util.ArrayList;
+import java.util.Collection;
+import java.util.Collections;
+import java.util.Enumeration;
+import java.util.List;
+import java.util.Map;
+import java.util.Properties;
+import java.util.regex.Pattern;
+import org.netbeans.api.project.Project;
+import org.netbeans.api.project.ProjectManager;
+import org.netbeans.api.templates.CreateDescriptor;
+import org.netbeans.api.templates.CreateFromTemplateHandler;
+import org.netbeans.modules.maven.api.archetype.Archetype;
+import org.netbeans.modules.maven.api.archetype.ArchetypeWizards;
+import org.netbeans.modules.maven.api.archetype.ProjectInfo;
+import org.netbeans.spi.project.ActionProvider;
+import org.netbeans.spi.project.ui.support.CommonProjectActions;
+import org.openide.filesystems.FileObject;
+import org.openide.filesystems.FileUtil;
+import org.openide.util.NbBundle;
+import org.openide.util.NbCollections;
+import org.openide.util.lookup.ServiceProvider;
+
+@ServiceProvider(service = CreateFromTemplateHandler.class, position = 5000)
+public final class ArchetypeTemplateHandler extends CreateFromTemplateHandler {
+ public ArchetypeTemplateHandler() {
+ }
+
+ @Override
+ protected boolean accept(CreateDescriptor desc) {
+ return desc.getTemplate().hasExt("archetype"); // NOI18N
+ }
+
+ @NbBundle.Messages({
+ "MSG_NoVersion=No version attribute specified for the Maven project",
+ "MSG_NoArtifactId=No artifactId attribute specified for the Maven project",
+ "MSG_NoGroupId=No groupId attribute specified for the Maven project",
+ })
+ @Override
+ protected List createFromTemplate(CreateDescriptor desc) throws IOException {
+ Properties p = new Properties();
+ try (InputStream is = desc.getTemplate().getInputStream()) {
+ p.load(is);
+ }
+ String version = (String)desc.getValue("version"); // NOI18N
+ if (version == null) {
+ throw new IOException(Bundle.MSG_NoVersion());
+ }
+ String artifactId = (String)desc.getValue("artifactId"); // NOI18N
+ if (version == null) {
+ throw new IOException(Bundle.MSG_NoArtifactId());
+ }
+ String groupId = (String)desc.getValue("groupId"); // NOI18N
+ if (version == null) {
+ throw new IOException(Bundle.MSG_NoGroupId());
+ }
+ String packageName = (String)desc.getValue("package"); // NOI18N
+ ProjectInfo pi = new ProjectInfo(groupId, artifactId, version, packageName);
+ Map,?> additionalProperties = desc.getValue("wizard"); // NOI18N
+ Archetype arch = new Archetype();
+ arch.setArtifactId(p.getProperty("artifactId")); // NOI18N
+ arch.setGroupId(p.getProperty("groupId")); // NOI18N
+ arch.setVersion(p.getProperty("version")); // NOI18N
+ File projDir = desc.getValue(CommonProjectActions.PROJECT_PARENT_FOLDER);
+ if (projDir == null && desc.getTarget() != null) {
+ projDir = FileUtil.toFile(desc.getTarget());
+ }
+ if (projDir == null) {
+ throw new IOException(CommonProjectActions.PROJECT_PARENT_FOLDER + " not specified");
+ }
+
+ Map filteredProperties =
+ additionalProperties == null ?
+ Collections.emptyMap()
+ :
+ NbCollections.checkedMapByFilter(additionalProperties, String.class, String.class, false);
+ ArchetypeWizards.createFromArchetype(projDir, pi, arch, filteredProperties, true);
+ FileObject fo = FileUtil.toFileObject(projDir);
+
+ List fos = new ArrayList<>();
+ collectPomDirs(fo, fos);
+ final String toOpen = p.getProperty("open"); // NOI18N
+ if (toOpen != null) {
+ collectFiles(fo, fos, toOpen.split(",")); // NOI18N
+ }
+
+ Project prj = ProjectManager.getDefault().findProject(fo);
+ ActionProvider ap = prj == null ? null : prj.getLookup().lookup(ActionProvider.class);
+ if (ap != null) {
+ ap.invokeAction(ActionProvider.COMMAND_BUILD, prj.getLookup());
+ }
+ return fos;
+ }
+
+ private static void collectPomDirs(FileObject dir, Collection super FileObject> found) {
+ if (dir == null || !dir.isFolder()) {
+ return;
+ }
+ if (dir.getFileObject("pom.xml") == null) {
+ return;
+ }
+ found.add(dir);
+ for (FileObject f : dir.getChildren()) {
+ collectPomDirs(f, found);
+ }
+ }
+
+ static void collectFiles(FileObject root, Collection super FileObject> found, String... includes) {
+ Pattern[] check = new Pattern[includes.length];
+ for (int i = 0; i < check.length; i++) {
+ check[i] = Pattern.compile(includes[i]);
+ }
+
+ Enumeration extends FileObject> en = root.getChildren(true);
+ while (en.hasMoreElements()) {
+ FileObject fo = en.nextElement();
+ String relPath = FileUtil.getRelativePath(root, fo);
+ if (relPath == null) {
+ continue;
+ }
+ for (Pattern p : check) {
+ if (p.matcher(relPath).matches()) {
+ found.add(fo);
+ break;
+ }
+ }
+ }
+ }
+
+}
--- a/maven/src/org/netbeans/modules/maven/newproject/ArchetypeWizardUtils.java Fri Sep 16 11:20:45 2016 +0200
+++ a/maven/src/org/netbeans/modules/maven/newproject/ArchetypeWizardUtils.java Tue Oct 25 15:27:53 2016 +0200
@@ -46,7 +46,6 @@
import java.io.IOException;
import java.util.ArrayList;
import java.util.Collections;
-import java.util.Enumeration;
import java.util.HashMap;
import java.util.LinkedHashSet;
import java.util.List;
--- a/maven/src/org/netbeans/modules/maven/newproject/BasicPanelVisual.java Fri Sep 16 11:20:45 2016 +0200
+++ a/maven/src/org/netbeans/modules/maven/newproject/BasicPanelVisual.java Tue Oct 25 15:27:53 2016 +0200
@@ -91,6 +91,8 @@
import org.openide.WizardDescriptor;
import org.openide.awt.Mnemonics;
import org.openide.filesystems.FileUtil;
+import org.openide.loaders.DataFolder;
+import org.openide.loaders.TemplateWizard;
import org.openide.util.NbBundle.Messages;
import org.openide.util.RequestProcessor;
import org.openide.util.Utilities;
@@ -530,9 +532,17 @@
}
String name = projectNameTextField.getText().trim();
String folder = createdFolderTextField.getText().trim();
+ final File parentFolder = new File(folder);
- d.putProperty(CommonProjectActions.PROJECT_PARENT_FOLDER, new File(folder)); //NOI18N
+ d.putProperty(CommonProjectActions.PROJECT_PARENT_FOLDER, parentFolder);
+ if (d instanceof TemplateWizard) {
+ parentFolder.mkdirs();
+ ((TemplateWizard) d).setTargetFolder(DataFolder.findFolder(FileUtil.toFileObject(parentFolder)));
+ }
d.putProperty("name", name); //NOI18N
+ if (d instanceof TemplateWizard) {
+ ((TemplateWizard) d).setTargetName(name);
+ }
d.putProperty("artifactId", txtArtifactId.getText().trim()); //NOI18N
d.putProperty("groupId", txtGroupId.getText().trim()); //NOI18N
MavenSettings.getDefault().setLastArchetypeGroupId(txtGroupId.getText().trim());
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ e66070a74aa4 Tue Oct 25 15:27:53 2016 +0200
@@ -0,0 +1,3 @@
+groupId=org.codehaus.mojo.archetypes
+artifactId=javafx
+version=0.6
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ e66070a74aa4 Tue Oct 25 15:27:53 2016 +0200
@@ -0,0 +1,18 @@
+
+
+
+ SimpleWizard
+
+
+
+
+
+
+
+
+
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ e66070a74aa4 Tue Oct 25 15:27:53 2016 +0200
@@ -0,0 +1,118 @@
+/*
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
+ *
+ * Copyright (c) 2016 Oracle and/or its affiliates. All rights reserved.
+ *
+ * Oracle and Java are registered trademarks of Oracle and/or its affiliates.
+ * Other names may be trademarks of their respective owners.
+ *
+ * The contents of this file are subject to the terms of either the GNU
+ * General Public License Version 2 only ("GPL") or the Common
+ * Development and Distribution License("CDDL") (collectively, the
+ * "License"). You may not use this file except in compliance with the
+ * License. You can obtain a copy of the License at
+ * http://www.netbeans.org/cddl-gplv2.html
+ * or nbbuild/licenses/CDDL-GPL-2-CP. See the License for the
+ * specific language governing permissions and limitations under the
+ * License. When distributing the software, include this License Header
+ * Notice in each file and include the License file at
+ * nbbuild/licenses/CDDL-GPL-2-CP. Oracle designates this
+ * particular file as subject to the "Classpath" exception as provided
+ * by Oracle in the GPL Version 2 section of the License file that
+ * accompanied this code. If applicable, add the following below the
+ * License Header, with the fields enclosed by brackets [] replaced by
+ * your own identifying information:
+ * "Portions Copyrighted [year] [name of copyright owner]"
+ *
+ * If you wish your version of this file to be governed by only the CDDL
+ * or only the GPL Version 2, indicate your decision by adding
+ * "[Contributor] elects to include this software in this distribution
+ * under the [CDDL or GPL Version 2] license." If you do not indicate a
+ * single choice of license, a recipient has the option to distribute
+ * your version of this file under either the CDDL, the GPL Version 2 or
+ * to extend the choice of license to its licensees as provided above.
+ * However, if you add GPL Version 2 code and therefore, elected the GPL
+ * Version 2 license, then the option applies only if the new code is
+ * made subject to such option by the copyright holder.
+ *
+ * Contributor(s):
+ */
+package org.netbeans.modules.maven.newproject.simplewizard;
+
+import java.io.File;
+import java.util.Set;
+import net.java.html.json.Model;
+import org.netbeans.api.templates.TemplateRegistration;
+import org.netbeans.junit.MockServices;
+import org.netbeans.junit.NbTestCase;
+import org.netbeans.modules.project.indexingbridge.IndexingBridge;
+import org.openide.WizardDescriptor;
+import org.openide.filesystems.FileObject;
+import org.openide.filesystems.FileUtil;
+import org.openide.loaders.DataFolder;
+import org.openide.loaders.DataObject;
+import org.openide.loaders.TemplateWizard;
+import org.openide.util.NbBundle;
+
+@Model(className = "EmptyModel", properties = {})
+public class SimpleWizardHandlerTest extends NbTestCase {
+
+ public SimpleWizardHandlerTest(String name) {
+ super(name);
+ }
+
+
+ @TemplateRegistration(
+ page = "SimpleWizard.html",
+ folder = "Project/Test",
+ displayName = "#Wizard_displayName",
+ content = "SimpleWizard.archetype"
+ )
+ @NbBundle.Messages({
+ "Wizard_displayName=SimpleWizard"
+ })
+ private static EmptyModel simpleWizard() {
+ return new EmptyModel();
+ }
+
+ public void testSimpleWizard() throws Exception {
+ clearWorkDir();
+ File whereTo = new File(getWorkDir(), "whereTo");
+ whereTo.mkdirs();
+ FileObject whereToObj = FileUtil.toFileObject(whereTo);
+ assertNotNull("Where obj found", whereToObj);
+ MockServices.setServices(MockIndexingBridge.class);
+
+ FileObject archetype = FileUtil.getConfigFile("Templates/Project/Test/SimpleWizard.archetype");
+ assertNotNull(archetype);
+ Object iterator = archetype.getAttribute("instantiatingIterator");
+ assertNotNull("Iterator found", iterator);
+ assertTrue("It is iterator", iterator instanceof WizardDescriptor.InstantiatingIterator);
+ WizardDescriptor.InstantiatingIterator instIter = (WizardDescriptor.InstantiatingIterator) iterator;
+
+ TemplateWizard tw = new TemplateWizard();
+ tw.setTemplate(DataObject.find(archetype));
+ tw.setTargetFolder(DataFolder.findFolder(whereToObj));
+ tw.putProperty("version", "6.5");
+ tw.putProperty("artifactId", "simplewizardtest");
+ tw.putProperty("groupId", "org.netbeans.test");
+
+ instIter.initialize(tw);
+ Set> results = instIter.instantiate();
+ fail("results: " + results);
+ }
+
+ public static final class MockIndexingBridge extends IndexingBridge {
+ public MockIndexingBridge() {
+ }
+
+ @Override
+ protected void enterProtectedMode() {
+ }
+
+ @Override
+ protected void exitProtectedMode() {
+ }
+ }
+
+}
--- a/parsing.indexing/src/org/netbeans/modules/parsing/impl/indexing/RepositoryUpdater.java Fri Sep 16 11:20:45 2016 +0200
+++ a/parsing.indexing/src/org/netbeans/modules/parsing/impl/indexing/RepositoryUpdater.java Tue Oct 25 15:27:53 2016 +0200
@@ -48,7 +48,6 @@
import java.lang.ref.Reference;
import java.lang.ref.WeakReference;
import java.net.MalformedURLException;
-import java.net.URI;
import java.net.URISyntaxException;
import java.net.URL;
import java.security.InvalidParameterException;
@@ -67,7 +66,6 @@
import java.util.logging.Logger;
import java.util.prefs.Preferences;
import java.util.stream.Collectors;
-import java.util.stream.Stream;
import java.util.zip.ZipEntry;
import java.util.zip.ZipFile;
import javax.swing.event.DocumentEvent;
--- a/templatesui/src/org/netbeans/modules/templatesui/AbstractWizard.java Fri Sep 16 11:20:45 2016 +0200
+++ a/templatesui/src/org/netbeans/modules/templatesui/AbstractWizard.java Tue Oct 25 15:27:53 2016 +0200
@@ -51,6 +51,7 @@
import java.util.ArrayList;
import java.util.Collections;
import java.util.HashMap;
+import java.util.LinkedHashSet;
import java.util.List;
import java.util.Map;
import java.util.NoSuchElementException;
@@ -74,8 +75,10 @@
import net.java.html.js.JavaScriptBody;
import net.java.html.json.Model;
import net.java.html.json.Models;
+import org.netbeans.api.templates.FileBuilder;
import org.openide.WizardDescriptor;
import org.openide.WizardValidationException;
+import org.openide.filesystems.FileObject;
import org.openide.loaders.DataObject;
import org.openide.loaders.TemplateWizard;
import org.openide.util.Lookup;
@@ -109,6 +112,7 @@
@Override
public Set extends Object> instantiate() throws IOException {
try {
+ final TemplateWizard tw = (TemplateWizard) wizard;
FutureTask> t = new FutureTask<>(new Callable