Example usage for org.eclipse.jdt.internal.compiler.env AutomaticModuleNaming determineAutomaticModuleName

List of usage examples for org.eclipse.jdt.internal.compiler.env AutomaticModuleNaming determineAutomaticModuleName

Introduction

In this page you can find the example usage for org.eclipse.jdt.internal.compiler.env AutomaticModuleNaming determineAutomaticModuleName.

Prototype

public static char[] determineAutomaticModuleName(final String fileName, boolean isFile, Manifest manifest) 

Source Link

Document

Determine the automatic module name of a given jar or project as specified in <a href= * "http://download.java.net/java/jdk9/docs/api/java/lang/module/ModuleFinder.html#of-java.nio.file.Path...-"> * ModuleFinder.of</a>

Usage

From source file:org.eclipse.m2e.jdt.internal.InternalModuleSupport.java

License:Open Source License

private static String getModuleNameFromProject(IPath projectPath, IProgressMonitor monitor) {
    IJavaProject project = getJavaProject(projectPath);
    String module = null;//w  w w.j  ava2s .c o  m
    if (project != null) {
        try {
            if (project.getModuleDescription() == null) {
                String buildName = null;
                IMavenProjectFacade facade = MavenPlugin.getMavenProjectRegistry()
                        .getProject(project.getProject());
                if (facade != null) {
                    MavenProject mavenProject = facade.getMavenProject(monitor);
                    if (mavenProject != null) {
                        buildName = mavenProject.getBuild().getFinalName();
                    }
                }
                if (buildName == null || buildName.isEmpty()) {
                    buildName = project.getElementName();
                }
                module = new String(AutomaticModuleNaming.determineAutomaticModuleName(buildName, false, null));
            } else {
                module = project.getModuleDescription().getElementName();
            }
        } catch (CoreException ex) {
            log.error(ex.getMessage(), ex);
        }
    }
    return module;
}