// 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 File withMetaInf = new File(generatedYangDir, YangToSourcesProcessor.META_INF_YANG_STRING);
- withMetaInf.mkdirs();
for (YangTextSchemaSource source : modelsInProject) {
final String fileName = source.getIdentifier().toYangFilename();
final File file = new File(withMetaInf, fileName);
+ Files.createParentDirs(file);
source.copyTo(Files.asByteSink(file));
LOG.debug("Created file {} for {}", file, source.getIdentifier());
import com.google.common.annotations.VisibleForTesting;
import com.google.common.collect.Collections2;
import com.google.common.collect.ImmutableList;
+import edu.umd.cs.findbugs.annotations.SuppressFBWarnings;
import java.io.File;
import java.util.Arrays;
import java.util.Collection;
private String yangSkip;
public YangToSourcesMojo() {
- }
- public void setProject(final MavenProject project) {
- this.project = project;
}
@VisibleForTesting
this.yangToSourcesProcessor = processor;
}
+ public void setProject(final MavenProject project) {
+ this.project = project;
+ }
+
@Override
+ @SuppressFBWarnings(value = "UWF_FIELD_NOT_INITIALIZED_IN_CONSTRUCTOR", justification = "yangFilesRootDir")
public void execute() throws MojoExecutionException, MojoFailureException {
Util.checkClasspath(project, repoSystem, localRepository, remoteRepos);
import org.opendaylight.yangtools.yang.model.parser.api.YangParser;
import org.opendaylight.yangtools.yang.model.parser.api.YangParserException;
import org.opendaylight.yangtools.yang.model.parser.api.YangParserFactory;
+import org.opendaylight.yangtools.yang.model.parser.api.YangSyntaxErrorException;
+import org.opendaylight.yangtools.yang.model.repo.api.SchemaSourceException;
import org.opendaylight.yangtools.yang.model.repo.api.StatementParserMode;
import org.opendaylight.yangtools.yang.model.repo.api.YangTextSchemaSource;
import org.opendaylight.yangtools.yang.parser.rfc7950.repo.ASTSchemaSource;
LOG.info("{} Project model files found: {}", LOG_PREFIX, yangFilesInProject.size());
final ProcessorModuleReactor reactor = new ProcessorModuleReactor(parser, sourcesInProject, dependencies);
- LOG.debug("Initialized reactor {}", reactor, yangFilesInProject);
+ LOG.debug("Initialized reactor {} with {}", reactor, yangFilesInProject);
return Optional.of(reactor);
- } catch (Exception e) {
+ } catch (IOException | SchemaSourceException | YangSyntaxErrorException | RuntimeException e) {
// MojoExecutionException is thrown since execution cannot continue
LOG.error("{} Unable to parse YANG files from {}", LOG_PREFIX, yangFilesRootDir, e);
Throwable rootCause = Throwables.getRootCause(e);
}
if (!thrown.isEmpty()) {
- String message = " One or more code generators failed, including failed list(generatorClass=exception) ";
- LOG.error("{}{}{}", LOG_PREFIX, message, thrown.toString());
- throw new MojoFailureException(LOG_PREFIX + message + thrown.toString());
+ LOG.error("{} One or more code generators failed, including failed list(generatorClass=exception) {}",
+ LOG_PREFIX, thrown);
+ throw new MojoFailureException(LOG_PREFIX
+ + " One or more code generators failed, including failed list(generatorClass=exception) " + thrown);
}
}