From c6eb9a8b766287e16f016e752f19e64d12e77321 Mon Sep 17 00:00:00 2001 From: Junichi Yamamoto Date: Sat, 25 Jan 2025 23:46:14 +0900 Subject: [PATCH 1/6] Don't add the listener if a document is not a test file - Avoid adding the listener to all PHP files (Add it to only test files) Because other than test files don't have test methods - Improve the deeply nested parts --- .../project/ComputeTestMethodAnnotations.java | 195 +++++++++++------- 1 file changed, 126 insertions(+), 69 deletions(-) diff --git a/php/php.project/src/org/netbeans/modules/php/project/ComputeTestMethodAnnotations.java b/php/php.project/src/org/netbeans/modules/php/project/ComputeTestMethodAnnotations.java index 08fd0de20634..012440b91f11 100644 --- a/php/php.project/src/org/netbeans/modules/php/project/ComputeTestMethodAnnotations.java +++ b/php/php.project/src/org/netbeans/modules/php/project/ComputeTestMethodAnnotations.java @@ -33,6 +33,8 @@ import javax.swing.text.BadLocationException; import javax.swing.text.Document; import javax.swing.text.JTextComponent; +import javax.swing.text.Position; +import org.netbeans.api.annotations.common.CheckForNull; import org.netbeans.api.editor.EditorRegistry; import org.netbeans.modules.editor.NbEditorUtilities; import org.netbeans.modules.gsf.testrunner.ui.api.TestMethodController; @@ -41,7 +43,6 @@ import org.netbeans.modules.php.api.editor.PhpClass; import org.netbeans.modules.php.api.editor.PhpType; import org.netbeans.modules.php.api.phpmodule.PhpModule; -import org.netbeans.modules.php.api.util.FileUtils; import org.netbeans.modules.php.project.ui.actions.support.CommandUtils; import org.netbeans.modules.php.project.util.PhpProjectUtils; import org.netbeans.modules.php.spi.testing.PhpTestingProvider; @@ -50,14 +51,13 @@ import org.openide.util.Lookup; import org.openide.util.RequestProcessor; - public class ComputeTestMethodAnnotations implements DocumentListener, PropertyChangeListener, Runnable { private static final Logger LOGGER = Logger.getLogger(ComputeTestMethodAnnotations.class.getName()); - private static final RequestProcessor RP = new RequestProcessor(ComputeTestMethodAnnotations.class); private static final ComputeTestMethodAnnotations INSTANCE = new ComputeTestMethodAnnotations(); private static final AtomicInteger USAGES_COUNT = new AtomicInteger(0); + private final RequestProcessor.Task task = RP.create(this); private volatile Document handledDocument; @@ -82,49 +82,93 @@ public void unregister() { @Override public void propertyChange(PropertyChangeEvent event) { - assert SwingUtilities.isEventDispatchThread() : "UI thread expected but is: " + Thread.currentThread().getName(); - + assert SwingUtilities.isEventDispatchThread() : "UI thread expected but is: " + Thread.currentThread().getName(); // NOI18N + Document document = getLastFocusedDocument(); + if (document == null) { + return; + } + long startTime = 0; + if (LOGGER.isLoggable(Level.FINE)) { + startTime = System.currentTimeMillis(); + } + PhpTestingProvider testingProvider = getFirstTestingProvider(document); + if (LOGGER.isLoggable(Level.FINE)) { + long time = System.currentTimeMillis() - startTime; + LOGGER.fine(String.format("getFirstTestingProvider() took %d ms", time)); // NOI18N + } + if (testingProvider == null) { + return; + } + // don't add the listener if this document is not a test file String propertyName = event.getPropertyName(); - - JTextComponent textComponent = EditorRegistry.lastFocusedComponent(); - if (textComponent != null) { - Document document = textComponent.getDocument(); - if (document != null) { - FileObject fileObject = NbEditorUtilities.getFileObject(document); - if (fileObject != null) { - if (FileUtils.isPhpFile(fileObject)) { - if (propertyName.equals(EditorRegistry.FOCUS_GAINED_PROPERTY)) { - handleFileChange(document); - document.addDocumentListener(ComputeTestMethodAnnotations.this); - } else if (propertyName.equals(EditorRegistry.FOCUS_LOST_PROPERTY)) { - document.removeDocumentListener(this); - } - } - } - } + if (propertyName.equals(EditorRegistry.FOCUS_GAINED_PROPERTY)) { + handleFileChange(document); + document.addDocumentListener(this); + } else if (propertyName.equals(EditorRegistry.FOCUS_LOST_PROPERTY)) { + document.removeDocumentListener(this); } } @Override public void insertUpdate(DocumentEvent event) { - handleFileChange(event.getDocument()); + processUpdate(); } @Override public void removeUpdate(DocumentEvent event) { - handleFileChange(event.getDocument()); + processUpdate(); } @Override public void changedUpdate(DocumentEvent event) { - handleFileChange(event.getDocument()); + processUpdate(); } private void handleFileChange(Document doc) { handledDocument = doc; + processUpdate(); + } + + private void processUpdate() { task.schedule(500); } + @CheckForNull + private Document getLastFocusedDocument() { + JTextComponent textComponent = EditorRegistry.lastFocusedComponent(); + if (textComponent == null) { + return null; + } + return textComponent.getDocument(); + } + + /** + * Get the first testing provider that recognizes this document as a test + * file. + * + * @param document + * @return the first testing provider if this document is recognized as a + * test file, {@code null} otherwise + */ + @CheckForNull + private PhpTestingProvider getFirstTestingProvider(Document document) { + FileObject fileObject = NbEditorUtilities.getFileObject(document); + if (fileObject == null) { + return null; + } + PhpProject project = PhpProjectUtils.getPhpProject(fileObject); + if (project == null) { + return null; + } + PhpModule phpModule = project.getPhpModule(); + for (PhpTestingProvider testingProvider : project.getTestingProviders()) { + if (testingProvider.isTestFile(phpModule, fileObject)) { + return testingProvider; + } + } + return null; + } + @Override public void run() { List testMethods = getTestMethods(handledDocument); @@ -142,59 +186,72 @@ public void run() { } } + /** + * Get test methods for the first available testing provider. + * + * @return test methods + */ private List getTestMethods(Document document) { - List testMethods = new ArrayList<>(); FileObject fileObject = NbEditorUtilities.getFileObject(document); - if (fileObject != null) { - PhpProject project = PhpProjectUtils.getPhpProject(fileObject); - assert project != null; - PhpModule phpModule = project.getPhpModule(); - for (PhpTestingProvider testingProvider : project.getTestingProviders()) { + if (fileObject == null) { + return Collections.emptyList(); + } + PhpProject project = PhpProjectUtils.getPhpProject(fileObject); + if (project == null) { + return Collections.emptyList(); + } + PhpTestingProvider testingProvider = getFirstTestingProvider(document); + if (testingProvider == null) { + return Collections.emptyList(); + } + return getTestMethods(document, fileObject, testingProvider, project.getPhpModule()); + } + private List getTestMethods(Document document, FileObject fileObject, PhpTestingProvider testingProvider, PhpModule phpModule) { + List testMethods = new ArrayList<>(); + Collection phpClasses = getPhpClasses(fileObject); + for (PhpClass phpClass : phpClasses) { + // check whether the document tab has already been switched to another one + if (!document.equals(handledDocument)) { + return Collections.emptyList(); + } + for (PhpType.Method method : phpClass.getMethods()) { if (!document.equals(handledDocument)) { return Collections.emptyList(); } - - if (testingProvider.isTestFile(phpModule, fileObject)) { - EditorSupport editorSupport = Lookup.getDefault().lookup(EditorSupport.class); - assert editorSupport != null; - Collection phpClasses = editorSupport.getClasses(fileObject); - for (PhpClass phpClass : phpClasses) { - - if (!document.equals(handledDocument)) { - return Collections.emptyList(); - } - - for (PhpType.Method method : phpClass.getMethods()) { - - if (!document.equals(handledDocument)) { - return Collections.emptyList(); - } - - if (!testingProvider.isTestCase(phpModule, method)) { - continue; - } - try { - testMethods.add(new TestMethod( - phpClass.getName(), - new SingleMethod(fileObject, CommandUtils.encodeMethod(method.getPhpType().getFullyQualifiedName(), method.getName())), - document.createPosition(method.getOffset()), - document.createPosition(method.getOffset() + method.getName().length()) - )); - } catch (BadLocationException exception) { - LOGGER.log(Level.WARNING, "Unable to create position: offset: {0}; method: {1}; class: {2}.", new Object[] {exception.offsetRequested(), method.getName(), phpClass.getName()}); // NOI18N - } - } - - if (!testMethods.isEmpty()) { - return testMethods; - } - } - + if (!testingProvider.isTestCase(phpModule, method)) { + continue; + } + TestMethod testMethod = createTestMethod(document, phpClass, method, fileObject); + if (testMethod != null) { + testMethods.add(testMethod); } } } - return testMethods; } + + private Collection getPhpClasses(FileObject fileObject) { + EditorSupport editorSupport = Lookup.getDefault().lookup(EditorSupport.class); + assert editorSupport != null; + return editorSupport.getClasses(fileObject); + } + + @CheckForNull + private TestMethod createTestMethod(Document document, PhpClass phpClass, PhpType.Method method, FileObject fileObject) { + Position startPosition = null; + Position endPosition = null; + try { + startPosition = document.createPosition(method.getOffset()); + endPosition = document.createPosition(method.getOffset() + method.getName().length()); + } catch (BadLocationException exception) { + LOGGER.log(Level.WARNING, "Unable to create position: offset: {0}; method: {1}; class: {2}.", // NOI18N + new Object[]{exception.offsetRequested(), method.getName(), phpClass.getName()}); + } + if (startPosition == null || endPosition == null) { + return null; + } + String methodName = CommandUtils.encodeMethod(method.getPhpType().getFullyQualifiedName(), method.getName()); + return new TestMethod(phpClass.getName(), new SingleMethod(fileObject, methodName), startPosition, endPosition); + } } From e157eab00c66d642378e6edc826af47682873df6 Mon Sep 17 00:00:00 2001 From: Michael Bien Date: Mon, 27 Jan 2025 03:02:31 +0100 Subject: [PATCH 2/6] Bump maven indexer query limits Some projects generated quite a lot of artifacts by now. Some queries didn't produce good results since pagination gave up too early. example: getVersions() is sometimes used to query the top x most recent artifacts. If cut off too early, some might be missing. --- .../modules/maven/indexer/NexusRepositoryIndexManager.java | 2 +- .../modules/maven/indexer/NexusRepositoryQueries.java | 5 ++++- 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/java/maven.indexer/src/org/netbeans/modules/maven/indexer/NexusRepositoryIndexManager.java b/java/maven.indexer/src/org/netbeans/modules/maven/indexer/NexusRepositoryIndexManager.java index 57d832e89bbe..7f2bc35d0d28 100644 --- a/java/maven.indexer/src/org/netbeans/modules/maven/indexer/NexusRepositoryIndexManager.java +++ b/java/maven.indexer/src/org/netbeans/modules/maven/indexer/NexusRepositoryIndexManager.java @@ -164,7 +164,7 @@ public final class NexusRepositoryIndexManager implements RepositoryIndexerImple private final NexusRepositoryQueries queries; - static final int MAX_RESULT_COUNT = 1024; + static final int MAX_RESULT_COUNT = 4096; static final int NO_CAP_RESULT_COUNT = AbstractSearchRequest.UNDEFINED; @SuppressWarnings("this-escape") diff --git a/java/maven.indexer/src/org/netbeans/modules/maven/indexer/NexusRepositoryQueries.java b/java/maven.indexer/src/org/netbeans/modules/maven/indexer/NexusRepositoryQueries.java index 2a82c659c19e..8d3944ecc177 100644 --- a/java/maven.indexer/src/org/netbeans/modules/maven/indexer/NexusRepositoryQueries.java +++ b/java/maven.indexer/src/org/netbeans/modules/maven/indexer/NexusRepositoryQueries.java @@ -248,7 +248,10 @@ private ResultImplementation getVersions(String groupId, String a .add(new BooleanClause(setBooleanRewrite(new PrefixQuery(new Term(ArtifactInfo.UINFO, id))), BooleanClause.Occur.MUST)) .build(); iterate(repos, (RepositoryInfo repo, IndexingContext context) -> { - IteratorSearchResponse response = repeatedPagedSearch(bq, context, NexusRepositoryIndexManager.MAX_RESULT_COUNT); + // Some projects generated quite a lot of artifacts by now. + // Since this query is sometimes used by code which wants to find the top x most recent artifacts, + // we have to use a relatively high results limit - this doesn't seem to be a performance problem (other queries set no limit) + IteratorSearchResponse response = repeatedPagedSearch(bq, context, 10_000); if (response != null) { try { for (ArtifactInfo ai : response) { From c88da071e83cf32d7fa5a77fc0c250758ca6fb07 Mon Sep 17 00:00:00 2001 From: Michael Bien Date: Mon, 27 Jan 2025 04:19:13 +0100 Subject: [PATCH 3/6] Release candidates should not steal the maven index from GA releases --- .../maven/indexer/NexusRepositoryIndexManager.java | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/java/maven.indexer/src/org/netbeans/modules/maven/indexer/NexusRepositoryIndexManager.java b/java/maven.indexer/src/org/netbeans/modules/maven/indexer/NexusRepositoryIndexManager.java index 57d832e89bbe..4773afd51973 100644 --- a/java/maven.indexer/src/org/netbeans/modules/maven/indexer/NexusRepositoryIndexManager.java +++ b/java/maven.indexer/src/org/netbeans/modules/maven/indexer/NexusRepositoryIndexManager.java @@ -400,17 +400,18 @@ boolean loadIndexingContext(final RepositoryInfo info) throws IOException { private void tryMoveRemoteIndexFromOldCache(RepositoryInfo info) { String buildnumber = System.getProperty("netbeans.buildnumber"); - if (buildnumber == null) { + if (buildnumber == null || buildnumber.isBlank() || !buildnumber.contains("-")) { return; // tests } + // see org.netbeans.modules.janitor.Janitor for '.lastUsedVersion' format int ourVersion; try { String debugRelease = System.getProperty("maven.indexing.diag.release"); ourVersion = debugRelease != null ? Integer.parseInt(debugRelease) - : Integer.parseInt(buildnumber.split("-")[0]); + : Integer.parseInt(buildnumber.substring(0, buildnumber.lastIndexOf("-"))); } catch (NumberFormatException ignore) { - return; + return; // rc or other dev build } Path cacheParent = Places.getCacheDirectory().toPath().getParent(); @@ -443,7 +444,7 @@ record CacheFolder(Path path, int version) {} } } } catch (Exception ex) { - LOGGER.log(Level.WARNING, "index import failed: {0}", ex.getMessage()); + LOGGER.log(Level.WARNING, "index import failed: {0}: {1}", new Object[] {ex.getClass().getName(), ex.getMessage()}); } } } From a11dbab6eb8dbd978ffbcf20262e0e8ff51e2e06 Mon Sep 17 00:00:00 2001 From: Neil C Smith Date: Fri, 31 Jan 2025 17:25:43 +0000 Subject: [PATCH 4/6] Fix infinite loop in FruchtermanReingoldLayout. Fixes GH8209 - infinite loop because isThereFreeSpaceNonFixedSpace always returns false. Only loop ~3 rotations. Increase force constant to improve result with reduced search. --- .../modules/java/graph/FruchtermanReingoldLayout.java | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/java/java.graph/src/org/netbeans/modules/java/graph/FruchtermanReingoldLayout.java b/java/java.graph/src/org/netbeans/modules/java/graph/FruchtermanReingoldLayout.java index 7eb2432e1d8c..4455d1af7ec2 100644 --- a/java/java.graph/src/org/netbeans/modules/java/graph/FruchtermanReingoldLayout.java +++ b/java/java.graph/src/org/netbeans/modules/java/graph/FruchtermanReingoldLayout.java @@ -137,7 +137,7 @@ public void rePerformLayout(int iters) { // System.out.println("scene bounds are =" + bounds); temp = bounds.getWidth() / 1000; // forceConstant = 0.75 * Math.sqrt(bounds.getHeight() * bounds.getWidth() / nds); - forceConstant = 0.25 * Math.sqrt(bounds.getHeight() * bounds.getWidth() / nds); + forceConstant = 1.75 * Math.sqrt(bounds.getHeight() * bounds.getWidth() / nds); // System.out.println("force constant2=" + forceConstant); performLayout(false); } @@ -150,7 +150,7 @@ private void init() { bounds = new Rectangle(magicSizeConstant + (magicSizeMultiplier * nds), magicSizeConstant + (magicSizeMultiplier * nds)); //g.getMaximumBounds(); temp = bounds.getWidth() / 10; - forceConstant = 0.75 * Math.sqrt(bounds.getHeight() * bounds.getWidth() / nds); + forceConstant = 1.75 * Math.sqrt(bounds.getHeight() * bounds.getWidth() / nds); GraphNode rn = scene.getRootGraphNode(); NodeWidget rw = getWidget(rn); @@ -382,7 +382,8 @@ private void relayoutNonFixed(NodeWidget w) { r = 30; theta = 0; w.setFixed(false); - while (true) { + // 48 - ~3 times round? + for (int i = 0; i < 48; i++) { AffineTransform tr = AffineTransform.getRotateInstance(theta); Point2D d2point = tr.transform(new Point2D.Double(0, r), null); Point point = new Point((int)d2point.getX() + masterPoint.x, (int)d2point.getY() + masterPoint.y); @@ -396,10 +397,9 @@ private void relayoutNonFixed(NodeWidget w) { if (theta > (Math.PI * 2 - Math.PI / 10)) { r = r + 30; theta = theta - Math.PI * 2; - thetaStep = thetaStep * 3 / 4; + thetaStep = thetaStep * 3 / 4; } } - } private NodeWidget getWidget(GraphNode n) { From d9d269cf307f7bcf3719ca650bacf272be5efcdd Mon Sep 17 00:00:00 2001 From: Michael Bien Date: Thu, 30 Jan 2025 08:34:16 +0100 Subject: [PATCH 5/6] Fix: tabs without file objects had null title in tab switcher - example: repo history with parent folder decorator enabled - or diff between two files - regression since ad776db73d --- .../multitabs/impl/DocumentSwitcherTable.java | 13 ++++++++----- .../multitabs/impl/FolderNameTabDecorator.java | 16 ++++++++++++++-- 2 files changed, 22 insertions(+), 7 deletions(-) diff --git a/platform/core.multitabs/src/org/netbeans/core/multitabs/impl/DocumentSwitcherTable.java b/platform/core.multitabs/src/org/netbeans/core/multitabs/impl/DocumentSwitcherTable.java index 54fef8067ee8..23417e8da2a5 100644 --- a/platform/core.multitabs/src/org/netbeans/core/multitabs/impl/DocumentSwitcherTable.java +++ b/platform/core.multitabs/src/org/netbeans/core/multitabs/impl/DocumentSwitcherTable.java @@ -68,8 +68,6 @@ class DocumentSwitcherTable extends SwitcherTable { private final ItemBorder ITEM_BORDER = new ItemBorder(); private final Border SEPARATOR_BORDER = BorderFactory.createEmptyBorder( 2, 2, 0, 5 ); - private String itemText; - public DocumentSwitcherTable( Controller controller, SwitcherTableItem[] items, int y ) { super( items, y ); this.controller = controller; @@ -113,9 +111,14 @@ public Component prepareRenderer( TableCellRenderer renderer, int row, int colum } else { if(null != folderNameDecorator && null != item) { TabData tab = item.getTabData(); - if(null != tab) { - itemText = folderNameDecorator.getText(tab) + (item.isActive() ? " ←" : ""); //NOI18N - lbl.setText(itemText); + if (null != tab) { + String decorated = folderNameDecorator.getText(tab); + if (decorated != null) { + if (item.isActive()) { + decorated += " ←"; //NOI18N + } + lbl.setText(decorated); + } } } lbl.setBorder( ITEM_BORDER ); diff --git a/platform/core.multitabs/src/org/netbeans/core/multitabs/impl/FolderNameTabDecorator.java b/platform/core.multitabs/src/org/netbeans/core/multitabs/impl/FolderNameTabDecorator.java index 43fd4b6b1c74..f6f8fd68faf3 100644 --- a/platform/core.multitabs/src/org/netbeans/core/multitabs/impl/FolderNameTabDecorator.java +++ b/platform/core.multitabs/src/org/netbeans/core/multitabs/impl/FolderNameTabDecorator.java @@ -21,6 +21,7 @@ import java.awt.Color; import java.awt.Graphics; import java.awt.Rectangle; +import java.io.CharConversionException; import java.io.File; import javax.swing.Icon; import javax.swing.UIManager; @@ -32,6 +33,7 @@ import org.openide.loaders.DataObject; import org.openide.util.lookup.ServiceProvider; import org.openide.windows.TopComponent; +import org.openide.xml.XMLUtil; import static java.util.Objects.requireNonNullElse; @@ -123,8 +125,18 @@ private static String merge( String prefix, String baseText ) { res.append( prefix ); res.append( baseText.substring( 6 ) ); } else { - res.append( prefix ); - res.append( baseText ); + if (prefix.startsWith(""); //NOI18N + res.append(prefix); + try { + res.append(XMLUtil.toElementContent(baseText)); + } catch (CharConversionException ex) { + res.append(baseText); + } + } else { + res.append(prefix); + res.append(baseText); + } } return res.toString(); From 9a13aa6f035e3c0204fde6b888d07526b81ce0f3 Mon Sep 17 00:00:00 2001 From: Laszlo Kishalmi Date: Tue, 4 Feb 2025 20:59:47 -0800 Subject: [PATCH 6/6] Gradle init shall honor the configured Java Runtime --- .../spi/newproject/TemplateOperation.java | 24 +++++++++++++------ 1 file changed, 17 insertions(+), 7 deletions(-) diff --git a/extide/gradle/src/org/netbeans/modules/gradle/spi/newproject/TemplateOperation.java b/extide/gradle/src/org/netbeans/modules/gradle/spi/newproject/TemplateOperation.java index fcc47567ceef..23d4ac1fb3b2 100644 --- a/extide/gradle/src/org/netbeans/modules/gradle/spi/newproject/TemplateOperation.java +++ b/extide/gradle/src/org/netbeans/modules/gradle/spi/newproject/TemplateOperation.java @@ -59,11 +59,12 @@ import org.netbeans.modules.gradle.ProjectTrust; import org.netbeans.modules.gradle.api.GradleProjects; import org.netbeans.modules.gradle.api.NbGradleProject; -import org.netbeans.modules.gradle.api.NbGradleProject.LoadOptions; import org.netbeans.modules.gradle.api.NbGradleProject.Quality; import org.netbeans.modules.gradle.execute.EscapeProcessingOutputStream; import org.netbeans.modules.gradle.execute.GradlePlainEscapeProcessor; +import org.netbeans.modules.gradle.options.GradleExperimentalSettings; import org.netbeans.modules.gradle.spi.GradleSettings; +import org.netbeans.modules.gradle.spi.execute.JavaRuntimeManager; import org.openide.loaders.DataFolder; import org.openide.loaders.DataObject; import org.openide.util.Exceptions; @@ -312,6 +313,8 @@ public String getMessage() { @Override public Set execute() { GradleConnector gconn = GradleConnector.newConnector(); + JavaRuntimeManager.JavaRuntime defaultRuntime = GradleExperimentalSettings.getDefault().getDefaultJavaRuntime(); + target.mkdirs(); InputOutput io = IOProvider.getDefault().getIO(projectName + " (init)", true); try (ProjectConnection pconn = gconn.forProjectDirectory(target).connect()) { @@ -359,7 +362,8 @@ public Set execute() { OutputStream out = new EscapeProcessingOutputStream(new GradlePlainEscapeProcessor(io, false)); OutputStream err = new EscapeProcessingOutputStream(new GradlePlainEscapeProcessor(io, false)) ) { - BuildLauncher gradleInit = pconn.newBuild().forTasks(args.toArray(new String[0])); + BuildLauncher gradleInit = pconn.newBuild().forTasks(args.toArray(String[]::new)); + gradleInit.setJavaHome(defaultRuntime.getJavaHome()); if (GradleSettings.getDefault().isOffline()) { gradleInit = gradleInit.withArguments("--offline"); } @@ -370,7 +374,7 @@ public Set execute() { } catch (IOException iox) { } } catch (GradleConnectionException | IllegalStateException ex) { - Exceptions.printStackTrace(ex); + ex.printStackTrace(io.getErr()); } finally { if (io.getOut() != null) io.getOut().close(); if (io.getErr() != null) io.getErr().close(); @@ -444,6 +448,7 @@ public Set execute() { FileUtil.createFolder(dir); Thread.sleep(200); } catch (InterruptedException | IOException ex) { + Exceptions.printStackTrace(ex); } return null; } @@ -479,6 +484,7 @@ public final Set execute() { } } catch (IOException ex) { + Exceptions.printStackTrace(ex); } } return Set.of(); @@ -542,6 +548,7 @@ public Set execute() { return ret; } } catch (IOException | IllegalArgumentException ex) { + Exceptions.printStackTrace(ex); } } return null; @@ -568,6 +575,7 @@ public String getMessage() { @Override public Set execute() { GradleConnector gconn = GradleConnector.newConnector(); + JavaRuntimeManager.JavaRuntime defaultRuntime = GradleExperimentalSettings.getDefault().getDefaultJavaRuntime(); try (ProjectConnection pconn = gconn.forProjectDirectory(projectDir).connect()) { List args = new ArrayList<>(); args.add("wrapper"); //NOI18N @@ -575,14 +583,16 @@ public Set execute() { args.add("--gradle-version"); //NOI18N args.add(version); } + BuildLauncher init = pconn.newBuild() + .setJavaHome(defaultRuntime.getJavaHome()); if (GradleSettings.getDefault().isOffline()) { - pconn.newBuild().withArguments("--offline").forTasks(args.toArray(new String[0])).run(); //NOI18N - } else { - pconn.newBuild().forTasks(args.toArray(new String[0])).run(); + init = init.withArguments("--offline"); } + init.forTasks(args.toArray(String[]::new)).run(); } catch (GradleConnectionException | IllegalStateException ex) { // Well for some reason we were not able to load Gradle. // Ignoring that for now + Exceptions.printStackTrace(ex); } gconn.disconnect(); return null; @@ -684,7 +694,7 @@ public Set execute() { DataObject newData = o.createFromTemplate(targetFolder, targetName, tokens); return important ? Set.of(newData.getPrimaryFile()) : null; } catch (IOException ex) { - + Exceptions.printStackTrace(ex); } } return null;