Fix for Bug 114.
[yangtools.git] / yang / yang-maven-plugin / src / main / java / org / opendaylight / yangtools / yang2sources / plugin / YangToSourcesMojo.java
index 174e2acf5f571902a7dad7f873079a689b22449f..933b0d58e82e82bbd9e6047e2af496c3c9a50759 100644 (file)
@@ -27,6 +27,9 @@ import org.opendaylight.yangtools.yang.parser.impl.YangParserImpl;
 import org.opendaylight.yangtools.yang2sources.plugin.ConfigArg.CodeGeneratorArg;
 import org.opendaylight.yangtools.yang2sources.spi.CodeGenerator;
 import org.slf4j.impl.StaticLoggerBinder;
+import org.sonatype.aether.RepositorySystem;
+import org.sonatype.aether.RepositorySystemSession;
+import org.sonatype.aether.repository.RemoteRepository;
 import org.sonatype.plexus.build.incremental.BuildContext;
 
 import com.google.common.annotations.VisibleForTesting;
@@ -46,6 +49,7 @@ import com.google.common.annotations.VisibleForTesting;
  */
 @Mojo(name = "generate-sources", defaultPhase = LifecyclePhase.GENERATE_SOURCES, requiresDependencyResolution = ResolutionScope.COMPILE, requiresProject = true)
 public final class YangToSourcesMojo extends AbstractMojo {
+    public static final String PLUGIN_NAME = "org.opendaylight.yangtools:yang-maven-plugin";
 
     /**
      * Classes implementing {@link CodeGenerator} interface. An instance will be
@@ -78,6 +82,16 @@ public final class YangToSourcesMojo extends AbstractMojo {
 
     private YangToSourcesProcessor yangToSourcesProcessor;
 
+    @Component
+    private RepositorySystem repoSystem;
+
+    @Parameter( readonly = true, defaultValue = "${repositorySystemSession}" )
+    private RepositorySystemSession repoSession;
+
+    @Parameter( readonly = true, defaultValue = "${project.remoteProjectRepositories}" )
+    private List<RemoteRepository> remoteRepos;
+
+
     public YangToSourcesMojo() {
 
     }
@@ -94,6 +108,9 @@ public final class YangToSourcesMojo extends AbstractMojo {
     @Override
     public void execute() throws MojoExecutionException, MojoFailureException {
         StaticLoggerBinder.getSingleton().setMavenLog(this.getLog());
+
+        Util.checkClasspath(project, getLog(), repoSystem, repoSession, remoteRepos);
+
         if (yangToSourcesProcessor == null) {
             List<CodeGeneratorArg> codeGeneratorArgs = processCodeGenerators(codeGenerators);