# dir

abstract fun dir(path: Any): File(source)

Registers an output directory.

For an absolute path, the location is registered as an output directory of the TransformAction. The path must to point to the InputArtifact, or point inside the input artifact if it is a directory. Example:

    import org.gradle.api.artifacts.transform.TransformParameters;

    public abstract class MyTransform implements TransformAction<TransformParameters.None> {
        @InputArtifact
        public abstract Provider<FileSystemLocation> getInputArtifact();
        @Override
        public void transform(TransformOutputs outputs) {
            outputs.dir(getInputArtifact().get().getAsFile());
            outputs.dir(new File(getInputArtifact().get().getAsFile(), "sub-dir"));
        }
    }

Content copied to clipboard

For a relative path, Gradle creates an output directory into which the TransformAction must place its output files. Example:

    import org.gradle.api.artifacts.transform.TransformParameters;

    public abstract class MyTransform implements TransformAction<TransformParameters.None> {
        @Override
        public void transform(TransformOutputs outputs) {
            File myOutput = outputs.dir("my-output");
            Files.write(myOutput.toPath().resolve("file.txt"), "Generated text");
        }
    }

Content copied to clipboard

Note: it is an error if the registered directory does not exist when the transform method finishes.

#### Return

determined location of the output

#### Since

5.3

#### Parameters

path

path of the output directory