public static IModule createAutomatic(String fileName, boolean isFile, Manifest manifest) { return createAutomatic(AutomaticModuleNaming.determineAutomaticModuleName(fileName, isFile, manifest)); } }
public static IModule createAutomatic(String fileName, boolean isFile, Manifest manifest) { boolean fromManifest = true; char[] inferredName = AutomaticModuleNaming.determineAutomaticModuleNameFromManifest(manifest); if (inferredName == null) { fromManifest = false; inferredName = AutomaticModuleNaming.determineAutomaticModuleNameFromFileName(fileName, true, isFile); } return createAutomatic(inferredName, fromManifest); } }
/** * Determine the automatic module name of a given jar or project as specified in {@link <a href= * "http://download.java.net/java/jdk9/docs/api/java/lang/module/ModuleFinder.html#of-java.nio.file.Path...-"> * ModuleFinder.of</a>} * @param fileName names either a jar file or a java project in the workspace * @param isFile <code>true</code> indicates that fileName denotes a file, <code>false</code> must be used for projects * @param manifest representation of the META-INF/MANIFEST.MF entry within the given source (jar or project), or <code>null</code> * @return the derived module name or <code>null</code> */ public static char[] determineAutomaticModuleName(final String fileName, boolean isFile, Manifest manifest) { if (manifest != null) { String automaticModuleName = manifest.getMainAttributes().getValue(AUTOMATIC_MODULE_NAME); if (automaticModuleName != null) { return automaticModuleName.toCharArray(); } } return determineAutomaticModuleNameFromFileName(fileName, true, isFile); }
/** * Determine the automatic module name of a given jar or project as specified in {@link <a href= * "http://download.java.net/java/jdk9/docs/api/java/lang/module/ModuleFinder.html#of-java.nio.file.Path...-"> * ModuleFinder.of</a>} * @param fileName names either a jar file or a java project in the workspace * @param isFile <code>true</code> indicates that fileName denotes a file, <code>false</code> must be used for projects * @param manifest representation of the META-INF/MANIFEST.MF entry within the given source (jar or project), or <code>null</code> * @return the derived module name or <code>null</code> */ public static char[] determineAutomaticModuleName(final String fileName, boolean isFile, Manifest manifest) { if (manifest != null) { String automaticModuleName = manifest.getMainAttributes().getValue(AUTOMATIC_MODULE_NAME); if (automaticModuleName != null) { return automaticModuleName.toCharArray(); } } return determineAutomaticModuleNameFromFileName(fileName, true, isFile); }
public IModuleDescription getAutomaticModuleDescription() throws JavaModelException { boolean nameFromManifest = true; char[] moduleName = AutomaticModuleNaming.determineAutomaticModuleNameFromManifest(getManifest()); if (moduleName == null) { nameFromManifest = false; moduleName = AutomaticModuleNaming.determineAutomaticModuleNameFromFileName(getElementName(), true, false); } return new AbstractModule.AutoModule(this, String.valueOf(moduleName), nameFromManifest); }
public IModuleDescription getAutomaticModuleDescription() throws JavaModelException { char[] moduleName = AutomaticModuleNaming.determineAutomaticModuleName(getElementName(), false, getManifest()); return new AbstractModule.AutoModule(this, String.valueOf(moduleName)); }
/** * Determine the automatic module name of a given jar as specified in {@link <a href= * "http://download.java.net/java/jdk9/docs/api/java/lang/module/ModuleFinder.html#of-java.nio.file.Path...-"> * ModuleFinder.of</a>} */ public static char[] determineAutomaticModuleName(final String jarFileName) { // "If the JAR file has the attribute "Automatic-Module-Name" in its main manifest then its value is the // module name." try (JarFile jar = new JarFile(jarFileName)) { Manifest manifest = jar.getManifest(); if (manifest != null) { String automaticModuleName = manifest.getMainAttributes().getValue(AUTOMATIC_MODULE_NAME); if (automaticModuleName != null) { return automaticModuleName.toCharArray(); } } } catch (IOException e) { // ignore } // The module name is otherwise derived from the name of the JAR file. return determineAutomaticModuleNameFromFileName(jarFileName, true, true); }
IModuleDescription getAutomaticModuleDescription(IClasspathEntry classpathEntry) { String elementName = getElementName(); Manifest manifest = null; switch (classpathEntry.getEntryKind()) { case IClasspathEntry.CPE_SOURCE: manifest = ((JavaProject) getJavaProject()).getManifest(); elementName = getJavaProject().getElementName(); break; case IClasspathEntry.CPE_LIBRARY: manifest = getManifest(); break; case IClasspathEntry.CPE_PROJECT: JavaProject javaProject = (JavaProject) getJavaModel().getJavaProject(classpathEntry.getPath().lastSegment()); manifest = javaProject.getManifest(); elementName = javaProject.getElementName(); break; } boolean nameFromManifest = true; char[] moduleName = AutomaticModuleNaming.determineAutomaticModuleNameFromManifest(manifest); if (moduleName == null) { nameFromManifest = false; moduleName = AutomaticModuleNaming.determineAutomaticModuleNameFromFileName(elementName, true, isArchive()); } return new AbstractModule.AutoModule(this, String.valueOf(moduleName), nameFromManifest); }
moduleName = AutomaticModuleNaming.determineAutomaticModuleName(file.getAbsolutePath());
/** * Determine the automatic module name of a given jar as specified in {@link <a href= * "http://download.java.net/java/jdk9/docs/api/java/lang/module/ModuleFinder.html#of-java.nio.file.Path...-"> * ModuleFinder.of</a>} */ public static char[] determineAutomaticModuleName(final String jarFileName) { // "If the JAR file has the attribute "Automatic-Module-Name" in its main manifest then its value is the // module name." try (JarFile jar = new JarFile(jarFileName)) { Manifest manifest = jar.getManifest(); if (manifest != null) { String automaticModuleName = manifest.getMainAttributes().getValue(AUTOMATIC_MODULE_NAME); if (automaticModuleName != null) { return automaticModuleName.toCharArray(); } } } catch (IOException e) { // ignore } // The module name is otherwise derived from the name of the JAR file. return determineAutomaticModuleNameFromFileName(jarFileName, true, true); }
s = this.resource == null ? this.containerPath.toOSString() : JavaModelManager.getLocalFile(this.resource.getFullPath()).toPath().toAbsolutePath().toString(); char[] autoModuleName = AutomaticModuleNaming.determineAutomaticModuleName(s); final char[] contents = CharOperation.append(CharOperation.append(TypeConstants.AUTOMATIC_MODULE_NAME.toCharArray(), ':'), autoModuleName);
JavaModelManager.getLocalFile(path).toPath().toAbsolutePath().toString() : pathString.split(Pattern.quote("|"))[0]; //$NON-NLS-1$ possibleMatch.autoModuleName = new String(AutomaticModuleNaming.determineAutomaticModuleName(s));
IModuleDescription getAutomaticModuleDescription(IClasspathEntry classpathEntry) { String elementName = getElementName(); Manifest manifest = null; switch (classpathEntry.getEntryKind()) { case IClasspathEntry.CPE_SOURCE: manifest = ((JavaProject) getJavaProject()).getManifest(); elementName = getJavaProject().getElementName(); break; case IClasspathEntry.CPE_LIBRARY: manifest = getManifest(); break; case IClasspathEntry.CPE_PROJECT: JavaProject javaProject = (JavaProject) getJavaModel().getJavaProject(classpathEntry.getPath().lastSegment()); manifest = javaProject.getManifest(); elementName = javaProject.getElementName(); break; } char[] moduleName = AutomaticModuleNaming.determineAutomaticModuleName(elementName, isArchive(), manifest); return new AbstractModule.AutoModule(this, String.valueOf(moduleName)); }