From: David Date: Thu, 7 Jul 2016 12:59:29 +0000 (+0200) Subject: Fix yang.skip feature to include all files needed X-Git-Tag: release/boron~73 X-Git-Url: https://git.opendaylight.org/gerrit/gitweb?a=commitdiff_plain;h=e29a2562c7403936a7b64617d6c3deacded43669;p=yangtools.git Fix yang.skip feature to include all files needed 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 --- diff --git a/yang/yang-maven-plugin/src/main/java/org/opendaylight/yangtools/yang2sources/plugin/ConfigArg.java b/yang/yang-maven-plugin/src/main/java/org/opendaylight/yangtools/yang2sources/plugin/ConfigArg.java index f8d4781c9a..1ccbb30a21 100644 --- a/yang/yang-maven-plugin/src/main/java/org/opendaylight/yangtools/yang2sources/plugin/ConfigArg.java +++ b/yang/yang-maven-plugin/src/main/java/org/opendaylight/yangtools/yang2sources/plugin/ConfigArg.java @@ -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; diff --git a/yang/yang-maven-plugin/src/main/java/org/opendaylight/yangtools/yang2sources/plugin/YangToSourcesProcessor.java b/yang/yang-maven-plugin/src/main/java/org/opendaylight/yangtools/yang2sources/plugin/YangToSourcesProcessor.java index 8b6c5c3537..6c224dc51e 100644 --- a/yang/yang-maven-plugin/src/main/java/org/opendaylight/yangtools/yang2sources/plugin/YangToSourcesProcessor.java +++ b/yang/yang-maven-plugin/src/main/java/org/opendaylight/yangtools/yang2sources/plugin/YangToSourcesProcessor.java @@ -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(); }