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

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


The following commit(s) were added to refs/heads/master by this push:
     new 4789517  [NETBEANS-2044] Use gradle.properties to store project build 
actions.
4789517 is described below

commit 4789517d49b7b0aa421433d6f203b6fce7c2a3a3
Author: Laszlo Kishalmi <[email protected]>
AuthorDate: Fri Feb 1 23:47:39 2019 -0800

    [NETBEANS-2044] Use gradle.properties to store project build actions.
---
 .../gradle/GradleAuxiliaryPropertiesImpl.java      | 29 +++----
 .../actions/ActionMappingPropertyReader.java       | 98 ++++++++++++++++++++++
 .../actions/CustomActionRegistrationSupport.java   | 91 ++++++++++++--------
 .../actions/ProjectActionMappingProviderImpl.java  | 39 +++------
 .../gradle/customizer/BuildActionsCustomizer.java  |  2 -
 .../actions/ActionMappingPropertyReaderTest.java   | 97 +++++++++++++++++++++
 .../gradle/actions/ActionMappingScannerTest.java   |  6 +-
 7 files changed, 280 insertions(+), 82 deletions(-)

diff --git 
a/groovy/gradle/src/org/netbeans/modules/gradle/GradleAuxiliaryPropertiesImpl.java
 
b/groovy/gradle/src/org/netbeans/modules/gradle/GradleAuxiliaryPropertiesImpl.java
index 891eaa6..aa70c21 100644
--- 
a/groovy/gradle/src/org/netbeans/modules/gradle/GradleAuxiliaryPropertiesImpl.java
+++ 
b/groovy/gradle/src/org/netbeans/modules/gradle/GradleAuxiliaryPropertiesImpl.java
@@ -38,9 +38,9 @@ import org.openide.util.Mutex.Action;
  * @author Laszlo Kishalmi
  */
 public class GradleAuxiliaryPropertiesImpl implements AuxiliaryProperties {
-    
+
     private static final String PROP_PREFIX = "nb-config."; //NOI18N
-    
+
     final NbGradleProjectImpl project;
 
     public GradleAuxiliaryPropertiesImpl(NbGradleProjectImpl project) {
@@ -59,18 +59,15 @@ public class GradleAuxiliaryPropertiesImpl implements 
AuxiliaryProperties {
 
     @Override
     public void put(final String key, final String value, final boolean 
shared) {
-        ProjectManager.mutex().writeAccess(new Runnable() {
-            @Override
-            public void run() {
-                EditableProperties props = getProperties(shared);
-                if (value != null) {
-                    props.put(PROP_PREFIX + key, value);
-                } else {
-                    props.remove(PROP_PREFIX + key);
-                }
-                
-                putProperties(props, shared);
+        ProjectManager.mutex().writeAccess(() -> {
+            EditableProperties props = getProperties(shared);
+            if (value != null) {
+                props.put(PROP_PREFIX + key, value);
+            } else {
+                props.remove(PROP_PREFIX + key);
             }
+
+            putProperties(props, shared);
         });
     }
 
@@ -85,7 +82,7 @@ public class GradleAuxiliaryPropertiesImpl implements 
AuxiliaryProperties {
         }
         return ret;
     }
-    
+
     private EditableProperties getProperties(boolean shared) {
         EditableProperties ret = new EditableProperties(false);
         File input = getPropFile(shared);
@@ -98,7 +95,7 @@ public class GradleAuxiliaryPropertiesImpl implements 
AuxiliaryProperties {
         }
         return ret;
     }
-    
+
     private void putProperties(EditableProperties props, boolean shared) {
         File output = getPropFile(shared);
         if (!props.isEmpty()) {
@@ -114,7 +111,7 @@ public class GradleAuxiliaryPropertiesImpl implements 
AuxiliaryProperties {
             output.delete();
         }
      }
-    
+
     private File getPropFile(boolean shared) {
         GradleFiles gf = project.getGradleFiles();
         return new File(shared ? gf.getProjectDir() : 
GradleProjectCache.getCacheDir(gf), GradleFiles.GRADLE_PROPERTIES_NAME);
diff --git 
a/groovy/gradle/src/org/netbeans/modules/gradle/actions/ActionMappingPropertyReader.java
 
b/groovy/gradle/src/org/netbeans/modules/gradle/actions/ActionMappingPropertyReader.java
new file mode 100644
index 0000000..9540f75
--- /dev/null
+++ 
b/groovy/gradle/src/org/netbeans/modules/gradle/actions/ActionMappingPropertyReader.java
@@ -0,0 +1,98 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.netbeans.modules.gradle.actions;
+
+import java.util.Arrays;
+import java.util.Collections;
+import java.util.HashSet;
+import java.util.LinkedHashSet;
+import java.util.Properties;
+import java.util.Set;
+import static 
org.netbeans.modules.gradle.actions.CustomActionRegistrationSupport.ACTION_PROP_PREFIX;
+import org.netbeans.modules.gradle.api.execute.ActionMapping;
+
+/**
+ *
+ * @author lkishalmi
+ */
+public final class ActionMappingPropertyReader {
+
+    final Properties props;
+    ActionMappingPropertyReader(Properties props) {
+        this.props = props;
+    }
+
+    public static Set<ActionMapping> loadMappings(Properties props) {
+        ActionMappingPropertyReader reader = new 
ActionMappingPropertyReader(props);
+        return Collections.unmodifiableSet(reader.buildMappings());
+    }
+
+    private Set<ActionMapping> buildMappings() {
+        Set<ActionMapping> mappings = new HashSet<>();
+        for (String actionName : getActionNames()) {
+            mappings.add(createMapping(actionName));
+        }
+        return mappings;
+    }
+
+    private Set<String> getActionNames() {
+        Set<String> ret = new HashSet<>();
+        for (String key : props.stringPropertyNames()) {
+            if (key.startsWith(ACTION_PROP_PREFIX)) {
+                int dot = key.indexOf('.', ACTION_PROP_PREFIX.length() + 1);
+                if (dot > 0) {
+                    String name = key.substring(ACTION_PROP_PREFIX.length(), 
dot);
+                    ret.add(name);
+                }
+            }
+        }
+        return ret;
+    }
+
+    private ActionMapping createMapping(String name) {
+        DefaultActionMapping ret = new DefaultActionMapping(name);
+        String prefix = ACTION_PROP_PREFIX + name + '.';
+        ret.displayName = props.getProperty(ACTION_PROP_PREFIX + name);
+        ret.args = props.getProperty(prefix + "args");
+        ret.reloadArgs = props.getProperty(prefix + "reload.args");
+        String rule = props.getProperty(prefix + "reload.rule", 
ActionMapping.ReloadRule.DEFAULT.name());
+        try {
+            ret.reloadRule = ActionMapping.ReloadRule.valueOf(rule.trim());
+        } catch (IllegalArgumentException ex) {
+
+        }
+        String repeatable = props.getProperty(prefix + "repeatable");
+        if (repeatable != null) {
+            ret.repeatableAction = Boolean.valueOf(repeatable);
+        }
+        if (props.containsKey(prefix + "plugins")) {
+            String[] plugins = props.getProperty(prefix + 
"plugins").split(",\\s");
+            ret.withPlugins = new LinkedHashSet<>();
+            ret.withPlugins.addAll(Arrays.asList(plugins));
+        }
+        if (props.containsKey(prefix + "priority")) {
+            try {
+                ret.priority = Integer.parseInt(props.getProperty(prefix + 
"priority"));
+            } catch(NumberFormatException ex) {
+
+            }
+        }
+        return ret;
+    }
+}
diff --git 
a/groovy/gradle/src/org/netbeans/modules/gradle/actions/CustomActionRegistrationSupport.java
 
b/groovy/gradle/src/org/netbeans/modules/gradle/actions/CustomActionRegistrationSupport.java
index ac94483..c7f70d0 100644
--- 
a/groovy/gradle/src/org/netbeans/modules/gradle/actions/CustomActionRegistrationSupport.java
+++ 
b/groovy/gradle/src/org/netbeans/modules/gradle/actions/CustomActionRegistrationSupport.java
@@ -18,19 +18,22 @@
  */
 package org.netbeans.modules.gradle.actions;
 
-import java.io.FileNotFoundException;
 import java.io.IOException;
-import java.io.PrintWriter;
-import java.io.UnsupportedEncodingException;
+import java.io.InputStream;
+import java.io.OutputStream;
 import java.util.Collection;
 import java.util.Collections;
+import java.util.Iterator;
 import java.util.Map;
 import java.util.Set;
 import java.util.TreeMap;
 import org.netbeans.api.project.Project;
+import org.netbeans.api.project.ProjectManager;
 import org.netbeans.modules.gradle.api.execute.ActionMapping;
 import org.netbeans.modules.gradle.customizer.CustomActionMapping;
+import org.netbeans.modules.gradle.spi.GradleFiles;
 import org.openide.filesystems.FileObject;
+import org.openide.util.EditableProperties;
 import org.openide.util.Exceptions;
 
 /**
@@ -38,7 +41,8 @@ import org.openide.util.Exceptions;
  * @author lkishalmi
  */
 public class CustomActionRegistrationSupport {
-    private static final String NB_ACTIONS = "nb-actions.xml"; //NOI18N
+
+    public static final String ACTION_PROP_PREFIX = "action."; //NOI18N
 
     final Map<String, CustomActionMapping> customActions = new TreeMap<>();
     final Project project;
@@ -68,15 +72,15 @@ public class CustomActionRegistrationSupport {
         mapping.setArgs(args);
         mapping.setReloadRule(rule);
         mapping.setRepeatable(repeatable);
-        
+
         return registerCustomAction(mapping);
     }
-    
+
     public CustomActionMapping registerCustomAction(CustomActionMapping 
mapping) {
         customActions.put(mapping.getName(), mapping);
         return mapping;
     }
-    
+
     public CustomActionMapping registerCustomAction(String displayName, String 
args) {
         String name = getByDisplayName(displayName);
         if (name == null) {
@@ -84,19 +88,19 @@ public class CustomActionRegistrationSupport {
         }
         return registerCustomAction(name, displayName, args, 
ActionMapping.ReloadRule.DEFAULT, true);
     }
-    
+
     public CustomActionMapping unregisterCustomAction(String name) {
         return customActions.remove(name);
     }
-    
+
     public CustomActionMapping getCustomAction(String name) {
         return customActions.get(name);
     }
-    
+
     public Collection<CustomActionMapping> getCustomActions() {
         return Collections.unmodifiableCollection(customActions.values());
     }
-    
+
     private String getByDisplayName(String displayName) {
         String ret = null;
         for (CustomActionMapping value : customActions.values()) {
@@ -107,38 +111,59 @@ public class CustomActionRegistrationSupport {
         }
         return ret;
     }
-    
+
     public void save() {
-        try {
-            FileObject fo = 
project.getProjectDirectory().getFileObject(NB_ACTIONS);
-            fo = fo != null ? fo : 
project.getProjectDirectory().createData(NB_ACTIONS);
-            try (PrintWriter out = new PrintWriter(fo.getOutputStream(), 
true)) {
-                out.println("<?xml version=\"1.0\"?>");
-                out.println("<!DOCTYPE actions SYSTEM 
\"action-mapping.dtd\">");
-                out.println("<actions>");
+        EditableProperties props = new EditableProperties(false);
+        ProjectManager.mutex().writeAccess(() -> {
+            try {
+                FileObject fo = 
project.getProjectDirectory().getFileObject(GradleFiles.GRADLE_PROPERTIES_NAME);
+                if (fo != null) {
+                    try (InputStream is = fo.getInputStream()) {
+                        props.load(is);
+                    }
+                }
+                // Remove previously defined acltion, if any
+                Iterator<String> it = props.keySet().iterator();
+                while (it.hasNext()) {
+                    if (it.next().startsWith(ACTION_PROP_PREFIX)) {
+                        it.remove();
+                    }
+                }
+                // Add new actions, if any
                 for (CustomActionMapping mapping : customActions.values()) {
-                    out.print("    <action name=\"" + mapping.getName() + 
"\"");
+                    String prefix = ACTION_PROP_PREFIX + mapping.getName() + 
'.';
                     if 
(mapping.getName().startsWith(ActionMapping.CUSTOM_PREFIX)) {
-                        out.print(" displayName=\"" + mapping.getDisplayName() 
+ "\"");
+                        props.setProperty(ACTION_PROP_PREFIX + 
mapping.getName(), mapping.getDisplayName());
+                    }
+                    if (!mapping.getArgs().isEmpty()) {
+                        props.setProperty(prefix + "args", mapping.getArgs()); 
//NOI18N
+                    }
+                    if (!mapping.getReloadArgs().isEmpty()) {
+                        props.setProperty(prefix + "reload.args", 
mapping.getReloadArgs()); //NOI18N
+                    }
+                    if (mapping.getReloadRule() != 
ActionMapping.ReloadRule.DEFAULT) {
+                        props.setProperty(prefix + "reload.rule", 
mapping.getReloadRule().name()); //NOI18N
                     }
                     if (!mapping.isRepeatable()) {
-                        out.print("repeatable=\"false\"");
+                        props.setProperty(prefix + "repeatable", "false"); 
//NOI18N
                     }
-                    out.println(">");
+                }
 
-                    out.println("        <args>" + mapping.getArgs() + 
"</args>");
-                    if (mapping.getReloadRule() != 
ActionMapping.ReloadRule.DEFAULT) {
-                        out.println("        <reload rule=\"" + 
mapping.getReloadRule().name() + "\"/>");
+                if ((fo != null) && props.isEmpty()) {
+                    fo.delete();
+                }
+                if ((fo == null) && !props.isEmpty()) {
+                    fo = 
project.getProjectDirectory().createData(GradleFiles.GRADLE_PROPERTIES_NAME);
+                }
+                if ((fo != null) && !props.isEmpty()) {
+                    try (OutputStream os = fo.getOutputStream()) {
+                        props.store(os);
                     }
-                    out.println("    </action>");
                 }
-                out.println("</actions>");
-            } catch (FileNotFoundException | UnsupportedEncodingException ex) {
+            } catch (IOException ex) {
                 Exceptions.printStackTrace(ex);
             }
-        } catch (IOException ex) {
-
-        }
+        });
     }
-    
+
 }
diff --git 
a/groovy/gradle/src/org/netbeans/modules/gradle/actions/ProjectActionMappingProviderImpl.java
 
b/groovy/gradle/src/org/netbeans/modules/gradle/actions/ProjectActionMappingProviderImpl.java
index d6b9181..429df8d 100644
--- 
a/groovy/gradle/src/org/netbeans/modules/gradle/actions/ProjectActionMappingProviderImpl.java
+++ 
b/groovy/gradle/src/org/netbeans/modules/gradle/actions/ProjectActionMappingProviderImpl.java
@@ -22,11 +22,9 @@ package org.netbeans.modules.gradle.actions;
 import org.netbeans.modules.gradle.api.GradleBaseProject;
 import org.netbeans.modules.gradle.api.NbGradleProject;
 import org.netbeans.modules.gradle.api.execute.ActionMapping;
-import org.netbeans.modules.gradle.spi.WatchedResourceProvider;
 import java.beans.PropertyChangeEvent;
 import java.beans.PropertyChangeListener;
 import java.io.File;
-import java.util.Collections;
 import java.util.HashMap;
 import java.util.HashSet;
 import java.util.Map;
@@ -37,23 +35,20 @@ import org.openide.filesystems.FileUtil;
 import org.openide.util.WeakListeners;
 
 import static 
org.netbeans.modules.gradle.api.NbGradleProject.PROP_PROJECT_INFO;
-import static org.netbeans.modules.gradle.api.NbGradleProject.PROP_RESOURCES;
 import static org.netbeans.spi.project.ActionProvider.*;
 import java.io.FileInputStream;
 import java.io.IOException;
 import java.io.InputStream;
+import java.util.Properties;
 import java.util.logging.Logger;
-import javax.xml.parsers.ParserConfigurationException;
-import org.xml.sax.SAXException;
+import org.netbeans.modules.gradle.spi.GradleFiles;
 
 /**
  *
  * @author Laszlo Kishalmi
  */
-@ProjectServiceProvider(service = {
-    ProjectActionMappingProvider.class, WatchedResourceProvider.class
-}, projectType = NbGradleProject.GRADLE_PROJECT_TYPE)
-public class ProjectActionMappingProviderImpl implements 
ProjectActionMappingProvider, WatchedResourceProvider {
+@ProjectServiceProvider(service = ProjectActionMappingProvider.class, 
projectType = NbGradleProject.GRADLE_PROJECT_TYPE)
+public class ProjectActionMappingProviderImpl implements 
ProjectActionMappingProvider {
 
     private static final Logger LOG = 
Logger.getLogger(ProjectActionMappingProviderImpl.class.getName());
     private static final ActionMapping DEFAULT_RUN = new 
DefaultActionMapping("run", "run"); //NOI18N
@@ -61,8 +56,6 @@ public class ProjectActionMappingProviderImpl implements 
ProjectActionMappingPro
     private static final ActionMapping DEFAULT_DEBUG = new 
DefaultActionMapping("debug", "debug"); //NOI18N
     private static final ActionMapping DEFAULT_DEBUG2 = new 
DefaultActionMapping("debug", "run --debug-jvm"); //NOI18N
 
-    private static final String NB_ACTIONS = "nb-actions.xml"; //NOI18N
-
     final Project project;
     final PropertyChangeListener pcl;
     final File projectMappingFile;
@@ -77,20 +70,15 @@ public class ProjectActionMappingProviderImpl implements 
ProjectActionMappingPro
         pcl = new PropertyChangeListener() {
             @Override
             public void propertyChange(PropertyChangeEvent evt) {
-                switch (evt.getPropertyName()) {
-                    case PROP_PROJECT_INFO:
-                        cleanCache();
-                        break;
-                    case PROP_RESOURCES:
-                        if 
(projectMappingFile.toURI().equals(evt.getNewValue())) {
-                            loadProjectCustomMappings();
-                        }
+                if (PROP_PROJECT_INFO.equals(evt.getPropertyName())) {
+                    cleanCache();
+                    loadProjectCustomMappings();
                 }
             }
         };
         NbGradleProject.addPropertyChangeListener(project, 
WeakListeners.propertyChange(pcl, null));
         File projectDir = FileUtil.toFile(project.getProjectDirectory());
-        projectMappingFile = new File(projectDir, NB_ACTIONS);
+        projectMappingFile = new File(projectDir, 
GradleFiles.GRADLE_PROPERTIES_NAME);
         loadProjectCustomMappings();
     }
 
@@ -169,22 +157,19 @@ public class ProjectActionMappingProviderImpl implements 
ProjectActionMappingPro
         projectMappings.clear();
         if (projectMappingFile.canRead()) {
             try (InputStream is = new FileInputStream(projectMappingFile)) {
-                Set<ActionMapping> customMappings = 
ActionMappingScanner.loadMappings(is);
+                Properties props = new Properties();
+                props.load(is);
+                Set<ActionMapping> customMappings = 
ActionMappingPropertyReader.loadMappings(props);
                 for (ActionMapping mapping : customMappings) {
                     projectMappings.put(mapping.getName(), mapping);
                 }
-            } catch (IOException | ParserConfigurationException | SAXException 
ex) {
+            } catch (IOException ex) {
 
             }
         }
     }
 
     @Override
-    public Set<File> getWatchedResources() {
-        return Collections.singleton(projectMappingFile);
-    }
-
-    @Override
     public Set<String> customizedActions() {
         return projectMappings.keySet();
     }
diff --git 
a/groovy/gradle/src/org/netbeans/modules/gradle/customizer/BuildActionsCustomizer.java
 
b/groovy/gradle/src/org/netbeans/modules/gradle/customizer/BuildActionsCustomizer.java
index 1771c69..bff7868 100644
--- 
a/groovy/gradle/src/org/netbeans/modules/gradle/customizer/BuildActionsCustomizer.java
+++ 
b/groovy/gradle/src/org/netbeans/modules/gradle/customizer/BuildActionsCustomizer.java
@@ -51,8 +51,6 @@ import org.openide.util.NbBundle.Messages;
 @Messages("TXT_CUSTOM=Custom...")
 public class BuildActionsCustomizer extends javax.swing.JPanel {
 
-    private static final String NB_ACTIONS = "nb-actions.xml"; //NOI18N
-
     private final static String CUSTOM_ACTION = Bundle.TXT_CUSTOM();
     private static final String CARD_NOSELECT = "empty"; //NOI18N
     private static final String CARD_DETAILS = "details"; //NOI18N
diff --git 
a/groovy/gradle/test/unit/src/org/netbeans/modules/gradle/actions/ActionMappingPropertyReaderTest.java
 
b/groovy/gradle/test/unit/src/org/netbeans/modules/gradle/actions/ActionMappingPropertyReaderTest.java
new file mode 100644
index 0000000..99a7dfd
--- /dev/null
+++ 
b/groovy/gradle/test/unit/src/org/netbeans/modules/gradle/actions/ActionMappingPropertyReaderTest.java
@@ -0,0 +1,97 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.netbeans.modules.gradle.actions;
+
+import java.util.Arrays;
+import java.util.HashSet;
+import java.util.Properties;
+import java.util.Set;
+import org.junit.After;
+import org.junit.AfterClass;
+import org.junit.Before;
+import org.junit.BeforeClass;
+import org.junit.Test;
+import static org.junit.Assert.*;
+import org.netbeans.modules.gradle.api.execute.ActionMapping;
+
+/**
+ *
+ * @author lkishalmi
+ */
+public class ActionMappingPropertyReaderTest {
+
+    /**
+     * Test of loadMappings method, of class ActionMappingPropertyReader.
+     */
+    @Test
+    public void testLoadMappings1() {
+        Properties props = new Properties();
+        Set<ActionMapping> result = 
ActionMappingPropertyReader.loadMappings(props);
+        assertEquals(result.size(), 0);
+    }
+
+    @Test
+    public void testLoadMappings2() {
+        Properties props = new Properties();
+        props.put("nb-action.run.args", "runArgs");
+        Set<ActionMapping> result = 
ActionMappingPropertyReader.loadMappings(props);
+        assertEquals(result.size(), 1);
+        ActionMapping mapping = result.iterator().next();
+        assertEquals(mapping.getName(), "run");
+        assertEquals(mapping.getArgs(), "runArgs");
+        assertTrue(mapping.isRepeatable());
+        assertEquals(mapping.getReloadRule(), 
ActionMapping.ReloadRule.DEFAULT);
+        assertTrue(mapping.getReloadArgs().isEmpty());
+    }
+
+    @Test
+    public void testLoadMappings3() {
+        Properties props = new Properties();
+        props.put("nb-action.custom-1", "Build with Arguments");
+        props.put("nb-action.custom-1.args", "runArgs ${test}");
+        props.put("nb-action.custom-1.reload.args", "runArgs");
+        props.put("nb-action.custom-1.reload.rule", "NEVER");
+        props.put("nb-action.custom-1.repeatable", "false");
+        Set<ActionMapping> result = 
ActionMappingPropertyReader.loadMappings(props);
+        assertEquals(result.size(), 1);
+        ActionMapping mapping = result.iterator().next();
+        assertEquals(mapping.getDisplayName(), "Build with Arguments");
+        assertEquals(mapping.getName(), "custom-1");
+        assertEquals(mapping.getArgs(), "runArgs ${test}");
+        assertFalse(mapping.isRepeatable());
+        assertEquals(mapping.getReloadRule(), ActionMapping.ReloadRule.NEVER);
+        assertEquals(mapping.getReloadArgs(), "runArgs");
+    }
+
+    @Test
+    public void testLoadMappings4() {
+        Properties props = new Properties();
+        props.put("nb-action.build.args", "build");
+        props.put("nb-action.build.priority", "100");
+        props.put("nb-action.build.plugins", "groovy, war");
+        Set<ActionMapping> result = 
ActionMappingPropertyReader.loadMappings(props);
+        assertEquals(result.size(), 1);
+        DefaultActionMapping mapping = (DefaultActionMapping) 
result.iterator().next();
+        assertEquals(mapping.getName(), "build");
+        assertEquals(mapping.priority, 100);
+        assertTrue(mapping.isApplicable(new 
HashSet<String>(Arrays.asList("groovy", "root", "war"))));
+        assertFalse(mapping.isApplicable(new 
HashSet<String>(Arrays.asList("groovy"))));
+    }
+
+}
diff --git 
a/groovy/gradle/test/unit/src/org/netbeans/modules/gradle/actions/ActionMappingScannerTest.java
 
b/groovy/gradle/test/unit/src/org/netbeans/modules/gradle/actions/ActionMappingScannerTest.java
index 588532d..ded1664 100644
--- 
a/groovy/gradle/test/unit/src/org/netbeans/modules/gradle/actions/ActionMappingScannerTest.java
+++ 
b/groovy/gradle/test/unit/src/org/netbeans/modules/gradle/actions/ActionMappingScannerTest.java
@@ -19,8 +19,6 @@
 
 package org.netbeans.modules.gradle.actions;
 
-import org.netbeans.modules.gradle.actions.ActionMappingScanner;
-import org.netbeans.modules.gradle.actions.ActionMappingScanner;
 import org.netbeans.modules.gradle.api.execute.ActionMapping;
 import java.io.IOException;
 import java.util.Set;
@@ -34,7 +32,7 @@ import org.xml.sax.SAXException;
  * @author Laszlo Kishalmi
  */
 public class ActionMappingScannerTest {
-    
+
     public ActionMappingScannerTest() {
     }
 
@@ -44,5 +42,5 @@ public class ActionMappingScannerTest {
         assertTrue(mappings.size() > 0);
     }
 
-    
+
 }


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