< prev index next >
jdk/src/jdk.jlink/share/classes/jdk/tools/jmod/JmodTask.java
Print this page
*** 29,39 ****
import java.io.ByteArrayOutputStream;
import java.io.File;
import java.io.IOException;
import java.io.InputStream;
import java.io.OutputStream;
- import java.io.PrintStream;
import java.io.PrintWriter;
import java.io.UncheckedIOException;
import java.lang.module.Configuration;
import java.lang.module.ModuleReader;
import java.lang.module.ModuleReference;
--- 29,38 ----
*** 82,92 ****
import java.util.jar.JarFile;
import java.util.jar.JarOutputStream;
import java.util.stream.Collectors;
import java.util.regex.Pattern;
import java.util.regex.PatternSyntaxException;
- import java.util.stream.Stream;
import java.util.zip.ZipEntry;
import java.util.zip.ZipException;
import java.util.zip.ZipFile;
import jdk.internal.jmod.JmodFile;
--- 81,90 ----
*** 167,176 ****
--- 165,175 ----
List<Path> cmds;
List<Path> configs;
List<Path> libs;
List<Path> headerFiles;
List<Path> manPages;
+ List<Path> legalNotices;;
ModuleFinder moduleFinder;
Version moduleVersion;
String mainClass;
String osName;
String osArch;
*** 357,366 ****
--- 356,366 ----
final List<Path> libs = options.libs;
final List<Path> configs = options.configs;
final List<Path> classpath = options.classpath;
final List<Path> headerFiles = options.headerFiles;
final List<Path> manPages = options.manPages;
+ final List<Path> legalNotices = options.legalNotices;
final Version moduleVersion = options.moduleVersion;
final String mainClass = options.mainClass;
final String osName = options.osName;
final String osArch = options.osArch;
*** 378,392 ****
writeModuleInfo(out, findPackages(classpath));
// classes
processClasses(out, classpath);
- processSection(out, Section.NATIVE_CMDS, cmds);
- processSection(out, Section.NATIVE_LIBS, libs);
processSection(out, Section.CONFIG, configs);
processSection(out, Section.HEADER_FILES, headerFiles);
processSection(out, Section.MAN_PAGES, manPages);
}
/**
* Returns a supplier of an input stream to the module-info.class
--- 378,393 ----
writeModuleInfo(out, findPackages(classpath));
// classes
processClasses(out, classpath);
processSection(out, Section.CONFIG, configs);
processSection(out, Section.HEADER_FILES, headerFiles);
+ processSection(out, Section.LEGAL_NOTICES, legalNotices);
processSection(out, Section.MAN_PAGES, manPages);
+ processSection(out, Section.NATIVE_CMDS, cmds);
+ processSection(out, Section.NATIVE_LIBS, libs);
}
/**
* Returns a supplier of an input stream to the module-info.class
*** 642,676 ****
throws IOException
{
if (paths == null)
return;
! for (Path p : paths)
processSection(out, section, p);
}
! void processSection(JmodOutputStream out, Section section, Path top)
throws IOException
{
! Files.walkFileTree(top, Set.of(FileVisitOption.FOLLOW_LINKS),
Integer.MAX_VALUE, new SimpleFileVisitor<Path>() {
@Override
public FileVisitResult visitFile(Path file, BasicFileAttributes attrs)
throws IOException
{
! Path relPath = top.relativize(file);
if (relPath.toString().equals(MODULE_INFO)
&& !Section.CLASSES.equals(section))
warning("warn.ignore.entry", MODULE_INFO, section);
if (!relPath.toString().equals(MODULE_INFO)
&& !matches(relPath, excludes)) {
try (InputStream in = Files.newInputStream(file)) {
out.writeEntry(in, section, relPath.toString());
} catch (IOException x) {
if (x.getMessage().contains("duplicate entry")) {
! warning("warn.ignore.duplicate.entry", relPath.toString(), section);
return FileVisitResult.CONTINUE;
}
throw x;
}
}
--- 643,679 ----
throws IOException
{
if (paths == null)
return;
! for (Path p : paths) {
processSection(out, section, p);
}
+ }
! void processSection(JmodOutputStream out, Section section, Path path)
throws IOException
{
! Files.walkFileTree(path, Set.of(FileVisitOption.FOLLOW_LINKS),
Integer.MAX_VALUE, new SimpleFileVisitor<Path>() {
@Override
public FileVisitResult visitFile(Path file, BasicFileAttributes attrs)
throws IOException
{
! Path relPath = path.relativize(file);
if (relPath.toString().equals(MODULE_INFO)
&& !Section.CLASSES.equals(section))
warning("warn.ignore.entry", MODULE_INFO, section);
if (!relPath.toString().equals(MODULE_INFO)
&& !matches(relPath, excludes)) {
try (InputStream in = Files.newInputStream(file)) {
out.writeEntry(in, section, relPath.toString());
} catch (IOException x) {
if (x.getMessage().contains("duplicate entry")) {
! warning("warn.ignore.duplicate.entry",
! relPath.toString(), section);
return FileVisitResult.CONTINUE;
}
throw x;
}
}
*** 1230,1239 ****
--- 1233,1249 ----
= parser.accepts("libs", getMessage("main.opt.libs"))
.withRequiredArg()
.withValuesSeparatedBy(File.pathSeparatorChar)
.withValuesConvertedBy(DirPathConverter.INSTANCE);
+ OptionSpec<Path> legalNotices
+ = parser.accepts("legal-notices", getMessage("main.opt.legal-notices"))
+ .withRequiredArg()
+ .withValuesSeparatedBy(File.pathSeparatorChar)
+ .withValuesConvertedBy(DirPathConverter.INSTANCE);
+
+
OptionSpec<String> mainClass
= parser.accepts("main-class", getMessage("main.opt.main-class"))
.withRequiredArg()
.describedAs(getMessage("main.opt.main-class.arg"));
*** 1311,1320 ****
--- 1321,1332 ----
options.libs = opts.valuesOf(libs);
if (opts.has(headerFiles))
options.headerFiles = opts.valuesOf(headerFiles);
if (opts.has(manPages))
options.manPages = opts.valuesOf(manPages);
+ if (opts.has(legalNotices))
+ options.legalNotices = opts.valuesOf(legalNotices);
if (opts.has(modulePath)) {
Path[] dirs = opts.valuesOf(modulePath).toArray(new Path[0]);
options.moduleFinder = JLMA.newModulePath(Runtime.version(), true, dirs);
}
if (opts.has(moduleVersion))
< prev index next >