projectlombok / lombok

Very spicy additions to the Java programming language.
https://projectlombok.org/
Other
12.86k stars 2.38k forks source link

[FEATURE] Add Ant support for noCopy, onlyChanged, etc. #3269

Open HarrisonMc555 opened 2 years ago

HarrisonMc555 commented 2 years ago

Describe the feature The Delombok Ant task supports setting the classpath, source path, verbosity, encoding, etc. However, several features have been added to the Delombok class that are not currently supported in the Ant Task. These include noCopy and onlyChanged.

I recently followed the instructions here and was able to get the Delombok task running in my current Ant project. However, I also wanted to add support for only running Delombok on changed files. Unfortunately, since the onlyChanged feature is not supported in the Ant task, I can't do that.

Describe the target audience Users who have Ant projects and want to use the new features Delombok features with the Delombok Ant task. This is especially useful for creating Javadocs.

Additional context I'm willing to implement support for this if you're open to accepting a pull request.

HarrisonMc555 commented 2 years ago

It actually didn't look too hard, so I made a quick patch. I wasn't able to get Lombok to compile on my machine so I can't say for sure if it works or not.

diff --git a/src/delombok/lombok/delombok/ant/DelombokTask.java b/src/delombok/lombok/delombok/ant/DelombokTask.java
index 7c585836..248ae46f 100644
--- a/src/delombok/lombok/delombok/ant/DelombokTask.java
+++ b/src/delombok/lombok/delombok/ant/DelombokTask.java
@@ -78,6 +78,8 @@ class Tasks {
        private Path sourcepath;
        private Path modulepath;
        private boolean verbose;
+       private boolean noCopy;
+       private boolean onlyChanged;
        private String encoding;
        private Path path;
        private List<Format> formatOptions = new ArrayList<Format>();
@@ -144,6 +146,14 @@ class Tasks {
        public void setVerbose(boolean verbose) {
            this.verbose = verbose;
        }
+
+       public void setNoCopy(boolean noCopy) {
+           this.noCopy = noCopy;
+       }
+
+       public void setOnlyChanged(boolean onlyChanged) {
+           this.onlyChanged = onlyChanged;
+       }

        public void setEncoding(String encoding) {
            this.encoding = encoding;
diff --git a/src/delombok/lombok/delombok/ant/DelombokTaskImpl.java b/src/delombok/lombok/delombok/ant/DelombokTaskImpl.java
index bd2f93e7..2c5a0005 100644
--- a/src/delombok/lombok/delombok/ant/DelombokTaskImpl.java
+++ b/src/delombok/lombok/delombok/ant/DelombokTaskImpl.java
@@ -42,6 +42,8 @@ public class DelombokTaskImpl {
    private Path sourcepath;
    private Path modulepath;
    private boolean verbose;
+   private boolean noCopy;
+   private boolean onlyChanged;
    private String encoding;
    private Path path;
    private List<String> formatOptions = new ArrayList<String>();
@@ -62,6 +64,8 @@ public class DelombokTaskImpl {
        if (classpath != null) delombok.setClasspath(classpath.toString());
        if (sourcepath != null) delombok.setSourcepath(sourcepath.toString());
        if (modulepath != null) delombok.setModulepath(modulepath.toString());
+       if (noCopy || onlyChanged) delombok.setNoCopy(true);
+       if (onlyChanged) delombok.setOnlyChanged(true);

        try {
            delombok.setFormatPreferences(Delombok.formatOptionsToMap(formatOptions));