Remove GeneratedDirectories 96/104796/1
authorRobert Varga <robert.varga@pantheon.tech>
Tue, 7 Mar 2023 22:28:31 +0000 (23:28 +0100)
committerRobert Varga <robert.varga@pantheon.tech>
Tue, 7 Mar 2023 22:31:34 +0000 (23:31 +0100)
GeneratedDirectories is useless as a separate object because its
instance methods have a single caller site. Inline the users, so we
remove one level of indirection.

This exposes the duplication of "generated-sources" name, which needs to
be further centralized, depending on how things pan out looking.

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

diff --git a/plugin/yang-maven-plugin/src/main/java/org/opendaylight/yangtools/yang2sources/plugin/GeneratedDirectories.java b/plugin/yang-maven-plugin/src/main/java/org/opendaylight/yangtools/yang2sources/plugin/GeneratedDirectories.java
deleted file mode 100644 (file)
index 4937124..0000000
+++ /dev/null
@@ -1,36 +0,0 @@
-/*
- * Copyright (c) 2017 Red Hat, Inc. and others. All rights reserved.
- *
- * This program and the accompanying materials are made available under the
- * terms of the Eclipse Public License v1.0 which accompanies this distribution,
- * and is available at http://www.eclipse.org/legal/epl-v10.html
- */
-package org.opendaylight.yangtools.yang2sources.plugin;
-
-import java.io.File;
-import org.apache.maven.project.MavenProject;
-
-/**
- * Utility to obtain the correct path to generated directories.
- * It's important that this does not hard-code "target/" anywhere, but uses
- * ${project.build.directory}/, to make target-ide/ possible.
- *
- * @author Michael Vorburger.ch
- */
-class GeneratedDirectories {
-
-    private final File targetGeneratedSources;
-
-    GeneratedDirectories(MavenProject project) {
-        this.targetGeneratedSources = new File(project.getBuild().getDirectory(), "generated-sources");
-    }
-
-    public File getYangServicesDir() {
-        return new File(targetGeneratedSources, "spi");
-    }
-
-    public File getYangDir() {
-        return new File(targetGeneratedSources, "yang");
-    }
-
-}
index 26fa900b05b6fc4cac8796ac3c94ca08b0e589f8..87da24b78a72b920bd4177212bc8b9b1c2ffc70f 100644 (file)
@@ -26,7 +26,10 @@ abstract class YangProvider {
         Collection<FileState> addYangsToMetaInf(final MavenProject project,
                 final Collection<YangTextSchemaSource> modelsInProject) throws IOException {
 
-            final File generatedYangDir = new GeneratedDirectories(project).getYangDir();
+            final File generatedYangDir =
+                // FIXME: why are we generating these in "generated-sources"? At the end of the day YANG files are more
+                //        resources (except we do not them to be subject to filtering)
+                new File(new File(project.getBuild().getDirectory(), "generated-sources"), "yang");
             LOG.debug("Generated dir {}", generatedYangDir);
 
             // copy project's src/main/yang/*.yang to ${project.builddir}/generated-sources/yang/META-INF/yang/
index 58f9a24089468e6d870b87e4af058bb69d299db6..7fc0df6c85c5bb978985bddead6c85f9e29c78f6 100644 (file)
@@ -269,7 +269,7 @@ class YangToSourcesProcessor {
         }
 
         // add META_INF/services
-        File generatedServicesDir = new GeneratedDirectories(project).getYangServicesDir();
+        File generatedServicesDir = new File(new File(project.getBuild().getDirectory(), "generated-sources"), "spi");
         YangProvider.setResource(generatedServicesDir, project);
         LOG.debug("{} Yang services files from: {} marked as resources: {}", LOG_PREFIX, generatedServicesDir,
             META_INF_YANG_SERVICES_STRING_JAR);