public void execute()

in src/main/java/org/apache/dolphinscheduler/maven/DolphinDescriptorGenerator.java [62:109]


    public void execute()
            throws MojoExecutionException
    {
        File spiServicesFile = new File(servicesDirectory, pluginClassName);

        // If users have already provided their own service file then we will not overwrite it
        if (spiServicesFile.exists()) {
            return;
        }

        if (!spiServicesFile.getParentFile().exists()) {
            File file = spiServicesFile.getParentFile();
            file.mkdirs();
            if (!file.isDirectory()) {
                throw new MojoExecutionException(String.format("%n%nFailed to create directory: %s", file));
            }
        }

        List<Class<?>> pluginImplClasses;
        try {
            URLClassLoader loader = createCLFromCompileTimeDependencies();
            pluginImplClasses = findPluginImplClasses(loader);
        }
        catch (Exception e) {
            throw new MojoExecutionException(String.format("%n%nError for find the classes that implements %s.", pluginClassName), e);
        }

        if (pluginImplClasses.isEmpty()) {
            throw new MojoExecutionException(String.format("%n%nNot find classes implements %s, You must have at least one class that implements %s.", pluginClassName, pluginClassName));
        }

        if (pluginImplClasses.size() > 1) {
            StringBuilder sb = new StringBuilder();
            for (Class<?> pluginClass : pluginImplClasses) {
                sb.append(pluginClass.getName()).append(LS_ALIAS);
            }
            throw new MojoExecutionException(String.format("%n%nFound more than one class that implements %s:%n%n%s%nYou can only have one per plugin project.", pluginClassName, sb));
        }

        try {
            Class<?> pluginClass = pluginImplClasses.get(0);
            Files.write(spiServicesFile.toPath(), pluginClass.getName().getBytes(UTF_8));
            getLog().info(String.format("Wrote %s to %s", pluginClass.getName(), spiServicesFile));
        }
        catch (IOException e) {
            throw new MojoExecutionException("Failed to write services JAR file.", e);
        }
    }