You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@netbeans.apache.org by lk...@apache.org on 2020/01/16 13:55:10 UTC
[netbeans] branch master updated: [NETBEANS-3684] Added support for
Gralde Composite Builds
This is an automated email from the ASF dual-hosted git repository.
lkishalmi pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/netbeans.git
The following commit(s) were added to refs/heads/master by this push:
new 729a705 [NETBEANS-3684] Added support for Gralde Composite Builds
729a705 is described below
commit 729a7056c46c9e8b1ecce5b13efb06f5f6709c44
Author: Laszlo Kishalmi <la...@gmail.com>
AuthorDate: Sun Jan 12 08:16:32 2020 -0800
[NETBEANS-3684] Added support for Gralde Composite Builds
---
groovy/gradle.java/nbproject/project.xml | 7 +-
.../gradle/java/customizer/Bundle.properties | 2 +
.../java/customizer/CompileOptionsPanel.form | 45 +++++++++--
.../java/customizer/CompileOptionsPanel.java | 31 +++++++-
groovy/gradle/manifest.mf | 2 +-
groovy/gradle/nbproject/project.properties | 3 +
groovy/gradle/nbproject/project.xml | 33 ++++++++
.../gradle/api/execute/GradleCommandLine.java | 38 +--------
.../modules/gradle/api/execute/RunUtils.java | 59 ++++++++++++--
.../gradle/execute/GradleDaemonExecutor.java | 2 -
.../gradle/AbstractGradleProjectTestCase.java | 92 ++++++++++++++++++++++
.../gradle/api/execute/GradleCommandLineTest.java | 2 -
.../modules/gradle/api/execute/RunUtilsTest.java | 68 ++++++++++++++++
13 files changed, 327 insertions(+), 57 deletions(-)
diff --git a/groovy/gradle.java/nbproject/project.xml b/groovy/gradle.java/nbproject/project.xml
index 3065224..3ab14e4 100644
--- a/groovy/gradle.java/nbproject/project.xml
+++ b/groovy/gradle.java/nbproject/project.xml
@@ -31,7 +31,7 @@
<compile-dependency/>
<run-dependency>
<release-version>1</release-version>
- <specification-version>1.4</specification-version>
+ <specification-version>1.5</specification-version>
</run-dependency>
</dependency>
<dependency>
@@ -334,6 +334,11 @@
<test/>
</test-dependency>
<test-dependency>
+ <code-name-base>org.netbeans.modules.masterfs</code-name-base>
+ <compile-dependency/>
+ <test/>
+ </test-dependency>
+ <test-dependency>
<code-name-base>org.openide.util.lookup</code-name-base>
<compile-dependency/>
<test/>
diff --git a/groovy/gradle.java/src/org/netbeans/modules/gradle/java/customizer/Bundle.properties b/groovy/gradle.java/src/org/netbeans/modules/gradle/java/customizer/Bundle.properties
index 70326cc..0c0198a 100644
--- a/groovy/gradle.java/src/org/netbeans/modules/gradle/java/customizer/Bundle.properties
+++ b/groovy/gradle.java/src/org/netbeans/modules/gradle/java/customizer/Bundle.properties
@@ -28,3 +28,5 @@ SourceSetPanel.jScrollPane1.TabConstraints.tabTitle=Source
SourceSetPanel.jScrollPane2.TabConstraints.tabTitle=Compile Classpath
SourceSetPanel.jScrollPane3.TabConstraints.tabTitle=Runtime Classpath
SourceSetPanel.tfSourceLevel.text=
+CompileOptionsPanel.cbIncludeOpenProjects.text=Include Open Projects
+CompileOptionsPanel.lbIncludeOpenProjects.text=<html>Create a composite project from this project and the other open Gradle projects by generating '--include-build' parameters.
diff --git a/groovy/gradle.java/src/org/netbeans/modules/gradle/java/customizer/CompileOptionsPanel.form b/groovy/gradle.java/src/org/netbeans/modules/gradle/java/customizer/CompileOptionsPanel.form
index 81cc2ec..97198c9 100644
--- a/groovy/gradle.java/src/org/netbeans/modules/gradle/java/customizer/CompileOptionsPanel.form
+++ b/groovy/gradle.java/src/org/netbeans/modules/gradle/java/customizer/CompileOptionsPanel.form
@@ -60,10 +60,23 @@
</Group>
</Group>
</Group>
- <Group type="102" attributes="0">
+ <Group type="102" alignment="0" attributes="0">
<EmptySpace min="-2" pref="25" max="-2" attributes="0"/>
<Component id="jLabel2" pref="0" max="32767" attributes="0"/>
</Group>
+ <Group type="102" alignment="0" attributes="0">
+ <EmptySpace max="-2" attributes="0"/>
+ <Group type="103" groupAlignment="0" attributes="0">
+ <Group type="102" attributes="0">
+ <EmptySpace min="21" pref="21" max="-2" attributes="0"/>
+ <Component id="lbIncludeOpenProjects" pref="0" max="32767" attributes="0"/>
+ </Group>
+ <Group type="102" attributes="0">
+ <Component id="cbIncludeOpenProjects" min="-2" max="-2" attributes="0"/>
+ <EmptySpace min="0" pref="0" max="32767" attributes="0"/>
+ </Group>
+ </Group>
+ </Group>
</Group>
<EmptySpace max="-2" attributes="0"/>
</Group>
@@ -78,15 +91,19 @@
<Component id="cbPlatform" alignment="3" min="-2" max="-2" attributes="0"/>
<Component id="btManagePlatforms" alignment="3" min="-2" max="-2" attributes="0"/>
</Group>
- <EmptySpace type="separate" max="-2" attributes="0"/>
+ <EmptySpace type="separate" min="-2" max="-2" attributes="0"/>
<Component id="cbCompileOnSave" min="-2" max="-2" attributes="0"/>
- <EmptySpace max="-2" attributes="0"/>
+ <EmptySpace min="-2" max="-2" attributes="0"/>
<Component id="lbCompileOnSave" min="-2" pref="60" max="-2" attributes="0"/>
- <EmptySpace max="-2" attributes="0"/>
+ <EmptySpace min="-2" max="-2" attributes="0"/>
<Component id="cbAugmentedBuild" min="-2" max="-2" attributes="0"/>
<EmptySpace max="-2" attributes="0"/>
- <Component id="jLabel2" min="-2" pref="51" max="-2" attributes="0"/>
- <EmptySpace pref="136" max="32767" attributes="0"/>
+ <Component id="jLabel2" min="-2" max="-2" attributes="0"/>
+ <EmptySpace type="separate" max="-2" attributes="0"/>
+ <Component id="cbIncludeOpenProjects" min="-2" max="-2" attributes="0"/>
+ <EmptySpace max="-2" attributes="0"/>
+ <Component id="lbIncludeOpenProjects" min="-2" pref="56" max="-2" attributes="0"/>
+ <EmptySpace pref="67" max="32767" attributes="0"/>
</Group>
</Group>
</DimensionLayout>
@@ -145,6 +162,22 @@
<Property name="text" type="java.lang.String" editor="org.netbeans.modules.i18n.form.FormI18nStringEditor">
<ResourceString bundle="org/netbeans/modules/gradle/java/customizer/Bundle.properties" key="CompileOptionsPanel.jLabel2.text" replaceFormat="org.openide.util.NbBundle.getMessage({sourceFileName}.class, "{key}")"/>
</Property>
+ <Property name="verticalAlignment" type="int" value="1"/>
+ </Properties>
+ </Component>
+ <Component class="javax.swing.JCheckBox" name="cbIncludeOpenProjects">
+ <Properties>
+ <Property name="text" type="java.lang.String" editor="org.netbeans.modules.i18n.form.FormI18nStringEditor">
+ <ResourceString bundle="org/netbeans/modules/gradle/java/customizer/Bundle.properties" key="CompileOptionsPanel.cbIncludeOpenProjects.text" replaceFormat="org.openide.util.NbBundle.getMessage({sourceFileName}.class, "{key}")"/>
+ </Property>
+ </Properties>
+ </Component>
+ <Component class="javax.swing.JLabel" name="lbIncludeOpenProjects">
+ <Properties>
+ <Property name="text" type="java.lang.String" editor="org.netbeans.modules.i18n.form.FormI18nStringEditor">
+ <ResourceString bundle="org/netbeans/modules/gradle/java/customizer/Bundle.properties" key="CompileOptionsPanel.lbIncludeOpenProjects.text" replaceFormat="org.openide.util.NbBundle.getMessage({sourceFileName}.class, "{key}")"/>
+ </Property>
+ <Property name="verticalAlignment" type="int" value="1"/>
</Properties>
</Component>
</SubComponents>
diff --git a/groovy/gradle.java/src/org/netbeans/modules/gradle/java/customizer/CompileOptionsPanel.java b/groovy/gradle.java/src/org/netbeans/modules/gradle/java/customizer/CompileOptionsPanel.java
index 72257dd..54e8376 100644
--- a/groovy/gradle.java/src/org/netbeans/modules/gradle/java/customizer/CompileOptionsPanel.java
+++ b/groovy/gradle.java/src/org/netbeans/modules/gradle/java/customizer/CompileOptionsPanel.java
@@ -79,6 +79,7 @@ public class CompileOptionsPanel extends javax.swing.JPanel {
initComponents();
setupCheckBox(cbCompileOnSave, RunUtils.PROP_COMPILE_ON_SAVE, false);
setupCheckBox(cbAugmentedBuild, RunUtils.PROP_AUGMENTED_BUILD, true);
+ setupCheckBox(cbIncludeOpenProjects, RunUtils.PROP_INCLUDE_OPEN_PROJECTS, false);
setupPlatform();
}
@@ -150,6 +151,7 @@ public class CompileOptionsPanel extends javax.swing.JPanel {
private void save() {
saveCheckBox(cbCompileOnSave, RunUtils.PROP_COMPILE_ON_SAVE);
saveCheckBox(cbAugmentedBuild, RunUtils.PROP_AUGMENTED_BUILD);
+ saveCheckBox(cbIncludeOpenProjects, RunUtils.PROP_INCLUDE_OPEN_PROJECTS);
savePlatform();
try {
NbGradleProject.getPreferences(project, false).flush();
@@ -172,6 +174,8 @@ public class CompileOptionsPanel extends javax.swing.JPanel {
cbPlatform = new javax.swing.JComboBox<>();
btManagePlatforms = new javax.swing.JButton();
jLabel2 = new javax.swing.JLabel();
+ cbIncludeOpenProjects = new javax.swing.JCheckBox();
+ lbIncludeOpenProjects = new javax.swing.JLabel();
org.openide.awt.Mnemonics.setLocalizedText(cbCompileOnSave, org.openide.util.NbBundle.getMessage(CompileOptionsPanel.class, "CompileOptionsPanel.cbCompileOnSave.text")); // NOI18N
cbCompileOnSave.setEnabled(false);
@@ -192,6 +196,12 @@ public class CompileOptionsPanel extends javax.swing.JPanel {
});
org.openide.awt.Mnemonics.setLocalizedText(jLabel2, org.openide.util.NbBundle.getMessage(CompileOptionsPanel.class, "CompileOptionsPanel.jLabel2.text")); // NOI18N
+ jLabel2.setVerticalAlignment(javax.swing.SwingConstants.TOP);
+
+ org.openide.awt.Mnemonics.setLocalizedText(cbIncludeOpenProjects, org.openide.util.NbBundle.getMessage(CompileOptionsPanel.class, "CompileOptionsPanel.cbIncludeOpenProjects.text")); // NOI18N
+
+ org.openide.awt.Mnemonics.setLocalizedText(lbIncludeOpenProjects, org.openide.util.NbBundle.getMessage(CompileOptionsPanel.class, "CompileOptionsPanel.lbIncludeOpenProjects.text")); // NOI18N
+ lbIncludeOpenProjects.setVerticalAlignment(javax.swing.SwingConstants.TOP);
javax.swing.GroupLayout layout = new javax.swing.GroupLayout(this);
this.setLayout(layout);
@@ -217,7 +227,16 @@ public class CompileOptionsPanel extends javax.swing.JPanel {
.addComponent(lbCompileOnSave, javax.swing.GroupLayout.DEFAULT_SIZE, 489, Short.MAX_VALUE))))
.addGroup(layout.createSequentialGroup()
.addGap(25, 25, 25)
- .addComponent(jLabel2, javax.swing.GroupLayout.PREFERRED_SIZE, 0, Short.MAX_VALUE)))
+ .addComponent(jLabel2, javax.swing.GroupLayout.PREFERRED_SIZE, 0, Short.MAX_VALUE))
+ .addGroup(layout.createSequentialGroup()
+ .addContainerGap()
+ .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
+ .addGroup(layout.createSequentialGroup()
+ .addGap(21, 21, 21)
+ .addComponent(lbIncludeOpenProjects, javax.swing.GroupLayout.PREFERRED_SIZE, 0, Short.MAX_VALUE))
+ .addGroup(layout.createSequentialGroup()
+ .addComponent(cbIncludeOpenProjects)
+ .addGap(0, 0, Short.MAX_VALUE)))))
.addContainerGap())
);
layout.setVerticalGroup(
@@ -235,8 +254,12 @@ public class CompileOptionsPanel extends javax.swing.JPanel {
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addComponent(cbAugmentedBuild)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
- .addComponent(jLabel2, javax.swing.GroupLayout.PREFERRED_SIZE, 51, javax.swing.GroupLayout.PREFERRED_SIZE)
- .addContainerGap(136, Short.MAX_VALUE))
+ .addComponent(jLabel2, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
+ .addGap(18, 18, 18)
+ .addComponent(cbIncludeOpenProjects)
+ .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
+ .addComponent(lbIncludeOpenProjects, javax.swing.GroupLayout.PREFERRED_SIZE, 56, javax.swing.GroupLayout.PREFERRED_SIZE)
+ .addContainerGap(67, Short.MAX_VALUE))
);
}// </editor-fold>//GEN-END:initComponents
@@ -278,9 +301,11 @@ public class CompileOptionsPanel extends javax.swing.JPanel {
private javax.swing.JButton btManagePlatforms;
private javax.swing.JCheckBox cbAugmentedBuild;
private javax.swing.JCheckBox cbCompileOnSave;
+ private javax.swing.JCheckBox cbIncludeOpenProjects;
private javax.swing.JComboBox<JavaPlatform> cbPlatform;
private javax.swing.JLabel jLabel2;
private javax.swing.JLabel lbCompileOnSave;
+ private javax.swing.JLabel lbIncludeOpenProjects;
private javax.swing.JLabel lbPlatform;
// End of variables declaration//GEN-END:variables
diff --git a/groovy/gradle/manifest.mf b/groovy/gradle/manifest.mf
index 15efa3d..12dfcb2 100644
--- a/groovy/gradle/manifest.mf
+++ b/groovy/gradle/manifest.mf
@@ -3,5 +3,5 @@ AutoUpdate-Show-In-Client: false
OpenIDE-Module: org.netbeans.modules.gradle/1
OpenIDE-Module-Layer: org/netbeans/modules/gradle/layer.xml
OpenIDE-Module-Localizing-Bundle: org/netbeans/modules/gradle/Bundle.properties
-OpenIDE-Module-Specification-Version: 1.4
+OpenIDE-Module-Specification-Version: 1.5
OpenIDE-Module-Requires: cnb.org.netbeans.modules.groovy.kit
diff --git a/groovy/gradle/nbproject/project.properties b/groovy/gradle/nbproject/project.properties
index d67d8a3..38fa388 100644
--- a/groovy/gradle/nbproject/project.properties
+++ b/groovy/gradle/nbproject/project.properties
@@ -23,6 +23,9 @@ javadoc.arch=${basedir}/arch.xml
nbm.module.author=Laszlo Kishalmi
source.reference.netbeans-gradle-tooling.jar=netbeans-gradle-tooling/src/main/groovy
+test-unit-sys-prop.test.netbeans.dest.dir=${netbeans.dest.dir}
+test-unit-sys-prop.java.awt.headless=true
+
release.external/gradle-tooling-api-6.0.jar=modules/gradle/gradle-tooling-api.jar
release.build/tooling/netbeans-gradle-tooling.jar=modules/gradle/netbeans-gradle-tooling.jar
release.build/tooling/nb-tooling.gradle=modules/gradle/nb-tooling.gradle
diff --git a/groovy/gradle/nbproject/project.xml b/groovy/gradle/nbproject/project.xml
index 4a12d8a..b3884b9 100644
--- a/groovy/gradle/nbproject/project.xml
+++ b/groovy/gradle/nbproject/project.xml
@@ -339,10 +339,43 @@
<compile-dependency/>
</test-dependency>
<test-dependency>
+ <code-name-base>org.netbeans.modules.apisupport.project</code-name-base>
+ <compile-dependency/>
+ <test/>
+ </test-dependency>
+ <test-dependency>
<code-name-base>org.netbeans.modules.nbjunit</code-name-base>
<recursive/>
<compile-dependency/>
</test-dependency>
+ <test-dependency>
+ <code-name-base>org.netbeans.modules.projectapi.nb</code-name-base>
+ <compile-dependency/>
+ </test-dependency>
+ <test-dependency>
+ <code-name-base>org.netbeans.modules.projectui</code-name-base>
+ <compile-dependency/>
+ </test-dependency>
+ <test-dependency>
+ <code-name-base>org.openide.filesystems</code-name-base>
+ <compile-dependency/>
+ <test/>
+ </test-dependency>
+ <test-dependency>
+ <code-name-base>org.netbeans.modules.masterfs</code-name-base>
+ <compile-dependency/>
+ <test/>
+ </test-dependency>
+ <test-dependency>
+ <code-name-base>org.openide.util.lookup</code-name-base>
+ <compile-dependency/>
+ <test/>
+ </test-dependency>
+ <test-dependency>
+ <code-name-base>org.openide.util.ui</code-name-base>
+ <compile-dependency/>
+ <test/>
+ </test-dependency>
</test-type>
</test-dependencies>
<public-packages>
diff --git a/groovy/gradle/src/org/netbeans/modules/gradle/api/execute/GradleCommandLine.java b/groovy/gradle/src/org/netbeans/modules/gradle/api/execute/GradleCommandLine.java
index a3015c8..983b5b3 100644
--- a/groovy/gradle/src/org/netbeans/modules/gradle/api/execute/GradleCommandLine.java
+++ b/groovy/gradle/src/org/netbeans/modules/gradle/api/execute/GradleCommandLine.java
@@ -194,7 +194,8 @@ public final class GradleCommandLine implements Serializable {
PROJECT_DIR(PARAM, "-p", "--project-dir"),
PROJECT_CACHE_DIR(UNSUPPORTED, "--project-cache-dir"),
EXCLUDE_TASK(PARAM, "-x", "--exclude-task"),
- IMPORT_BUILD(PARAM, "--import-build");
+ IMPORT_BUILD(UNSUPPORTED),
+ INCLUDE_BUILD(PARAM, "--include-build");
final Argument.Kind kind;
final List<String> flags;
@@ -465,40 +466,7 @@ public final class GradleCommandLine implements Serializable {
}
public GradleCommandLine(CharSequence argLine) {
- this(parseArgLine(argLine));
- }
-
- static String[] parseArgLine(CharSequence cli) {
- char quote = 0;
- StringBuilder buf = new StringBuilder();
- List<String> args = new ArrayList<>();
- for (int i = 0; i < cli.length(); i++) {
- char ch = cli.charAt(i);
- if (quote == 0) {
- if (Character.isWhitespace(ch)) {
- if (buf.length() > 0) {
- args.add(buf.toString());
- buf.setLength(0);
- }
- } else {
- if (ch == '"' || ch == '\'') {
- quote = ch;
- } else {
- buf.append(ch);
- }
- }
- } else {
- if (quote == ch) {
- quote = 0;
- } else {
- buf.append(ch);
- }
- }
- }
- if (buf.length() > 0) {
- args.add(buf.toString());
- }
- return args.toArray(new String[args.size()]);
+ this(Utilities.parseParameters(argLine.toString()));
}
private List<String> getArgs(Set<Argument.Kind> kinds) {
diff --git a/groovy/gradle/src/org/netbeans/modules/gradle/api/execute/RunUtils.java b/groovy/gradle/src/org/netbeans/modules/gradle/api/execute/RunUtils.java
index 8ab22fd..6cb8218 100644
--- a/groovy/gradle/src/org/netbeans/modules/gradle/api/execute/RunUtils.java
+++ b/groovy/gradle/src/org/netbeans/modules/gradle/api/execute/RunUtils.java
@@ -26,6 +26,7 @@ import org.netbeans.modules.gradle.execute.GradleDaemonExecutor;
import org.netbeans.modules.gradle.execute.GradleExecutor;
import org.netbeans.modules.gradle.execute.ProxyNonSelectableInputOutput;
import java.io.IOException;
+import java.nio.file.Path;
import java.util.Iterator;
import java.util.List;
import java.util.logging.Level;
@@ -45,6 +46,7 @@ import java.util.ArrayList;
import java.util.Collection;
import java.util.Collections;
import java.util.EnumSet;
+import java.util.HashSet;
import java.util.Map;
import java.util.Set;
import java.util.WeakHashMap;
@@ -54,6 +56,7 @@ import org.netbeans.api.java.platform.JavaPlatformManager;
import org.netbeans.api.java.platform.Specification;
import org.netbeans.api.project.ProjectUtils;
+import org.netbeans.api.project.ui.OpenProjects;
import org.netbeans.modules.gradle.GradleDistributionManager;
import org.netbeans.modules.gradle.spi.GradleSettings;
import org.netbeans.spi.project.ActionProvider;
@@ -75,6 +78,7 @@ public final class RunUtils {
public static final String PROP_JDK_PLATFORM = "jdkPlatform"; //NOI18N
public static final String PROP_COMPILE_ON_SAVE = "compile.on.save"; //NOI18N
public static final String PROP_AUGMENTED_BUILD = "augmented.build"; //NOI18N
+ public static final String PROP_INCLUDE_OPEN_PROJECTS = "include.open.projects"; //NOI18N
public static final String PROP_DEFAULT_CLI = "gradle.cli"; //NOI18N
private RunUtils() {}
@@ -142,6 +146,11 @@ public final class RunUtils {
basecmd = GradleCommandLine.combine(syscmd, prjcmd);
}
+ if (isIncludeOpenProjectsEnabled(project)) {
+ GradleCommandLine include = getIncludedOpenProjects(project);
+ basecmd = GradleCommandLine.combine(basecmd, include);
+ }
+
// Make sure we only exclude 'test' and 'check' by default if the
// project allows this (has these tasks or root project with sub projects).
validateExclude(basecmd, gbp, GradleCommandLine.TEST_TASK);
@@ -194,6 +203,18 @@ public final class RunUtils {
return isOptionEnabled(project, PROP_AUGMENTED_BUILD, true);
}
+ /**
+ * Returns true if the include open projects checkbox is marked
+ * in the project configuration.
+ *
+ * @param project the given project.
+ * @return true if the settings has been enabled.
+ * @since 1.5
+ */
+ public static boolean isIncludeOpenProjectsEnabled(Project project) {
+ return isOptionEnabled(project, PROP_INCLUDE_OPEN_PROJECTS, false);
+ }
+
public static GradleCommandLine getDefaultCommandLine(Project project) {
String args = NbGradleProject.getPreferences(project, true).get(PROP_DEFAULT_CLI, null);
return args != null ? new GradleCommandLine(args) : null;
@@ -362,14 +383,38 @@ public final class RunUtils {
return getActivePlatform(platformId);
}
- private static String stringsInCurly(List<String> l) {
- StringBuilder sb = new StringBuilder("(");
- Iterator<String> it = l.iterator();
- while (it.hasNext()) {
- sb.append(it.next());
- sb.append(it.hasNext() ? ", " : ")");
+ static GradleCommandLine getIncludedOpenProjects(Project project) {
+ GradleCommandLine ret = new GradleCommandLine();
+ Set<File> openRoots = new HashSet<>();
+ for (Project openProject : OpenProjects.getDefault().getOpenProjects()){
+ GradleBaseProject gpb = GradleBaseProject.get(openProject);
+ if (gpb != null) {
+ openRoots.add(gpb.getRootDir());
+ }
}
- return sb.toString();
+ GradleBaseProject gbp = GradleBaseProject.get(project);
+ if (gbp != null) {
+ //Removing ourself
+ openRoots.remove(gbp.getRootDir());
+ openRoots.removeAll(gbp.getIncludedBuilds().values());
+
+ Path projectPath = gbp.getProjectDir().toPath();
+ for (File openRoot : openRoots) {
+ Path root = openRoot.toPath();
+ String ib = root.toString();
+ try {
+ Path rel = projectPath.relativize(root);
+
+ if (rel.getNameCount() < root.getNameCount()) {
+ ib = rel.toString();
+ }
+ } catch (IllegalArgumentException ex) {
+ // Relative path cannot be computed, just use the full path then.
+ }
+ ret.addParameter(GradleCommandLine.Parameter.INCLUDE_BUILD, ib);
+ }
+ }
+ return ret;
}
}
diff --git a/groovy/gradle/src/org/netbeans/modules/gradle/execute/GradleDaemonExecutor.java b/groovy/gradle/src/org/netbeans/modules/gradle/execute/GradleDaemonExecutor.java
index baac702..029c0dd 100644
--- a/groovy/gradle/src/org/netbeans/modules/gradle/execute/GradleDaemonExecutor.java
+++ b/groovy/gradle/src/org/netbeans/modules/gradle/execute/GradleDaemonExecutor.java
@@ -46,13 +46,11 @@ import org.gradle.tooling.GradleConnectionException;
import org.gradle.tooling.GradleConnector;
import org.gradle.tooling.ProgressEvent;
import org.gradle.tooling.ProjectConnection;
-import org.gradle.tooling.internal.gradle.GradleBuildIdentity;
import org.netbeans.api.java.platform.JavaPlatform;
import org.netbeans.api.progress.ProgressHandle;
import org.netbeans.api.progress.ProgressHandleFactory;
import org.netbeans.api.project.ProjectInformation;
import org.netbeans.api.project.ProjectUtils;
-import org.netbeans.modules.gradle.api.NbGradleProject;
import org.netbeans.modules.gradle.spi.GradleFiles;
import org.netbeans.spi.project.ui.support.BuildExecutionSupport;
import org.openide.awt.StatusDisplayer;
diff --git a/groovy/gradle/test/unit/src/org/netbeans/modules/gradle/AbstractGradleProjectTestCase.java b/groovy/gradle/test/unit/src/org/netbeans/modules/gradle/AbstractGradleProjectTestCase.java
new file mode 100644
index 0000000..c0c8810
--- /dev/null
+++ b/groovy/gradle/test/unit/src/org/netbeans/modules/gradle/AbstractGradleProjectTestCase.java
@@ -0,0 +1,92 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.netbeans.modules.gradle;
+
+import java.io.File;
+import java.io.IOException;
+import static junit.framework.TestCase.assertNotNull;
+import org.netbeans.api.project.Project;
+import org.netbeans.api.project.ProjectManager;
+import org.netbeans.api.project.ui.OpenProjects;
+import org.netbeans.junit.NbTestCase;
+import org.netbeans.modules.apisupport.project.InstalledFileLocatorImpl;
+import org.netbeans.modules.project.uiapi.ProjectOpenedTrampoline;
+import org.netbeans.spi.project.ui.ProjectOpenedHook;
+import org.openide.filesystems.FileObject;
+import org.openide.filesystems.FileUtil;
+import org.openide.filesystems.test.TestFileUtils;
+
+/**
+ *
+ * @author lkishalmi
+ */
+public class AbstractGradleProjectTestCase extends NbTestCase {
+
+ public AbstractGradleProjectTestCase(String name) {
+ super(name);
+ }
+
+ /** Represents destination directory with NetBeans (always available). */
+ protected File destDirF;
+
+ @Override
+ protected void setUp() throws Exception {
+ super.setUp();
+ clearWorkDir();
+ destDirF = getTestNBDestDir();
+ InstalledFileLocatorImpl.registerDestDir(destDirF);
+ }
+
+ @Override
+ protected void tearDown() throws Exception {
+ OpenProjects.getDefault().close(OpenProjects.getDefault().getOpenProjects());
+ }
+
+ protected FileObject createGradleProject(String buildScript) throws IOException {
+ return createGradleProject(null, buildScript, null);
+ }
+
+ protected Project openProject(FileObject projectDir) throws IOException {
+ Project prj = ProjectManager.getDefault().findProject(projectDir);
+ assertNotNull(prj);
+ ProjectOpenedTrampoline.DEFAULT.projectOpened(prj.getLookup().lookup(ProjectOpenedHook.class));
+ return prj;
+ }
+
+ protected FileObject createGradleProject(String path, String buildScript, String settingsScript) throws IOException {
+ FileObject ret = FileUtil.toFileObject(getWorkDir());
+ if (path != null) {
+ for (String p : path.split("/")) {
+ ret = ret.createFolder(p);
+ }
+ }
+ TestFileUtils.writeFile(ret, "build.gradle", buildScript);
+ if (settingsScript != null) {
+ TestFileUtils.writeFile(ret, "settings.gradle", settingsScript);
+ }
+ return ret;
+ }
+
+ private static File getTestNBDestDir() {
+ String destDir = System.getProperty("test.netbeans.dest.dir");
+ // set in project.properties as test-unit-sys-prop.test.netbeans.dest.dir
+ assertNotNull("test.netbeans.dest.dir property has to be set when running within binary distribution", destDir);
+ return new File(destDir);
+ }
+}
diff --git a/groovy/gradle/test/unit/src/org/netbeans/modules/gradle/api/execute/GradleCommandLineTest.java b/groovy/gradle/test/unit/src/org/netbeans/modules/gradle/api/execute/GradleCommandLineTest.java
index 827b596..70bfc40 100644
--- a/groovy/gradle/test/unit/src/org/netbeans/modules/gradle/api/execute/GradleCommandLineTest.java
+++ b/groovy/gradle/test/unit/src/org/netbeans/modules/gradle/api/execute/GradleCommandLineTest.java
@@ -31,8 +31,6 @@ import java.util.Set;
import org.junit.Test;
import static org.junit.Assert.*;
import org.junit.rules.TemporaryFolder;
-import org.netbeans.modules.gradle.spi.GradleFiles;
-import org.netbeans.modules.gradle.spi.GradleFilesTest;
/**
*
diff --git a/groovy/gradle/test/unit/src/org/netbeans/modules/gradle/api/execute/RunUtilsTest.java b/groovy/gradle/test/unit/src/org/netbeans/modules/gradle/api/execute/RunUtilsTest.java
new file mode 100644
index 0000000..39648b9
--- /dev/null
+++ b/groovy/gradle/test/unit/src/org/netbeans/modules/gradle/api/execute/RunUtilsTest.java
@@ -0,0 +1,68 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.netbeans.modules.gradle.api.execute;
+
+import java.io.File;
+import java.util.Collection;
+import static junit.framework.TestCase.assertEquals;
+import org.netbeans.api.project.Project;
+import org.netbeans.api.project.ProjectManager;
+import org.netbeans.api.project.ui.OpenProjects;
+import org.netbeans.modules.gradle.AbstractGradleProjectTestCase;
+import org.openide.filesystems.FileObject;
+
+/**
+ *
+ * @author lkishalmi
+ */
+public class RunUtilsTest extends AbstractGradleProjectTestCase {
+
+ public RunUtilsTest(String name) {
+ super(name);
+ }
+
+ public void testIncludeOpenProjects1() throws Exception {
+ FileObject a = createGradleProject("projectA",
+ "apply plugin: 'java'\n", "");
+ FileObject b = createGradleProject("projectB",
+ "apply plugin: 'java'\n", "");
+ Project prjA = ProjectManager.getDefault().findProject(a);
+ Project prjB = ProjectManager.getDefault().findProject(b);
+ OpenProjects.getDefault().open(new Project[] {prjA, prjB}, false);
+ GradleCommandLine cmd = RunUtils.getIncludedOpenProjects(prjB);
+ Collection<String> params = cmd.getParameters(GradleCommandLine.Parameter.INCLUDE_BUILD);
+ assertEquals(1, params.size());
+ String value = params.iterator().next();
+ assertEquals(".." + File.separator + "projectA", value);
+ }
+
+ public void testIncludeOpenProjects2() throws Exception {
+ FileObject a = createGradleProject("projectA",
+ "apply plugin: 'java'\n", "");
+ FileObject b = createGradleProject("projectB",
+ "apply plugin: 'java'\n", "includeBuild '../projectA'\n");
+ Project prjA = ProjectManager.getDefault().findProject(a);
+ Project prjB = ProjectManager.getDefault().findProject(b);
+ OpenProjects.getDefault().open(new Project[] {prjA, prjB}, false);
+ GradleCommandLine cmd = RunUtils.getIncludedOpenProjects(prjB);
+ Collection<String> params = cmd.getParameters(GradleCommandLine.Parameter.INCLUDE_BUILD);
+ assertEquals(0, params.size());
+ }
+
+}
---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@netbeans.apache.org
For additional commands, e-mail: commits-help@netbeans.apache.org
For further information about the NetBeans mailing lists, visit:
https://cwiki.apache.org/confluence/display/NETBEANS/Mailing+lists