You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@netbeans.apache.org by sd...@apache.org on 2023/12/20 11:39:24 UTC

(netbeans) 03/13: Gradle + Maven implementation of project add

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

sdedic pushed a commit to branch sdedic/feature/project-dependency-add_base2
in repository https://gitbox.apache.org/repos/asf/netbeans.git

commit 43a1407b060cc045b26dfad21521604b738bef87
Author: Svata Dedic <sv...@oracle.com>
AuthorDate: Wed Dec 13 17:49:41 2023 +0100

    Gradle + Maven implementation of project add
---
 java/gradle.dependencies/build.xml                 |   5 +
 java/gradle.dependencies/manifest.mf               |   5 +
 .../nbproject/project.properties                   |   6 +
 .../nbproject/project.xml                          | 171 +++------
 .../gradle/dependencies/AbstractWorker.java        | 120 +++++++
 .../modules/gradle/dependencies/Bundle.properties  |   5 +
 .../gradle/dependencies/DependencyAdder.java       | 288 +++++++++++++++
 .../dependencies/DependencyModifierImpl.java       | 115 ++++++
 .../gradle/dependencies/RewriteContext.java        | 119 ++++++
 .../test/unit/data/projects/micronaut/build.gradle |  65 ++++
 .../unit/data/projects/micronaut/build2.gradle     |  66 ++++
 .../unit/data/projects/micronaut/build3.gradle     |  53 +++
 .../data/projects/micronaut/gradle.properties}     |   5 +-
 .../gradle/wrapper/gradle-wrapper.properties       |   5 +
 .../unit/data/projects/micronaut/settings.gradle   |  21 ++
 .../src/main/java/com/example/Application.java     |  27 ++
 .../micronaut/src/main/resources/application.yml   |   7 +
 .../micronaut/src/main/resources/logback.xml       |  15 +
 .../src/test/java/com/example/MicrodemoTest.java   |  39 ++
 .../dependencies/DependencyModifierImplTest.java   | 400 +++++++++++++++++++++
 java/gradle.java/manifest.mf                       |   1 +
 .../nbcode/nbproject/platform.properties           |   1 -
 java/maven.model/nbproject/project.xml             |   1 +
 .../netbeans/modules/maven/model/Utilities.java    |   7 +
 java/maven.refactoring/manifest.mf                 |   2 +-
 .../maven.refactoring/nbproject/project.properties |   1 +
 java/maven.refactoring/nbproject/project.xml       |  92 +++++
 .../refactoring/dependency/DependencyAdder.java    | 159 ++++++++
 .../dependency/DocumentChangesConverter.java       | 368 +++++++++++++++++++
 .../dependency/MavenDependencyModifierImpl.java    | 122 +++++++
 .../refactoring/dependency/RewriteContext.java     | 113 ++++++
 .../simpleProject/pom-with-processor-broken.xml    |  77 ++++
 .../unit/data/simpleProject/pom-with-processor.xml |  77 ++++
 .../simpleProject/pom-with-separateProcessors.xml  | 111 ++++++
 .../test/unit/data/simpleProject/pom.xml           |  65 ++++
 .../unit/data/simpleProject/src/main/java/README   |   1 +
 .../unit/data/simpleProject/src/test/java/README   |   1 +
 .../dependency/DocumentChangesConverterTest.java   | 396 ++++++++++++++++++++
 .../MavenDependencyModifierImplTest.java           | 162 +++++++++
 nbbuild/cluster.properties                         |   1 +
 40 files changed, 3176 insertions(+), 119 deletions(-)

diff --git a/java/gradle.dependencies/build.xml b/java/gradle.dependencies/build.xml
new file mode 100644
index 0000000000..2a04e77a74
--- /dev/null
+++ b/java/gradle.dependencies/build.xml
@@ -0,0 +1,5 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<project basedir="." default="netbeans" name="java/gradle.dependencies">
+    <description>Builds, tests, and runs the project org.netbeans.modules.gradle.dependencies</description>
+    <import file="../../nbbuild/templates/projectized.xml"/>
+</project>
diff --git a/java/gradle.dependencies/manifest.mf b/java/gradle.dependencies/manifest.mf
new file mode 100644
index 0000000000..ca01d98508
--- /dev/null
+++ b/java/gradle.dependencies/manifest.mf
@@ -0,0 +1,5 @@
+Manifest-Version: 1.0
+AutoUpdate-Show-In-Client: true
+OpenIDE-Module: org.netbeans.modules.gradle.dependencies
+OpenIDE-Module-Localizing-Bundle: org/netbeans/modules/gradle/dependencies/Bundle.properties
+
diff --git a/java/gradle.dependencies/nbproject/project.properties b/java/gradle.dependencies/nbproject/project.properties
new file mode 100644
index 0000000000..f9c36a8127
--- /dev/null
+++ b/java/gradle.dependencies/nbproject/project.properties
@@ -0,0 +1,6 @@
+javac.source=1.8
+javac.compilerargs=-Xlint -Xlint:-serial
+spec.version.base=1.0.0
+
+test-unit-sys-prop.test.netbeans.dest.dir=${netbeans.dest.dir}
+test-unit-sys-prop.java.awt.headless=true
diff --git a/java/maven.model/nbproject/project.xml b/java/gradle.dependencies/nbproject/project.xml
similarity index 50%
copy from java/maven.model/nbproject/project.xml
copy to java/gradle.dependencies/nbproject/project.xml
index d2faac0f13..4abedaaec8 100644
--- a/java/maven.model/nbproject/project.xml
+++ b/java/gradle.dependencies/nbproject/project.xml
@@ -1,46 +1,17 @@
 <?xml version="1.0" encoding="UTF-8"?>
-<!--
-
-    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.
-
--->
 <project xmlns="http://www.netbeans.org/ns/project/1">
     <type>org.netbeans.modules.apisupport.project</type>
     <configuration>
         <data xmlns="http://www.netbeans.org/ns/nb-module-project/3">
-            <code-name-base>org.netbeans.modules.maven.model</code-name-base>
+            <code-name-base>org.netbeans.modules.gradle.dependencies</code-name-base>
             <module-dependencies>
                 <dependency>
-                    <code-name-base>org.netbeans.api.annotations.common</code-name-base>
+                    <code-name-base>org.netbeans.api.lsp</code-name-base>
                     <build-prerequisite/>
                     <compile-dependency/>
                     <run-dependency>
                         <release-version>1</release-version>
-                        <specification-version>1.22</specification-version>
-                    </run-dependency>
-                </dependency>
-                <dependency>
-                    <code-name-base>org.netbeans.modules.editor</code-name-base>
-                    <build-prerequisite/>
-                    <compile-dependency/>
-                    <run-dependency>
-                        <release-version>3</release-version>
-                        <specification-version>1.85</specification-version>
+                        <specification-version>1.21</specification-version>
                     </run-dependency>
                 </dependency>
                 <dependency>
@@ -48,51 +19,49 @@
                     <build-prerequisite/>
                     <compile-dependency/>
                     <run-dependency>
-                        <specification-version>1.3</specification-version>
+                        <specification-version>1.32</specification-version>
                     </run-dependency>
                 </dependency>
                 <dependency>
-                    <code-name-base>org.netbeans.modules.editor.lib</code-name-base>
+                    <code-name-base>org.netbeans.modules.gradle</code-name-base>
                     <build-prerequisite/>
                     <compile-dependency/>
                     <run-dependency>
-                        <release-version>3</release-version>
-                        <specification-version>4.0</specification-version>
+                        <release-version>2</release-version>
+                        <specification-version>2.38</specification-version>
                     </run-dependency>
                 </dependency>
                 <dependency>
-                    <code-name-base>org.netbeans.modules.maven.embedder</code-name-base>
+                    <code-name-base>org.netbeans.modules.gradle.java</code-name-base>
                     <build-prerequisite/>
                     <compile-dependency/>
                     <run-dependency>
-                        <release-version>2</release-version>
-                        <specification-version>2.54</specification-version>
+                        <implementation-version/>
                     </run-dependency>
                 </dependency>
                 <dependency>
-                    <code-name-base>org.netbeans.modules.queries</code-name-base>
+                    <code-name-base>org.netbeans.modules.project.dependency</code-name-base>
                     <build-prerequisite/>
                     <compile-dependency/>
                     <run-dependency>
-                        <release-version>1</release-version>
-                        <specification-version>1.21</specification-version>
+                        <implementation-version/>
                     </run-dependency>
                 </dependency>
                 <dependency>
-                    <code-name-base>org.netbeans.modules.xml.xam</code-name-base>
+                    <code-name-base>org.netbeans.modules.projectapi</code-name-base>
                     <build-prerequisite/>
                     <compile-dependency/>
                     <run-dependency>
                         <release-version>1</release-version>
-                        <specification-version>1.22</specification-version>
+                        <specification-version>1.94</specification-version>
                     </run-dependency>
                 </dependency>
                 <dependency>
-                    <code-name-base>org.openide.awt</code-name-base>
+                    <code-name-base>org.netbeans.modules.refactoring.api</code-name-base>
                     <build-prerequisite/>
                     <compile-dependency/>
                     <run-dependency>
-                        <specification-version>7.16</specification-version>
+                        <specification-version>1.70</specification-version>
                     </run-dependency>
                 </dependency>
                 <dependency>
@@ -100,15 +69,7 @@
                     <build-prerequisite/>
                     <compile-dependency/>
                     <run-dependency>
-                        <specification-version>9.0</specification-version>
-                    </run-dependency>
-                </dependency>
-                <dependency>
-                    <code-name-base>org.openide.loaders</code-name-base>
-                    <build-prerequisite/>
-                    <compile-dependency/>
-                    <run-dependency>
-                        <specification-version>7.61</specification-version>
+                        <specification-version>9.36</specification-version>
                     </run-dependency>
                 </dependency>
                 <dependency>
@@ -116,7 +77,7 @@
                     <build-prerequisite/>
                     <compile-dependency/>
                     <run-dependency>
-                        <specification-version>7.7</specification-version>
+                        <specification-version>7.38.1</specification-version>
                     </run-dependency>
                 </dependency>
                 <dependency>
@@ -124,7 +85,7 @@
                     <build-prerequisite/>
                     <compile-dependency/>
                     <run-dependency>
-                        <specification-version>6.21</specification-version>
+                        <specification-version>6.91</specification-version>
                     </run-dependency>
                 </dependency>
                 <dependency>
@@ -132,7 +93,7 @@
                     <build-prerequisite/>
                     <compile-dependency/>
                     <run-dependency>
-                        <specification-version>9.3</specification-version>
+                        <specification-version>9.31</specification-version>
                     </run-dependency>
                 </dependency>
                 <dependency>
@@ -140,15 +101,7 @@
                     <build-prerequisite/>
                     <compile-dependency/>
                     <run-dependency>
-                        <specification-version>8.0</specification-version>
-                    </run-dependency>
-                </dependency>
-                <dependency>
-                    <code-name-base>org.openide.util.ui</code-name-base>
-                    <build-prerequisite/>
-                    <compile-dependency/>
-                    <run-dependency>
-                        <specification-version>9.3</specification-version>
+                        <specification-version>8.57</specification-version>
                     </run-dependency>
                 </dependency>
             </module-dependencies>
@@ -160,89 +113,79 @@
                         <compile-dependency/>
                     </test-dependency>
                     <test-dependency>
-                        <code-name-base>org.netbeans.modules.editor.lib</code-name-base>
+                        <code-name-base>org.netbeans.modules.gradle</code-name-base>
+                        <recursive/>
                         <compile-dependency/>
+                        <test/>
                     </test-dependency>
                     <test-dependency>
-                        <code-name-base>org.netbeans.modules.editor.mimelookup.impl</code-name-base>
+                        <code-name-base>org.netbeans.modules.nbjunit</code-name-base>
+                        <recursive/>
                         <compile-dependency/>
                     </test-dependency>
                     <test-dependency>
-                        <code-name-base>org.netbeans.modules.editor.settings.storage</code-name-base>
+                        <code-name-base>org.netbeans.modules.projectapi.nb</code-name-base>
                         <recursive/>
                         <compile-dependency/>
                     </test-dependency>
                     <test-dependency>
-                        <code-name-base>org.netbeans.modules.masterfs</code-name-base>
+                        <code-name-base>org.netbeans.modules.projectui</code-name-base>
+                        <recursive/>
                         <compile-dependency/>
                     </test-dependency>
                     <test-dependency>
-                        <code-name-base>org.netbeans.modules.nbjunit</code-name-base>
+                        <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>
                         <recursive/>
                         <compile-dependency/>
                     </test-dependency>
                     <test-dependency>
-                        <code-name-base>org.netbeans.modules.projectapi</code-name-base>
+                        <code-name-base>org.openide.util.lookup</code-name-base>
                         <compile-dependency/>
+                        <test/>
                     </test-dependency>
                     <test-dependency>
-                        <code-name-base>org.netbeans.modules.projectapi.nb</code-name-base>
+                        <code-name-base>org.openide.modules</code-name-base>
+                        <compile-dependency/>
+                        <test/>
                     </test-dependency>
                     <test-dependency>
-                        <code-name-base>org.netbeans.modules.xml.lexer</code-name-base>
+                        <code-name-base>org.openide.util.ui</code-name-base>
                         <compile-dependency/>
+                        <test/>
                     </test-dependency>
                     <test-dependency>
-                        <code-name-base>org.netbeans.modules.xml.retriever</code-name-base>
+                        <code-name-base>org.netbeans.modules.java.j2seplatform</code-name-base>
+                        <recursive/>
+                    </test-dependency>
+                    <test-dependency>
+                        <code-name-base>org.netbeans.modules.project.dependency</code-name-base>
                         <compile-dependency/>
                     </test-dependency>
                     <test-dependency>
-                        <code-name-base>org.netbeans.modules.xml.xdm</code-name-base>
+                        <code-name-base>org.netbeans.modules.editor</code-name-base>
                         <recursive/>
                         <compile-dependency/>
                     </test-dependency>
                     <test-dependency>
-                        <code-name-base>org.openide.filesystems</code-name-base>
+                        <code-name-base>org.openide.loaders</code-name-base>
+                        <recursive/>
                         <compile-dependency/>
-                        <test/>
+                    </test-dependency>
+                    <test-dependency>
+                        <!-- Because otherwise data systems and their services will not materialize -->
+                        <code-name-base>org.netbeans.modules.settings</code-name-base>
+                    </test-dependency>
+                    <test-dependency>
+                        <code-name-base>org.netbeans.modules.editor.mimelookup.impl</code-name-base>
                     </test-dependency>
                 </test-type>
             </test-dependencies>
-            <friend-packages>
-                <friend>org.javeleon.netbeans</friend>
-                <friend>org.netbeans.modules.groovy.support</friend>
-                <friend>org.netbeans.modules.hudson.maven</friend>
-                <friend>org.netbeans.modules.kenai.maven</friend>
-                <friend>org.netbeans.modules.licensechanger</friend>
-                <friend>org.netbeans.modules.maven</friend>
-                <friend>org.netbeans.modules.maven.apisupport</friend>
-                <friend>org.netbeans.modules.maven.checkstyle</friend>
-                <friend>org.netbeans.modules.maven.grammar</friend>
-                <friend>org.netbeans.modules.maven.graph</friend>
-                <friend>org.netbeans.modules.maven.groovy</friend>
-                <friend>org.netbeans.modules.maven.hints</friend>
-                <friend>org.netbeans.modules.maven.j2ee</friend>
-                <friend>org.netbeans.modules.maven.jaxws</friend>
-                <friend>org.netbeans.modules.maven.osgi</friend>
-                <friend>org.netbeans.modules.maven.persistence</friend>
-                <friend>org.netbeans.modules.maven.repository</friend>
-                <friend>org.netbeans.modules.selenium.maven</friend>
-                <friend>org.netbeans.modules.selenium2.maven</friend>
-                <friend>org.netbeans.modules.testng.maven</friend>
-                <!-- danis@netbeans.org -->
-                <friend>org.vaadin.netbeans.maven</friend>
-                <friend>org.netbeans.modules.payara.micro</friend>
-                <friend>org.netbeans.modules.jakarta.transformer</friend>
-                <!-- NetBeans support for Google App Engine -->
-                <friend>org.netbeans.modules.j2ee.appengine</friend>
-                <friend>org.netbeans.modules.maven.util</friend>
-                <friend>io.github.jeddict.jcode.util</friend>
-                <friend>io.github.jeddict.runtime</friend>
-                <friend>io.github.jeddict.rest.generator</friend>
-                <package>org.netbeans.modules.maven.model</package>
-                <package>org.netbeans.modules.maven.model.pom</package>
-                <package>org.netbeans.modules.maven.model.settings</package>
-            </friend-packages>
+            <public-packages/>
         </data>
     </configuration>
 </project>
diff --git a/java/gradle.dependencies/src/org/netbeans/modules/gradle/dependencies/AbstractWorker.java b/java/gradle.dependencies/src/org/netbeans/modules/gradle/dependencies/AbstractWorker.java
new file mode 100644
index 0000000000..f12e4c7cf8
--- /dev/null
+++ b/java/gradle.dependencies/src/org/netbeans/modules/gradle/dependencies/AbstractWorker.java
@@ -0,0 +1,120 @@
+/*
+ * 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.dependencies;
+
+import java.util.ArrayList;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+import org.netbeans.api.editor.document.LineDocument;
+import org.netbeans.api.lsp.TextEdit;
+import org.netbeans.api.project.Project;
+import org.netbeans.modules.gradle.java.queries.GradleScope;
+import org.netbeans.modules.project.dependency.Dependency;
+import org.netbeans.modules.project.dependency.DependencyChange;
+import org.netbeans.modules.project.dependency.DependencyChangeException;
+
+/**
+ * Code hopefully common for Remove and Add workers.
+ * 
+ * @author sdedic
+ */
+public abstract class AbstractWorker {
+    protected final Project project;
+    protected DependencyChange request;
+    protected final RewriteContext context;
+    
+    public AbstractWorker(Project project, RewriteContext context) {
+        this.project = project;
+        this.context = context;
+    }
+
+    /**
+     * Dependencies that are accepted for adding. They do not exist in the 
+     * file yet.
+     */
+    protected final List<Dependency> accepted = new ArrayList<>();
+    
+    /**
+     * Accumulated text edits.
+     */
+    protected List<TextEdit>  textEdits = new ArrayList<>();
+
+    /**
+     * Line document opened for the project's buildscript.
+     */
+    protected LineDocument lineDoc;
+    
+    protected Map<Dependency, Dependency> offending = new HashMap<>();
+    
+    static StringBuilder indent(StringBuilder sb, int size) {
+        for (int i = 0; i < size; i++) {
+            sb.append(" ");
+        }
+        return sb;
+    }
+    
+    protected abstract boolean checkDependencyConflicts(Dependency current, Dependency toAdd)  throws DependencyChangeException;
+    
+    protected abstract void throwDependencyConflicts() throws DependencyChangeException;
+   
+    protected abstract void generateDependencies()  throws DependencyChangeException;
+    
+    protected GradleScope getScope(Dependency d) throws DependencyChangeException {
+        GradleScope gs = context.getScopes().toGradleScope(d.getScope().name());
+        if (gs == null) {
+            throwUnknownScope(d);
+        }
+        return gs;
+    }
+
+    protected void throwUnknownScope(Dependency d) throws DependencyChangeException {
+        throw new DependencyChangeException(request, d, DependencyChangeException.Reason.MALFORMED);
+    }
+    
+    protected void recordConflict(Dependency requested, Dependency existing) {
+        if (!request.getOptions().contains(DependencyChange.Options.skipConflicts)) {
+            offending.putIfAbsent(requested, existing);
+        }
+    }
+    
+    public void processRequest(DependencyChange change)  throws DependencyChangeException {
+        this.request = change;
+        for (Dependency d : request.getDependencies()) {
+            boolean toAccept = true;
+            for (Dependency c : context.getCurrentDependencies().getRoot().getChildren()) {
+                if (!checkDependencyConflicts(c, d)) {
+                    toAccept = false;
+                    break;
+                }
+            }
+            if (toAccept) {
+                accepted.add(d);
+            }
+        }
+        throwDependencyConflicts();
+        this.request = null;
+    }
+    
+    public void execute() throws DependencyChangeException {
+        lineDoc = context.openDocument();
+        generateDependencies();
+        context.addTextEdits(textEdits);
+    }
+}
diff --git a/java/gradle.dependencies/src/org/netbeans/modules/gradle/dependencies/Bundle.properties b/java/gradle.dependencies/src/org/netbeans/modules/gradle/dependencies/Bundle.properties
new file mode 100644
index 0000000000..a815bce935
--- /dev/null
+++ b/java/gradle.dependencies/src/org/netbeans/modules/gradle/dependencies/Bundle.properties
@@ -0,0 +1,5 @@
+OpenIDE-Module-Display-Category=Gradle
+OpenIDE-Module-Long-Description=\
+    An experimental module that allows to manipulate dependencies in Gradle project.
+OpenIDE-Module-Name=Gradle Project Dependencies
+OpenIDE-Module-Short-Description=Project Dependency Management support
diff --git a/java/gradle.dependencies/src/org/netbeans/modules/gradle/dependencies/DependencyAdder.java b/java/gradle.dependencies/src/org/netbeans/modules/gradle/dependencies/DependencyAdder.java
new file mode 100644
index 0000000000..bfe2aeb80c
--- /dev/null
+++ b/java/gradle.dependencies/src/org/netbeans/modules/gradle/dependencies/DependencyAdder.java
@@ -0,0 +1,288 @@
+/*
+ * 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.dependencies;
+
+import java.io.IOException;
+import java.util.List;
+import java.util.Objects;
+import javax.swing.text.BadLocationException;
+import org.netbeans.api.editor.document.LineDocumentUtils;
+import org.netbeans.api.lsp.TextEdit;
+import org.netbeans.api.project.Project;
+import org.netbeans.modules.gradle.java.queries.GradleScope;
+import org.netbeans.modules.project.dependency.ArtifactSpec;
+import org.netbeans.modules.project.dependency.Dependency;
+import org.netbeans.modules.project.dependency.DependencyChangeException;
+import org.netbeans.modules.project.dependency.DependencyResult;
+import org.netbeans.modules.project.dependency.SourceLocation;
+import org.openide.util.*;
+
+/**
+ *
+ * Handles adding dependencies to the project.
+ * 
+ * @author sdedic
+ */
+public class DependencyAdder extends AbstractWorker {
+    /*
+    private Map<Dependency, Dependency> upgrades = new HashMap<>();
+    */
+
+    public DependencyAdder(Project project, RewriteContext context) {
+        super(project, context);
+    }
+    
+    /*
+    boolean newerVersion(String existing, String added) {
+        String[] parts1 = existing.split(".");
+        String[] parts2 = added.split(".");
+        
+        for (int i = 0; i < Math.min(parts1.length, parts2.length); i++) {
+            if (parts1.length < i) {
+                return true;
+            } else if (parts2.length < i) {
+                return false;
+            }
+            String p1 = parts1[i];
+            String p2 = parts1[i];
+            
+            int suffix1 = p1.indexOf('-');
+            int suffix2 = p2.indexOf('-');
+            if ((suffix1 == -1) != (suffix2 == -1)) {
+                // different qualifiers
+                return false;
+            }
+            if (suffix1 != -1) {
+                String s1 = p1.substring(suffix1 + 1);
+                String s2 = p1.substring(suffix2 + 1);
+                if (s1.compareTo(s2) >= 0) {
+                    return false;
+                }
+            }
+            int r;
+            try {
+                int v1, v2;
+                v1 = Integer.parseInt(p1);
+                v2 = Integer.parseInt(p2);
+                r = v1 - v2;
+            } catch (NumberFormatException ex) {
+                // expected
+                r = p1.compareTo(p2);
+            }
+            if (r < 0) {
+                return true;
+            } else if (r > 0) {
+                return false;
+            }
+        }
+        return false;
+    }
+    */
+
+    @Override
+    protected void throwDependencyConflicts() throws DependencyChangeException {
+        if (!offending.isEmpty()) {
+            throw new DependencyChangeException(request, DependencyChangeException.Reason.CONFLICT, offending);
+        }
+    }
+    
+    /**
+     * 
+     * ignoreVersions - exact versions are not relevant. For remove, it means remove a dependency regardless of the version.
+     * skipConflicts - conflicting dependencies are just skipped instead of creating an error.
+     * 
+     */
+    
+    @Override
+    protected boolean checkDependencyConflicts(Dependency existing, Dependency d) throws DependencyChangeException {
+        ArtifactSpec existingA = existing.getArtifact();
+        ArtifactSpec toAdd = d.getArtifact();
+        
+        GradleScope s = getScope(d);
+        if (!(existingA.getGroupId().equals(toAdd.getGroupId()) &&
+            existingA.getArtifactId().equals(toAdd.getArtifactId()))) {
+            // different artifacts -> no conflicts
+            return true;
+        }
+        if (!(existing.getScope().equals(s) || existing.getScope().name().equals(s.getTargetConfigurationName()))) {
+            // second chance -- the specified scope could be a meta-scope that maps to Gradle configuration
+            return true;
+        }
+        String existingC = existingA.getClassifier();
+        if (existingA != null) {
+            if (!Objects.equals(existingC, toAdd.getClassifier())) {
+                return true;
+            }
+        }
+        recordConflict(d, existing);
+        return false;
+        /*
+        if (existingA.getVersionSpec() != null) {
+            if (!existingA.getVersionSpec().equals(toAdd.getVersionSpec())) {
+                recordConflict(d, existing);
+                return false;
+            }
+            /*
+            RETAIN for reference, upgrade was too complex, will be added later.
+            if (request.getOptions().contains(Options.upgrade)) {
+                if (newerVersion(existingA.getVersionSpec(), toAdd.getVersionSpec())) {
+                    upgrades.put(existing, d);
+                    return true;
+                }
+            }
+        } else if (request.getOptions().contains(Options.upgrade)) {
+            if (toAdd.getVersionSpec() != null) {
+                upgrades.put(existing, d);
+                return true;
+            }
+            * /
+        } else {
+            // skipConflicts - any potential conflict that would result in an exception, will be skipped.
+            recordConflict(d, existing);
+            return false;
+        }
+        
+        // if versions should be ignored, then any version will result in a conflict, possibly skipped.
+        if (request.getOptions().contains(Options.ignoreVersions)) {
+            recordConflict(d, existing);
+            return false;
+        }
+        
+        return true;
+        */
+    }
+    
+    public static String[] gavSplit(String gav) {
+        // the general GAV format is - <group>:<artifact>:<version/snapshot>[:<classifier>][@extension]
+        int firstColon = gav.indexOf(':'); // NOI18N
+        int versionColon = gav.indexOf(':', firstColon + 1); // NOI18N
+        int versionEnd = versionColon > firstColon ? gav.indexOf(':', versionColon + 1) : -1; // NO18N
+
+        if (firstColon == -1 || versionColon == -1 || firstColon == versionColon) {
+            throw new IllegalArgumentException("Invalid GAV format: '" + gav + "'"); //NOI18N
+        }
+        int end = versionEnd == -1 ? gav.length() : versionEnd;
+
+        return new String[]{
+            gav.substring(0, firstColon),
+            gav.substring(firstColon + 1, versionColon),
+            gav.substring(versionColon + 1, end)
+        };
+    }
+
+    private StringBuilder appendDependencyDecl(StringBuilder sb, Dependency d) throws DependencyChangeException {
+        GradleScope gs = getScope(d);
+        sb.append(gs.getTargetConfigurationName()).append("('");
+        ArtifactSpec a = d.getArtifact();
+        sb.append(a.getGroupId()).append(':').append(a.getArtifactId());
+        if (a.getVersionSpec() != null) {
+            sb.append(':').append(a.getVersionSpec());
+        }
+        sb.append("')");
+        return sb;
+    }
+    
+    /**
+     * Generates a complete dependency block, assuming it is missing at all.
+     * @throws DependencyChangeException 
+     */
+    void generateDependencyBlockAtEnd() throws DependencyChangeException {
+        int start = lineDoc.getLength();
+        StringBuilder sb = new StringBuilder();
+        sb.append("dependencies {\n");
+        for (Dependency d : accepted) {
+            sb.append("    "); // indent
+            appendDependencyDecl(sb, d);
+            sb.append("\n");
+        }
+        sb.append("}\n");
+        textEdits.add(new TextEdit(start, start, sb.toString()));
+    }
+    
+    @Override
+    protected void generateDependencies() throws DependencyChangeException {
+        if (accepted.isEmpty()) {
+            return;
+        }
+        DependencyResult current = context.getCurrentDependencies();
+        SourceLocation loc;
+        List<Dependency> roots = current.getRoot().getChildren();
+        try {
+            // do it a stupid way: choose indent according to the 1st dependency in the container,
+            // place the declaration at the following line after the last dependency in the container.
+            loc = current.getDeclarationRange(null, DependencyResult.PART_CONTAINER);
+            
+            if (loc == null) {
+                // whoa ! No dependencies at all.
+                generateDependencyBlockAtEnd();
+                return;
+            }
+            
+            // get the indent initially from the container's declaration itself, plus fixed indent
+            int dependencyIndent = Math.max(0, 
+                    LineDocumentUtils.getLineFirstNonWhitespace(lineDoc, loc.getStartOffset()) - 
+                    LineDocumentUtils.getLineStart(lineDoc, loc.getStartOffset()));
+            int declarationIndent = dependencyIndent + 4; // fixed-size indent, may need to change
+            
+            // but better to try one of the declarations within the container:
+            for (int i = roots.size() - 1; i >= 0; i++) {
+                Dependency d = roots.get(i);
+                SourceLocation l2 = current.getDeclarationRange(d, null);
+                if (l2 == null) {
+                    continue;
+                }
+                SourceLocation container = current.getDeclarationRange(d, DependencyResult.PART_CONTAINER);
+                if (container != null) {
+                    // instead of nested declaration, get the start of the declaration group, as the new declaration will be indented
+                    // on the same level.
+                    l2 = container;
+                }
+                declarationIndent = Math.max(0, 
+                    LineDocumentUtils.getLineFirstNonWhitespace(lineDoc, l2.getStartOffset()) - 
+                    LineDocumentUtils.getLineStart(lineDoc, l2.getStartOffset()));
+                // one item should be sufficient
+                break;
+            }
+            
+            // insert at the line where the `dependencies' ending } is; if it is alone, start from the beginning of the line with the indent, terminate
+            // with a newline.
+            int start = LineDocumentUtils.getLineStart(lineDoc, loc.getEndOffset());
+            int nonWhite = LineDocumentUtils.getLineFirstNonWhitespace(lineDoc, loc.getEndOffset());
+            StringBuilder toInsert = new StringBuilder();
+            StringBuilder suffix = new StringBuilder();
+            
+            if (!"}".equals(lineDoc.getText(nonWhite, 1))) {
+                // and if not alone on the line, cut the line at the } position, but add the whitespaces up to the former } column at the end (suffix).
+                toInsert.append("\n");
+                indent(suffix, loc.getEndOffset() - 1 - start);
+                start = loc.getEndOffset() - 1;
+            }
+
+            for (Dependency d : accepted) {
+                appendDependencyDecl(indent(toInsert, declarationIndent), d).append('\n');
+            }
+            toInsert.append(suffix);
+            textEdits.add(new TextEdit(start, start, toInsert.toString()));
+        } catch (BadLocationException | IOException ex) {
+            // FIXME - handle
+            Exceptions.printStackTrace(ex);
+        }
+    }
+    
+}
diff --git a/java/gradle.dependencies/src/org/netbeans/modules/gradle/dependencies/DependencyModifierImpl.java b/java/gradle.dependencies/src/org/netbeans/modules/gradle/dependencies/DependencyModifierImpl.java
new file mode 100644
index 0000000000..b33a49f7d4
--- /dev/null
+++ b/java/gradle.dependencies/src/org/netbeans/modules/gradle/dependencies/DependencyModifierImpl.java
@@ -0,0 +1,115 @@
+/*
+ * 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.dependencies;
+
+import java.io.File;
+import java.util.LinkedHashSet;
+import java.util.Set;
+import org.netbeans.api.lsp.WorkspaceEdit;
+import org.netbeans.api.project.Project;
+import org.netbeans.modules.gradle.api.NbGradleProject;
+import org.netbeans.modules.project.dependency.DependencyChange;
+import org.netbeans.modules.project.dependency.DependencyChangeException;
+import org.netbeans.modules.project.dependency.DependencyChangeRequest;
+import org.netbeans.modules.project.dependency.DependencyResult;
+import org.netbeans.modules.project.dependency.ProjectDependencies;
+import org.netbeans.modules.project.dependency.ProjectOperationException;
+import org.netbeans.modules.project.dependency.Scopes;
+import org.netbeans.modules.project.dependency.spi.ProjectDependencyModifier;
+import org.netbeans.spi.project.ProjectServiceProvider;
+import org.openide.cookies.EditorCookie;
+import org.openide.filesystems.FileObject;
+import org.openide.filesystems.FileUtil;
+import org.openide.util.NbBundle;
+
+/**
+ *
+ * @author sdedic
+ */
+@ProjectServiceProvider(service = ProjectDependencyModifier.class, projectType = NbGradleProject.GRADLE_PROJECT_TYPE)
+public class DependencyModifierImpl implements ProjectDependencyModifier {
+    private final Project   project;
+
+    public DependencyModifierImpl(Project project) {
+        this.project = project;
+    }
+    
+    @NbBundle.Messages({
+        "ERR_ProjectFilesOutOfSync=Some project files are unsaved."
+    })
+    void assertProjectMetadataCorrect() throws DependencyChangeException {
+        NbGradleProject gp = NbGradleProject.get(project);
+        Set<FileObject> files = new LinkedHashSet<>();
+        for (File f : gp.getGradleFiles().getProjectFiles()) {
+            FileObject fo = FileUtil.toFileObject(f);
+            if (fo == null) {
+                continue;
+            }
+            EditorCookie cake = fo.getLookup().lookup(EditorCookie.class);
+            if (cake != null && cake.isModified()) {
+                files.add(fo);
+            }
+        }
+        if (!files.isEmpty()) {
+            throw new ProjectOperationException(project, ProjectOperationException.State.OUT_OF_SYNC, Bundle.ERR_ProjectFilesOutOfSync(), files);
+        }
+    }
+
+    @Override
+    public Result computeChange(DependencyChangeRequest request) throws DependencyChangeException {
+        DependencyResult r = ProjectDependencies.findDependencies(project, ProjectDependencies.newQuery(Scopes.DECLARED));
+        if (r == null) {
+            return null;
+        }
+        assertProjectMetadataCorrect();
+        RewriteContext context = new RewriteContext(project, r);
+        DependencyAdder adder = new DependencyAdder(project, context);
+        
+        for (DependencyChange change : request.getOperations()) {
+            switch (change.getKind()) {
+                case ADD:
+                    adder.processRequest(change);
+                    break;
+                case REMOVE:
+                default:
+                    throw new DependencyChangeException(change, null, DependencyChangeException.Reason.MALFORMED);
+            }
+        }
+        
+        adder.execute();
+        WorkspaceEdit e = context.createWorkspaceEdit();
+        
+        return new Result() {
+            @Override
+            public String getId() {
+                return "project-dependency-add";
+            }
+
+            @Override
+            public boolean suppresses(Result check) {
+                return false;
+            }
+
+            @Override
+            public WorkspaceEdit getWorkspaceEdit() {
+                return e;
+            }
+        };
+    }
+}
diff --git a/java/gradle.dependencies/src/org/netbeans/modules/gradle/dependencies/RewriteContext.java b/java/gradle.dependencies/src/org/netbeans/modules/gradle/dependencies/RewriteContext.java
new file mode 100644
index 0000000000..b7a9f40d1b
--- /dev/null
+++ b/java/gradle.dependencies/src/org/netbeans/modules/gradle/dependencies/RewriteContext.java
@@ -0,0 +1,119 @@
+/*
+ * 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.dependencies;
+
+import java.io.File;
+import java.io.FileNotFoundException;
+import java.io.IOException;
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.Collections;
+import java.util.List;
+import org.netbeans.api.editor.document.LineDocument;
+import org.netbeans.api.editor.document.LineDocumentUtils;
+import org.netbeans.api.lsp.TextDocumentEdit;
+import org.netbeans.api.lsp.TextEdit;
+import org.netbeans.api.lsp.WorkspaceEdit;
+import org.netbeans.api.project.Project;
+import org.netbeans.modules.gradle.api.NbGradleProject;
+import org.netbeans.modules.gradle.java.queries.GradleScopes;
+import org.netbeans.modules.gradle.java.queries.GradleScopesBuilder;
+import org.netbeans.modules.project.dependency.DependencyResult;
+import org.netbeans.modules.project.dependency.ProjectOperationException;
+import org.openide.cookies.EditorCookie;
+import org.openide.filesystems.FileObject;
+import org.openide.filesystems.FileUtil;
+import org.openide.filesystems.URLMapper;
+import org.openide.util.NbBundle;
+import org.openide.util.Union2;
+
+/**
+ * Accumulates changes from the dependency change.
+ * @author sdedic
+ */
+public class RewriteContext {
+    private final Project project;
+    private final DependencyResult current;
+    private LineDocument lineDoc;
+    private GradleScopes scopes;
+    private List<TextEdit> edits = new ArrayList<>();
+    private FileObject buildFile;
+
+    public RewriteContext(Project project, DependencyResult current) {
+        this.project = project;
+        this.current = current;
+        
+        scopes = new GradleScopesBuilder(project).build();
+        NbGradleProject nbgp = NbGradleProject.get(project);
+        File f = nbgp.getGradleFiles().getBuildScript();
+        buildFile = FileUtil.toFileObject(f);
+    }
+
+    public GradleScopes getScopes() {
+        return scopes;
+    }
+    
+    @NbBundle.Messages({
+        "# {0} - project buildscript name",
+        "ERR_ProjectFileNotFound=Cannot locate buildscript {0}"
+    })
+    public LineDocument openDocument() throws ProjectOperationException {
+        if (lineDoc != null) {
+            return lineDoc;
+        }
+        NbGradleProject nbgp = NbGradleProject.get(project);
+        File f = nbgp.getGradleFiles().getBuildScript();
+        buildFile = FileUtil.toFileObject(f);
+        if (buildFile == null) {
+            throw new ProjectOperationException(project, ProjectOperationException.State.UNSUPPORTED, 
+                Bundle.ERR_ProjectFileNotFound(f.toString()),
+                new FileNotFoundException(f.toString()));
+        }
+        EditorCookie cake = buildFile.getLookup().lookup(EditorCookie.class);
+        try {
+            lineDoc = LineDocumentUtils.asRequired(cake.openDocument(), LineDocument.class);
+            return lineDoc;
+        } catch (IOException ex) {
+            throw new ProjectOperationException(project, ProjectOperationException.State.ERROR, 
+                Bundle.ERR_ProjectFileNotFound(f.toString()),
+                ex);
+        }
+    }
+    
+    public DependencyResult getCurrentDependencies() {
+        return current;
+    }
+    
+    public void addTextEdits(List<TextEdit> add) {
+        edits.addAll(add);
+    }
+    
+    public WorkspaceEdit createWorkspaceEdit() {
+        FileObject fo;
+        return new WorkspaceEdit(
+            edits.isEmpty() ? 
+                    Collections.emptyList() : 
+                    Arrays.asList(
+                    Union2.createFirst(new TextDocumentEdit(URLMapper.findURL(buildFile, URLMapper.EXTERNAL).toString(), edits)
+                    )
+            )
+        );
+    }
+    
+}
diff --git a/java/gradle.dependencies/test/unit/data/projects/micronaut/build.gradle b/java/gradle.dependencies/test/unit/data/projects/micronaut/build.gradle
new file mode 100644
index 0000000000..3ce34ee2b6
--- /dev/null
+++ b/java/gradle.dependencies/test/unit/data/projects/micronaut/build.gradle
@@ -0,0 +1,65 @@
+/*
+ * 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.
+ */
+
+plugins {
+    id("com.github.johnrengelman.shadow") version "7.1.2"
+    id("io.micronaut.application") version "3.5.1"
+}
+
+version = "0.1"
+group = "com.example"
+
+repositories {
+    mavenCentral()
+}
+
+dependencies {
+    annotationProcessor("io.micronaut:micronaut-http-validation")
+    implementation("io.micronaut:micronaut-http-client")
+    implementation("io.micronaut:micronaut-jackson-databind")
+    implementation("jakarta.annotation:jakarta.annotation-api")
+    runtimeOnly("ch.qos.logback:logback-classic")
+    implementation("io.micronaut:micronaut-validation")
+
+    implementation("org.apache.logging.log4j:log4j-core:2.17.0")
+}
+
+
+application {
+    mainClass.set("com.example.Application")
+}
+java {
+    sourceCompatibility = JavaVersion.toVersion("11")
+    targetCompatibility = JavaVersion.toVersion("11")
+}
+
+graalvmNative.toolchainDetection = false
+micronaut {
+    runtime("netty")
+    testRuntime("junit5")
+    processing {
+        incremental(true)
+        annotations("com.example.*")
+    }
+}
+
+
+println project.group
+println project.name
+println project.version
diff --git a/java/gradle.dependencies/test/unit/data/projects/micronaut/build2.gradle b/java/gradle.dependencies/test/unit/data/projects/micronaut/build2.gradle
new file mode 100644
index 0000000000..f33b0d4e95
--- /dev/null
+++ b/java/gradle.dependencies/test/unit/data/projects/micronaut/build2.gradle
@@ -0,0 +1,66 @@
+/*
+ * 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.
+ */
+
+plugins {
+    id("com.github.johnrengelman.shadow") version "7.1.2"
+    id("io.micronaut.application") version "3.5.1"
+}
+
+version = "0.1"
+group = "com.example"
+
+repositories {
+    mavenCentral()
+}
+
+dependencies {
+    annotationProcessor("io.micronaut:micronaut-http-validation")
+    implementation("io.micronaut:micronaut-http-client")
+    implementation("io.micronaut:micronaut-jackson-databind")
+    implementation("jakarta.annotation:jakarta.annotation-api")
+    runtimeOnly("ch.qos.logback:logback-classic")
+    implementation(
+            "io.micronaut:micronaut-validation",
+            "org.apache.logging.log4j:log4j-core:2.17.0"
+    )
+}
+
+
+application {
+    mainClass.set("com.example.Application")
+}
+java {
+    sourceCompatibility = JavaVersion.toVersion("11")
+    targetCompatibility = JavaVersion.toVersion("11")
+}
+
+graalvmNative.toolchainDetection = false
+micronaut {
+    runtime("netty")
+    testRuntime("junit5")
+    processing {
+        incremental(true)
+        annotations("com.example.*")
+    }
+}
+
+
+println project.group
+println project.name
+println project.version
diff --git a/java/gradle.dependencies/test/unit/data/projects/micronaut/build3.gradle b/java/gradle.dependencies/test/unit/data/projects/micronaut/build3.gradle
new file mode 100644
index 0000000000..436e432b95
--- /dev/null
+++ b/java/gradle.dependencies/test/unit/data/projects/micronaut/build3.gradle
@@ -0,0 +1,53 @@
+/*
+ * 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.
+ */
+
+plugins {
+    id("com.github.johnrengelman.shadow") version "7.1.2"
+    id("io.micronaut.application") version "3.5.1"
+}
+
+version = "0.1"
+group = "com.example"
+
+repositories {
+    mavenCentral()
+}
+
+application {
+    mainClass.set("com.example.Application")
+}
+java {
+    sourceCompatibility = JavaVersion.toVersion("11")
+    targetCompatibility = JavaVersion.toVersion("11")
+}
+
+graalvmNative.toolchainDetection = false
+micronaut {
+    runtime("netty")
+    testRuntime("junit5")
+    processing {
+        incremental(true)
+        annotations("com.example.*")
+    }
+}
+
+
+println project.group
+println project.name
+println project.version
diff --git a/java/maven.refactoring/nbproject/project.properties b/java/gradle.dependencies/test/unit/data/projects/micronaut/gradle.properties
similarity index 90%
copy from java/maven.refactoring/nbproject/project.properties
copy to java/gradle.dependencies/test/unit/data/projects/micronaut/gradle.properties
index 9f9ea400db..2651a61b63 100644
--- a/java/maven.refactoring/nbproject/project.properties
+++ b/java/gradle.dependencies/test/unit/data/projects/micronaut/gradle.properties
@@ -14,6 +14,5 @@
 # KIND, either express or implied.  See the License for the
 # specific language governing permissions and limitations
 # under the License.
-javac.source=1.8
-javac.compilerargs=-Xlint -Xlint:-serial
-requires.nb.javac=true
+
+micronautVersion=3.6.0
diff --git a/java/gradle.dependencies/test/unit/data/projects/micronaut/gradle/wrapper/gradle-wrapper.properties b/java/gradle.dependencies/test/unit/data/projects/micronaut/gradle/wrapper/gradle-wrapper.properties
new file mode 100644
index 0000000000..8049c684f0
--- /dev/null
+++ b/java/gradle.dependencies/test/unit/data/projects/micronaut/gradle/wrapper/gradle-wrapper.properties
@@ -0,0 +1,5 @@
+distributionBase=GRADLE_USER_HOME
+distributionPath=wrapper/dists
+distributionUrl=https\://services.gradle.org/distributions/gradle-7.5-bin.zip
+zipStoreBase=GRADLE_USER_HOME
+zipStorePath=wrapper/dists
diff --git a/java/gradle.dependencies/test/unit/data/projects/micronaut/settings.gradle b/java/gradle.dependencies/test/unit/data/projects/micronaut/settings.gradle
new file mode 100644
index 0000000000..01b39d9bb1
--- /dev/null
+++ b/java/gradle.dependencies/test/unit/data/projects/micronaut/settings.gradle
@@ -0,0 +1,21 @@
+/*
+ * 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.
+ */
+
+rootProject.name="microdemo"
+
diff --git a/java/gradle.dependencies/test/unit/data/projects/micronaut/src/main/java/com/example/Application.java b/java/gradle.dependencies/test/unit/data/projects/micronaut/src/main/java/com/example/Application.java
new file mode 100644
index 0000000000..8f054b52d4
--- /dev/null
+++ b/java/gradle.dependencies/test/unit/data/projects/micronaut/src/main/java/com/example/Application.java
@@ -0,0 +1,27 @@
+/*
+ * 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 com.example;
+
+import io.micronaut.runtime.Micronaut;
+
+public class Application {
+    public static void main(String[] args) {
+        Micronaut.run(Application.class, args);
+    }
+}
diff --git a/java/gradle.dependencies/test/unit/data/projects/micronaut/src/main/resources/application.yml b/java/gradle.dependencies/test/unit/data/projects/micronaut/src/main/resources/application.yml
new file mode 100644
index 0000000000..f916f3831c
--- /dev/null
+++ b/java/gradle.dependencies/test/unit/data/projects/micronaut/src/main/resources/application.yml
@@ -0,0 +1,7 @@
+micronaut:
+  application:
+    name: microdemo
+netty:
+  default:
+    allocator:
+      max-order: 3
diff --git a/java/gradle.dependencies/test/unit/data/projects/micronaut/src/main/resources/logback.xml b/java/gradle.dependencies/test/unit/data/projects/micronaut/src/main/resources/logback.xml
new file mode 100644
index 0000000000..6010eb5233
--- /dev/null
+++ b/java/gradle.dependencies/test/unit/data/projects/micronaut/src/main/resources/logback.xml
@@ -0,0 +1,15 @@
+<configuration>
+
+    <appender name="STDOUT" class="ch.qos.logback.core.ConsoleAppender">
+        <withJansi>true</withJansi>
+        <!-- encoders are assigned the type
+             ch.qos.logback.classic.encoder.PatternLayoutEncoder by default -->
+        <encoder>
+            <pattern>%cyan(%d{HH:mm:ss.SSS}) %gray([%thread]) %highlight(%-5level) %magenta(%logger{36}) - %msg%n</pattern>
+        </encoder>
+    </appender>
+
+    <root level="info">
+        <appender-ref ref="STDOUT" />
+    </root>
+</configuration>
diff --git a/java/gradle.dependencies/test/unit/data/projects/micronaut/src/test/java/com/example/MicrodemoTest.java b/java/gradle.dependencies/test/unit/data/projects/micronaut/src/test/java/com/example/MicrodemoTest.java
new file mode 100644
index 0000000000..75b138ffe7
--- /dev/null
+++ b/java/gradle.dependencies/test/unit/data/projects/micronaut/src/test/java/com/example/MicrodemoTest.java
@@ -0,0 +1,39 @@
+/*
+ * 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 com.example;
+
+import io.micronaut.runtime.EmbeddedApplication;
+import io.micronaut.test.extensions.junit5.annotation.MicronautTest;
+import org.junit.jupiter.api.Test;
+import org.junit.jupiter.api.Assertions;
+
+import jakarta.inject.Inject;
+
+@MicronautTest
+class MicrodemoTest {
+
+    @Inject
+    EmbeddedApplication<?> application;
+
+    @Test
+    void testItWorks() {
+        Assertions.assertTrue(application.isRunning());
+    }
+
+}
diff --git a/java/gradle.dependencies/test/unit/src/org/netbeans/modules/gradle/dependencies/DependencyModifierImplTest.java b/java/gradle.dependencies/test/unit/src/org/netbeans/modules/gradle/dependencies/DependencyModifierImplTest.java
new file mode 100644
index 0000000000..17670f94d6
--- /dev/null
+++ b/java/gradle.dependencies/test/unit/src/org/netbeans/modules/gradle/dependencies/DependencyModifierImplTest.java
@@ -0,0 +1,400 @@
+/*
+ * 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.dependencies;
+
+import java.beans.PropertyChangeEvent;
+import java.beans.PropertyChangeListener;
+import java.io.File;
+import java.util.ArrayDeque;
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.Collection;
+import java.util.Deque;
+import java.util.LinkedHashSet;
+import java.util.List;
+import java.util.Set;
+import java.util.concurrent.CountDownLatch;
+import java.util.concurrent.TimeUnit;
+import java.util.stream.Collectors;
+import static junit.framework.TestCase.assertNotNull;
+import static junit.framework.TestCase.assertTrue;
+import org.netbeans.api.lsp.TextEdit;
+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.gradle.ProjectTrust;
+import org.netbeans.modules.gradle.api.GradleBaseProject;
+import org.netbeans.modules.gradle.api.GradleConfiguration;
+import org.netbeans.modules.gradle.api.GradleDependency;
+import org.netbeans.modules.gradle.api.GradleDependency.ModuleDependency;
+import static org.netbeans.modules.gradle.api.GradleDependency.Type.MODULE;
+import static org.netbeans.modules.gradle.api.GradleDependency.Type.UNRESOLVED;
+import org.netbeans.modules.gradle.api.GradleDependency.UnresolvedDependency;
+import org.netbeans.modules.gradle.api.NbGradleProject;
+import org.netbeans.modules.gradle.options.GradleExperimentalSettings;
+import org.netbeans.modules.project.dependency.ArtifactSpec;
+import org.netbeans.modules.project.dependency.Dependency;
+import org.netbeans.modules.project.dependency.DependencyChange;
+import org.netbeans.modules.project.dependency.DependencyChangeException;
+import org.netbeans.modules.project.dependency.DependencyChangeRequest;
+import org.netbeans.modules.project.dependency.DependencyResult;
+import org.netbeans.modules.project.dependency.ProjectDependencies;
+import org.netbeans.modules.project.dependency.ProjectModificationResult;
+import org.netbeans.modules.project.dependency.Scope;
+import org.netbeans.modules.project.dependency.Scopes;
+import org.openide.filesystems.FileObject;
+import org.openide.filesystems.FileUtil;
+import org.openide.modules.DummyInstalledFileLocator;
+import org.openide.windows.IOProvider;
+
+/**
+ *
+ * @author sdedic
+ */
+public class DependencyModifierImplTest extends NbTestCase {
+    FileObject projectDir;
+    File destDirF;
+    
+    @org.openide.util.lookup.ServiceProvider(service=org.openide.modules.InstalledFileLocator.class, position = 1000)
+    public static class InstalledFileLocator extends DummyInstalledFileLocator {
+    }
+
+   public DependencyModifierImplTest(String name) {
+        super(name);
+    }
+
+    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);
+    }
+
+    @Override
+    protected void setUp() throws Exception {
+        super.setUp();
+        // This is needed, otherwose the core window's startup code will redirect
+        // System.out/err to the IOProvider, and its Trivial implementation will redirect
+        // it back to System.err - loop is formed. Initialize IOProvider first, it gets
+        // the real System.err/out references.
+        IOProvider p = IOProvider.getDefault();
+        System.setProperty("test.reload.sync", "true");
+        
+        destDirF = getTestNBDestDir();
+        clearWorkDir();
+    
+        DummyInstalledFileLocator.registerDestDir(destDirF);
+        GradleExperimentalSettings.getDefault().setOpenLazy(false);
+    }
+
+    @Override
+    protected void tearDown() throws Exception {
+        super.tearDown();
+    }
+    
+    private Project project;
+    
+    private Project makeProject(String subdir) throws Exception {
+        return makeProject(subdir, null);
+    }
+    
+    private Project makeProject(String subdir, String alternateBuildscript) throws Exception {
+        FileObject src = FileUtil.toFileObject(getDataDir()).getFileObject(subdir);
+        projectDir = FileUtil.copyFile(src, FileUtil.toFileObject(getWorkDir()), src.getNameExt());
+        if (alternateBuildscript != null) {
+            FileObject fo = src.getFileObject(alternateBuildscript);
+            FileObject target = projectDir.getFileObject("build.gradle");
+            if (target != null) {
+                target.delete();
+            }
+            fo.copy(projectDir, "build", "gradle");
+        }
+        
+        Project p = ProjectManager.getDefault().findProject(projectDir);
+        assertNotNull(p);
+        ProjectTrust.getDefault().trustProject(p);
+        
+        OpenProjects.getDefault().open(new Project[] { p }, true);
+        OpenProjects.getDefault().openProjects().get();
+        
+        NbGradleProject.get(p).toQuality("Load data", NbGradleProject.Quality.FULL, false).toCompletableFuture().get();
+        this.project = p;
+        return p;
+    }
+    
+    private void assertDependencyAddFails(String msg, ArtifactSpec art) throws Exception {
+        Dependency toAdd = Dependency.make(art, Scopes.COMPILE);
+        try {
+            DependencyChange change = DependencyChange.builder(DependencyChange.Kind.ADD).
+                    dependency(toAdd).
+                    create();
+            ProjectDependencies.modifyDependencies(project, change);
+            fail(msg);
+        } catch (DependencyChangeException ex) {
+            assertEquals(DependencyChangeException.Reason.CONFLICT, ex.getReason());
+        }        
+    }
+    
+    public void testDependencyConflict() throws Exception {
+        Project p = makeProject("projects/micronaut");
+        assertDependencyAddFails("Versionless artifacts should cause conflict", ArtifactSpec.make("io.micronaut", "micronaut-http-client"));
+        assertDependencyAddFails("Versioned artifact added on top of versionless should cause conflict", ArtifactSpec.make("io.micronaut", "micronaut-http-client", "1.0"));
+        assertDependencyAddFails("Versionless artifact added on top of versioned should conflict", ArtifactSpec.make("org.apache.logging.log4j", "log4j-core"));
+        assertDependencyAddFails("Different versions should conflict", ArtifactSpec.make("org.apache.logging.log4j", "log4j-core", "2.17.1"));
+    }
+    
+    private void assertNoChange(String reason, ArtifactSpec spec) throws Exception {
+        Dependency toAdd = Dependency.make(spec, Scopes.COMPILE);
+        DependencyChange change = DependencyChange.builder(DependencyChange.Kind.ADD).
+                dependency(toAdd).
+                option(DependencyChange.Options.skipConflicts).
+                create();
+        ProjectModificationResult res = ProjectDependencies.modifyDependencies(project, change);
+        assertNotNull(res);
+        assertTrue(reason, res.getWorkspaceEdit().getDocumentChanges().isEmpty());
+    }
+    
+    public void testMatchingDependencySkips() throws Exception {
+        makeProject("projects/micronaut");
+        assertNoChange("Exactly matching artifact should be no-op", ArtifactSpec.make("io.micronaut", "micronaut-http-client"));
+    }
+    
+    public void testAddUnknownScopeFails() throws Exception {
+        Project p = makeProject("projects/micronaut");
+        ArtifactSpec art = ArtifactSpec.make("io.micronaut", "micronaut-http-client2");
+        Dependency toAdd = Dependency.make(art, Scope.named("microfiber"));
+        DependencyChange change = DependencyChange.builder(DependencyChange.Kind.ADD).
+                dependency(toAdd).
+                create();
+        try {
+            ProjectModificationResult res = ProjectDependencies.modifyDependencies(p, change);
+            fail("Should have failed because of unknown scope");
+        } catch (DependencyChangeException ex) {
+            assertEquals(DependencyChangeException.Reason.MALFORMED, ex.getReason());
+            assertSame(toAdd, ex.getFailedDependencies().iterator().next());
+        }
+    }
+    
+    public void testAbstractScopesMappedToGradle() throws Exception {
+        Project p = makeProject("projects/micronaut");
+        ArtifactSpec art = ArtifactSpec.make("io.micronaut", "micronaut-http-client2");
+        Dependency toAdd;
+        DependencyChange change;
+
+        List<Scope> scopes = Arrays.asList(
+                Scopes.COMPILE,
+                Scopes.PROCESS,
+                Scopes.RUNTIME,
+                Scopes.TEST,
+                Scopes.TEST_COMPILE,
+                Scopes.TEST_RUNTIME,
+                Scopes.EXTERNAL
+        );
+        
+        for (Scope s :scopes) {
+            toAdd = Dependency.make(art, s);
+            change = DependencyChange.builder(DependencyChange.Kind.ADD).
+                    dependency(toAdd).
+                    create();
+            try {
+                ProjectModificationResult res = ProjectDependencies.modifyDependencies(p, change);
+            } catch (DependencyChangeException ex) {
+                fail("Failed to add dependency for scope: " + s);
+            }
+        }
+    }
+    
+    public void testAddGenericCompilation() throws Exception {
+        Project p = makeProject("projects/micronaut");
+        ArtifactSpec art = ArtifactSpec.make("io.micronaut", "micronaut-http-client2");
+        Dependency toAdd = Dependency.make(art, Scopes.COMPILE);
+        DependencyChange change = DependencyChange.builder(DependencyChange.Kind.ADD).
+                dependency(toAdd).
+                create();
+        ProjectModificationResult res = ProjectDependencies.modifyDependencies(p, change);
+        
+        assertTrue("No new files should be created", res.getNewFiles().isEmpty());
+        assertEquals("A single file should be changed", 1, res.getWorkspaceEdit().getDocumentChanges().size());
+        List<TextEdit> edits = res.getWorkspaceEdit().getDocumentChanges().get(0).first().getEdits();
+        assertEquals("A single file should be changed", 1, edits.size());
+        String text = edits.get(0).getNewText();
+        
+        assertTrue(text.contains("implementation("));
+        
+        
+        toAdd = Dependency.make(art, Scope.named("implementation"));
+        change = DependencyChange.builder(DependencyChange.Kind.ADD).
+                dependency(toAdd).
+                create();
+        res = ProjectDependencies.modifyDependencies(p, change);
+        assertEquals("A single file should be changed", 1, res.getWorkspaceEdit().getDocumentChanges().size());
+        edits = res.getWorkspaceEdit().getDocumentChanges().get(0).first().getEdits();
+        assertEquals("A single file should be changed", 1, edits.size());
+        text = edits.get(0).getNewText();
+        assertTrue(text.contains("implementation("));
+    }
+    
+    /**
+     * Checks generation of the "dependency" block, if there's not one.
+     * @throws Exception 
+     */
+    public void testValidAddFirstDependency() throws Exception {
+        makeProject("projects/micronaut", "build3.gradle");
+        assertAddRouterValid();
+    }
+    
+    /**
+     * Checks that the generation succeeds after simple-style dependency like "implementation 'foo:bar:ver'"
+     * @throws Exception 
+     */
+    public void testValidAfterSingleDependency() throws Exception {
+        makeProject("projects/micronaut");
+        assertAddRouterValid();
+    }
+    
+    private void executeChangeAndWait(DependencyChange change) throws Exception {
+        Project p = this.project;
+        ProjectModificationResult res = ProjectDependencies.modifyDependencies(p, change);
+        NbGradleProject gp = NbGradleProject.get(project);
+        CountDownLatch l = new CountDownLatch(1);
+        gp.addPropertyChangeListener(new PropertyChangeListener() {
+            @Override
+            public void propertyChange(PropertyChangeEvent evt) {
+                if (NbGradleProject.PROP_PROJECT_INFO.equals(evt.getPropertyName())) {
+                    l.countDown();
+                }
+            }
+        });
+        res.commit();
+        l.await(10, TimeUnit.SECONDS);
+        gp = NbGradleProject.get(p);
+        assertTrue("Should successfuly load the project", gp.getQuality().atLeast(NbGradleProject.Quality.FULL));
+    }
+    
+    private void assertContainsArtifacts(boolean shouldContainDirect, String configuration, ArtifactSpec... artifacts) throws Exception {
+        Project p = this.project;
+        List<String> artifactIds = Arrays.asList(artifacts).stream().map(a -> a.getGroupId() + ":" + a.getArtifactId()).collect(Collectors.toList());
+        List<String> matches = new ArrayList<>(artifactIds);
+        List<String> found = new ArrayList<>();
+        
+        GradleBaseProject gbp = GradleBaseProject.get(p);
+        GradleConfiguration cfg = gbp.getConfigurations().get(configuration);
+        Collection<? extends GradleDependency> deps = cfg.getConfiguredDependencies();
+
+        F: for (GradleDependency d  : deps) {
+            String id;
+            
+            switch (d.getType()) {
+                case MODULE:
+                case UNRESOLVED:
+                    id = d.getId();
+                    break;
+                default:
+                    // skip the rest of the cycle
+                    continue;
+            }
+            String[] split = id.split(":");
+            String ga = split[0] + ":" + split[1];
+            artifactIds.remove(ga);
+            found.add(ga);
+        }
+        found.retainAll(Arrays.asList(matches));
+        
+        if (shouldContainDirect) {
+            assertTrue("Must contain " + artifactIds, artifactIds.isEmpty());
+        } else {
+            assertTrue("Must not contain " + artifactIds, found.isEmpty());
+        }
+    }
+    
+    private void assertContainsDependency(boolean containsInScope, Scope scope, ArtifactSpec... artifacts) throws Exception {
+        Project p = this.project;
+        List<String> artifactIds = Arrays.asList(artifacts).stream().map(a -> a.getGroupId() + ":" + a.getArtifactId()).collect(Collectors.toList());
+        List<String> matches = new ArrayList<>(artifactIds);
+        Set<String> found = new LinkedHashSet<>();
+        
+        DependencyResult r = ProjectDependencies.findDependencies(project, ProjectDependencies.newBuilder().scope(scope).build());
+        
+        Deque<Dependency> toProcess = new ArrayDeque<>();
+        toProcess.add(r.getRoot());
+        while (!toProcess.isEmpty()) {
+            Dependency d = toProcess.poll();
+            toProcess.addAll(d.getChildren());
+            
+            String ga = d.getArtifact().getGroupId() + ":" + d.getArtifact().getArtifactId();
+            artifactIds.remove(ga);
+            found.add(ga);
+        }
+        found.retainAll(matches);
+        if (containsInScope) {
+            assertTrue("Must contain " + artifactIds, artifactIds.isEmpty());
+        } else {
+            assertTrue("Must not contain " + artifactIds, found.isEmpty());
+        }
+        
+        if (scope == null) {
+            return;
+        }
+    }
+    
+    void assertAddRouterValid() throws Exception {
+        ArtifactSpec art = ArtifactSpec.make("io.micronaut", "micronaut-tracing");
+        Dependency toAdd = Dependency.make(art, Scopes.COMPILE);
+        DependencyChange change = DependencyChange.builder(DependencyChange.Kind.ADD).
+                dependency(toAdd).
+                create();
+        executeChangeAndWait(change);
+        assertContainsArtifacts(true, "implementation", art);
+        assertContainsDependency(true, Scopes.COMPILE, art);
+        assertContainsDependency(true, Scopes.RUNTIME, art);
+        assertContainsDependency(false, Scopes.PROCESS, art);
+    }
+    
+    
+    /**
+     * Checks that the generation succeeds when dependency is generated after a dependency block
+     * 
+     * @throws Exception 
+     */
+    public void testValidAfterDependencyBlock() throws Exception {
+        makeProject("projects/micronaut", "build2.gradle");
+        assertAddRouterValid();
+    }
+    
+    public void testInsertMultipleDependencies() throws Exception {
+        makeProject("projects/micronaut", "build2.gradle");
+        ArtifactSpec art = ArtifactSpec.make("io.micronaut", "micronaut-messaging");
+        ArtifactSpec art2 = ArtifactSpec.make("io.micronaut", "micronaut-tracing");
+        Dependency toAdd = Dependency.make(art, Scopes.RUNTIME);
+        Dependency toAdd2 = Dependency.make(art2, Scopes.RUNTIME);
+        
+        DependencyChange change = DependencyChange.builder(DependencyChange.Kind.ADD).
+                dependency(toAdd, toAdd2).
+                create();
+        executeChangeAndWait(change);
+        // artifacts are present in the buildfile / appropriate configuration
+        assertContainsArtifacts(true, "runtimeOnly", art, art2);
+        
+        // dependency is listed for runtime
+        assertContainsDependency(true, Scopes.RUNTIME, art);
+        // dependency is NOT listed for compile
+        assertContainsDependency(false, Scopes.COMPILE, art);
+    }
+}
diff --git a/java/gradle.java/manifest.mf b/java/gradle.java/manifest.mf
index 2bfb46ced8..e7b6d301ae 100644
--- a/java/gradle.java/manifest.mf
+++ b/java/gradle.java/manifest.mf
@@ -3,3 +3,4 @@ AutoUpdate-Show-In-Client: false
 OpenIDE-Module: org.netbeans.modules.gradle.java
 OpenIDE-Module-Layer: org/netbeans/modules/gradle/java/layer.xml
 OpenIDE-Module-Localizing-Bundle: org/netbeans/modules/gradle/java/Bundle.properties
+OpenIDE-Module-Implementation-Version: 1
diff --git a/java/java.lsp.server/nbcode/nbproject/platform.properties b/java/java.lsp.server/nbcode/nbproject/platform.properties
index d112b30f15..c776abd7bc 100644
--- a/java/java.lsp.server/nbcode/nbproject/platform.properties
+++ b/java/java.lsp.server/nbcode/nbproject/platform.properties
@@ -232,7 +232,6 @@ disabled.modules=\
     org.netbeans.modules.maven.graph,\
     org.netbeans.modules.maven.kit,\
     org.netbeans.modules.maven.osgi,\
-    org.netbeans.modules.maven.refactoring,\
     org.netbeans.modules.maven.repository,\
     org.netbeans.modules.maven.search,\
     org.netbeans.modules.maven.spring,\
diff --git a/java/maven.model/nbproject/project.xml b/java/maven.model/nbproject/project.xml
index d2faac0f13..fb79e8b047 100644
--- a/java/maven.model/nbproject/project.xml
+++ b/java/maven.model/nbproject/project.xml
@@ -226,6 +226,7 @@
                 <friend>org.netbeans.modules.maven.osgi</friend>
                 <friend>org.netbeans.modules.maven.persistence</friend>
                 <friend>org.netbeans.modules.maven.repository</friend>
+                <friend>org.netbeans.modules.maven.refactoring</friend>
                 <friend>org.netbeans.modules.selenium.maven</friend>
                 <friend>org.netbeans.modules.selenium2.maven</friend>
                 <friend>org.netbeans.modules.testng.maven</friend>
diff --git a/java/maven.model/src/org/netbeans/modules/maven/model/Utilities.java b/java/maven.model/src/org/netbeans/modules/maven/model/Utilities.java
index 5649fbbac6..2deeb9eb1f 100644
--- a/java/maven.model/src/org/netbeans/modules/maven/model/Utilities.java
+++ b/java/maven.model/src/org/netbeans/modules/maven/model/Utilities.java
@@ -164,6 +164,13 @@ public class Utilities {
 
     }
     
+    public static ModelSource createModelSource(final FileObject thisFileObj, final Document document) {
+        if (!(document instanceof BaseDocument)) {
+            throw new IllegalArgumentException();
+        }
+        return createModelSource(thisFileObj, null, (BaseDocument)document);
+    }
+    
     public static ModelSource createModelSource(final FileObject thisFileObj, final DataObject dobject, final BaseDocument document) {
         assert thisFileObj != null : "Null file object.";
         final File fl = FileUtil.toFile(thisFileObj);
diff --git a/java/maven.refactoring/manifest.mf b/java/maven.refactoring/manifest.mf
index 7caa1d29dd..9b7f956e7f 100644
--- a/java/maven.refactoring/manifest.mf
+++ b/java/maven.refactoring/manifest.mf
@@ -2,5 +2,5 @@ Manifest-Version: 1.0
 AutoUpdate-Show-In-Client: false
 OpenIDE-Module: org.netbeans.modules.maven.refactoring
 OpenIDE-Module-Localizing-Bundle: org/netbeans/modules/maven/refactoring/Bundle.properties
-OpenIDE-Module-Specification-Version: 1.43
+
 
diff --git a/java/maven.refactoring/nbproject/project.properties b/java/maven.refactoring/nbproject/project.properties
index 9f9ea400db..805a4c7b9b 100644
--- a/java/maven.refactoring/nbproject/project.properties
+++ b/java/maven.refactoring/nbproject/project.properties
@@ -17,3 +17,4 @@
 javac.source=1.8
 javac.compilerargs=-Xlint -Xlint:-serial
 requires.nb.javac=true
+spec.version.base=1.43
diff --git a/java/maven.refactoring/nbproject/project.xml b/java/maven.refactoring/nbproject/project.xml
index 406a91180c..e6edc20382 100644
--- a/java/maven.refactoring/nbproject/project.xml
+++ b/java/maven.refactoring/nbproject/project.xml
@@ -34,6 +34,15 @@
                         <specification-version>1.30</specification-version>
                     </run-dependency>
                 </dependency>
+                <dependency>
+                    <code-name-base>org.netbeans.api.lsp</code-name-base>
+                    <build-prerequisite/>
+                    <compile-dependency/>
+                    <run-dependency>
+                        <release-version>1</release-version>
+                        <specification-version>1.21</specification-version>
+                    </run-dependency>
+                </dependency>
                 <dependency>
                     <code-name-base>org.netbeans.libs.javacapi</code-name-base>
                     <build-prerequisite/>
@@ -42,6 +51,14 @@
                         <specification-version>7.7</specification-version>
                     </run-dependency>
                 </dependency>
+                <dependency>
+                    <code-name-base>org.netbeans.modules.editor.document</code-name-base>
+                    <build-prerequisite/>
+                    <compile-dependency/>
+                    <run-dependency>
+                        <specification-version>1.32</specification-version>
+                    </run-dependency>
+                </dependency>
                 <dependency>
                     <code-name-base>org.netbeans.modules.java.source.base</code-name-base>
                     <build-prerequisite/>
@@ -77,6 +94,23 @@
                         <specification-version>2.12</specification-version>
                     </run-dependency>
                 </dependency>
+                <dependency>
+                    <code-name-base>org.netbeans.modules.maven.model</code-name-base>
+                    <build-prerequisite/>
+                    <compile-dependency/>
+                    <run-dependency>
+                        <release-version>1</release-version>
+                        <specification-version>1.26</specification-version>
+                    </run-dependency>
+                </dependency>
+                <dependency>
+                    <code-name-base>org.netbeans.modules.project.dependency</code-name-base>
+                    <build-prerequisite/>
+                    <compile-dependency/>
+                    <run-dependency>
+                        <implementation-version/>
+                    </run-dependency>
+                </dependency>
                 <dependency>
                     <code-name-base>org.netbeans.modules.projectapi</code-name-base>
                     <build-prerequisite/>
@@ -94,6 +128,24 @@
                         <specification-version>1.17</specification-version>
                     </run-dependency>
                 </dependency>
+                <dependency>
+                    <code-name-base>org.netbeans.modules.xml.xam</code-name-base>
+                    <build-prerequisite/>
+                    <compile-dependency/>
+                    <run-dependency>
+                        <release-version>1</release-version>
+                        <specification-version>1.55</specification-version>
+                    </run-dependency>
+                </dependency>
+                <dependency>
+                    <code-name-base>org.netbeans.modules.xml.xdm</code-name-base>
+                    <build-prerequisite/>
+                    <compile-dependency/>
+                    <run-dependency>
+                        <release-version>1</release-version>
+                        <specification-version>1.57</specification-version>
+                    </run-dependency>
+                </dependency>
                 <dependency>
                     <code-name-base>org.openide.awt</code-name-base>
                     <build-prerequisite/>
@@ -159,6 +211,46 @@
                     </run-dependency>
                 </dependency>
             </module-dependencies>
+            <test-dependencies>
+                <test-type>
+                    <name>unit</name>
+                    <test-dependency>
+                        <code-name-base>org.netbeans.libs.junit4</code-name-base>
+                        <compile-dependency/>
+                    </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.parsing.nb</code-name-base>
+                        <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.editor.mimelookup.impl</code-name-base>
+                        <recursive/>
+                    </test-dependency>
+                    <test-dependency>
+                        <code-name-base>org.netbeans.modules.editor</code-name-base>
+                        <recursive/>
+                        <compile-dependency/>
+                    </test-dependency>
+                    <test-dependency>
+                        <!-- Because otherwise data systems and their services will not materialize -->
+                        <code-name-base>org.netbeans.modules.settings</code-name-base>
+                    </test-dependency>
+                    <test-dependency>
+                        <code-name-base>org.netbeans.modules.editor.plain</code-name-base>
+                        <recursive/>
+                        <compile-dependency/>
+                    </test-dependency>
+                </test-type>
+            </test-dependencies>
             <public-packages/>
         </data>
     </configuration>
diff --git a/java/maven.refactoring/src/org/netbeans/modules/maven/refactoring/dependency/DependencyAdder.java b/java/maven.refactoring/src/org/netbeans/modules/maven/refactoring/dependency/DependencyAdder.java
new file mode 100644
index 0000000000..2fa8107640
--- /dev/null
+++ b/java/maven.refactoring/src/org/netbeans/modules/maven/refactoring/dependency/DependencyAdder.java
@@ -0,0 +1,159 @@
+/*
+ * 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.maven.refactoring.dependency;
+
+import java.io.IOException;
+import java.util.ArrayList;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+import java.util.Objects;
+import org.netbeans.api.project.Project;
+import org.netbeans.modules.maven.api.NbMavenProject;
+import org.netbeans.modules.maven.model.pom.POMModel;
+import org.netbeans.modules.project.dependency.ArtifactSpec;
+import org.netbeans.modules.project.dependency.Dependency;
+import org.netbeans.modules.project.dependency.DependencyChange;
+import org.netbeans.modules.project.dependency.DependencyChangeException;
+import org.netbeans.modules.project.dependency.DependencyResult;
+import org.netbeans.modules.project.dependency.ProjectDependencies;
+import org.netbeans.modules.project.dependency.ProjectOperationException;
+import org.netbeans.modules.project.dependency.Scopes;
+import org.openide.util.NbBundle;
+
+/**
+ *
+ * @author sdedic
+ */
+public class DependencyAdder {
+    private final Project project;
+    private final DependencyChange request;
+    private final RewriteContext rewrite;
+    
+    public DependencyAdder(Project project, DependencyChange request, RewriteContext rewrite) {
+        this.project = project;
+        this.request = request;
+        this.rewrite = rewrite;
+    }
+    
+    private List<Dependency> accepted = new ArrayList<>();
+    protected Map<Dependency, Dependency> offending = new HashMap<>();
+    
+    protected void throwDependencyConflicts() throws DependencyChangeException {
+        if (!offending.isEmpty()) {
+            throw new DependencyChangeException(request, DependencyChangeException.Reason.CONFLICT, offending);
+        }
+    }
+
+    protected void throwUnknownScope(Dependency d) throws DependencyChangeException {
+        throw new DependencyChangeException(request, d, DependencyChangeException.Reason.MALFORMED);
+    }
+    
+    protected void recordConflict(Dependency requested, Dependency existing) {
+        if (!request.getOptions().contains(DependencyChange.Options.skipConflicts)) {
+            offending.putIfAbsent(requested, existing);
+        }
+    }
+    
+    protected boolean checkDependencyConflicts(Dependency existing, Dependency d) throws DependencyChangeException {
+        ArtifactSpec existingA = existing.getArtifact();
+        ArtifactSpec toAdd = d.getArtifact();
+        
+        if (!(existingA.getGroupId().equals(toAdd.getGroupId()) &&
+            existingA.getArtifactId().equals(toAdd.getArtifactId()))) {
+            // different artifacts -> no conflicts
+            return true;
+        }
+        String existingC = existingA.getClassifier();
+        if (existingA != null) {
+            if (!Objects.equals(existingC, toAdd.getClassifier())) {
+                return true;
+            }
+        }
+        String mavenScope = rewrite.mavenScope(d);
+        String existingScope = rewrite.mavenScope(existing);
+        if (!mavenScope.equals(existingScope)) {
+            // second chance -- the specified scope could be a meta-scope that maps to Gradle configuration
+            return true;
+        }
+        recordConflict(d, existing);
+        return false;
+    }
+    
+    DependencyResult current;
+    
+    @NbBundle.Messages({
+        "ERR_AddingDependency=Error adding dependency"
+    })
+    public void execute() throws DependencyChangeException {
+        current = ProjectDependencies.findDependencies(project, ProjectDependencies.newQuery(Scopes.DECLARED));
+        
+        try {
+
+            POMModel mutableModel = rewrite.getWriteModel();
+            for (Dependency d : request.getDependencies()) {
+                boolean toAccept = true;
+                for (Dependency c : current.getRoot().getChildren()) {
+                    if (!checkDependencyConflicts(c, d)) {
+                        toAccept = false;
+                        break;
+                    }
+                }
+                if (toAccept) {
+                    accepted.add(d);
+                }
+            }
+
+            throwDependencyConflicts();
+
+            mutableModel.sync();            
+            mutableModel.startTransaction();
+            boolean ok = false;
+            try {
+                for (Dependency d : accepted) {
+                    ArtifactSpec a = d.getArtifact();
+                    org.netbeans.modules.maven.model.pom.Dependency mavenDep = mutableModel.getFactory().createDependency();
+                    mavenDep.setGroupId(a.getGroupId());
+                    mavenDep.setArtifactId(a.getArtifactId());
+                    if (a.getVersionSpec() != null && !a.getVersionSpec().isEmpty()) {
+                        mavenDep.setVersion(a.getVersionSpec());
+                    }
+                    if (a.getClassifier() != null) {
+                        mavenDep.setClassifier(a.getClassifier());
+                    }
+                    String scope = rewrite.mavenScope(d);
+                    if (!"compile".equals(scope)) {
+                        mavenDep.setScope(scope);
+                    }
+                    mutableModel.getProject().addDependency(mavenDep);
+                }
+                mutableModel.endTransaction();
+                ok = true;
+            } finally {
+                if (!ok) {
+                    mutableModel.rollbackTransaction();
+                }
+            }
+        } catch (IOException ex) {
+            throw new ProjectOperationException(project, ProjectOperationException.State.UNSUPPORTED, Bundle.ERR_CannotModifyProject(rewrite.getPomFile()));
+        } catch (IllegalArgumentException | IllegalStateException | UnsupportedOperationException ex) {
+            throw new ProjectOperationException(project, ProjectOperationException.State.ERROR, Bundle.ERR_AddingDependency(), ex);
+        }
+    }
+}
diff --git a/java/maven.refactoring/src/org/netbeans/modules/maven/refactoring/dependency/DocumentChangesConverter.java b/java/maven.refactoring/src/org/netbeans/modules/maven/refactoring/dependency/DocumentChangesConverter.java
new file mode 100644
index 0000000000..437b8da84b
--- /dev/null
+++ b/java/maven.refactoring/src/org/netbeans/modules/maven/refactoring/dependency/DocumentChangesConverter.java
@@ -0,0 +1,368 @@
+/*
+ * 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.maven.refactoring.dependency;
+
+import java.util.ArrayList;
+import java.util.Collection;
+import java.util.Collections;
+import java.util.Iterator;
+import java.util.List;
+import java.util.NavigableSet;
+import java.util.SortedSet;
+import java.util.TreeSet;
+import javax.swing.event.DocumentEvent;
+import javax.swing.event.DocumentListener;
+import javax.swing.text.BadLocationException;
+import javax.swing.text.Document;
+import org.netbeans.api.lsp.TextEdit;
+import org.openide.util.Exceptions;
+
+/**
+ * Converts a series of edits of a Document to a series of TextEdits.
+ * The class acts as a Listener on a document, watching changes. At the end,
+ * it computes list of TextEdits from those changes. It supports even overlapping edits:
+ * it merges the overlapping changes into a single TextEdit (or several non-overlapping TextEdits)
+ * since LSP specification does not like overlaps.
+ * <p>
+ * The code is originally written as a DocumentListener, so it accepts document edits as they are generated
+ * and captures them as TextEdits, but still uses the original offsets, which shift from the original
+ * state as the document is modified.
+ * <p>
+ * It could be also used to normalize a sequence of overlapping TextEdits.
+ * @author sdedic
+ */
+public class DocumentChangesConverter implements DocumentListener {
+    private final Document document;
+    private boolean adjustPositions;
+
+    public DocumentChangesConverter(Document document) {
+        this.document = document;
+    }
+    
+    /**
+     * Edits captured from the document.
+     */
+    private List<TextEdit> recordedEdits = new ArrayList<>();
+    
+    @Override
+    public void insertUpdate(DocumentEvent e) {
+        try {
+            String text = document.getText(e.getOffset(), e.getLength());
+            TextEdit edit = new TextEdit(e.getOffset(), e.getOffset(), text);
+            recordedEdits.add(edit);
+        } catch (BadLocationException ex) {
+            Exceptions.printStackTrace(ex);
+        }
+    }
+
+    @Override
+    public void removeUpdate(DocumentEvent e) {
+        TextEdit edit = new TextEdit(e.getOffset(), e.getOffset() + e.getLength(), null);
+        recordedEdits.add(edit);
+    }
+
+    @Override
+    public void changedUpdate(DocumentEvent e) {
+        // no op
+    }
+    
+    /**
+     * Order of edits in the sequence they have been applied to the document.
+     * When an edit is modified or coalesced (a new instance is created), the edit (or all coalesced edits) must be replaced by
+     * that new instance.
+     */
+    private List<TextEdit> ordered = new ArrayList<>();
+    
+    // must process events in the edit queue. Must insert into 'ordered' first !
+    private TreeSet<TextEdit> condensed = new TreeSet<TextEdit>((TextEdit t1, TextEdit t2) -> {
+        int d = t1.getStartOffset() - t2.getStartOffset();
+        if (d != 0) {
+            return d;
+        }
+        int n1 = ordered.indexOf(t1);
+        int n2 = ordered.indexOf(t2);
+        if (n1 == -1) {
+            return 1;
+        } else if (n2 == -1) {
+            return 1;
+        }
+        return n1 - n2;
+    });
+    
+    /**
+     * Replaces one or more edits in the collection that defines order with the new one.
+     * The order will be computed as the position of first (in therms of the original order) 
+     * of the edits, that inserted new text to the document; or any of the remove edits.
+     * @param remove edits to remove
+     * @param replaceWith the replacement.
+     */
+    void replaceOrderedEdits(Collection<TextEdit> remove, TextEdit replaceWith) {
+        int pos = -1;
+        
+        for (TextEdit candidate : remove) {
+            int p = ordered.indexOf(candidate);
+            if (pos == -1) {
+                pos = p;
+            } else {
+                if ((candidate.getNewText() != null) && (p < pos)) {
+                    pos = p;
+                }
+            }
+        }
+        
+        ordered.set(pos, replaceWith);
+        ordered.removeAll(remove);
+    }
+    
+    /**
+     * Turns the recorded edits into a series of non-overlapping TextEdits that
+     * make the same modification to the document. The edits may be coalesced, though
+     * not completely (some adjacent edits that may be further collapsed may be present).
+     * 
+     * @return series of non-overlapping edits.
+     */
+    public List<TextEdit> makeTextEdits() {
+        ordered.clear();
+        ordered.addAll(recordedEdits);
+        
+        condensed.clear();
+        
+        T: for (int i = 0; i < recordedEdits.size(); i++) {
+            TextEdit t = recordedEdits.get(i);
+            
+            int adjustedStart = t.getStartOffset();
+            int adjustedEnd = t.getEndOffset();
+            int l = t.getEndOffset() - t.getStartOffset();
+
+            NavigableSet<TextEdit> priorEdits = condensed.headSet(t, false).descendingSet();
+            
+            for (Iterator<TextEdit> it = priorEdits.iterator(); it.hasNext(); ) {
+                TextEdit p = it.next();
+                int added = p.getNewText() != null ? p.getNewText().length() : 0;
+                if (p.getStartOffset() + added >= adjustedStart) {
+                    // if "p" specifies insert, but this edit delete in the middle or after the text, do not merge
+                    //if ((t.getStartOffset() <= p.getEndOffset()) || (t.getEndOffset() == t.getStartOffset())) {
+                    if ((l == 0) || (adjustedStart < p.getStartOffset() + added)) {
+                        mergePrecedingOverlap(t, p, adjustedStart, it);
+                        continue T;
+                    }
+                }
+                int editLength = p.getNewText() != null ? p.getNewText().length() : 0;
+                editLength -= (p.getEndOffset() - p.getStartOffset());
+                adjustedStart -= editLength;
+                adjustedEnd = adjustedStart + l;
+            }
+            
+            SortedSet<TextEdit> nextEdits = condensed.tailSet(t);
+            int sz = t.getNewText() == null ? 0 : t.getNewText().length();
+            
+            if (!nextEdits.isEmpty()) {
+                List<TextEdit> toMerge = new ArrayList<>();
+                for (Iterator<TextEdit> it = nextEdits.iterator(); it.hasNext(); ) {
+                    TextEdit n = it.next();
+                    if (n.getStartOffset() <= adjustedEnd + sz) {
+                        toMerge.add(n);
+                        it.remove();
+                    } else {
+                        break;
+                    }
+                }
+                
+                if (!toMerge.isEmpty()) {
+                    mergeOverlappingEdits(toMerge, t, adjustedStart, adjustedEnd);
+                    continue T;
+                }
+            }
+            if (adjustedStart != t.getStartOffset()) {
+                TextEdit edit = new TextEdit(adjustedStart, adjustedEnd, t.getNewText());
+                replaceOrderedEdits(Collections.singletonList(t), edit);
+                condensed.add(edit);
+            } else {
+                // already is in the ordered list
+                condensed.add(t);
+            }
+        }
+        
+        return new ArrayList<>(condensed);
+    }
+    
+    /**
+     * Merges the new edit with edits that follow this one. Note that the only way how 
+     * we could overlap with following edits is to delete part of text.
+     * @param toMerge
+     * @param newEdit 
+     */
+    private void mergeOverlappingEdits(List<TextEdit> toMerge, TextEdit newEdit, int adjustedStart, int adjustedEnd) {
+        TextEdit remainder = null;
+        
+        for (int i = 0; i < toMerge.size(); i++) {
+            TextEdit t = toMerge.get(i);
+            int l = t.getNewText() == null ? 0 : t.getNewText().length();
+            int nl = newEdit.getNewText() == null ? 0 : newEdit.getNewText().length();
+            if (adjustedEnd >= t.getStartOffset() + l) {
+                // whole text edit was deleted by newEdit
+                adjustedEnd += (t.getEndOffset() - t.getStartOffset());
+                // compensate for the inserted text
+                adjustedEnd -= l;
+            } else {
+                if (adjustedEnd > t.getStartOffset()) {
+                    // part of the t's text was deleted by newEdit, rest of text is appended to newEdit's text
+                    int delPart = adjustedEnd - t.getStartOffset();
+                    String nt = t.getNewText().substring(delPart);
+                    if (newEdit.getNewText() != null) {
+                        // this is probably unreachable from plain document events, since we have remove (so no insert can be done)
+                        nt = newEdit.getNewText() + t.getNewText().substring(delPart);
+                    } else {
+                        nt = t.getNewText().substring(delPart);
+                    }
+                    if (nt.isEmpty()) {
+                        nt = null;
+                    }
+                    TextEdit edit = new TextEdit(adjustedStart, t.getEndOffset(), nt);
+                    replaceOrderedEdits(toMerge, edit);
+                    condensed.add(edit);
+                    return;
+                } 
+                if (adjustedEnd + nl == t.getStartOffset()) {
+                    // t immediately follows newEdit, will be merged unless there are two deletes separeted by newEdit's text
+                    if (nl == 0 || (t.getEndOffset() == t.getStartOffset() && t.getNewText() != null)) {
+                        TextEdit edit = new TextEdit(adjustedStart, adjustedEnd, 
+                            nl == 0 ? "" : newEdit.getNewText() + t.getNewText());
+                        
+                        replaceOrderedEdits(toMerge, edit);
+                        condensed.add(edit);
+                        return;
+                    }
+                }
+                remainder = t;
+                break;
+            }
+        }
+        
+        TextEdit edit = new TextEdit(adjustedStart, adjustedEnd, newEdit.getNewText());
+        if (remainder != null) {
+            // unchanged, is in the ordered list
+            condensed.add(remainder);
+        } else {
+            replaceOrderedEdits(toMerge, edit);
+        }
+        condensed.add(edit);
+    }
+
+    /**
+     * Merges a subsequent `newEdit` with preceding `conflicting` one. Note that 'newEdit'
+     * is always a delete-only, or insert-only instruction as Swing Document reports only those.
+     * 
+     * @param newEdit
+     * @param conflicting 
+     */
+    private void mergePrecedingOverlap(TextEdit newEdit, TextEdit conflicting, int adjustedStart, Iterator<TextEdit> it) {
+        /*
+            |---------XXXXXXXX|
+                         cL
+                      ^
+                      conf.endOffset
+
+                      __ <- off    
+            |---------XXXXXXXX|
+                        |-------YYY|
+                          del    nL
+                        ^
+                      adjStart
+        */
+        // the overlapping edit just inserts, mold the insert into the previous one.
+        int del = newEdit.getEndOffset() - newEdit.getStartOffset();
+        String confText = conflicting.getNewText();
+        String newText = newEdit.getNewText();
+        int confLen = confText == null ? 0 : confText.length();
+        int off = adjustedStart - conflicting.getStartOffset(); //conflicting.getEndOffset();
+        
+        /*
+            |------XXXXXX|
+                     |YYY|
+                    |---YYY|
+        */
+        boolean deleteContained = conflicting.getStartOffset()+ confLen >= adjustedStart + del;
+        if (deleteContained) {
+            String text;
+            if (off == confLen) {
+                // just append
+                if (confText != null) {
+                    if (newText != null) {
+                        text = confText + newText;
+                    } else {
+                        text = confText;
+                    }
+                } else {
+                    text = newText;
+                }
+            } else {
+                if (newText != null) {
+                    if (confText != null) {
+                        text = confText.substring(0, off) + newText + confText.substring(off + del);
+                    } else {
+                        // should never happen, as confContext == null => confLen = 0 => off == confLenn
+                        text = newText + confText.substring(off + del);
+                    }
+                }  else {
+                    text = confText.substring(0, off) + confText.substring(off + del);
+                }
+            }
+            if (text != null && text.isEmpty()) {
+                text = null;
+            }
+            it.remove();
+            if (conflicting.getStartOffset() != conflicting.getEndOffset() || text != null) {
+                TextEdit edit = new TextEdit(conflicting.getStartOffset(), conflicting.getEndOffset(), text);
+                replaceOrderedEdits(Collections.singleton(conflicting), edit);
+                condensed.add(edit);
+            }
+            return;
+        }
+        
+        if (off == 0) {
+            /*
+                |------XXXXXX|
+                |------|
+                       |-----------YYY|
+            */
+            int mergeDel = conflicting.getEndOffset() - conflicting.getStartOffset() + (del - confLen);
+            it.remove();
+            TextEdit edit = new TextEdit(conflicting.getStartOffset(), 
+                    conflicting.getStartOffset() + mergeDel, newText);
+            replaceOrderedEdits(Collections.singleton(conflicting), edit);
+            condensed.add(edit);
+            return;
+        }
+        /*
+            |------XXXXXX|
+                     |-------YYY|
+        */
+        it.remove();
+        TextEdit edit = new TextEdit(conflicting.getStartOffset(), conflicting.getEndOffset(), 
+                confText.substring(0, off));
+        replaceOrderedEdits(Collections.singleton(conflicting), edit);
+        condensed.add(edit);
+        int del2 = del - (confLen - off);
+        
+        TextEdit edit2 = new TextEdit(adjustedStart, adjustedStart + del2, newText);
+        ordered.add(edit2);
+        condensed.add(edit2);
+    }
+}
diff --git a/java/maven.refactoring/src/org/netbeans/modules/maven/refactoring/dependency/MavenDependencyModifierImpl.java b/java/maven.refactoring/src/org/netbeans/modules/maven/refactoring/dependency/MavenDependencyModifierImpl.java
new file mode 100644
index 0000000000..2f7a94f440
--- /dev/null
+++ b/java/maven.refactoring/src/org/netbeans/modules/maven/refactoring/dependency/MavenDependencyModifierImpl.java
@@ -0,0 +1,122 @@
+/*
+ * 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.maven.refactoring.dependency;
+
+import java.util.Collections;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+import org.netbeans.api.lsp.TextDocumentEdit;
+import org.netbeans.api.lsp.TextEdit;
+import org.netbeans.api.lsp.WorkspaceEdit;
+import org.netbeans.api.project.Project;
+import org.netbeans.modules.maven.api.NbMavenProject;
+import org.netbeans.modules.project.dependency.DependencyChange;
+import org.netbeans.modules.project.dependency.DependencyChangeException;
+import org.netbeans.modules.project.dependency.DependencyChangeRequest;
+import org.netbeans.modules.project.dependency.ProjectOperationException;
+import org.netbeans.modules.project.dependency.Scope;
+import org.netbeans.modules.project.dependency.Scopes;
+import org.netbeans.modules.project.dependency.spi.ProjectDependencyModifier;
+import org.netbeans.spi.project.ProjectServiceProvider;
+import org.openide.filesystems.FileObject;
+import org.openide.filesystems.URLMapper;
+import org.openide.util.NbBundle;
+import org.openide.util.Union2;
+
+/**
+ *
+ * @author sdedic
+ */
+@ProjectServiceProvider(service = ProjectDependencyModifier.class, projectType = NbMavenProject.TYPE)
+public class MavenDependencyModifierImpl implements ProjectDependencyModifier {
+    private final Project project;
+
+    public MavenDependencyModifierImpl(Project project) {
+        this.project = project;
+    }
+    
+    static final Map<String, String> scope2Maven;
+    static final Map<String, Scope> maven2Scope;
+    
+    static {
+        scope2Maven = new HashMap<>();
+        scope2Maven.put(Scopes.PROCESS.name(), "compile");
+        scope2Maven.put(Scopes.COMPILE.name(), "compile");
+        scope2Maven.put(Scopes.RUNTIME.name(), "runtime");
+        scope2Maven.put(Scopes.TEST.name(), "test");
+        scope2Maven.put(Scopes.TEST_COMPILE.name(), "test");
+        scope2Maven.put(Scopes.TEST_RUNTIME.name(), "test");
+        scope2Maven.put(Scopes.EXTERNAL.name(), "provided");
+        
+        maven2Scope = new HashMap<>();
+        maven2Scope.put("compile", Scopes.COMPILE);
+        maven2Scope.put("runtime", Scopes.RUNTIME);
+        maven2Scope.put("test", Scopes.TEST);
+        maven2Scope.put("runtime", Scopes.RUNTIME);
+    }
+    
+
+    @NbBundle.Messages({
+        "# {0} - pom file",
+        "ERR_CannotModifyProject=Cannot modify POM {1}",
+        "ERR_UnsupportedOperation=Operation {0} is unsupported."
+    })
+    @Override
+    public Result computeChange(DependencyChangeRequest batch) throws DependencyChangeException {
+        List<TextEdit> edits = null;
+
+        RewriteContext rewrite = new RewriteContext(project);
+        for (DependencyChange request : batch.getOperations()) {
+        
+            switch (request.getKind()) {
+                case ADD:
+                    DependencyAdder adder = new DependencyAdder(project, request, rewrite);
+                    adder.execute();
+                    break;
+                default:
+                    throw new ProjectOperationException(project, ProjectOperationException.State.UNSUPPORTED, Bundle.ERR_UnsupportedOperation(request.getKind()));
+            }
+
+        }
+        edits = rewrite.createEdits();
+        if (edits == null) {
+            throw new ProjectOperationException(project, ProjectOperationException.State.UNSUPPORTED, Bundle.ERR_CannotModifyProject(rewrite.getPomFile()));
+        }
+        
+        TextDocumentEdit e = new TextDocumentEdit(URLMapper.findURL(rewrite.getPomFile(), URLMapper.EXTERNAL).toString(), edits);
+        WorkspaceEdit we = new WorkspaceEdit(Collections.singletonList(Union2.createFirst(e)));
+        return new Result() {
+            @Override
+            public String getId() {
+                return "maven-add-dependency";
+            }
+
+            @Override
+            public boolean suppresses(Result check) {
+                return false;
+            }
+
+            @Override
+            public WorkspaceEdit getWorkspaceEdit() {
+                return we;
+            }
+        };
+    }
+}
diff --git a/java/maven.refactoring/src/org/netbeans/modules/maven/refactoring/dependency/RewriteContext.java b/java/maven.refactoring/src/org/netbeans/modules/maven/refactoring/dependency/RewriteContext.java
new file mode 100644
index 0000000000..0ed5dfe566
--- /dev/null
+++ b/java/maven.refactoring/src/org/netbeans/modules/maven/refactoring/dependency/RewriteContext.java
@@ -0,0 +1,113 @@
+/*
+ * 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.maven.refactoring.dependency;
+
+import java.io.File;
+import java.io.IOException;
+import java.util.ArrayList;
+import java.util.List;
+import javax.swing.text.BadLocationException;
+import javax.swing.text.Document;
+import org.netbeans.api.editor.document.LineDocumentUtils;
+import org.netbeans.api.lsp.TextEdit;
+import org.netbeans.api.project.Project;
+import org.netbeans.modules.maven.api.NbMavenProject;
+import org.netbeans.modules.maven.model.pom.POMModel;
+import org.netbeans.modules.maven.model.pom.POMModelFactory;
+import org.netbeans.modules.project.dependency.Dependency;
+import org.netbeans.modules.xml.xam.ModelSource;
+import org.openide.cookies.EditorCookie;
+import org.openide.filesystems.FileObject;
+import org.openide.filesystems.FileUtil;
+import org.openide.util.lookup.Lookups;
+
+/**
+ *
+ * @author sdedic
+ */
+public class RewriteContext {
+    private final Project project;
+    private final FileObject pomFile;
+
+    private POMModel mutableModel;
+    private Document documentCopy;
+    private DocumentChangesConverter converter;
+
+    public RewriteContext(Project project) {
+        this.project = project;
+        this.pomFile = project.getLookup().lookup(FileObject.class);
+    }
+
+    public FileObject getPomFile() {
+        return pomFile;
+    }
+    
+    public POMModel getWriteModel() throws IOException {
+        if (mutableModel == null) {
+            createModel();
+        }
+        return mutableModel;
+    }
+    
+    public List<TextEdit> createEdits() {
+        return converter.makeTextEdits();
+    }
+    
+    public String mavenScope(Dependency d) {
+        if (d.getScope() == null) {
+            return "compile";
+        }
+        String ms = MavenDependencyModifierImpl.scope2Maven.get(d.getScope().name());
+        if (ms == null) {
+            return "compile";
+        } else {
+            return ms;
+        }
+    }
+
+    private void createModel() throws IOException {
+        NbMavenProject mp = project.getLookup().lookup(NbMavenProject.class);
+        FileObject pomFile = project.getLookup().lookup(FileObject.class);
+        EditorCookie cake = pomFile.getLookup().lookup(EditorCookie.class);
+        Document d = cake.openDocument();
+        
+        // create a copy of the document
+        Document copy = LineDocumentUtils.createDocument("text/pom+xml");
+        try {
+            copy.insertString(0, d.getText(0, d.getLength()), null);
+        } catch (BadLocationException ex) {
+            ex.printStackTrace();
+        }
+        copy.putProperty(Document.StreamDescriptionProperty, d.getProperty(Document.StreamDescriptionProperty));
+        documentCopy = copy;
+        converter = new DocumentChangesConverter(documentCopy);
+        copy.addDocumentListener(converter);
+        
+        List<Object> lkpContents = new ArrayList<>();
+        lkpContents.add(pomFile); 
+        lkpContents.add(copy);
+        File f = FileUtil.toFile(pomFile);
+        if (f != null) {
+            lkpContents.add(f);
+        }
+        
+        ModelSource ms = new ModelSource(Lookups.fixed(lkpContents.toArray()), true);
+        mutableModel = POMModelFactory.getDefault().getModel(ms);
+    }
+}
diff --git a/java/maven.refactoring/test/unit/data/simpleProject/pom-with-processor-broken.xml b/java/maven.refactoring/test/unit/data/simpleProject/pom-with-processor-broken.xml
new file mode 100644
index 0000000000..6c8fd68165
--- /dev/null
+++ b/java/maven.refactoring/test/unit/data/simpleProject/pom-with-processor-broken.xml
@@ -0,0 +1,77 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+
+    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.
+
+-->
+<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 https://maven.apache.org/xsd/maven-4.0.0.xsd">
+    <modelVersion>4.0.0</modelVersion>
+
+    <groupId>nbtest.grp</groupId>
+    <artifactId>test-app</artifactId>
+    <version>12.6</version>
+
+    <name>Test App</name>
+    <description>Test App</description>
+  
+    <dependencies>
+        <dependency>
+            <groupId>nbtest.grp</groupId>
+            <artifactId>annotation</artifactId>
+            <version>12.6</version>
+        </dependency>
+        <dependency>
+            <groupId>nbtest.grp</groupId>
+            <artifactId>test-lib</artifactId>
+            <version>12.6</version>
+        </dependency>
+        <dependency>
+            <groupId>nbtest.grp</groupId>
+            <artifactId>test-lib3</artifactId>
+            <scope>test</scope>
+            <version>12.6</version>
+        </dependency>
+    </dependencies>
+  
+    <build>
+        <!-- To use the plugin goals in your POM or parent POM -->
+        <plugins>
+            <plugin>
+                <groupId>org.apache.maven.plugins</groupId>
+                <artifactId>maven-compiler-plugin</artifactId>
+                <version>3.8.1</version>
+                <configuration>
+                    <annotationProcessorPaths>
+                        <path>
+                            <groupId>nbtest.grp</groupId>
+                            <artifactId>test-processor</artifactId>
+                            <version>12.6</version>
+                        </path>            
+                        <path>
+                            <groupId>nbtest.grp</groupId>
+                            <artifactId>foobar</artifactId>
+                            <version>12.6</version>
+                        </path>            
+                    </annotationProcessorPaths>
+                </configuration>
+            </plugin>
+        </plugins>
+    </build>
+
+</project>
+
diff --git a/java/maven.refactoring/test/unit/data/simpleProject/pom-with-processor.xml b/java/maven.refactoring/test/unit/data/simpleProject/pom-with-processor.xml
new file mode 100644
index 0000000000..4c07959647
--- /dev/null
+++ b/java/maven.refactoring/test/unit/data/simpleProject/pom-with-processor.xml
@@ -0,0 +1,77 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+
+    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.
+
+-->
+<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 https://maven.apache.org/xsd/maven-4.0.0.xsd">
+    <modelVersion>4.0.0</modelVersion>
+
+    <groupId>nbtest.grp</groupId>
+    <artifactId>test-app</artifactId>
+    <version>12.6</version>
+
+    <name>Test App</name>
+    <description>Test App</description>
+  
+    <dependencies>
+        <dependency>
+            <groupId>nbtest.grp</groupId>
+            <artifactId>annotation</artifactId>
+            <version>12.6</version>
+        </dependency>
+        <dependency>
+            <groupId>nbtest.grp</groupId>
+            <artifactId>test-lib</artifactId>
+            <version>12.6</version>
+        </dependency>
+        <dependency>
+            <groupId>nbtest.grp</groupId>
+            <artifactId>test-lib3</artifactId>
+            <scope>test</scope>
+            <version>12.6</version>
+        </dependency>
+    </dependencies>
+  
+    <build>
+        <!-- To use the plugin goals in your POM or parent POM -->
+        <plugins>
+            <plugin>
+                <groupId>org.apache.maven.plugins</groupId>
+                <artifactId>maven-compiler-plugin</artifactId>
+                <version>3.8.1</version>
+                <configuration>
+                    <annotationProcessorPaths>
+                        <path>
+                            <groupId>nbtest.grp</groupId>
+                            <artifactId>test-processor</artifactId>
+                            <version>12.6</version>
+                        </path>            
+                        <path>
+                            <groupId>nbtest.grp</groupId>
+                            <artifactId>test-lib2</artifactId>
+                            <version>12.6</version>
+                        </path>            
+                    </annotationProcessorPaths>
+                </configuration>
+            </plugin>
+        </plugins>
+    </build>
+
+</project>
+
diff --git a/java/maven.refactoring/test/unit/data/simpleProject/pom-with-separateProcessors.xml b/java/maven.refactoring/test/unit/data/simpleProject/pom-with-separateProcessors.xml
new file mode 100644
index 0000000000..14e3f0d026
--- /dev/null
+++ b/java/maven.refactoring/test/unit/data/simpleProject/pom-with-separateProcessors.xml
@@ -0,0 +1,111 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+
+    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.
+
+-->
+<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 https://maven.apache.org/xsd/maven-4.0.0.xsd">
+    <modelVersion>4.0.0</modelVersion>
+
+    <groupId>nbtest.grp</groupId>
+    <artifactId>test-app</artifactId>
+    <version>12.6</version>
+
+    <name>Test App</name>
+    <description>Test App</description>
+  
+    <dependencies>
+        <dependency>
+            <groupId>nbtest.grp</groupId>
+            <artifactId>annotation</artifactId>
+            <version>12.6</version>
+        </dependency>
+        <dependency>
+            <groupId>nbtest.grp</groupId>
+            <artifactId>test-lib</artifactId>
+            <version>12.6</version>
+        </dependency>
+        <dependency>
+            <groupId>nbtest.grp</groupId>
+            <artifactId>test-lib3</artifactId>
+            <scope>test</scope>
+            <version>12.6</version>
+        </dependency>
+    </dependencies>
+  
+    <build>
+        <!-- To use the plugin goals in your POM or parent POM -->
+        <plugins>
+            <plugin>
+                <groupId>org.apache.maven.plugins</groupId>
+                <artifactId>maven-compiler-plugin</artifactId>
+                <version>3.8.1</version>
+                <executions>
+                    <execution>
+                        <id>default-compile</id>
+                        <phase>compile</phase>
+                        <!--
+                        <goals>
+                            <goal>testCompile</goal>                            
+                        </goals>
+                        -->
+                        <configuration>
+                            <annotationProcessorPaths>
+                                <path>
+                                    <groupId>nbtest.grp</groupId>
+                                    <artifactId>test-processor</artifactId>
+                                    <version>12.6</version>
+                                </path>            
+                                <path>
+                                    <groupId>nbtest.grp</groupId>
+                                    <artifactId>test-lib2</artifactId>
+                                    <version>12.6</version>
+                                </path>            
+                            </annotationProcessorPaths>
+                        </configuration>
+                    </execution>
+                    <execution>
+                        <id>default-testCompile</id>
+                        <phase>test-compile</phase>
+                        <!--
+                        <goals>
+                            <goal>testCompile</goal>                            
+                        </goals>
+                        -->
+                        <configuration>
+                            <annotationProcessorPaths>
+                                <path>
+                                    <groupId>nbtest.grp</groupId>
+                                    <artifactId>test-processor</artifactId>
+                                    <version>12.6</version>
+                                </path>            
+                                <path>
+                                    <groupId>nbtest.grp</groupId>
+                                    <artifactId>test-lib4</artifactId>
+                                    <version>12.6</version>
+                                </path>            
+                            </annotationProcessorPaths>
+                        </configuration>
+                    </execution>
+                </executions>
+            </plugin>
+        </plugins>
+    </build>
+
+</project>
+
diff --git a/java/maven.refactoring/test/unit/data/simpleProject/pom.xml b/java/maven.refactoring/test/unit/data/simpleProject/pom.xml
new file mode 100644
index 0000000000..ff1b919c0b
--- /dev/null
+++ b/java/maven.refactoring/test/unit/data/simpleProject/pom.xml
@@ -0,0 +1,65 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+
+    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.
+
+-->
+<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 https://maven.apache.org/xsd/maven-4.0.0.xsd">
+    <modelVersion>4.0.0</modelVersion>
+
+    <groupId>nbtest.grp</groupId>
+    <artifactId>test-app</artifactId>
+    <version>12.6</version>
+
+    <name>Test App</name>
+    <description>Test App</description>
+
+    <dependencies>
+        <dependency>
+            <groupId>nbtest.grp</groupId>
+            <artifactId>annotation</artifactId>
+            <version>12.6</version>
+        </dependency>
+        <dependency>
+            <groupId>nbtest.grp</groupId>
+            <artifactId>test-lib</artifactId>
+            <version>13</version>
+        </dependency>
+        <dependency>
+            <groupId>nbtest.grp</groupId>
+            <artifactId>test-lib4</artifactId>
+            <version>12.6</version>
+            <scope>runtime</scope>
+        </dependency>
+        <dependency>
+            <groupId>nbtest.grp</groupId>
+            <artifactId>test-lib3</artifactId>
+            <scope>test</scope>
+            <version>12.6</version>
+        </dependency>
+    
+        <dependency>
+            <groupId>org.slf4j</groupId>
+            <artifactId>slf4j-jdk14</artifactId>
+            <version>1.7.36</version>
+            <scope>runtime</scope>
+        </dependency>
+
+    </dependencies>
+</project>
+
diff --git a/java/maven.refactoring/test/unit/data/simpleProject/src/main/java/README b/java/maven.refactoring/test/unit/data/simpleProject/src/main/java/README
new file mode 100644
index 0000000000..e4427aced7
--- /dev/null
+++ b/java/maven.refactoring/test/unit/data/simpleProject/src/main/java/README
@@ -0,0 +1 @@
+Placeholder file, to keep Git happy with otherwise empty dir.
diff --git a/java/maven.refactoring/test/unit/data/simpleProject/src/test/java/README b/java/maven.refactoring/test/unit/data/simpleProject/src/test/java/README
new file mode 100644
index 0000000000..e4427aced7
--- /dev/null
+++ b/java/maven.refactoring/test/unit/data/simpleProject/src/test/java/README
@@ -0,0 +1 @@
+Placeholder file, to keep Git happy with otherwise empty dir.
diff --git a/java/maven.refactoring/test/unit/src/org/netbeans/modules/maven/refactoring/dependency/DocumentChangesConverterTest.java b/java/maven.refactoring/test/unit/src/org/netbeans/modules/maven/refactoring/dependency/DocumentChangesConverterTest.java
new file mode 100644
index 0000000000..a9c75dc5d6
--- /dev/null
+++ b/java/maven.refactoring/test/unit/src/org/netbeans/modules/maven/refactoring/dependency/DocumentChangesConverterTest.java
@@ -0,0 +1,396 @@
+/*
+ * 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.maven.refactoring.dependency;
+
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.List;
+import javax.swing.text.BadLocationException;
+import javax.swing.text.DefaultStyledDocument;
+import javax.swing.text.Document;
+import javax.swing.text.Position;
+import org.netbeans.api.lsp.TextEdit;
+import org.netbeans.junit.NbTestCase;
+
+/**
+ *
+ * @author sdedic
+ */
+public class DocumentChangesConverterTest extends NbTestCase {
+
+    public DocumentChangesConverterTest(String name) {
+        super(name);
+    }
+    
+    private Document document;
+    private DocumentChangesConverter converter;
+
+    @Override
+    protected void setUp() throws Exception {
+        super.setUp();
+        document = new DefaultStyledDocument();
+        converter = new DocumentChangesConverter(document);
+        document.addDocumentListener(converter);
+    }
+    
+    public void testNoEdits() throws Exception {
+        assertEquals(Arrays.asList(), converter.makeTextEdits());
+    }
+    
+    private static final String CONTENT = 
+                "Lorem ipsum dolor sit amet, consectetuer adipiscing elit. Integer tempor. Ut tempus purus at lorem. "
+                + "Nulla pulvinar eleifend sem. Proin pede metus, vulputate nec, fermentum fringilla, vehicula vitae, "
+                + "justo. Nullam faucibus mi quis velit. Nullam justo enim, consectetuer nec, ullamcorper ac, vestibulum "
+                + "in, elit. Curabitur sagittis hendrerit ante. Sed vel lectus. Donec odio tempus molestie, porttitor "
+                + "ut, iaculis quis, sem. Cum sociis natoque penatibus et magnis dis parturient montes, nascetur "
+                + "ridiculus mus. Aenean vel massa quis mauris vehicula lacinia. Morbi leo mi, nonummy eget tristique non, "
+                + "rhoncus non leo. Duis bibendum, lectus ut viverra rhoncus, dolor nunc faucibus libero, eget facilisis "
+                + "enim ipsum id lacus. Maecenas aliquet accumsan leo. Cum sociis natoque penatibus et magnis dis parturient "
+                + "montes, nascetur ridiculus mus. Class aptent taciti sociosqu ad litora torquent per conubia nostra, per "
+                + "inceptos hymenaeos.\n";
+    
+    void insertInitialText() throws BadLocationException {
+        document.removeDocumentListener(converter);
+        document.insertString(0, CONTENT, null);
+        document.addDocumentListener(converter);
+    }
+    
+    public void testSeparateEdits() throws Exception {
+        insertInitialText();
+        document.insertString(0, "112233", null);
+        document.remove(41 + 6, 10);
+        document.remove(58 + 6 - 10, 7);
+        document.insertString(74 + 6 - 10 - 7, "Non ", null);
+        assertSeparateEdits();
+    }
+    
+    /**
+     * The positions reported to the converter shift as the document is being edited.
+     * So 2nd edit will not be observed on position 11, but position 11 + length of the previous insertion.
+     * Check that the converter successfully adjusts the positions to point to the original document locations.
+     */
+    public void testOriginalDocPositions() throws Exception {
+        insertInitialText();
+        List<Integer> wordPositions = new ArrayList<>();
+        List<Position> docPositions = new ArrayList<>();
+        for (int p = CONTENT.indexOf(' '); p != -1; p = CONTENT.indexOf(' ', p + 1)) {
+            wordPositions.add(p);
+            docPositions.add(document.createPosition(p));
+        }
+        wordPositions.add(document.getLength());
+        
+        boolean add = true;
+        int index = 0;
+        for (Position p : docPositions) {
+            if (add) {
+                document.insertString(p.getOffset(), "0123", null);
+            } else {
+                document.remove(p.getOffset(), (wordPositions.get(index + 1) - wordPositions.get(index)));
+            }
+            index++;
+        }
+        
+        List<TextEdit> edits = converter.makeTextEdits();
+        
+        for (int i = 0; i < edits.size(); i++) {
+            assertEquals((int)wordPositions.get(i), edits.get(i).getStartOffset());
+        }
+    }
+    
+    /**
+     * Checks that separate edits have their offsets adjusted accordingly
+     */
+    void assertSeparateEdits() throws Exception {
+        List<TextEdit> edits = converter.makeTextEdits();
+        assertEquals(4, edits.size());
+        
+        TextEdit first = edits.get(0);
+        TextEdit second = edits.get(1);
+        
+        assertEquals(0, first.getStartOffset());
+        assertEquals(0, first.getEndOffset());
+        assertEquals("112233", first.getNewText());
+        
+        assertEquals(41, second.getStartOffset());
+        assertEquals(41 + 10, second.getEndOffset());
+        assertNull(second.getNewText());
+        
+        TextEdit third = edits.get(2);
+        TextEdit fourth = edits.get(3);
+        
+        assertEquals("Integer", CONTENT.substring(third.getStartOffset(), third.getEndOffset()));
+        assertEquals(74, fourth.getStartOffset());
+    }
+    
+    /**
+     * Checks that random-ordered separate edits have their offsets adjusted accordingly and
+     * come out ordered.
+     */
+    public void testUnorderedSeparateEdits() throws Exception {
+        insertInitialText();
+        document.remove(41, 10);
+        document.insertString(74 - 10, "Non ", null);
+
+        document.insertString(0, "112233", null);
+        document.remove(58 + 6 - 10, 7);
+        
+        assertSeparateEdits();
+    }
+    
+    public void testCoalesceFollowingInsert() throws Exception {
+        insertInitialText();
+        document.insertString(0, "112233", null);
+        document.insertString(6, "445566", null);
+        
+        List<TextEdit> edits = converter.makeTextEdits();
+        assertEquals(1, edits.size());
+        
+        assertEquals("112233445566", edits.get(0).getNewText());
+    }
+
+    /**
+     * 
+     * Insert a text, and delete part of it
+     */
+    public void testInsertAndSmallDelete() throws Exception {
+        document.insertString(0, "112233", null);
+        document.remove(3, 2);
+        
+        List<TextEdit> edits = converter.makeTextEdits();
+        assertEquals(1, edits.size());
+        assertEquals("1123", edits.get(0).getNewText());
+        assertNoDelete(edits.get(0));
+    }
+
+    /**
+     * 
+     * Insert a text, and delete part of it
+     */
+    public void testInsertAndDeleteFromStart() throws Exception {
+        document.insertString(0, "112233", null);
+        document.remove(0, 3);
+        
+        List<TextEdit> edits = converter.makeTextEdits();
+        assertEquals(1, edits.size());
+        assertEquals("233", edits.get(0).getNewText());
+        assertNoDelete(edits.get(0));
+    }
+
+    /**
+     * 
+     * Insert a text, and delete part of it
+     */
+    public void testInsertAndDeleteToEnd() throws Exception {
+        document.insertString(0, "112233", null);
+        document.remove(3, 3);
+        
+        List<TextEdit> edits = converter.makeTextEdits();
+        assertEquals(1, edits.size());
+        assertEquals("112", edits.get(0).getNewText());
+        assertNoDelete(edits.get(0));
+    }
+
+    /**
+     * 
+     * Insert a text, and delete part of it
+     */
+    public void testInsertAndDeleteAfterEnd() throws Exception {
+        insertInitialText();
+        document.insertString(0, "112233", null);
+        document.remove(3, 5);
+        
+        // the first edit will be trimmed. The second edit will contain rest of the delete.
+        
+        List<TextEdit> edits = converter.makeTextEdits();
+        assertEquals(2, edits.size());
+        
+        TextEdit first = edits.get(0);
+        TextEdit second = edits.get(1);
+        
+        assertNull(second.getNewText());
+        assertNoDelete(first);
+        assertDeleteLength(second, 2);
+        assertEquals("112", first.getNewText());
+    }
+    
+    void assertNoDelete(TextEdit e) {
+        assertEquals(0, e.getEndOffset() - e.getStartOffset());
+    }
+    
+    void assertDeleteLength(TextEdit e, int l) {
+        assertEquals(l, e.getEndOffset() - e.getStartOffset());
+    }
+    
+    /**
+     * 
+     * Insert a text, and delete part of it
+     */
+    public void testInsertAndDeleteAll() throws Exception {
+        insertInitialText();
+        document.insertString(0, "112233", null);
+        document.remove(0, 6);
+        
+        List<TextEdit> edits = converter.makeTextEdits();
+        assertEquals(0, edits.size());
+    }
+    
+    /**
+     * Coalesces with an edit that continues right after, but was made in the past.
+     * @throws Exception 
+     */
+    public void testCoalesceReverseEdits() throws Exception {
+        insertInitialText();
+        document.insertString(3, "112233", null);
+        document.insertString(0, "000", null);
+
+        List<TextEdit> edits = converter.makeTextEdits();
+        assertEquals(1, edits.size());
+        assertEquals("000112233", edits.get(0).getNewText());
+    }
+
+    /**
+     * Partially delete from a start of prior edit
+     */
+    public void testMergeToNextEdit() throws Exception {
+        insertInitialText();
+        document.insertString(3, "112233", null);
+        document.remove(0, 5);
+        
+        List<TextEdit> edits = converter.makeTextEdits();
+        assertEquals(1, edits.size());
+        assertEquals("2233", edits.get(0).getNewText());
+    }
+    
+    /**
+     * Makes a replace at 6. Checks that a deletion that starts prior to 6
+     * and deletes part of the replacing text will mold into single 
+     * replace edit.
+     * @throws Exception 
+     */
+    public void testDeleteFromNextReplace() throws Exception {
+        insertInitialText();
+        
+        document.remove(6, 5);
+        document.insertString(6, "0123456", null);
+        List<TextEdit> edits = converter.makeTextEdits();
+        assertEquals(1, edits.size());
+        
+        document.remove(3, 6);
+        edits = converter.makeTextEdits();
+        assertEquals(1, edits.size());
+        assertEquals("3456", edits.get(0).getNewText());
+    }
+
+    /**
+     * Makes a replace at 6. Check that replace that starts prior to 6
+     * and deletes all replacing text will mold into a pure delete.
+     * @throws Exception 
+     */
+    public void testMergeDeleteReplaceFully() throws Exception {
+        insertInitialText();
+        
+        document.remove(6, 7);
+        document.insertString(6, "0123456", null);
+        List<TextEdit> edits = converter.makeTextEdits();
+        assertEquals(1, edits.size());
+        
+        document.remove(3, 3 + 7);
+        edits = converter.makeTextEdits();
+        assertEquals(1, edits.size());
+        
+        TextEdit first = edits.get(0);
+        assertNull(first.getNewText());
+        assertEquals(3 + 7, first.getEndOffset() - first.getStartOffset());
+    }
+    
+    /**
+     * Make two replaces (one follows other). Delete all text from one replace plus
+     * some of the text of the other
+     * @throws Exception 
+     */
+    public void testDeleteOneAndHalfEdits() throws Exception {
+        insertInitialText();
+        
+        document.remove(6, 7);
+        document.insertString(6, "0123456", null);
+        
+        List<TextEdit> edits = converter.makeTextEdits();
+        document.remove(6 + 7, 7);
+        document.insertString(6 + 7, "0123456", null);
+        
+        edits = converter.makeTextEdits();
+        assertEquals(2, edits.size());
+        
+        document.remove(3, 3 + 7 + 4);
+        edits = converter.makeTextEdits();
+        assertEquals(1, edits.size());
+        
+        TextEdit first = edits.get(0);
+        assertEquals("456", first.getNewText());
+        assertEquals(3, first.getStartOffset());
+        // deleted: 3 prior to the first replace, then 7 chars of the 1st replace,
+        // then additional 4 chars from the 2nd replace. 
+        // Will absorb the 1st replace (7 chars deleted) and merge with the 2nd
+        // (7 chars deleted)
+        assertEquals(3 + (3 + 7 + 7), first.getEndOffset());
+    }
+    
+    /**
+     * Make a replace in the document, then insert that immediately precedes the replace.
+     * These edits should merge into one.
+     */
+    public void testInsertBeforeReplace() throws Exception {
+        insertInitialText();
+        
+        document.remove(6, 7);
+        document.insertString(6, "0123456", null);
+
+        List<TextEdit> edits = converter.makeTextEdits();
+        assertEquals(1, edits.size());
+        document.insertString(6, "ABCD", null);
+        
+        edits = converter.makeTextEdits();
+        assertEquals(1, edits.size());
+        TextEdit first = edits.get(0);
+        assertEquals("ABCD0123456", first.getNewText());
+    }
+    
+    /**
+     * Make a replace in the text. Then, make another replace inside the newly 
+     * inserted text.
+     * 
+     * @throws Exception 
+     */
+    public void testReplaceFullyInsideReplace() throws Exception {
+        insertInitialText();
+        document.remove(6, 7);
+        document.insertString(6, "abcdefghijkl", null);
+        
+        
+        List<TextEdit> edits = converter.makeTextEdits();
+        assertEquals(1, edits.size());
+        document.remove(10, 3);
+        document.insertString(10, "EFG--", null);
+        edits = converter.makeTextEdits();
+        
+        assertEquals(1, edits.size());
+        TextEdit first = edits.get(0);
+        assertEquals("abcdEFG--hijkl", first.getNewText());
+    }
+}
diff --git a/java/maven.refactoring/test/unit/src/org/netbeans/modules/maven/refactoring/dependency/MavenDependencyModifierImplTest.java b/java/maven.refactoring/test/unit/src/org/netbeans/modules/maven/refactoring/dependency/MavenDependencyModifierImplTest.java
new file mode 100644
index 0000000000..09a7539ff4
--- /dev/null
+++ b/java/maven.refactoring/test/unit/src/org/netbeans/modules/maven/refactoring/dependency/MavenDependencyModifierImplTest.java
@@ -0,0 +1,162 @@
+/*
+ * 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.maven.refactoring.dependency;
+
+import java.util.Collections;
+import java.util.Optional;
+import static junit.framework.TestCase.assertNotNull;
+import org.apache.maven.project.MavenProject;
+import org.netbeans.api.lsp.WorkspaceEdit;
+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.maven.NbMavenProjectImpl;
+import org.netbeans.modules.maven.api.NbMavenProject;
+import org.netbeans.modules.project.dependency.ArtifactSpec;
+import org.netbeans.modules.project.dependency.Dependency;
+import org.netbeans.modules.project.dependency.DependencyChange;
+import org.netbeans.modules.project.dependency.DependencyChangeRequest;
+import org.netbeans.modules.project.dependency.DependencyResult;
+import org.netbeans.modules.project.dependency.ProjectDependencies;
+import org.netbeans.modules.project.dependency.ProjectModificationResult;
+import org.netbeans.modules.project.dependency.Scopes;
+import org.openide.filesystems.FileObject;
+import org.openide.filesystems.FileUtil;
+
+/**
+ *
+ * @author sdedic
+ */
+public class MavenDependencyModifierImplTest extends NbTestCase {
+
+    public MavenDependencyModifierImplTest(String name) {
+        super(name);
+    }
+    
+    private FileObject projectDir;
+    private Project project;
+
+    @Override
+    protected void tearDown() throws Exception {
+        super.tearDown();
+    }
+
+    @Override
+    protected void setUp() throws Exception {
+        super.setUp(); 
+        clearWorkDir();
+    }
+    
+    
+    
+    private Project makeProject(String subdir, String alternateBuildscript) throws Exception {
+        FileObject src = FileUtil.toFileObject(getDataDir()).getFileObject(subdir);
+        projectDir = FileUtil.copyFile(src, FileUtil.toFileObject(getWorkDir()), src.getNameExt());
+        if (alternateBuildscript != null) {
+            FileObject fo = src.getFileObject(alternateBuildscript);
+            FileObject target = projectDir.getFileObject("build.gradle");
+            if (target != null) {
+                target.delete();
+            }
+            fo.copy(projectDir, "build", "gradle");
+        }
+        
+        Project p = ProjectManager.getDefault().findProject(projectDir);
+        assertNotNull(p);
+        
+        OpenProjects.getDefault().open(new Project[] { p }, true);
+        OpenProjects.getDefault().openProjects().get();
+
+        this.project = p;
+        return p;
+    }
+
+    public void testSimpleAdd() throws Exception {
+        makeProject("simpleProject", null);
+        
+        DependencyResult res = ProjectDependencies.findDependencies(project, ProjectDependencies.newQuery(Scopes.DECLARED));
+        assertNotNull(res);
+
+        ArtifactSpec art = ArtifactSpec.make("io.micronaut", "micronaut-router", "4.1.12");
+        Dependency toAdd = Dependency.make(art, Scopes.COMPILE);
+        DependencyChange change = DependencyChange.builder(DependencyChange.Kind.ADD).
+                dependency(toAdd).
+                create();
+        ProjectModificationResult mod = ProjectDependencies.modifyDependencies(project, new DependencyChangeRequest(Collections.singletonList(change)));
+        mod.commit();
+        
+        NbMavenProjectImpl impl = project.getLookup().lookup(NbMavenProjectImpl.class);
+        impl.fireProjectReload().waitFinished();
+        
+        NbMavenProject mp = project.getLookup().lookup(NbMavenProject.class);
+        MavenProject p = mp.getMavenProject();
+        Optional<org.apache.maven.model.Dependency> opt = p.getDependencies().stream().filter(d -> "micronaut-router".equals(d.getArtifactId())).findAny();
+        assertTrue(opt.isPresent());
+        
+        org.apache.maven.model.Dependency d = opt.get();
+        assertEquals("compile", d.getScope());
+    }
+    
+    public void testAddRuntime() throws Exception {
+        makeProject("simpleProject", null);
+        ArtifactSpec art = ArtifactSpec.make("io.micronaut", "micronaut-router", "4.1.12");
+        Dependency toAdd = Dependency.make(art, Scopes.RUNTIME);
+        DependencyChange change = DependencyChange.builder(DependencyChange.Kind.ADD).
+                dependency(toAdd).
+                create();
+        ProjectModificationResult mod = ProjectDependencies.modifyDependencies(project, new DependencyChangeRequest(Collections.singletonList(change)));
+        mod.commit();
+        
+        NbMavenProjectImpl impl = project.getLookup().lookup(NbMavenProjectImpl.class);
+        impl.fireProjectReload().waitFinished();
+        
+        NbMavenProject mp = project.getLookup().lookup(NbMavenProject.class);
+        MavenProject p = mp.getMavenProject();
+        Optional<org.apache.maven.model.Dependency> opt = p.getDependencies().stream().filter(d -> "micronaut-router".equals(d.getArtifactId())).findAny();
+        org.apache.maven.model.Dependency d = opt.get();
+        assertEquals("runtime", d.getScope());
+    }
+    
+    public void testAddMultiple() throws Exception {
+        makeProject("simpleProject", null);
+        ArtifactSpec art = ArtifactSpec.make("io.micronaut", "micronaut-router", "4.1.12");
+        ArtifactSpec art2 = ArtifactSpec.make("io.micronaut", "micronaut-websocket", "4.1.12");
+        Dependency toAdd = Dependency.make(art, Scopes.RUNTIME);
+        Dependency toAdd2 = Dependency.make(art2, Scopes.RUNTIME);
+        DependencyChange change = DependencyChange.builder(DependencyChange.Kind.ADD).
+                dependency(toAdd, toAdd2).
+                create();
+
+        ProjectModificationResult mod = ProjectDependencies.modifyDependencies(project, new DependencyChangeRequest(Collections.singletonList(change)));
+        mod.commit();
+        
+        NbMavenProjectImpl impl = project.getLookup().lookup(NbMavenProjectImpl.class);
+        impl.fireProjectReload().waitFinished();
+        
+        NbMavenProject mp = project.getLookup().lookup(NbMavenProject.class);
+        MavenProject p = mp.getMavenProject();
+        Optional<org.apache.maven.model.Dependency> opt = p.getDependencies().stream().filter(d -> "micronaut-router".equals(d.getArtifactId())).findAny();
+        Optional<org.apache.maven.model.Dependency> opt2 = p.getDependencies().stream().filter(d -> "micronaut-websocket".equals(d.getArtifactId())).findAny();
+        org.apache.maven.model.Dependency d = opt.get();
+        org.apache.maven.model.Dependency d2 = opt2.get();
+        assertEquals("runtime", d.getScope());
+        assertEquals("runtime", d2.getScope());
+    }
+}
diff --git a/nbbuild/cluster.properties b/nbbuild/cluster.properties
index 45110038ad..6654632045 100644
--- a/nbbuild/cluster.properties
+++ b/nbbuild/cluster.properties
@@ -575,6 +575,7 @@ nb.cluster.java=\
         form.kit,\
         form.nb,\
         form.refactoring,\
+        gradle.dependencies,\
         gradle.htmlui,\
         gradle.java,\
         gradle.java.coverage,\


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