Fix yang.skip feature to include all files needed 80/41480/2
authorDavid <david.lopez.munoz@ericsson.com>
Thu, 7 Jul 2016 12:59:29 +0000 (14:59 +0200)
committerRobert Varga <nite@hq.sk>
Mon, 11 Jul 2016 13:11:28 +0000 (13:11 +0000)
The generation process, as a side-effect, is also including
some META-INF folders to the project final files. When
skipping the generation process, this inclusion must
be done separately

Change-Id: I1e2d2f48a2fc5b33c06ba83258a477b5a046ee08
Signed-off-by: David <david.lopez.munoz@ericsson.com>
yang/yang-maven-plugin/src/main/java/org/opendaylight/yangtools/yang2sources/plugin/ConfigArg.java
yang/yang-maven-plugin/src/main/java/org/opendaylight/yangtools/yang2sources/plugin/YangToSourcesProcessor.java

index f8d4781c9a7a75fde0388a0e68bfe8d87682364a..1ccbb30a21f104a1f2a855a821ab83597cf0ecd9 100644 (file)
@@ -46,6 +46,7 @@ public abstract class ConfigArg {
         private static final String TARGET_GENERATED_SOURCES = "target" + File.separator + "generated-sources";
         private static final String CODE_GEN_DEFAULT_RESOURCE_DIR = TARGET_GENERATED_SOURCES + File.separator + "spi";
         public static final String YANG_GENERATED_DIR = TARGET_GENERATED_SOURCES + File.separator + "yang";
+        public static final String YANG_SERVICES_GENERATED_DIR = TARGET_GENERATED_SOURCES + File.separator + "spi";
 
 
         private String codeGeneratorClass;
index 8b6c5c35373de9bab8700eb61a5b5957d57672fe..6c224dc51e7e3fb9db8dd5ffb59f7f881024428c 100644 (file)
@@ -50,6 +50,7 @@ class YangToSourcesProcessor {
     static final String LOG_PREFIX = "yang-to-sources:";
     static final String META_INF_YANG_STRING = "META-INF" + File.separator + "yang";
     static final String META_INF_YANG_STRING_JAR = "META-INF" + "/" + "yang";
+    static final String META_INF_YANG_SERVICES_STRING_JAR = "META-INF" + "/" + "services";
 
     private final File yangFilesRootDir;
     private final File[] excludedFiles;
@@ -100,6 +101,18 @@ class YangToSourcesProcessor {
     void conditionalExecute(boolean skip) throws MojoExecutionException, MojoFailureException {
         if (skip) {
             LOG.info("Skipping YANG code generation because property yang.skip is true");
+
+            // But manually add resources
+            // add META_INF/yang
+            yangProvider.addYangsToMetaInf(project, yangFilesRootDir, excludedFiles);
+
+            // add META_INF/services
+            File generatedServicesDir = new File(project.getBasedir(), CodeGeneratorArg.YANG_SERVICES_GENERATED_DIR);
+            yangProvider.setResource(generatedServicesDir, project);
+            LOG.debug("{} Yang services files from: {} marked as resources: {}", LOG_PREFIX, generatedServicesDir,
+                    META_INF_YANG_SERVICES_STRING_JAR);
+
+
         } else {
             execute();
         }