Ditch use of Files.createParentDirs() 10/104810/2
authorRobert Varga <robert.varga@pantheon.tech>
Thu, 9 Mar 2023 15:54:31 +0000 (16:54 +0100)
committerRobert Varga <robert.varga@pantheon.tech>
Thu, 9 Mar 2023 16:36:27 +0000 (17:36 +0100)
We have Files.createDirectories() which has a tad nicer behaviour,
use that instead of a Guava utility.

JIRA: YANGTOOLS-745
Change-Id: I766469340fe8628ed70a2dd933c89191f661f70f
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
plugin/yang-maven-plugin/src/main/java/org/opendaylight/yangtools/yang2sources/plugin/YangToSourcesProcessor.java

index 5262a53002393d53f3ea1aa279a3de071506966b..6467d4498c62d01429d9f49cd1a1e7034c6afe04 100644 (file)
@@ -81,13 +81,11 @@ class YangToSourcesProcessor {
         // copy project's src/main/yang/*.yang to ${project.builddir}/generated-sources/yang/META-INF/yang/
         // This honors setups like a Eclipse-profile derived one
         final var withMetaInf = new File(generatedYangDir, YangToSourcesProcessor.META_INF_YANG_STRING);
-        final var stateListBuilder = ImmutableList.<FileState>builderWithExpectedSize(modelsInProject.size());
+        Files.createDirectories(withMetaInf.toPath());
 
+        final var stateListBuilder = ImmutableList.<FileState>builderWithExpectedSize(modelsInProject.size());
         for (var source : modelsInProject) {
             final File file = new File(withMetaInf, source.getIdentifier().toYangFilename());
-            // FIXME: ditch this use
-            com.google.common.io.Files.createParentDirs(file);
-
             stateListBuilder.add(FileState.ofWrittenFile(file, source::copyTo));
             LOG.debug("Created file {} for {}", file, source.getIdentifier());
         }