public void execute()

in mps-maven-plugin/src/main/java/org/jetbrains/mps/mavenplugin/GenerateJavaMojo.java [76:131]


    public void execute() throws MojoExecutionException, MojoFailureException {
        List<String> compileSourceRoots = new ArrayList<>(mavenProject.getCompileSourceRoots());
        mavenProject.addCompileSourceRoot(outputDirectory.getPath());

        Map<ArtifactCoordinates, File> resolvedDependencies;

        try {
            resolvedDependencies = resolveDependencies(ObjectArrays.concat(mps, dependencies));
        } catch (DependencyResolutionException e) {
            throw new MojoExecutionException("Error resolving dependencies", e);
        }

        File temporaryWorkingDirectory = Files.createTempDir();

        try {
            Map<ArtifactCoordinates, File> extractedDependencies = extractDependencies(resolvedDependencies, temporaryWorkingDirectory);

            // Remove MPS from extracted dependencies so that its jars are not needlessly included into generator input libraries
            File mpsHome = extractedDependencies.remove(toCoordinates(mps));

            Dependency driver = new Dependency();
            driver.setGroupId(DRIVER_GROUP_ID);
            driver.setArtifactId(DRIVER_ARTIFACT_ID);
            driver.setVersion(this.mavenProject.getPlugin(MY_KEY).getVersion());

            DependencyResult dependencyResult = resolveSingleDependencyViaAether(driver);

            logResolutionResult(driver, dependencyResult);

            List<File> driverClassPath = new ArrayList<>();
            for (ArtifactResult artifactResult : dependencyResult.getArtifactResults()) {
                driverClassPath.add(artifactResult.getArtifact().getFile());
            }

            GeneratorStartupInfo startupInfo = new GeneratorStartupInfo(mpsHome,
                    "org.jetbrains.mps.maven.driver.Driver",
                    driverClassPath);

            Mps.launchMps(
                    startupInfo,
                    new GeneratorInput(
                            mavenProject.getBasedir(),
                            mavenProject.getArtifactId(),
                            modelsDirectory,
                            compileSourceRoots,
                            outputDirectory,
                            getJars(extractedDependencies.values()),
                            nameDependencies(mavenProject.getDependencyArtifacts())),
                    getLog());
        } catch (Exception e) {
            Throwables.propagateIfPossible(e, MojoExecutionException.class, MojoFailureException.class);
            throw new MojoExecutionException("Unexpected exception", e);
        } finally {
             tryDeletingDirectory(temporaryWorkingDirectory);
        }
    }