This Bugzilla instance is a read-only archive of historic NetBeans bug reports. To report a bug in NetBeans please follow the project's instructions for reporting issues.

View | Details | Raw Unified | Return to bug 230565
Collapse All | Expand All

(-)a/maven.j2ee/nbproject/project.xml (-1 / +1 lines)
Lines 263-269 Link Here
263
                    <compile-dependency/>
263
                    <compile-dependency/>
264
                    <run-dependency>
264
                    <run-dependency>
265
                        <release-version>2</release-version>
265
                        <release-version>2</release-version>
266
                        <specification-version>2.88</specification-version>
266
                        <specification-version>2.97</specification-version>
267
                    </run-dependency>
267
                    </run-dependency>
268
                </dependency>
268
                </dependency>
269
                <dependency>
269
                <dependency>
(-)a/maven.j2ee/src/org/netbeans/modules/maven/j2ee/ExecutionChecker.java (-213 / +3 lines)
Lines 41-81 Link Here
41
 */
41
 */
42
package org.netbeans.modules.maven.j2ee;
42
package org.netbeans.modules.maven.j2ee;
43
43
44
import java.io.File;
45
import java.io.IOException;
46
import java.net.MalformedURLException;
47
import java.net.URL;
48
import java.util.concurrent.Callable;
49
import java.util.logging.Level;
50
import java.util.logging.Logger;
51
import org.apache.maven.model.Build;
52
import org.netbeans.api.project.Project;
44
import org.netbeans.api.project.Project;
53
import org.netbeans.api.project.ProjectUtils;
54
import org.netbeans.modules.j2ee.deployment.devmodules.api.Deployment;
45
import org.netbeans.modules.j2ee.deployment.devmodules.api.Deployment;
55
import org.netbeans.modules.j2ee.deployment.devmodules.api.InstanceRemovedException;
46
import org.netbeans.modules.j2ee.deployment.devmodules.api.InstanceRemovedException;
56
import org.netbeans.modules.j2ee.deployment.devmodules.api.ServerInstance;
47
import org.netbeans.modules.j2ee.deployment.devmodules.api.ServerInstance;
57
import org.netbeans.modules.j2ee.deployment.devmodules.spi.J2eeModuleProvider;
48
import org.netbeans.modules.j2ee.deployment.devmodules.spi.J2eeModuleProvider;
58
import org.netbeans.modules.j2ee.deployment.plugins.api.ServerDebugInfo;
59
import org.netbeans.modules.maven.api.NbMavenProject;
49
import org.netbeans.modules.maven.api.NbMavenProject;
60
import org.netbeans.modules.maven.api.execute.ExecutionContext;
50
import org.netbeans.modules.maven.api.execute.ExecutionContext;
61
import org.netbeans.modules.maven.api.execute.ExecutionResultChecker;
51
import org.netbeans.modules.maven.api.execute.ExecutionResultChecker;
62
import org.netbeans.modules.maven.api.execute.PrerequisitesChecker;
52
import org.netbeans.modules.maven.api.execute.PrerequisitesChecker;
63
import org.netbeans.modules.maven.api.execute.RunConfig;
53
import org.netbeans.modules.maven.api.execute.RunConfig;
64
import org.netbeans.modules.maven.api.execute.RunUtils;
65
import org.netbeans.modules.maven.j2ee.ui.SelectAppServerPanel;
54
import org.netbeans.modules.maven.j2ee.ui.SelectAppServerPanel;
66
import org.netbeans.modules.maven.j2ee.ui.customizer.impl.CustomizerRunWeb;
67
import org.netbeans.modules.maven.j2ee.utils.MavenProjectSupport;
68
import org.netbeans.modules.maven.spi.debug.MavenDebugger;
69
import org.netbeans.modules.web.browser.spi.URLDisplayerImplementation;
70
import org.netbeans.spi.project.ProjectServiceProvider;
55
import org.netbeans.spi.project.ProjectServiceProvider;
71
import org.openide.DialogDisplayer;
56
import org.openide.DialogDisplayer;
72
import org.openide.NotifyDescriptor;
57
import org.openide.NotifyDescriptor;
73
import org.openide.awt.HtmlBrowser;
74
import org.openide.filesystems.FileObject;
75
import org.openide.filesystems.FileUtil;
76
import org.openide.util.NbBundle;
58
import org.openide.util.NbBundle;
77
import org.openide.windows.OutputWriter;
78
import static org.netbeans.modules.maven.j2ee.Bundle.*;
59
import static org.netbeans.modules.maven.j2ee.Bundle.*;
60
import org.netbeans.modules.maven.j2ee.execution.DeploymentHelper;
79
import org.openide.util.Exceptions;
61
import org.openide.util.Exceptions;
80
62
81
63
Lines 94-107 Link Here
94
public class ExecutionChecker implements ExecutionResultChecker, PrerequisitesChecker {
76
public class ExecutionChecker implements ExecutionResultChecker, PrerequisitesChecker {
95
77
96
    public static final String CLIENTURLPART = "netbeans.deploy.clientUrlPart"; //NOI18N
78
    public static final String CLIENTURLPART = "netbeans.deploy.clientUrlPart"; //NOI18N
97
    public static final String MODULEURI = "netbeans.deploy.clientModuleUri"; //NOI18N
98
    public static final String DEV_NULL = "DEV-NULL"; //NOI18N
79
    public static final String DEV_NULL = "DEV-NULL"; //NOI18N
99
80
100
    private static final Logger LOGGER = Logger.getLogger(ExecutionChecker.class.getName());
101
    private static final String NB_COS = ".netbeans_automatic_build"; //NOI18N
102
81
103
    private final Project project;
82
    private final Project project;
104
83
    
105
84
106
    public ExecutionChecker(Project prj) {
85
    public ExecutionChecker(Project prj) {
107
        project = prj;
86
        project = prj;
Lines 112-262 Link Here
112
    public void executionResult(RunConfig config, ExecutionContext res, int resultCode) {
91
    public void executionResult(RunConfig config, ExecutionContext res, int resultCode) {
113
        boolean depl = Boolean.parseBoolean(config.getProperties().get(MavenJavaEEConstants.ACTION_PROPERTY_DEPLOY));
92
        boolean depl = Boolean.parseBoolean(config.getProperties().get(MavenJavaEEConstants.ACTION_PROPERTY_DEPLOY));
114
        if (depl && resultCode == 0) {
93
        if (depl && resultCode == 0) {
115
            if (RunUtils.hasApplicationCompileOnSaveEnabled(config)) {
94
            DeploymentHelper.perform(config, res);
116
                //dump the nb java support's timestamp fil in output directory..
117
                touchCoSTimeStamp(config, System.currentTimeMillis());
118
            }
119
            String moduleUri = config.getProperties().get(MODULEURI);
120
            String clientUrl = config.getProperties().get(CLIENTURLPART);
121
            if (clientUrl == null) {
122
                clientUrl = ""; // NOI18N
123
            }
124
            String _redeploy = config.getProperties().get(MavenJavaEEConstants.ACTION_PROPERTY_DEPLOY_REDEPLOY);
125
            boolean redeploy = _redeploy != null ? Boolean.parseBoolean(_redeploy) : true;
126
            boolean debugmode = Boolean.parseBoolean(config.getProperties().get(MavenJavaEEConstants.ACTION_PROPERTY_DEPLOY_DEBUG_MODE));
127
            boolean profilemode = Boolean.parseBoolean(config.getProperties().get("netbeans.deploy.profilemode")); //NOI18N
128
            String openInBrowser = config.getProperties().get(MavenJavaEEConstants.ACTION_PROPERTY_DEPLOY_OPEN);
129
            boolean showInBrowser = openInBrowser == null ? true : Boolean.parseBoolean(openInBrowser);
130
131
            performDeploy(res, debugmode, profilemode, moduleUri, clientUrl, redeploy, showInBrowser);
132
        }
95
        }
133
    }
96
    }
134
97
135
    private void performDeploy(
136
            final ExecutionContext res,
137
            boolean debugmode,
138
            boolean profilemode,
139
            String clientModuleUri,
140
            String clientUrlPart,
141
            boolean forceRedeploy,
142
            boolean showInBrowser) {
143
144
        FileUtil.refreshFor(FileUtil.toFile(project.getProjectDirectory()));
145
        OutputWriter err = res.getInputOutput().getErr();
146
        OutputWriter out = res.getInputOutput().getOut();
147
        final J2eeModuleProvider jmp = project.getLookup().lookup(J2eeModuleProvider.class);
148
        if (jmp == null) {
149
            err.println();
150
            err.println();
151
            err.println("NetBeans: Application Server deployment not available for Maven project '" + ProjectUtils.getInformation(project).getDisplayName() + "'"); // NOI18N
152
            return;
153
        }
154
155
        String serverInstanceID = null;
156
157
        // First check if the one-time deployment server is set
158
        OneTimeDeployment oneTimeDeployment = project.getLookup().lookup(OneTimeDeployment.class);
159
        if (oneTimeDeployment != null) {
160
            serverInstanceID = oneTimeDeployment.getServerInstanceId();
161
        }
162
163
        if (serverInstanceID == null) {
164
            serverInstanceID = jmp.getServerInstanceID();
165
            if (DEV_NULL.equals(serverInstanceID) || serverInstanceID == null) {
166
                err.println();
167
                err.println();
168
                err.println("NetBeans: No suitable Deployment Server is defined for the project or globally."); // NOI18N
169
                return;
170
            }
171
        }
172
        ServerInstance si = Deployment.getDefault().getServerInstance(serverInstanceID);
173
        try {
174
            out.println("NetBeans: Deploying on " + (si != null ? si.getDisplayName() : serverInstanceID)); //NOI18N - no localization in maven build now.
175
        } catch (InstanceRemovedException ex) {
176
            out.println("NetBeans: Deploying on " + serverInstanceID); // NOI18N
177
        }
178
        try {
179
            out.println("    profile mode: " + profilemode); // NOI18N
180
            out.println("    debug mode: " + debugmode); // NOI18N
181
            out.println("    force redeploy: " + forceRedeploy); //NOI18N
182
183
184
            Deployment.Mode mode = Deployment.Mode.RUN;
185
            if (debugmode) {
186
                mode = Deployment.Mode.DEBUG;
187
            } else if (profilemode) {
188
                mode = Deployment.Mode.PROFILE;
189
            }
190
191
            Callable<Void> debuggerHook = null;
192
            if (debugmode) {
193
                debuggerHook = new Callable<Void>() {
194
195
                    @Override
196
                    public Void call() throws Exception {
197
                        ServerDebugInfo sdi = jmp.getServerDebugInfo();
198
199
                        if (sdi != null) { //fix for bug 57854, this can be null
200
                            String h = sdi.getHost();
201
                            String transport = sdi.getTransport();
202
                            String address;
203
204
                            if (transport.equals(ServerDebugInfo.TRANSPORT_SHMEM)) {
205
                                address = sdi.getShmemName();
206
                            } else {
207
                                address = Integer.toString(sdi.getPort());
208
                            }
209
                            MavenDebugger deb = project.getLookup().lookup(MavenDebugger.class);
210
                            try {
211
                                deb.attachDebugger(res.getInputOutput(), "Debug Deployed app", transport, h, address); // NOI18N
212
                            } catch (Exception ex) {
213
                                // See issue #235796 --> We were not able to attach debugger because
214
                                // it's already attached, BUT we still want to deploy the application
215
                                LOGGER.log(Level.FINE, "Exception occured while trying to attach debugger", ex); //NOI18N
216
                            }
217
                        }
218
                        return null;
219
                    }
220
                };
221
222
            }
223
224
            String clientUrl = Deployment.getDefault().deploy(jmp, mode, clientModuleUri,
225
                    clientUrlPart, forceRedeploy, new DLogger(out), debuggerHook);
226
            if (clientUrl != null) {
227
                FileObject fo = project.getProjectDirectory();
228
                boolean show = showInBrowser;
229
                if (fo != null && show) {
230
                    String browser = (String) fo.getAttribute(CustomizerRunWeb.PROP_SHOW_IN_BROWSER);
231
                    show = browser != null ? Boolean.parseBoolean(browser) : true;
232
                }
233
                if (show) {
234
                    URL url = new URL(clientUrl);
235
                    URLDisplayerImplementation urlDisplayer = project.getLookup().lookup(URLDisplayerImplementation.class);
236
                    if (urlDisplayer != null) {
237
                        URL appRoot = url;
238
                        if (clientUrlPart != null && clientUrlPart.length() > 0) {
239
                            if (clientUrl.endsWith(clientUrlPart)) {
240
                                appRoot = new URL(clientUrl.substring(0, clientUrl.length() - clientUrlPart.length()));
241
                            }
242
                        }
243
                        urlDisplayer.showURL(appRoot, url, fo);
244
                    } else {
245
                        HtmlBrowser.URLDisplayer.getDefault().showURL(url);
246
                    }
247
                }
248
            }
249
        } catch (Deployment.DeploymentException | MalformedURLException ex) {
250
            LOGGER.log(Level.FINE, "Exception occured wile deploying to Application Server.", ex); //NOI18N
251
        }
252
253
        // Reset the value of the one-time server
254
        if (oneTimeDeployment != null) {
255
            oneTimeDeployment.reset();
256
            MavenProjectSupport.changeServer(project, false);
257
        }
258
    }
259
    
260
    @Override
98
    @Override
261
    public boolean checkRunConfig(RunConfig config) {
99
    public boolean checkRunConfig(RunConfig config) {
262
        if (!isSupported()) { // #234767
100
        if (!isSupported()) { // #234767
Lines 316-367 Link Here
316
        }
154
        }
317
        return serverInstanceID;
155
        return serverInstanceID;
318
    }
156
    }
319
320
    private boolean touchCoSTimeStamp(RunConfig rc, long stamp) {
321
        if (rc.getProject() == null) {
322
            return false;
323
        }
324
        Build build = rc.getMavenProject().getBuild();
325
        if (build == null || build.getOutputDirectory() == null) {
326
            return false;
327
        }
328
        File fl = new File(build.getOutputDirectory());
329
        fl = FileUtil.normalizeFile(fl);
330
        if (!fl.exists()) {
331
            //the project was not built
332
            return false;
333
        }
334
        File check = new File(fl, NB_COS);
335
        if (!check.exists()) {
336
            try {
337
                return check.createNewFile();
338
            } catch (IOException ex) {
339
                return false;
340
            }
341
        }
342
        return check.setLastModified(stamp);
343
    }
344
345
    public static boolean hasCoSTimeStamp(Project prj) {
346
        NbMavenProject nbprj = prj.getLookup().lookup(NbMavenProject.class);
347
        if (nbprj == null) {
348
            return false;
349
        }
350
        return new File(nbprj.getOutputDirectory(false), NB_COS).exists();
351
    }
352
353
354
    static class DLogger implements Deployment.Logger {
355
356
        private final OutputWriter logger;
357
358
        public DLogger(OutputWriter log) {
359
            logger = log;
360
        }
361
362
        @Override
363
        public void log(String string) {
364
            logger.println(string);
365
        }
366
    }
367
}
157
}
(-)a/maven.j2ee/src/org/netbeans/modules/maven/j2ee/J2EEPrerequisitesChecker.java (-1 / +13 lines)
Lines 54-59 Link Here
54
import org.netbeans.modules.j2ee.deployment.devmodules.spi.J2eeModuleProvider;
54
import org.netbeans.modules.j2ee.deployment.devmodules.spi.J2eeModuleProvider;
55
import org.netbeans.modules.maven.api.NbMavenProject;
55
import org.netbeans.modules.maven.api.NbMavenProject;
56
import org.netbeans.modules.maven.api.execute.LateBoundPrerequisitesChecker;
56
import org.netbeans.modules.maven.api.execute.LateBoundPrerequisitesChecker;
57
import org.netbeans.modules.maven.j2ee.execution.DeploymentLogger;
58
import static org.netbeans.modules.maven.j2ee.ui.customizer.impl.CustomizerRunWeb.PROP_ALWAYS_BUILD_BEFORE_RUNNING;
57
import org.netbeans.spi.project.ActionProvider;
59
import org.netbeans.spi.project.ActionProvider;
58
import org.netbeans.spi.project.ProjectServiceProvider;
60
import org.netbeans.spi.project.ProjectServiceProvider;
59
import org.openide.util.Exceptions;
61
import org.openide.util.Exceptions;
Lines 86-91 Link Here
86
88
87
    @Override
89
    @Override
88
    public boolean checkRunConfig(RunConfig config) {
90
    public boolean checkRunConfig(RunConfig config) {
91
        // To be able to skip standard run behavior we need to set this property
92
        // with respect to the current CoS/DoS setting --> See issue 230565
93
        Boolean alwaysBuild = (Boolean) config.getProject().getProjectDirectory().getAttribute(PROP_ALWAYS_BUILD_BEFORE_RUNNING);
94
        if (alwaysBuild == null) {
95
            alwaysBuild = Boolean.FALSE;
96
        }
97
98
        // If we don't want to build always, set skip.build property
99
        config.setInternalProperty("skip.build", !alwaysBuild); //NOI18N
100
89
        String actionName = config.getActionName();
101
        String actionName = config.getActionName();
90
        if (!applicableActions.contains(actionName)) {
102
        if (!applicableActions.contains(actionName)) {
91
            return true;
103
            return true;
Lines 134-140 Link Here
134
                return true;
146
                return true;
135
            }
147
            }
136
            try {
148
            try {
137
                Deployment.getDefault ().undeploy(provider, false, new ExecutionChecker.DLogger(con.getInputOutput().getOut()));
149
                Deployment.getDefault ().undeploy(provider, false, new DeploymentLogger(con.getInputOutput().getOut()));
138
            } catch (DeploymentException ex) {
150
            } catch (DeploymentException ex) {
139
                Exceptions.printStackTrace(ex);
151
                Exceptions.printStackTrace(ex);
140
            }
152
            }
(-)a/maven.j2ee/src/org/netbeans/modules/maven/j2ee/execution/AlternativeExecutorImpl.java (+86 lines)
Line 0 Link Here
1
/*
2
 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
3
 *
4
 * Copyright 2013 Oracle and/or its affiliates. All rights reserved.
5
 *
6
 * Oracle and Java are registered trademarks of Oracle and/or its affiliates.
7
 * Other names may be trademarks of their respective owners.
8
 *
9
 * The contents of this file are subject to the terms of either the GNU
10
 * General Public License Version 2 only ("GPL") or the Common
11
 * Development and Distribution License("CDDL") (collectively, the
12
 * "License"). You may not use this file except in compliance with the
13
 * License. You can obtain a copy of the License at
14
 * http://www.netbeans.org/cddl-gplv2.html
15
 * or nbbuild/licenses/CDDL-GPL-2-CP. See the License for the
16
 * specific language governing permissions and limitations under the
17
 * License.  When distributing the software, include this License Header
18
 * Notice in each file and include the License file at
19
 * nbbuild/licenses/CDDL-GPL-2-CP.  Oracle designates this
20
 * particular file as subject to the "Classpath" exception as provided
21
 * by Oracle in the GPL Version 2 section of the License file that
22
 * accompanied this code. If applicable, add the following below the
23
 * License Header, with the fields enclosed by brackets [] replaced by
24
 * your own identifying information:
25
 * "Portions Copyrighted [year] [name of copyright owner]"
26
 *
27
 * If you wish your version of this file to be governed by only the CDDL
28
 * or only the GPL Version 2, indicate your decision by adding
29
 * "[Contributor] elects to include this software in this distribution
30
 * under the [CDDL or GPL Version 2] license." If you do not indicate a
31
 * single choice of license, a recipient has the option to distribute
32
 * your version of this file under either the CDDL, the GPL Version 2 or
33
 * to extend the choice of license to its licensees as provided above.
34
 * However, if you add GPL Version 2 code and therefore, elected the GPL
35
 * Version 2 license, then the option applies only if the new code is
36
 * made subject to such option by the copyright holder.
37
 *
38
 * Contributor(s):
39
 *
40
 * Portions Copyrighted 2013 Sun Microsystems, Inc.
41
 */
42
43
package org.netbeans.modules.maven.j2ee.execution;
44
45
import org.netbeans.modules.maven.api.NbMavenProject;
46
import org.netbeans.modules.maven.api.execute.ExecutionContext;
47
import org.netbeans.modules.maven.api.execute.RunConfig;
48
import org.netbeans.modules.maven.spi.execute.AlternativeExecutorImplementation;
49
import org.netbeans.spi.project.ProjectServiceProvider;
50
51
/**
52
 * Implementation of the {@link AlternativeExecutorImplementation} enables to changes the default run/debug/profile
53
 * behavior and does not force rebuild of application when one of these action is invoked.
54
 *
55
 * <p>
56
 * In combination with CoS/DoS feature this save time that was earlier needed for rebuild
57
 * application started before actual redeployment.
58
 *
59
 * <p>
60
 * See issue 230565 for some details about why this was needed.
61
 *
62
 * <p>
63
 * This class is <i>immutable</i> and thus <i>thread safe</i>.
64
 *
65
 * @author Martin Janicek <mjanicek@netbeans.org>
66
 * @since 2.97
67
 */
68
@ProjectServiceProvider(
69
    service = {
70
        AlternativeExecutorImplementation.class
71
    },
72
    projectType = {
73
        "org-netbeans-modules-maven/" + NbMavenProject.TYPE_WAR,
74
        "org-netbeans-modules-maven/" + NbMavenProject.TYPE_EJB,
75
        "org-netbeans-modules-maven/" + NbMavenProject.TYPE_APPCLIENT,
76
        "org-netbeans-modules-maven/" + NbMavenProject.TYPE_EAR,
77
        "org-netbeans-modules-maven/" + NbMavenProject.TYPE_OSGI
78
    }
79
)
80
public class AlternativeExecutorImpl implements AlternativeExecutorImplementation {
81
82
    @Override
83
    public boolean execute(RunConfig config, ExecutionContext executionContext) {
84
        return DeploymentHelper.perform(config, executionContext);
85
    }
86
}
(-)a/maven.j2ee/src/org/netbeans/modules/maven/j2ee/execution/DeploymentHelper.java (+287 lines)
Line 0 Link Here
1
/*
2
 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
3
 *
4
 * Copyright 2013 Oracle and/or its affiliates. All rights reserved.
5
 *
6
 * Oracle and Java are registered trademarks of Oracle and/or its affiliates.
7
 * Other names may be trademarks of their respective owners.
8
 *
9
 * The contents of this file are subject to the terms of either the GNU
10
 * General Public License Version 2 only ("GPL") or the Common
11
 * Development and Distribution License("CDDL") (collectively, the
12
 * "License"). You may not use this file except in compliance with the
13
 * License. You can obtain a copy of the License at
14
 * http://www.netbeans.org/cddl-gplv2.html
15
 * or nbbuild/licenses/CDDL-GPL-2-CP. See the License for the
16
 * specific language governing permissions and limitations under the
17
 * License.  When distributing the software, include this License Header
18
 * Notice in each file and include the License file at
19
 * nbbuild/licenses/CDDL-GPL-2-CP.  Oracle designates this
20
 * particular file as subject to the "Classpath" exception as provided
21
 * by Oracle in the GPL Version 2 section of the License file that
22
 * accompanied this code. If applicable, add the following below the
23
 * License Header, with the fields enclosed by brackets [] replaced by
24
 * your own identifying information:
25
 * "Portions Copyrighted [year] [name of copyright owner]"
26
 *
27
 * If you wish your version of this file to be governed by only the CDDL
28
 * or only the GPL Version 2, indicate your decision by adding
29
 * "[Contributor] elects to include this software in this distribution
30
 * under the [CDDL or GPL Version 2] license." If you do not indicate a
31
 * single choice of license, a recipient has the option to distribute
32
 * your version of this file under either the CDDL, the GPL Version 2 or
33
 * to extend the choice of license to its licensees as provided above.
34
 * However, if you add GPL Version 2 code and therefore, elected the GPL
35
 * Version 2 license, then the option applies only if the new code is
36
 * made subject to such option by the copyright holder.
37
 *
38
 * Contributor(s):
39
 *
40
 * Portions Copyrighted 2013 Sun Microsystems, Inc.
41
 */
42
43
package org.netbeans.modules.maven.j2ee.execution;
44
45
import java.io.File;
46
import java.io.IOException;
47
import java.net.MalformedURLException;
48
import java.net.URL;
49
import java.util.concurrent.Callable;
50
import java.util.logging.Level;
51
import java.util.logging.Logger;
52
import org.apache.maven.model.Build;
53
import org.netbeans.api.project.Project;
54
import org.netbeans.api.project.ProjectUtils;
55
import org.netbeans.modules.j2ee.deployment.devmodules.api.Deployment;
56
import org.netbeans.modules.j2ee.deployment.devmodules.api.InstanceRemovedException;
57
import org.netbeans.modules.j2ee.deployment.devmodules.api.ServerInstance;
58
import org.netbeans.modules.j2ee.deployment.devmodules.spi.J2eeModuleProvider;
59
import org.netbeans.modules.j2ee.deployment.plugins.api.ServerDebugInfo;
60
import org.netbeans.modules.maven.api.execute.ExecutionContext;
61
import org.netbeans.modules.maven.api.execute.RunConfig;
62
import org.netbeans.modules.maven.api.execute.RunUtils;
63
import static org.netbeans.modules.maven.j2ee.ExecutionChecker.DEV_NULL;
64
import org.netbeans.modules.maven.j2ee.MavenJavaEEConstants;
65
import org.netbeans.modules.maven.j2ee.OneTimeDeployment;
66
import org.netbeans.modules.maven.j2ee.ui.customizer.impl.CustomizerRunWeb;
67
import org.netbeans.modules.maven.j2ee.utils.MavenProjectSupport;
68
import org.netbeans.modules.maven.spi.debug.MavenDebugger;
69
import org.netbeans.modules.web.browser.spi.URLDisplayerImplementation;
70
import org.openide.awt.HtmlBrowser;
71
import org.openide.filesystems.FileObject;
72
import org.openide.filesystems.FileUtil;
73
import org.openide.windows.OutputWriter;
74
75
/**
76
 * General helper class encapsulating behavior needed to perform deployment execution.
77
 *
78
 * <p>
79
 * This class is <i>immutable</i> and thus <i>thread safe</i>.
80
 * </p>
81
 *
82
 * @author Martin Janicek <mjanicek@netbeans.org>
83
 */
84
public final class DeploymentHelper {
85
86
    private static final String MODULEURI = "netbeans.deploy.clientModuleUri"; //NOI18N
87
    private static final String NB_COS = ".netbeans_automatic_build"; //NOI18N
88
    private static final Logger LOGGER = Logger.getLogger(DeploymentHelper.class.getName());
89
90
    public static final String CLIENTURLPART = "netbeans.deploy.clientUrlPart"; //NOI18N
91
92
    private DeploymentHelper() {
93
    }
94
95
96
    /**
97
     * Performs deploy based on the given arguments.
98
     *
99
     * @param config configuration
100
     * @param executionContext execution context
101
     * @return {@code true} if the execution was successful, {@code false} otherwise
102
     */
103
    public static boolean perform(final RunConfig config, final ExecutionContext executionContext) {
104
        final Project project = config.getProject();
105
106
        if (RunUtils.isCompileOnSaveEnabled(config)) {
107
            //dump the nb java support's timestamp fil in output directory..
108
            touchCoSTimeStamp(config, System.currentTimeMillis());
109
        }
110
        String moduleUri = config.getProperties().get(MODULEURI);
111
        String clientUrlPart = config.getProperties().get(CLIENTURLPART);
112
        if (clientUrlPart == null) {
113
            clientUrlPart = ""; // NOI18N
114
        }
115
        boolean redeploy = isRedeploy(config);
116
        boolean debugmode = isDebugMode(config);
117
        boolean profilemode = isProfileMode(config);
118
        boolean showInBrowser = showInBrowser(config);
119
120
        FileUtil.refreshFor(FileUtil.toFile(project.getProjectDirectory()));
121
        OutputWriter err = executionContext.getInputOutput().getErr();
122
        OutputWriter out = executionContext.getInputOutput().getOut();
123
        final J2eeModuleProvider jmp = project.getLookup().lookup(J2eeModuleProvider.class);
124
        if (jmp == null) {
125
            err.println();
126
            err.println();
127
            err.println("NetBeans: Application Server deployment not available for Maven project '" + ProjectUtils.getInformation(project).getDisplayName() + "'"); // NOI18N
128
            return false;
129
        }
130
131
        String serverInstanceID = null;
132
133
        // First check if the one-time deployment server is set
134
        OneTimeDeployment oneTimeDeployment = project.getLookup().lookup(OneTimeDeployment.class);
135
        if (oneTimeDeployment != null) {
136
            serverInstanceID = oneTimeDeployment.getServerInstanceId();
137
        }
138
139
        if (serverInstanceID == null) {
140
            serverInstanceID = jmp.getServerInstanceID();
141
            if (DEV_NULL.equals(serverInstanceID) || serverInstanceID == null) {
142
                err.println();
143
                err.println();
144
                err.println("NetBeans: No suitable Deployment Server is defined for the project or globally."); // NOI18N
145
                return false;
146
            }
147
        }
148
        ServerInstance si = Deployment.getDefault().getServerInstance(serverInstanceID);
149
        try {
150
            out.println("NetBeans: Deploying on " + (si != null ? si.getDisplayName() : serverInstanceID)); //NOI18N - no localization in maven build now.
151
        } catch (InstanceRemovedException ex) {
152
            out.println("NetBeans: Deploying on " + serverInstanceID); // NOI18N
153
        }
154
        try {
155
            out.println("    profile mode: " + profilemode); // NOI18N
156
            out.println("    debug mode: " + debugmode); // NOI18N
157
            out.println("    force redeploy: " + redeploy); //NOI18N
158
159
160
            Deployment.Mode mode = Deployment.Mode.RUN;
161
            if (debugmode) {
162
                mode = Deployment.Mode.DEBUG;
163
            } else if (profilemode) {
164
                mode = Deployment.Mode.PROFILE;
165
            }
166
167
            Callable<Void> debuggerHook = null;
168
            if (debugmode) {
169
                debuggerHook = new Callable<Void>() {
170
171
                    @Override
172
                    public Void call() throws Exception {
173
                        ServerDebugInfo sdi = jmp.getServerDebugInfo();
174
175
                        if (sdi != null) { //fix for bug 57854, this can be null
176
                            String h = sdi.getHost();
177
                            String transport = sdi.getTransport();
178
                            String address;
179
180
                            if (transport.equals(ServerDebugInfo.TRANSPORT_SHMEM)) {
181
                                address = sdi.getShmemName();
182
                            } else {
183
                                address = Integer.toString(sdi.getPort());
184
                            }
185
                            MavenDebugger deb = project.getLookup().lookup(MavenDebugger.class);
186
                            try {
187
                                deb.attachDebugger(executionContext.getInputOutput(), "Debug Deployed app", transport, h, address); // NOI18N
188
                            } catch (Exception ex) {
189
                                // See issue #235796 --> We were not able to attach debugger because
190
                                // it's already attached, BUT we still want to deploy the application
191
                                LOGGER.log(Level.FINE, "Exception occured while trying to attach debugger", ex); //NOI18N
192
                            }
193
                        }
194
                        return null;
195
                    }
196
                };
197
198
            }
199
200
            String clientUrl = Deployment.getDefault().deploy(jmp, mode, moduleUri, clientUrlPart, redeploy, new DeploymentLogger(out), debuggerHook);
201
            if (clientUrl != null) {
202
                if (showInBrowser) {
203
                    URL url = new URL(clientUrl);
204
                    URLDisplayerImplementation urlDisplayer = project.getLookup().lookup(URLDisplayerImplementation.class);
205
                    if (urlDisplayer != null) {
206
                        URL appRoot = url;
207
                        if (clientUrlPart.length() > 0 && clientUrl.endsWith(clientUrlPart)) {
208
                            appRoot = new URL(clientUrl.substring(0, clientUrl.length() - clientUrlPart.length()));
209
                        }
210
                        urlDisplayer.showURL(appRoot, url, project.getProjectDirectory());
211
                    } else {
212
                        HtmlBrowser.URLDisplayer.getDefault().showURL(url);
213
                    }
214
                }
215
            }
216
        } catch (Deployment.DeploymentException | MalformedURLException ex) {
217
            LOGGER.log(Level.FINE, "Exception occured wile deploying to Application Server.", ex); //NOI18N
218
        }
219
220
        // Reset the value of the one-time server
221
        if (oneTimeDeployment != null) {
222
            oneTimeDeployment.reset();
223
            MavenProjectSupport.changeServer(project, false);
224
        }
225
        return true;
226
    }
227
228
    private static boolean isRedeploy(RunConfig config) {
229
        return readBooleanValue(config, MavenJavaEEConstants.ACTION_PROPERTY_DEPLOY_REDEPLOY, true);
230
    }
231
232
    private static boolean isDebugMode(RunConfig config) {
233
        return readBooleanValue(config, MavenJavaEEConstants.ACTION_PROPERTY_DEPLOY_DEBUG_MODE, false);
234
    }
235
236
    private static boolean isProfileMode(RunConfig config) {
237
        return readBooleanValue(config, "netbeans.deploy.profilemode", false); //NOI18N
238
    }
239
240
    private static boolean showInBrowser(RunConfig config) {
241
        if (!readBooleanValue(config, MavenJavaEEConstants.ACTION_PROPERTY_DEPLOY_OPEN, true)) {
242
            return false;
243
        }
244
245
        FileObject projectDir = config.getProject().getProjectDirectory();
246
        if (projectDir != null) {
247
            String browser = (String) projectDir.getAttribute(CustomizerRunWeb.PROP_SHOW_IN_BROWSER);
248
            if (browser != null && Boolean.parseBoolean(browser)) {
249
                return false;
250
            }
251
        }
252
        return true;
253
    }
254
255
    private static boolean readBooleanValue(RunConfig config, String key, boolean defaultValue) {
256
        String value = config.getProperties().get(key);
257
        if (value != null) {
258
            return Boolean.parseBoolean(value);
259
        }
260
        return defaultValue;
261
    }
262
263
    private static boolean touchCoSTimeStamp(RunConfig rc, long stamp) {
264
        if (rc.getProject() == null) {
265
            return false;
266
        }
267
        Build build = rc.getMavenProject().getBuild();
268
        if (build == null || build.getOutputDirectory() == null) {
269
            return false;
270
        }
271
        File fl = new File(build.getOutputDirectory());
272
        fl = FileUtil.normalizeFile(fl);
273
        if (!fl.exists()) {
274
            //the project was not built
275
            return false;
276
        }
277
        File check = new File(fl, NB_COS);
278
        if (!check.exists()) {
279
            try {
280
                return check.createNewFile();
281
            } catch (IOException ex) {
282
                return false;
283
            }
284
        }
285
        return check.setLastModified(stamp);
286
    }
287
}
(-)a/maven.j2ee/src/org/netbeans/modules/maven/j2ee/execution/DeploymentLogger.java (+69 lines)
Line 0 Link Here
1
/*
2
 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
3
 *
4
 * Copyright 2013 Oracle and/or its affiliates. All rights reserved.
5
 *
6
 * Oracle and Java are registered trademarks of Oracle and/or its affiliates.
7
 * Other names may be trademarks of their respective owners.
8
 *
9
 * The contents of this file are subject to the terms of either the GNU
10
 * General Public License Version 2 only ("GPL") or the Common
11
 * Development and Distribution License("CDDL") (collectively, the
12
 * "License"). You may not use this file except in compliance with the
13
 * License. You can obtain a copy of the License at
14
 * http://www.netbeans.org/cddl-gplv2.html
15
 * or nbbuild/licenses/CDDL-GPL-2-CP. See the License for the
16
 * specific language governing permissions and limitations under the
17
 * License.  When distributing the software, include this License Header
18
 * Notice in each file and include the License file at
19
 * nbbuild/licenses/CDDL-GPL-2-CP.  Oracle designates this
20
 * particular file as subject to the "Classpath" exception as provided
21
 * by Oracle in the GPL Version 2 section of the License file that
22
 * accompanied this code. If applicable, add the following below the
23
 * License Header, with the fields enclosed by brackets [] replaced by
24
 * your own identifying information:
25
 * "Portions Copyrighted [year] [name of copyright owner]"
26
 *
27
 * If you wish your version of this file to be governed by only the CDDL
28
 * or only the GPL Version 2, indicate your decision by adding
29
 * "[Contributor] elects to include this software in this distribution
30
 * under the [CDDL or GPL Version 2] license." If you do not indicate a
31
 * single choice of license, a recipient has the option to distribute
32
 * your version of this file under either the CDDL, the GPL Version 2 or
33
 * to extend the choice of license to its licensees as provided above.
34
 * However, if you add GPL Version 2 code and therefore, elected the GPL
35
 * Version 2 license, then the option applies only if the new code is
36
 * made subject to such option by the copyright holder.
37
 *
38
 * Contributor(s):
39
 *
40
 * Portions Copyrighted 2013 Sun Microsystems, Inc.
41
 */
42
43
package org.netbeans.modules.maven.j2ee.execution;
44
45
import org.netbeans.modules.j2ee.deployment.devmodules.api.Deployment;
46
import org.openide.windows.OutputWriter;
47
48
/**
49
 * Simple implementation of the {@link Deployment.Logger} used by the infrastructure to log deployment messages.
50
 *
51
 * <p>
52
 * This class is <i>immutable</i> and thus <i>thread safe</i>.
53
 * </p>
54
 *
55
 * @author Martin Janicek <mjanicek@netbeans.org>
56
 */
57
public class DeploymentLogger implements Deployment.Logger {
58
59
    private final OutputWriter logger;
60
61
    public DeploymentLogger(OutputWriter logger) {
62
        this.logger = logger;
63
    }
64
65
    @Override
66
    public void log(String string) {
67
        logger.println(string);
68
    }
69
}
(-)a/maven.j2ee/src/org/netbeans/modules/maven/j2ee/ui/customizer/BaseRunCustomizer.java (-2 / +37 lines)
Lines 57-64 Link Here
57
import org.netbeans.modules.maven.j2ee.ExecutionChecker;
57
import org.netbeans.modules.maven.j2ee.ExecutionChecker;
58
import org.netbeans.modules.maven.j2ee.utils.Server;
58
import org.netbeans.modules.maven.j2ee.utils.Server;
59
import static org.netbeans.modules.maven.j2ee.ui.customizer.Bundle.*;
59
import static org.netbeans.modules.maven.j2ee.ui.customizer.Bundle.*;
60
import org.netbeans.modules.maven.j2ee.ui.util.WarningPanel;
61
import org.netbeans.modules.maven.j2ee.ui.util.WarningPanelSupport;
60
import org.netbeans.modules.maven.j2ee.utils.MavenProjectSupport;
62
import org.netbeans.modules.maven.j2ee.utils.MavenProjectSupport;
61
import org.netbeans.modules.maven.j2ee.utils.ServerUtils;
63
import org.netbeans.modules.maven.j2ee.utils.ServerUtils;
64
import org.openide.DialogDisplayer;
65
import org.openide.NotifyDescriptor;
62
import org.openide.util.HelpCtx;
66
import org.openide.util.HelpCtx;
63
import org.openide.util.NbBundle.Messages;
67
import org.openide.util.NbBundle.Messages;
64
68
Lines 79-93 Link Here
79
        this.project = project;
83
        this.project = project;
80
    }
84
    }
81
85
86
    @Messages({
87
        "WARNING_ChangingAutomaticBuild=<html>You are trying to turn deploy on save feature off. <b>Please be aware about "
88
            + "possible consequences</b>. Your files won't be redeployed immediately after the save which means you "
89
            + "will be responsible for redeployment of the application content every time when you want to see actual "
90
            + "state of sources on server. <br><br> Because of that it is highly recommended to turn option called \"Always "
91
            + "perform build\" on, so you will need only to Run application and NetBeans will take care about automatic rebuild "
92
            + "of sources before deployment.</html>."
93
    })
82
    protected void initDeployOnSave(final JCheckBox dosCheckBox, final JLabel dosDescription) {
94
    protected void initDeployOnSave(final JCheckBox dosCheckBox, final JLabel dosDescription) {
83
        boolean isDoS = MavenProjectSupport.isDeployOnSave(project);
95
        boolean isDoS = MavenProjectSupport.isDeployOnSave(project);
84
        deployOnSaveUpdater = CheckBoxUpdater.create(dosCheckBox, isDoS, new CheckBoxUpdater.Store() {
96
97
        CheckBoxUpdater.Store store = new CheckBoxUpdater.Store() {
85
98
86
            @Override
99
            @Override
87
            public void storeValue(boolean value) {
100
            public void storeValue(boolean value) {
88
                MavenProjectSupport.setDeployOnSave(project, value);
101
                MavenProjectSupport.setDeployOnSave(project, value);
89
            }
102
            }
90
        });
103
        };
104
105
        CheckBoxUpdater.Verify verifier = new CheckBoxUpdater.Verify() {
106
107
            @Override
108
            public boolean verifyValue(boolean value) {
109
                if (!value && WarningPanelSupport.isAutomaticBuildWarningActivated()) {
110
                    WarningPanel panel = new WarningPanel(WARNING_ChangingAutomaticBuild());
111
                    NotifyDescriptor dd = new NotifyDescriptor.Confirmation(panel, NotifyDescriptor.OK_CANCEL_OPTION);
112
                    DialogDisplayer.getDefault().notify(dd);
113
114
                    if (dd.getValue() == NotifyDescriptor.CANCEL_OPTION) {
115
                        return false;
116
                    }
117
                    if (panel.disabledWarning()) {
118
                        WarningPanelSupport.dontShowAutomaticBuildWarning();
119
                    }
120
                }
121
                return true;
122
            }
123
        };
124
125
        deployOnSaveUpdater = CheckBoxUpdater.create(dosCheckBox, isDoS, store, verifier);
91
126
92
        addAncestorListener(new AncestorListener() {
127
        addAncestorListener(new AncestorListener() {
93
128
(-)a/maven.j2ee/src/org/netbeans/modules/maven/j2ee/ui/customizer/CheckBoxUpdater.java (-4 / +69 lines)
Lines 66-71 Link Here
66
 *
66
 *
67
 * @see ComboBoxUpdater
67
 * @see ComboBoxUpdater
68
 * @see Store
68
 * @see Store
69
 * @see Verify
69
 *
70
 *
70
 * @author Martin Janicek <mjanicek@netbeans.org>
71
 * @author Martin Janicek <mjanicek@netbeans.org>
71
 */
72
 */
Lines 89-96 Link Here
89
        void storeValue(boolean value);
90
        void storeValue(boolean value);
90
    }
91
    }
91
92
93
    /**
94
     * Interface used by the updater to verify if the new value can be stored in the combo box.
95
     * <p>
96
     *
97
     * Please be aware that if this method returns {@code false}, the {@link Store#storeValue(java.lang.Object)}
98
     * won't be called.
99
     */
100
    public interface Verify {
101
102
        /**
103
         * Verifies value given by the parameter.
104
         *
105
         * @param value to be verified
106
         * @return {@code true} if the value is OK, {@code false} otherwise
107
         */
108
        boolean verifyValue(boolean value);
109
    }
110
92
111
93
    private final Store store;
112
    private final Store store;
113
    private final Verify verifier;
94
    private final JCheckBox checkBox;
114
    private final JCheckBox checkBox;
95
    private final boolean defaultValue;
115
    private final boolean defaultValue;
96
116
Lines 103-120 Link Here
103
     * be called.
123
     * be called.
104
     *
124
     *
105
     * @param checkBox we want to decorate
125
     * @param checkBox we want to decorate
126
     * @param defaultValue default value for the check box
106
     * @param store implementation used to store check box value
127
     * @param store implementation used to store check box value
107
     * @param defaultValue default value for the check box
108
     * @return instance of the {@link CheckBoxUpdater}
128
     * @return instance of the {@link CheckBoxUpdater}
109
     */
129
     */
110
    public static CheckBoxUpdater create(JCheckBox checkBox, boolean defaultValue, Store store) {
130
    public static CheckBoxUpdater create(JCheckBox checkBox, boolean defaultValue, Store store) {
111
        CheckBoxUpdater instance = new CheckBoxUpdater(checkBox, defaultValue, store);
131
        return create(checkBox, defaultValue, store, null);
132
    }
133
134
    /**
135
     * Creates an instance of the {@link CheckBoxUpdater}.
136
     *
137
     * <p>
138
     * The check box will be initialized using the given default value. If the client
139
     * want to store current value, {@link CheckBoxUpdater#storeValue()} method has to
140
     * be called.
141
     *
142
     * <p>
143
     * For the value verification, pass instance of {@link CheckBoxUpdater.Verify} which
144
     * will be called before the new value will be set into the check box.
145
     *
146
     * @param checkBox we want to decorate
147
     * @param defaultValue default value for the check box
148
     * @param store implementation used to store check box value
149
     * @param verifier implementation used to verify new check box value
150
     * @return instance of the {@link CheckBoxUpdater}
151
     */
152
    public static CheckBoxUpdater create(JCheckBox checkBox, boolean defaultValue, Store store, Verify verifier) {
153
        CheckBoxUpdater instance = new CheckBoxUpdater(checkBox, defaultValue, store, verifier);
112
        instance.checkBox.addItemListener(instance);
154
        instance.checkBox.addItemListener(instance);
113
155
114
        return instance;
156
        return instance;
115
    }
157
    }
116
158
117
    private CheckBoxUpdater(JCheckBox checkBox, boolean defaultValue, Store store) {
159
    private CheckBoxUpdater(JCheckBox checkBox, boolean defaultValue, Store store, Verify verifier) {
118
        assert (checkBox != null);
160
        assert (checkBox != null);
119
        assert (store != null);
161
        assert (store != null);
120
162
Lines 122-127 Link Here
122
        this.checkBox.setSelected(defaultValue);
164
        this.checkBox.setSelected(defaultValue);
123
        this.defaultValue = defaultValue;
165
        this.defaultValue = defaultValue;
124
        this.store = store;
166
        this.store = store;
167
        this.verifier = verifier;
125
        setValue(defaultValue);
168
        setValue(defaultValue);
126
    }
169
    }
127
170
Lines 138-148 Link Here
138
181
139
    @Override
182
    @Override
140
    public void itemStateChanged(ItemEvent e) {
183
    public void itemStateChanged(ItemEvent e) {
141
        setValue(checkBox.isSelected());
184
        if (ItemEvent.DESELECTED == e.getStateChange()) {
185
            boolean isSelected = checkBox.isSelected();
186
            if (verifier != null) {
187
                if (verifier.verifyValue(isSelected)) {
188
                    setValue(isSelected);
189
                }
190
            } else {
191
                // If there is no defined verifier, simply change the value
192
                setValue(isSelected);
193
            }
194
        }
142
    }
195
    }
143
196
144
    @NbBundle.Messages("MSG_CheckBox_Value_Changed=This value had been changed from the default one")
197
    @NbBundle.Messages("MSG_CheckBox_Value_Changed=This value had been changed from the default one")
145
    private void setValue(boolean value) {
198
    private void setValue(boolean value) {
199
        // We don't want to notify listeners about state changes made in this method
200
        ItemListener[] itemListeners = checkBox.getItemListeners();
201
        for (ItemListener listener : itemListeners) {
202
            checkBox.removeItemListener(listener);
203
        }
204
146
        if (defaultValue == value) {
205
        if (defaultValue == value) {
147
            checkBox.setFont(checkBox.getFont().deriveFont(Font.PLAIN));
206
            checkBox.setFont(checkBox.getFont().deriveFont(Font.PLAIN));
148
            checkBox.setToolTipText(null);
207
            checkBox.setToolTipText(null);
Lines 150-154 Link Here
150
            checkBox.setFont(checkBox.getFont().deriveFont(Font.BOLD));
209
            checkBox.setFont(checkBox.getFont().deriveFont(Font.BOLD));
151
            checkBox.setToolTipText(MSG_CheckBox_Value_Changed());
210
            checkBox.setToolTipText(MSG_CheckBox_Value_Changed());
152
        }
211
        }
212
        checkBox.setSelected(value);
213
214
        // Register listeners back to have them consistent
215
        for (ItemListener listener : itemListeners) {
216
            checkBox.addItemListener(listener);
217
        }
153
    }
218
    }
154
}
219
}
(-)a/maven.j2ee/src/org/netbeans/modules/maven/j2ee/ui/customizer/impl/Bundle.properties (+3 lines)
Lines 53-55 Link Here
53
CustomizerRunWeb.jCBCopyStaticResources.toolTipText=If selected, static resources (like jsp, html etc.) are copied to the target directory when you save them.
53
CustomizerRunWeb.jCBCopyStaticResources.toolTipText=If selected, static resources (like jsp, html etc.) are copied to the target directory when you save them.
54
CustomizerRunWeb.jCBCopyStaticResources.text=Copy Static Resources on Save
54
CustomizerRunWeb.jCBCopyStaticResources.text=Copy Static Resources on Save
55
CustomizerRunWeb.jCBDeployOnSave.text=D&eploy on Save
55
CustomizerRunWeb.jCBDeployOnSave.text=D&eploy on Save
56
CustomizerRunWeb.jCBAlwaysBuild.toolTipText=<html>If selected, IDE will perform <i>mvn package</i> everytime when running application</html>
57
CustomizerRunWeb.jCBAlwaysBuild.text=Always perform build before running application
58
CustomizerRunWeb.btnLearnMore.text=<html><a href="">Learn More about Deploy On Save feature in Maven projects</a></html>
(-)a/maven.j2ee/src/org/netbeans/modules/maven/j2ee/ui/customizer/impl/CustomizerRunWeb.form (-7 / +38 lines)
Lines 38-54 Link Here
38
                      </Group>
38
                      </Group>
39
                  </Group>
39
                  </Group>
40
                  <Group type="102" alignment="0" attributes="0">
40
                  <Group type="102" alignment="0" attributes="0">
41
                      <EmptySpace min="21" pref="21" max="-2" attributes="0"/>
42
                      <Component id="dosDescription" pref="609" max="32767" attributes="0"/>
43
                  </Group>
44
                  <Group type="102" alignment="0" attributes="0">
45
                      <Component id="jCBDeployOnSave" min="-2" max="-2" attributes="0"/>
41
                      <Component id="jCBDeployOnSave" min="-2" max="-2" attributes="0"/>
46
                      <EmptySpace max="32767" attributes="0"/>
42
                      <EmptySpace max="32767" attributes="0"/>
47
                  </Group>
43
                  </Group>
48
                  <Group type="102" attributes="0">
44
                  <Group type="102" attributes="0">
49
                      <Group type="103" groupAlignment="0" max="-2" attributes="0">
45
                      <EmptySpace min="21" pref="21" max="-2" attributes="0"/>
50
                          <Component id="jCBshowBrowser" max="32767" attributes="0"/>
46
                      <Component id="dosDescription" pref="609" max="32767" attributes="0"/>
51
                          <Component id="jCBCopyStaticResources" max="32767" attributes="0"/>
47
                  </Group>
48
                  <Group type="102" attributes="0">
49
                      <Group type="103" groupAlignment="0" attributes="0">
50
                          <Group type="102" attributes="0">
51
                              <EmptySpace min="21" pref="21" max="-2" attributes="0"/>
52
                              <Component id="btnLearnMore" min="-2" max="-2" attributes="0"/>
53
                          </Group>
54
                          <Component id="jCBAlwaysBuild" min="-2" max="-2" attributes="0"/>
55
                          <Group type="103" groupAlignment="0" max="-2" attributes="0">
56
                              <Component id="jCBshowBrowser" max="32767" attributes="0"/>
57
                              <Component id="jCBCopyStaticResources" max="32767" attributes="0"/>
58
                          </Group>
52
                      </Group>
59
                      </Group>
53
                      <EmptySpace min="0" pref="0" max="32767" attributes="0"/>
60
                      <EmptySpace min="0" pref="0" max="32767" attributes="0"/>
54
                  </Group>
61
                  </Group>
Lines 94-99 Link Here
94
              <Component id="jCBDeployOnSave" min="-2" max="-2" attributes="0"/>
101
              <Component id="jCBDeployOnSave" min="-2" max="-2" attributes="0"/>
95
              <EmptySpace max="-2" attributes="0"/>
102
              <EmptySpace max="-2" attributes="0"/>
96
              <Component id="dosDescription" min="-2" max="-2" attributes="0"/>
103
              <Component id="dosDescription" min="-2" max="-2" attributes="0"/>
104
              <EmptySpace type="unrelated" max="-2" attributes="0"/>
105
              <Component id="jCBAlwaysBuild" min="-2" max="-2" attributes="0"/>
106
              <EmptySpace type="unrelated" max="-2" attributes="0"/>
107
              <Component id="btnLearnMore" min="-2" max="-2" attributes="0"/>
97
              <EmptySpace max="32767" attributes="0"/>
108
              <EmptySpace max="32767" attributes="0"/>
98
          </Group>
109
          </Group>
99
      </Group>
110
      </Group>
Lines 234-238 Link Here
234
        </Property>
245
        </Property>
235
      </Properties>
246
      </Properties>
236
    </Component>
247
    </Component>
248
    <Component class="javax.swing.JCheckBox" name="jCBAlwaysBuild">
249
      <Properties>
250
        <Property name="text" type="java.lang.String" editor="org.netbeans.modules.i18n.form.FormI18nStringEditor">
251
          <ResourceString bundle="org/netbeans/modules/maven/j2ee/ui/customizer/impl/Bundle.properties" key="CustomizerRunWeb.jCBAlwaysBuild.text" replaceFormat="org.openide.util.NbBundle.getMessage({sourceFileName}.class, &quot;{key}&quot;)"/>
252
        </Property>
253
        <Property name="toolTipText" type="java.lang.String" editor="org.netbeans.modules.i18n.form.FormI18nStringEditor">
254
          <ResourceString bundle="org/netbeans/modules/maven/j2ee/ui/customizer/impl/Bundle.properties" key="CustomizerRunWeb.jCBAlwaysBuild.toolTipText" replaceFormat="org.openide.util.NbBundle.getMessage({sourceFileName}.class, &quot;{key}&quot;)"/>
255
        </Property>
256
      </Properties>
257
    </Component>
258
    <Component class="javax.swing.JButton" name="btnLearnMore">
259
      <Properties>
260
        <Property name="text" type="java.lang.String" editor="org.netbeans.modules.i18n.form.FormI18nStringEditor">
261
          <ResourceString bundle="org/netbeans/modules/maven/j2ee/ui/customizer/impl/Bundle.properties" key="CustomizerRunWeb.btnLearnMore.text" replaceFormat="org.openide.util.NbBundle.getMessage({sourceFileName}.class, &quot;{key}&quot;)"/>
262
        </Property>
263
        <Property name="borderPainted" type="boolean" value="false"/>
264
        <Property name="contentAreaFilled" type="boolean" value="false"/>
265
        <Property name="horizontalTextPosition" type="int" value="2"/>
266
      </Properties>
267
    </Component>
237
  </SubComponents>
268
  </SubComponents>
238
</Form>
269
</Form>
(-)a/maven.j2ee/src/org/netbeans/modules/maven/j2ee/ui/customizer/impl/CustomizerRunWeb.java (-7 / +69 lines)
Lines 43-49 Link Here
43
package org.netbeans.modules.maven.j2ee.ui.customizer.impl;
43
package org.netbeans.modules.maven.j2ee.ui.customizer.impl;
44
44
45
import java.awt.Component;
45
import java.awt.Component;
46
import java.awt.Cursor;
47
import java.awt.event.ActionEvent;
48
import java.awt.event.ActionListener;
46
import java.io.IOException;
49
import java.io.IOException;
50
import java.net.MalformedURLException;
51
import java.net.URL;
47
import java.util.List;
52
import java.util.List;
48
import java.util.Set;
53
import java.util.Set;
49
import java.util.TreeSet;
54
import java.util.TreeSet;
Lines 83-88 Link Here
83
import org.netbeans.spi.project.ActionProvider;
88
import org.netbeans.spi.project.ActionProvider;
84
import org.openide.DialogDisplayer;
89
import org.openide.DialogDisplayer;
85
import org.openide.NotifyDescriptor;
90
import org.openide.NotifyDescriptor;
91
import org.openide.awt.HtmlBrowser;
86
import org.openide.util.Exceptions;
92
import org.openide.util.Exceptions;
87
import org.openide.util.NbBundle;
93
import org.openide.util.NbBundle;
88
import org.openide.util.NbBundle.Messages;
94
import org.openide.util.NbBundle.Messages;
Lines 95-105 Link Here
95
public class CustomizerRunWeb extends BaseRunCustomizer {
101
public class CustomizerRunWeb extends BaseRunCustomizer {
96
102
97
    public static final String PROP_SHOW_IN_BROWSER = "netbeans.deploy.showBrowser"; //NOI18N
103
    public static final String PROP_SHOW_IN_BROWSER = "netbeans.deploy.showBrowser"; //NOI18N
104
    public static final String PROP_ALWAYS_BUILD_BEFORE_RUNNING = "netbeans.always.build"; // NOI18N
98
    private static final Set<Profile> WEB_PROFILES;
105
    private static final Set<Profile> WEB_PROFILES;
99
    private static final Set<Profile> FULL_PROFILES;
106
    private static final Set<Profile> FULL_PROFILES;
100
107
101
    private final CheckBoxUpdater copyStaticResourcesUpdater;
108
    private final CheckBoxUpdater copyStaticResourcesUpdater;
102
    private final CheckBoxUpdater showBrowserUpdater;
109
    private final CheckBoxUpdater showBrowserUpdater;
110
    private final CheckBoxUpdater alwaysBuildUpdater;
103
    private final ComboBoxUpdater versionUpdater;
111
    private final ComboBoxUpdater versionUpdater;
104
    private final boolean noServer;
112
    private final boolean noServer;
105
113
Lines 141-146 Link Here
141
        super(handle, project);
149
        super(handle, project);
142
        initComponents();
150
        initComponents();
143
151
152
        btnLearnMore.setCursor(Cursor.getPredefinedCursor(Cursor.HAND_CURSOR));
153
        btnLearnMore.addActionListener(new ActionListener() {
154
            @Override
155
            public void actionPerformed(ActionEvent e) {
156
                try {
157
                    HtmlBrowser.URLDisplayer.getDefault().showURL(new URL("http://wiki.netbeans.org/FaqDeployOnSave"));
158
                } catch (MalformedURLException ex) {
159
                    Exceptions.printStackTrace(ex);
160
                }
161
            }
162
        });
163
144
        module = WebModule.getWebModule(project.getProjectDirectory());
164
        module = WebModule.getWebModule(project.getProjectDirectory());
145
        if (module != null) {
165
        if (module != null) {
146
            contextPathTField.setText(module.getContextPath());
166
            contextPathTField.setText(module.getContextPath());
Lines 178-183 Link Here
178
            }
198
            }
179
        });
199
        });
180
200
201
        Boolean alwaysBuild = (Boolean) project.getProjectDirectory().getAttribute(PROP_ALWAYS_BUILD_BEFORE_RUNNING);
202
        if (alwaysBuild == null) {
203
            alwaysBuild = Boolean.FALSE;
204
        }
205
        alwaysBuildUpdater = CheckBoxUpdater.create(jCBAlwaysBuild, alwaysBuild, new CheckBoxUpdater.Store() {
206
207
            @Override
208
            public void storeValue(boolean value) {
209
                try {
210
                    if (value) {
211
                        project.getProjectDirectory().setAttribute(PROP_ALWAYS_BUILD_BEFORE_RUNNING, true);
212
                    } else {
213
                        project.getProjectDirectory().setAttribute(PROP_ALWAYS_BUILD_BEFORE_RUNNING, false);
214
                    }
215
                } catch (IOException ex) {
216
                    Exceptions.printStackTrace(ex);
217
                }
218
            }
219
        });
220
181
        versionUpdater = createVersionUpdater(J2eeModule.Type.WAR);
221
        versionUpdater = createVersionUpdater(J2eeModule.Type.WAR);
182
    }
222
    }
183
    
223
    
Lines 198-203 Link Here
198
238
199
        serverUpdater.storeValue();
239
        serverUpdater.storeValue();
200
        versionUpdater.storeValue();
240
        versionUpdater.storeValue();
241
        alwaysBuildUpdater.storeValue();
201
        deployOnSaveUpdater.storeValue();
242
        deployOnSaveUpdater.storeValue();
202
        copyStaticResourcesUpdater.storeValue();
243
        copyStaticResourcesUpdater.storeValue();
203
244
Lines 297-303 Link Here
297
            public boolean verifyValue(Object value) {
338
            public boolean verifyValue(Object value) {
298
                if (WarningPanelSupport.isJavaEEChangeWarningActivated()) {
339
                if (WarningPanelSupport.isJavaEEChangeWarningActivated()) {
299
                    WarningPanel panel = new WarningPanel(WARNING_ChangingJavaEEVersion());
340
                    WarningPanel panel = new WarningPanel(WARNING_ChangingJavaEEVersion());
300
                    NotifyDescriptor dd = new NotifyDescriptor.Message(panel, NotifyDescriptor.OK_CANCEL_OPTION);
341
                    NotifyDescriptor dd = new NotifyDescriptor.Confirmation(panel, NotifyDescriptor.OK_CANCEL_OPTION);
301
                    DialogDisplayer.getDefault().notify(dd);
342
                    DialogDisplayer.getDefault().notify(dd);
302
343
303
                    if (dd.getValue() == NotifyDescriptor.CANCEL_OPTION) {
344
                    if (dd.getValue() == NotifyDescriptor.CANCEL_OPTION) {
Lines 402-407 Link Here
402
        browserLabel = new javax.swing.JLabel();
443
        browserLabel = new javax.swing.JLabel();
403
        jCBBrowser = createBrowserComboBox();
444
        jCBBrowser = createBrowserComboBox();
404
        jCBCopyStaticResources = new javax.swing.JCheckBox();
445
        jCBCopyStaticResources = new javax.swing.JCheckBox();
446
        jCBAlwaysBuild = new javax.swing.JCheckBox();
447
        btnLearnMore = new javax.swing.JButton();
405
448
406
        org.openide.awt.Mnemonics.setLocalizedText(serverLabel, org.openide.util.NbBundle.getMessage(CustomizerRunWeb.class, "LBL_Server")); // NOI18N
449
        org.openide.awt.Mnemonics.setLocalizedText(serverLabel, org.openide.util.NbBundle.getMessage(CustomizerRunWeb.class, "LBL_Server")); // NOI18N
407
450
Lines 438-443 Link Here
438
        org.openide.awt.Mnemonics.setLocalizedText(jCBCopyStaticResources, org.openide.util.NbBundle.getMessage(CustomizerRunWeb.class, "CustomizerRunWeb.jCBCopyStaticResources.text")); // NOI18N
481
        org.openide.awt.Mnemonics.setLocalizedText(jCBCopyStaticResources, org.openide.util.NbBundle.getMessage(CustomizerRunWeb.class, "CustomizerRunWeb.jCBCopyStaticResources.text")); // NOI18N
439
        jCBCopyStaticResources.setToolTipText(org.openide.util.NbBundle.getMessage(CustomizerRunWeb.class, "CustomizerRunWeb.jCBCopyStaticResources.toolTipText")); // NOI18N
482
        jCBCopyStaticResources.setToolTipText(org.openide.util.NbBundle.getMessage(CustomizerRunWeb.class, "CustomizerRunWeb.jCBCopyStaticResources.toolTipText")); // NOI18N
440
483
484
        org.openide.awt.Mnemonics.setLocalizedText(jCBAlwaysBuild, org.openide.util.NbBundle.getMessage(CustomizerRunWeb.class, "CustomizerRunWeb.jCBAlwaysBuild.text")); // NOI18N
485
        jCBAlwaysBuild.setToolTipText(org.openide.util.NbBundle.getMessage(CustomizerRunWeb.class, "CustomizerRunWeb.jCBAlwaysBuild.toolTipText")); // NOI18N
486
487
        org.openide.awt.Mnemonics.setLocalizedText(btnLearnMore, org.openide.util.NbBundle.getMessage(CustomizerRunWeb.class, "CustomizerRunWeb.btnLearnMore.text")); // NOI18N
488
        btnLearnMore.setBorderPainted(false);
489
        btnLearnMore.setContentAreaFilled(false);
490
        btnLearnMore.setHorizontalTextPosition(javax.swing.SwingConstants.LEFT);
491
441
        javax.swing.GroupLayout layout = new javax.swing.GroupLayout(this);
492
        javax.swing.GroupLayout layout = new javax.swing.GroupLayout(this);
442
        this.setLayout(layout);
493
        this.setLayout(layout);
443
        layout.setHorizontalGroup(
494
        layout.setHorizontalGroup(
Lines 461-475 Link Here
461
                            .addComponent(txtRelativeUrl, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
512
                            .addComponent(txtRelativeUrl, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
462
                            .addComponent(jCBBrowser, javax.swing.GroupLayout.Alignment.TRAILING, 0, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)))
513
                            .addComponent(jCBBrowser, javax.swing.GroupLayout.Alignment.TRAILING, 0, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)))
463
                    .addGroup(layout.createSequentialGroup()
514
                    .addGroup(layout.createSequentialGroup()
515
                        .addComponent(jCBDeployOnSave)
516
                        .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
517
                    .addGroup(layout.createSequentialGroup()
464
                        .addGap(21, 21, 21)
518
                        .addGap(21, 21, 21)
465
                        .addComponent(dosDescription, javax.swing.GroupLayout.DEFAULT_SIZE, 609, Short.MAX_VALUE))
519
                        .addComponent(dosDescription, javax.swing.GroupLayout.DEFAULT_SIZE, 609, Short.MAX_VALUE))
466
                    .addGroup(layout.createSequentialGroup()
520
                    .addGroup(layout.createSequentialGroup()
467
                        .addComponent(jCBDeployOnSave)
521
                        .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
468
                        .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
522
                            .addGroup(layout.createSequentialGroup()
469
                    .addGroup(layout.createSequentialGroup()
523
                                .addGap(21, 21, 21)
470
                        .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false)
524
                                .addComponent(btnLearnMore, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
471
                            .addComponent(jCBshowBrowser, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
525
                            .addComponent(jCBAlwaysBuild)
472
                            .addComponent(jCBCopyStaticResources, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
526
                            .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false)
527
                                .addComponent(jCBshowBrowser, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
528
                                .addComponent(jCBCopyStaticResources, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)))
473
                        .addGap(0, 0, Short.MAX_VALUE))))
529
                        .addGap(0, 0, Short.MAX_VALUE))))
474
        );
530
        );
475
        layout.setVerticalGroup(
531
        layout.setVerticalGroup(
Lines 505-510 Link Here
505
                .addComponent(jCBDeployOnSave)
561
                .addComponent(jCBDeployOnSave)
506
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
562
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
507
                .addComponent(dosDescription, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
563
                .addComponent(dosDescription, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
564
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
565
                .addComponent(jCBAlwaysBuild)
566
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
567
                .addComponent(btnLearnMore, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
508
                .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
568
                .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
509
        );
569
        );
510
570
Lines 543-551 Link Here
543
603
544
    // Variables declaration - do not modify//GEN-BEGIN:variables
604
    // Variables declaration - do not modify//GEN-BEGIN:variables
545
    private javax.swing.JLabel browserLabel;
605
    private javax.swing.JLabel browserLabel;
606
    private javax.swing.JButton btnLearnMore;
546
    private javax.swing.JLabel contextPathLabel;
607
    private javax.swing.JLabel contextPathLabel;
547
    private javax.swing.JTextField contextPathTField;
608
    private javax.swing.JTextField contextPathTField;
548
    private javax.swing.JLabel dosDescription;
609
    private javax.swing.JLabel dosDescription;
610
    private javax.swing.JCheckBox jCBAlwaysBuild;
549
    private javax.swing.JComboBox jCBBrowser;
611
    private javax.swing.JComboBox jCBBrowser;
550
    private javax.swing.JCheckBox jCBCopyStaticResources;
612
    private javax.swing.JCheckBox jCBCopyStaticResources;
551
    private javax.swing.JCheckBox jCBDeployOnSave;
613
    private javax.swing.JCheckBox jCBDeployOnSave;
(-)a/maven.j2ee/src/org/netbeans/modules/maven/j2ee/ui/util/WarningPanel.form (-1 / +1 lines)
Lines 35-41 Link Here
35
      <Group type="103" groupAlignment="0" attributes="0">
35
      <Group type="103" groupAlignment="0" attributes="0">
36
          <Group type="102" alignment="1" attributes="0">
36
          <Group type="102" alignment="1" attributes="0">
37
              <EmptySpace max="-2" attributes="0"/>
37
              <EmptySpace max="-2" attributes="0"/>
38
              <Component id="lblText" pref="137" max="32767" attributes="0"/>
38
              <Component id="lblText" pref="270" max="32767" attributes="0"/>
39
              <EmptySpace max="-2" attributes="0"/>
39
              <EmptySpace max="-2" attributes="0"/>
40
              <Component id="cbNextTime" min="-2" max="-2" attributes="0"/>
40
              <Component id="cbNextTime" min="-2" max="-2" attributes="0"/>
41
          </Group>
41
          </Group>
(-)a/maven.j2ee/src/org/netbeans/modules/maven/j2ee/ui/util/WarningPanel.java (-1 / +1 lines)
Lines 92-98 Link Here
92
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
92
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
93
            .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, layout.createSequentialGroup()
93
            .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, layout.createSequentialGroup()
94
                .addContainerGap()
94
                .addContainerGap()
95
                .addComponent(lblText, javax.swing.GroupLayout.DEFAULT_SIZE, 137, Short.MAX_VALUE)
95
                .addComponent(lblText, javax.swing.GroupLayout.DEFAULT_SIZE, 270, Short.MAX_VALUE)
96
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
96
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
97
                .addComponent(cbNextTime))
97
                .addComponent(cbNextTime))
98
        );
98
        );
(-)a/maven.j2ee/src/org/netbeans/modules/maven/j2ee/ui/util/WarningPanelSupport.java (-1 / +10 lines)
Lines 51-57 Link Here
51
 */
51
 */
52
public final class WarningPanelSupport {
52
public final class WarningPanelSupport {
53
53
54
    private static final String JAVA_EE_VERSION_CHANGE = "showJavaEEVersionChangeWarning"; //NOI18N
54
    private static final String JAVA_EE_VERSION_CHANGE = "showJavaEEVersionChangeWarning"; // NOI18N
55
    private static final String AUTOMATIC_BUILD = "automaticBuildWarning";                 // NOI18N
55
56
56
    private WarningPanelSupport() {
57
    private WarningPanelSupport() {
57
    }
58
    }
Lines 67-70 Link Here
67
    public static void dontShowJavaEEChangeWarning() {
68
    public static void dontShowJavaEEChangeWarning() {
68
        getPreferences().putBoolean(JAVA_EE_VERSION_CHANGE, false);
69
        getPreferences().putBoolean(JAVA_EE_VERSION_CHANGE, false);
69
    }
70
    }
71
72
    public static boolean isAutomaticBuildWarningActivated() {
73
        return getPreferences().getBoolean(AUTOMATIC_BUILD, true);
74
    }
75
76
    public static void dontShowAutomaticBuildWarning() {
77
        getPreferences().putBoolean(AUTOMATIC_BUILD, false);
78
    }
70
}
79
}
(-)a/maven/manifest.mf (-1 / +1 lines)
Lines 1-6 Link Here
1
Manifest-Version: 1.0
1
Manifest-Version: 1.0
2
OpenIDE-Module: org.netbeans.modules.maven/2
2
OpenIDE-Module: org.netbeans.modules.maven/2
3
OpenIDE-Module-Specification-Version: 2.96
3
OpenIDE-Module-Specification-Version: 2.97
4
OpenIDE-Module-Localizing-Bundle: org/netbeans/modules/maven/Bundle.properties
4
OpenIDE-Module-Localizing-Bundle: org/netbeans/modules/maven/Bundle.properties
5
OpenIDE-Module-Layer: org/netbeans/modules/maven/layer.xml
5
OpenIDE-Module-Layer: org/netbeans/modules/maven/layer.xml
6
AutoUpdate-Show-In-Client: false
6
AutoUpdate-Show-In-Client: false
(-)a/maven/nbproject/project.xml (-8 / +5 lines)
Lines 478-491 Link Here
478
            </test-dependencies>
478
            </test-dependencies>
479
            <friend-packages>
479
            <friend-packages>
480
                <friend>org.javeleon.netbeans</friend>
480
                <friend>org.javeleon.netbeans</friend>
481
                <!-- sven reimers -->
482
                <friend>org.nbheaven.sqe.core.maven</friend>
481
                <friend>org.nbheaven.sqe.core.maven</friend>
483
                <friend>org.nbheaven.sqe.core.maven3</friend>
482
                <friend>org.nbheaven.sqe.core.maven3</friend>
483
                <friend>org.netbeans.modules.android.maven</friend>
484
                <friend>org.netbeans.modules.apisupport.installer.maven</friend>
484
                <friend>org.netbeans.modules.apisupport.installer.maven</friend>
485
                <friend>org.netbeans.modules.groovy.support</friend>
485
                <friend>org.netbeans.modules.groovy.support</friend>
486
                <friend>org.netbeans.modules.hudson.maven</friend>
486
                <friend>org.netbeans.modules.hudson.maven</friend>
487
                <friend>org.netbeans.modules.jbi.fuji.support</friend>
487
                <friend>org.netbeans.modules.jbi.fuji.support</friend>
488
                <friend>org.netbeans.modules.kenai.maven</friend>
488
                <friend>org.netbeans.modules.kenai.maven</friend>
489
                <friend>org.netbeans.modules.ko4j.debugging</friend>
489
                <friend>org.netbeans.modules.maven.apisupport</friend>
490
                <friend>org.netbeans.modules.maven.apisupport</friend>
490
                <friend>org.netbeans.modules.maven.checkstyle</friend>
491
                <friend>org.netbeans.modules.maven.checkstyle</friend>
491
                <friend>org.netbeans.modules.maven.coverage</friend>
492
                <friend>org.netbeans.modules.maven.coverage</friend>
Lines 503-518 Link Here
503
                <friend>org.netbeans.modules.maven.repository</friend>
504
                <friend>org.netbeans.modules.maven.repository</friend>
504
                <friend>org.netbeans.modules.maven.samples</friend>
505
                <friend>org.netbeans.modules.maven.samples</friend>
505
                <friend>org.netbeans.modules.maven.spring</friend>
506
                <friend>org.netbeans.modules.maven.spring</friend>
507
                <friend>org.netbeans.modules.maven.util</friend>
508
                <friend>org.netbeans.modules.scala.maven</friend>
506
                <friend>org.netbeans.modules.selenium.maven</friend>
509
                <friend>org.netbeans.modules.selenium.maven</friend>
507
                <friend>org.netbeans.modules.ko4j.debugging</friend>
508
                <friend>org.netbeans.modules.testng.maven</friend>
510
                <friend>org.netbeans.modules.testng.maven</friend>
509
                <!-- radim kubacki -->
510
                <friend>org.netbeans.modules.android.maven</friend>
511
                <!-- dcaoyuan@gmail.com -->
512
                <friend>org.netbeans.modules.scala.maven</friend>
513
                <!-- danis@netbeans.org -->
514
                <friend>org.vaadin.netbeans.maven</friend>
511
                <friend>org.vaadin.netbeans.maven</friend>
515
                <friend>org.netbeans.modules.maven.util</friend>
516
                <package>org.netbeans.modules.maven.api</package>
512
                <package>org.netbeans.modules.maven.api</package>
517
                <package>org.netbeans.modules.maven.api.archetype</package>
513
                <package>org.netbeans.modules.maven.api.archetype</package>
518
                <package>org.netbeans.modules.maven.api.classpath</package>
514
                <package>org.netbeans.modules.maven.api.classpath</package>
Lines 529-534 Link Here
529
                <package>org.netbeans.modules.maven.spi.cos</package>
525
                <package>org.netbeans.modules.maven.spi.cos</package>
530
                <package>org.netbeans.modules.maven.spi.customizer</package>
526
                <package>org.netbeans.modules.maven.spi.customizer</package>
531
                <package>org.netbeans.modules.maven.spi.debug</package>
527
                <package>org.netbeans.modules.maven.spi.debug</package>
528
                <package>org.netbeans.modules.maven.spi.execute</package>
532
                <package>org.netbeans.modules.maven.spi.grammar</package>
529
                <package>org.netbeans.modules.maven.spi.grammar</package>
533
                <package>org.netbeans.modules.maven.spi.nodes</package>
530
                <package>org.netbeans.modules.maven.spi.nodes</package>
534
                <package>org.netbeans.modules.maven.spi.queries</package>
531
                <package>org.netbeans.modules.maven.spi.queries</package>
(-)a/maven/src/org/netbeans/modules/maven/api/execute/AlternativeExecutor.java (+80 lines)
Line 0 Link Here
1
/*
2
 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
3
 *
4
 * Copyright 2013 Oracle and/or its affiliates. All rights reserved.
5
 *
6
 * Oracle and Java are registered trademarks of Oracle and/or its affiliates.
7
 * Other names may be trademarks of their respective owners.
8
 *
9
 * The contents of this file are subject to the terms of either the GNU
10
 * General Public License Version 2 only ("GPL") or the Common
11
 * Development and Distribution License("CDDL") (collectively, the
12
 * "License"). You may not use this file except in compliance with the
13
 * License. You can obtain a copy of the License at
14
 * http://www.netbeans.org/cddl-gplv2.html
15
 * or nbbuild/licenses/CDDL-GPL-2-CP. See the License for the
16
 * specific language governing permissions and limitations under the
17
 * License.  When distributing the software, include this License Header
18
 * Notice in each file and include the License file at
19
 * nbbuild/licenses/CDDL-GPL-2-CP.  Oracle designates this
20
 * particular file as subject to the "Classpath" exception as provided
21
 * by Oracle in the GPL Version 2 section of the License file that
22
 * accompanied this code. If applicable, add the following below the
23
 * License Header, with the fields enclosed by brackets [] replaced by
24
 * your own identifying information:
25
 * "Portions Copyrighted [year] [name of copyright owner]"
26
 *
27
 * If you wish your version of this file to be governed by only the CDDL
28
 * or only the GPL Version 2, indicate your decision by adding
29
 * "[Contributor] elects to include this software in this distribution
30
 * under the [CDDL or GPL Version 2] license." If you do not indicate a
31
 * single choice of license, a recipient has the option to distribute
32
 * your version of this file under either the CDDL, the GPL Version 2 or
33
 * to extend the choice of license to its licensees as provided above.
34
 * However, if you add GPL Version 2 code and therefore, elected the GPL
35
 * Version 2 license, then the option applies only if the new code is
36
 * made subject to such option by the copyright holder.
37
 *
38
 * Contributor(s):
39
 *
40
 * Portions Copyrighted 2013 Sun Microsystems, Inc.
41
 */
42
43
package org.netbeans.modules.maven.api.execute;
44
45
import org.netbeans.modules.maven.spi.execute.AlternativeExecutorImplementation;
46
47
/**
48
 * API for alternative execution of Maven Run/Debug/Profile actions.
49
 *
50
 * @see AlternativeExecutorImplementation
51
 *
52
 * @author Martin Janicek <mjanicek@netbeans.org>
53
 * @since 2.97
54
 */
55
public final class AlternativeExecutor {
56
57
    private AlternativeExecutor() {
58
    }
59
60
    /**
61
     * Perform an alternative execution.
62
     *
63
     * <p>
64
     * Using the given {@link RunConfig}, finds {@link AlternativeExecutorImplementation}
65
     * registered for the project and performs it's execute method.
66
     *
67
     * @param config configuration
68
     * @param context execution context
69
     * @return {@code true} if the execution was successful, {@code false} otherwise
70
     */
71
    public static boolean execute(RunConfig config, ExecutionContext context) {
72
        AlternativeExecutorImplementation alternativeExecutor = config.getProject().getLookup().lookup(AlternativeExecutorImplementation.class);
73
        if (alternativeExecutor != null) {
74
            if (alternativeExecutor.execute(config, context)) {
75
                return false;
76
            }
77
        }
78
        return true;
79
    }
80
}
(-)a/maven/src/org/netbeans/modules/maven/cos/CosChecker.java (-4 / +23 lines)
Lines 158-170 Link Here
158
                touchProject(openprj);
158
                touchProject(openprj);
159
            }
159
            }
160
            //new style Compile on Save
160
            //new style Compile on Save
161
            checkRunMainClass(config, con);
161
            if (!checkRunMainClass(config, con)) {
162
                return false;
163
            }
162
            checkRunTest(config, con);
164
            checkRunTest(config, con);
163
        } 
165
        } 
164
        return true;
166
        return true;
165
    }
167
    }
166
168
167
    private void checkRunMainClass(final RunConfig config, ExecutionContext con) {
169
    /**
170
     * Returns {@code false} if execution should skip standard build phases.
171
     *
172
     * @param config run configuration
173
     * @param con execution context
174
     * @return {@code false} if execution should skip standard build phases,
175
     *         {@code true} otherwise
176
     */
177
    private boolean checkRunMainClass(final RunConfig config, ExecutionContext con) {
168
        final String actionName = config.getActionName();
178
        final String actionName = config.getActionName();
169
        //compile on save stuff
179
        //compile on save stuff
170
        if (RunUtils.isCompileOnSaveEnabled(config)) {
180
        if (RunUtils.isCompileOnSaveEnabled(config)) {
Lines 179-191 Link Here
179
                //check the COS timestamp against critical files (pom.xml)
189
                //check the COS timestamp against critical files (pom.xml)
180
                // if changed, don't do COS.
190
                // if changed, don't do COS.
181
                if (checkImportantFiles(stamp, config)) {
191
                if (checkImportantFiles(stamp, config)) {
182
                    return;
192
                    return true;
183
                }
193
                }
184
                //check the COS timestamp against resources etc.
194
                //check the COS timestamp against resources etc.
185
                //if changed, perform part of the maven build. (or skip COS)
195
                //if changed, perform part of the maven build. (or skip COS)
186
                for (CompileOnSaveSkipper skipper : Lookup.getDefault().lookupAll(CompileOnSaveSkipper.class)) {
196
                for (CompileOnSaveSkipper skipper : Lookup.getDefault().lookupAll(CompileOnSaveSkipper.class)) {
187
                    if (skipper.skip(config, false, stamp)) {
197
                    if (skipper.skip(config, false, stamp)) {
188
                        return;
198
                        return true;
189
                    }
199
                    }
190
                }
200
                }
191
                
201
                
Lines 193-198 Link Here
193
                if ((javarunnerCheckprops != null && javarunnerCheckprops.containsKey(USE_OLD_COS_EXECUTION)) || config.getProperties().containsKey(USE_OLD_COS_EXECUTION)) {
203
                if ((javarunnerCheckprops != null && javarunnerCheckprops.containsKey(USE_OLD_COS_EXECUTION)) || config.getProperties().containsKey(USE_OLD_COS_EXECUTION)) {
194
                    LOG.fine("use.old.cos.execution found, using JavaRunner to execute.");
204
                    LOG.fine("use.old.cos.execution found, using JavaRunner to execute.");
195
                } else {
205
                } else {
206
                    // #230565
207
                    Object skipBuild = config.getInternalProperties().get("skip.build"); //NOI18N
208
                    if (skipBuild instanceof Boolean && (Boolean) skipBuild) {
209
                        if (!AlternativeExecutor.execute(config, con)) {
210
                            return false;
211
                        }
212
                    }
213
196
                    //now attempt to extract
214
                    //now attempt to extract
197
                    if (config instanceof BeanRunConfig) {
215
                    if (config instanceof BeanRunConfig) {
198
                        BeanRunConfig brc = (BeanRunConfig) config;
216
                        BeanRunConfig brc = (BeanRunConfig) config;
Lines 217-222 Link Here
217
                }
235
                }
218
            }
236
            }
219
        }
237
        }
238
        return true;
220
    }
239
    }
221
240
222
    private void checkRunTest(final RunConfig config, ExecutionContext con) {
241
    private void checkRunTest(final RunConfig config, ExecutionContext con) {
(-)a/maven/src/org/netbeans/modules/maven/spi/execute/AlternativeExecutorImplementation.java (+87 lines)
Line 0 Link Here
1
/*
2
 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
3
 *
4
 * Copyright 2013 Oracle and/or its affiliates. All rights reserved.
5
 *
6
 * Oracle and Java are registered trademarks of Oracle and/or its affiliates.
7
 * Other names may be trademarks of their respective owners.
8
 *
9
 * The contents of this file are subject to the terms of either the GNU
10
 * General Public License Version 2 only ("GPL") or the Common
11
 * Development and Distribution License("CDDL") (collectively, the
12
 * "License"). You may not use this file except in compliance with the
13
 * License. You can obtain a copy of the License at
14
 * http://www.netbeans.org/cddl-gplv2.html
15
 * or nbbuild/licenses/CDDL-GPL-2-CP. See the License for the
16
 * specific language governing permissions and limitations under the
17
 * License.  When distributing the software, include this License Header
18
 * Notice in each file and include the License file at
19
 * nbbuild/licenses/CDDL-GPL-2-CP.  Oracle designates this
20
 * particular file as subject to the "Classpath" exception as provided
21
 * by Oracle in the GPL Version 2 section of the License file that
22
 * accompanied this code. If applicable, add the following below the
23
 * License Header, with the fields enclosed by brackets [] replaced by
24
 * your own identifying information:
25
 * "Portions Copyrighted [year] [name of copyright owner]"
26
 *
27
 * If you wish your version of this file to be governed by only the CDDL
28
 * or only the GPL Version 2, indicate your decision by adding
29
 * "[Contributor] elects to include this software in this distribution
30
 * under the [CDDL or GPL Version 2] license." If you do not indicate a
31
 * single choice of license, a recipient has the option to distribute
32
 * your version of this file under either the CDDL, the GPL Version 2 or
33
 * to extend the choice of license to its licensees as provided above.
34
 * However, if you add GPL Version 2 code and therefore, elected the GPL
35
 * Version 2 license, then the option applies only if the new code is
36
 * made subject to such option by the copyright holder.
37
 *
38
 * Contributor(s):
39
 *
40
 * Portions Copyrighted 2013 Sun Microsystems, Inc.
41
 */
42
43
package org.netbeans.modules.maven.spi.execute;
44
45
import org.netbeans.modules.maven.api.execute.AlternativeExecutor;
46
import org.netbeans.modules.maven.api.execute.ExecutionContext;
47
import org.netbeans.modules.maven.api.execute.RunConfig;
48
49
/**
50
 * Alternative executor enables to rewrite default way how run/debug/profile actions
51
 * are performed.
52
 *
53
 * <p>
54
 * This can be useful in cases when we don't need to execute standard run behavior.
55
 * For example when re-running Maven Web application with enabled CoS/DoS, we don't
56
 * want to rebuild whole project every-time and simply re-opening index.html is enough.
57
 *
58
 * <p>
59
 * If the project want to use {@link AlternativeExecutorImplementation} it should register
60
 * it in it's project {@link Lookup}.
61
 *
62
 * <p>
63
 * This class should not be used directly. Use {@link AlternativeExecutor} API class instead.
64
 *
65
 * <p>
66
 * See issue 230565 for some details about why this was needed in the first place.
67
 *
68
 * @see AlternativeExecutor
69
 *
70
 * @author Martin Janicek <mjanicek@netbeans.org>
71
 * @since 2.97
72
 */
73
public interface AlternativeExecutorImplementation {
74
75
    /**
76
     * Perform an alternative execution.
77
     *
78
     * <p>
79
     * SPI client should perform whatever he wants to do instead of the default execution behavior.
80
     *
81
     * @param config configuration
82
     * @param executionContext execution context
83
     * @return {@code true} if the execution was successful, {@code false} otherwise
84
     */
85
    boolean execute(RunConfig config, ExecutionContext executionContext);
86
87
}

Return to bug 230565