{"record":{"id":"2a7753c2dfc1fad6","repo":"projectlombok/lombok","slug":"you-can-t-specify-both-from-attribute-and-nested","errorCode":null,"errorMessage":"You can't specify both 'from' attribute and nested filesets. You need one or the other.","messagePattern":"You can't specify both 'from' attribute and nested filesets\\. You need one or the other\\.","errorType":"exception","errorClass":"BuildException","httpStatus":null,"severity":"error","filePath":"src/delombok/lombok/delombok/ant/DelombokTaskImpl.java","lineNumber":51,"sourceCode":"\nimport org.apache.tools.ant.BuildException;\nimport org.apache.tools.ant.Location;\nimport org.apache.tools.ant.types.Path;\nimport org.apache.tools.ant.types.resources.FileResource;\n\npublic class DelombokTaskImpl {\n\tprivate File fromDir, toDir;\n\tprivate Path classpath;\n\tprivate Path sourcepath;\n\tprivate Path modulepath;\n\tprivate boolean verbose;\n\tprivate String encoding;\n\tprivate Path path;\n\tprivate List<String> formatOptions = new ArrayList<String>();\n\t\n\tpublic void execute(Location location) throws BuildException {\n\t\tif (fromDir == null && path == null) throw new BuildException(\"Either 'from' attribute, or nested <fileset> tags are required.\");\n\t\tif (fromDir != null && path != null) throw new BuildException(\"You can't specify both 'from' attribute and nested filesets. You need one or the other.\");\n\t\tif (toDir == null) throw new BuildException(\"The to attribute is required.\");\n\t\t\n\t\tDelombok delombok = new Delombok();\n\t\tif (verbose) delombok.setVerbose(true);\n\t\ttry {\n\t\t\tif (encoding != null) delombok.setCharset(encoding);\n\t\t} catch (UnsupportedCharsetException e) {\n\t\t\tthrow new BuildException(\"Unknown charset: \" + encoding, location);\n\t\t}\n\t\t\n\t\tif (classpath != null) delombok.setClasspath(classpath.toString());\n\t\tif (sourcepath != null) delombok.setSourcepath(sourcepath.toString());\n\t\tif (modulepath != null) delombok.setModulepath(modulepath.toString());\n\t\t\n\t\ttry {\n\t\t\tdelombok.setFormatPreferences(Delombok.formatOptionsToMap(formatOptions));\n\t\t} catch (InvalidFormatOptionException e) {\n\t\t\tthrow new BuildException(e.getMessage() + \" Run java -jar lombok.jar --format-help for detailed format help.\");","sourceCodeStart":33,"sourceCodeEnd":69,"githubUrl":"https://github.com/projectlombok/lombok/blob/6d6a3e9fec0a9555702561fbeb8eac836575116e/src/delombok/lombok/delombok/ant/DelombokTaskImpl.java#L33-L69","documentation":"DelombokTaskImpl.execute rejects mutually exclusive input specifications: `from` (single directory) and nested filesets cannot both be present, because the task would not know whether to scan one directory or the fileset list. Both set at once throws BuildException.","triggerScenarios":"An Ant `<delombok from=\"src\" to=\"out\">` that also contains `<fileset>` children; calling `setFrom(...)` and `createFileset()`/`setPath(...)` on the task instance programmatically.","commonSituations":"Merging two working delombok task definitions into one; adding a fileset to narrow the scan while forgetting to remove `from`.","solutions":["Remove the `from` attribute and keep the `<fileset>` elements, or","Remove the `<fileset>` elements and keep `from`","To narrow a `from` directory scan, switch entirely to filesets with include/exclude patterns"],"exampleFix":"<!-- before -->\n<delombok from=\"src/main/java\" to=\"out\">\n  <fileset dir=\"src/main/java\"><include name=\"**/*.java\"/></fileset>\n</delombok>\n<!-- after -->\n<delombok to=\"out\">\n  <fileset dir=\"src/main/java\"><include name=\"**/*.java\"/></fileset>\n</delombok>","handlingStrategy":"validation","validationCode":"if (fromDir != null && (path != null || hasFilesets)) throw new IllegalStateException(\"use from OR filesets, not both\");","typeGuard":null,"tryCatchPattern":"catch (BuildException e) { if (e.getMessage().contains(\"both 'from'\")) { /* remove one input spec */ } throw e; }","preventionTips":["Pick one input style per task and document it in the build","Review diffs that merge ant targets","Use include/exclude patterns in filesets instead of adding from"],"tags":["ant","build","mutually-exclusive","validation"],"backgroundTag":"mutually-exclusive-options","analyzedSha":"6d6a3e9fec0a9555702561fbeb8eac836575116e","analyzedAt":"2026-09-07T23:18:01.841Z","contentChangedAt":"2026-09-07T23:18:01.841Z","schemaVersion":2},"datasetVersion":"2026-09-16T09:17:16.951Z"}