Java 类org.springframework.boot.loader.tools.MainClassFinder 实例源码

项目:https-github.com-g0t4-jenkins2-course-spring-boot    文件:FindMainClass.java   
private String findMainClass() {
    if (this.classesRoot == null) {
        throw new BuildException(
                "one of @mainClass or @classesRoot must be specified");
    }
    if (!this.classesRoot.exists()) {
        throw new BuildException(
                "@classesRoot " + this.classesRoot + " does not exist");
    }
    try {
        if (this.classesRoot.isDirectory()) {
            return MainClassFinder.findSingleMainClass(this.classesRoot);
        }
        return MainClassFinder.findSingleMainClass(new JarFile(this.classesRoot),
                "/");
    }
    catch (IOException ex) {
        throw new BuildException(ex);
    }
}
项目:https-github.com-g0t4-jenkins2-course-spring-boot    文件:AbstractRunMojo.java   
private String getStartClass() throws MojoExecutionException {
    String mainClass = this.mainClass;
    if (mainClass == null) {
        try {
            mainClass = MainClassFinder.findSingleMainClass(this.classesDirectory);
        }
        catch (IOException ex) {
            throw new MojoExecutionException(ex.getMessage(), ex);
        }
    }
    if (mainClass == null) {
        throw new MojoExecutionException("Unable to find a suitable main class, "
                + "please add a 'mainClass' property");
    }
    return mainClass;
}
项目:spring-boot-concourse    文件:FindMainClass.java   
private String findMainClass() {
    if (this.classesRoot == null) {
        throw new BuildException(
                "one of @mainClass or @classesRoot must be specified");
    }
    if (!this.classesRoot.exists()) {
        throw new BuildException(
                "@classesRoot " + this.classesRoot + " does not exist");
    }
    try {
        if (this.classesRoot.isDirectory()) {
            return MainClassFinder.findSingleMainClass(this.classesRoot);
        }
        return MainClassFinder.findSingleMainClass(new JarFile(this.classesRoot),
                "/");
    }
    catch (IOException ex) {
        throw new BuildException(ex);
    }
}
项目:spring-boot-concourse    文件:AbstractRunMojo.java   
private String getStartClass() throws MojoExecutionException {
    String mainClass = this.mainClass;
    if (mainClass == null) {
        try {
            mainClass = MainClassFinder.findSingleMainClass(this.classesDirectory);
        }
        catch (IOException ex) {
            throw new MojoExecutionException(ex.getMessage(), ex);
        }
    }
    if (mainClass == null) {
        throw new MojoExecutionException("Unable to find a suitable main class, "
                + "please add a 'mainClass' property");
    }
    return mainClass;
}
项目:contestparser    文件:FindMainClass.java   
private String findMainClass() {
    if (this.classesRoot == null) {
        throw new BuildException(
                "one of @mainClass or @classesRoot must be specified");
    }
    if (!this.classesRoot.exists()) {
        throw new BuildException(
                "@classesRoot " + this.classesRoot + " does not exist");
    }
    try {
        if (this.classesRoot.isDirectory()) {
            return MainClassFinder.findSingleMainClass(this.classesRoot);
        }
        return MainClassFinder.findSingleMainClass(new JarFile(this.classesRoot),
                "/");
    }
    catch (IOException ex) {
        throw new BuildException(ex);
    }
}
项目:contestparser    文件:AbstractRunMojo.java   
private String getStartClass() throws MojoExecutionException {
    String mainClass = this.mainClass;
    if (mainClass == null) {
        try {
            mainClass = MainClassFinder.findSingleMainClass(this.classesDirectory);
        }
        catch (IOException ex) {
            throw new MojoExecutionException(ex.getMessage(), ex);
        }
    }
    if (mainClass == null) {
        throw new MojoExecutionException("Unable to find a suitable main class, "
                + "please add a 'mainClass' property");
    }
    return mainClass;
}
项目:https-github.com-g0t4-jenkins2-course-spring-boot    文件:FindMainClassTask.java   
private String findMainClass() {
    Project project = getProject();

    String mainClass = null;

    // Try the SpringBoot extension setting
    SpringBootPluginExtension bootExtension = project.getExtensions()
            .getByType(SpringBootPluginExtension.class);
    if (bootExtension.getMainClass() != null) {
        mainClass = bootExtension.getMainClass();
    }

    ApplicationPluginConvention application = (ApplicationPluginConvention) project
            .getConvention().getPlugins().get("application");

    if (mainClass == null && application != null) {
        // Try the Application extension setting
        mainClass = application.getMainClassName();
    }

    JavaExec runTask = findRunTask(project);
    if (mainClass == null && runTask != null) {
        mainClass = runTask.getMain();
    }

    if (mainClass == null) {
        Task bootRunTask = project.getTasks().findByName("bootRun");
        if (bootRunTask != null) {
            mainClass = (String) bootRunTask.property("main");
        }
    }

    if (mainClass == null) {
        // Search
        if (this.mainClassSourceSetOutput != null) {
            project.getLogger().debug("Looking for main in: "
                    + this.mainClassSourceSetOutput.getClassesDir());
            try {
                mainClass = MainClassFinder.findSingleMainClass(
                        this.mainClassSourceSetOutput.getClassesDir());
                project.getLogger().info("Computed main class: " + mainClass);
            }
            catch (IOException ex) {
                throw new IllegalStateException("Cannot find main class", ex);
            }
        }
    }

    project.getLogger().info("Found main: " + mainClass);

    if (bootExtension.getMainClass() == null) {
        bootExtension.setMainClass(mainClass);
    }
    if (application != null && application.getMainClassName() == null) {
        application.setMainClassName(mainClass);
    }
    if (runTask != null && !runTask.hasProperty("main")) {
        runTask.setMain(mainClass);
    }

    return mainClass;
}
项目:spring-boot-concourse    文件:FindMainClassTask.java   
private String findMainClass() {
    Project project = getProject();

    String mainClass = null;

    // Try the SpringBoot extension setting
    SpringBootPluginExtension bootExtension = project.getExtensions()
            .getByType(SpringBootPluginExtension.class);
    if (bootExtension.getMainClass() != null) {
        mainClass = bootExtension.getMainClass();
    }

    ApplicationPluginConvention application = (ApplicationPluginConvention) project
            .getConvention().getPlugins().get("application");

    if (mainClass == null && application != null) {
        // Try the Application extension setting
        mainClass = application.getMainClassName();
    }

    JavaExec runTask = findRunTask(project);
    if (mainClass == null && runTask != null) {
        mainClass = runTask.getMain();
    }

    if (mainClass == null) {
        Task bootRunTask = project.getTasks().findByName("bootRun");
        if (bootRunTask != null) {
            mainClass = (String) bootRunTask.property("main");
        }
    }

    if (mainClass == null) {
        // Search
        if (this.mainClassSourceSetOutput != null) {
            project.getLogger().debug("Looking for main in: "
                    + this.mainClassSourceSetOutput.getClassesDir());
            try {
                mainClass = MainClassFinder.findSingleMainClass(
                        this.mainClassSourceSetOutput.getClassesDir());
                project.getLogger().info("Computed main class: " + mainClass);
            }
            catch (IOException ex) {
                throw new IllegalStateException("Cannot find main class", ex);
            }
        }
    }

    project.getLogger().info("Found main: " + mainClass);

    if (bootExtension.getMainClass() == null) {
        bootExtension.setMainClass(mainClass);
    }
    if (application != null && application.getMainClassName() == null) {
        application.setMainClassName(mainClass);
    }
    if (runTask != null && !runTask.hasProperty("main")) {
        runTask.setMain(mainClass);
    }

    return mainClass;
}
项目:contestparser    文件:FindMainClassTask.java   
private String findMainClass() {
    Project project = getProject();

    String mainClass = null;

    // Try the SpringBoot extension setting
    SpringBootPluginExtension bootExtension = project.getExtensions()
            .getByType(SpringBootPluginExtension.class);
    if (bootExtension.getMainClass() != null) {
        mainClass = bootExtension.getMainClass();
    }

    ApplicationPluginConvention application = (ApplicationPluginConvention) project
            .getConvention().getPlugins().get("application");

    if (mainClass == null && application != null) {
        // Try the Application extension setting
        mainClass = application.getMainClassName();
    }

    Task runTask = project.getTasks().findByName("run");
    if (mainClass == null && runTask != null) {
        mainClass = (String) runTask.property("main");
    }

    if (mainClass == null) {
        Task bootRunTask = project.getTasks().findByName("bootRun");
        if (bootRunTask != null) {
            mainClass = (String) bootRunTask.property("main");
        }
    }

    if (mainClass == null) {
        // Search
        if (this.mainClassSourceSetOutput != null) {
            project.getLogger().debug("Looking for main in: "
                    + this.mainClassSourceSetOutput.getClassesDir());
            try {
                mainClass = MainClassFinder.findSingleMainClass(
                        this.mainClassSourceSetOutput.getClassesDir());
                project.getLogger().info("Computed main class: " + mainClass);
            }
            catch (IOException ex) {
                throw new IllegalStateException("Cannot find main class", ex);
            }
        }
    }

    project.getLogger().info("Found main: " + mainClass);

    if (bootExtension.getMainClass() == null) {
        bootExtension.setMainClass(mainClass);
    }
    if (application != null && application.getMainClassName() == null) {
        application.setMainClassName(mainClass);
    }
    if (runTask != null && !runTask.hasProperty("main")) {
        runTask.setProperty("main", mainClass);
    }

    return mainClass;
}