< prev index next >

test/jdk/tools/jpackage/helpers/jdk/jpackage/test/JavaAppDesc.java

Print this page

        

*** 38,59 **** public JavaAppDesc setModuleName(String v) { moduleName = v; return this; } ! public JavaAppDesc setJarFileName(String v) { ! jarFileName = v; return this; } public JavaAppDesc setModuleVersion(String v) { moduleVersion = v; return this; } ! public JavaAppDesc setJarWithMainClass(boolean v) { ! jarWithMainClass = v; return this; } public String className() { return qualifiedClassName; --- 38,59 ---- public JavaAppDesc setModuleName(String v) { moduleName = v; return this; } ! public JavaAppDesc setBundleFileName(String v) { ! bundleFileName = v; return this; } public JavaAppDesc setModuleVersion(String v) { moduleVersion = v; return this; } ! public JavaAppDesc setWithMainClass(boolean v) { ! withMainClass = v; return this; } public String className() { return qualifiedClassName;
*** 75,108 **** } return qualifiedClassName.substring(0, lastDotIdx); } public String jarFileName() { ! return jarFileName; } public String moduleVersion() { return moduleVersion; } ! public boolean jarWithMainClass() { ! return jarWithMainClass; } @Override public String toString() { StringBuilder sb = new StringBuilder(); ! if (jarFileName != null) { ! sb.append(jarFileName).append(':'); } if (moduleName != null) { sb.append(moduleName).append('/'); } if (qualifiedClassName != null) { sb.append(qualifiedClassName); } ! if (jarWithMainClass) { sb.append('!'); } if (moduleVersion != null) { sb.append('@').append(moduleVersion); } --- 75,122 ---- } return qualifiedClassName.substring(0, lastDotIdx); } public String jarFileName() { ! if (bundleFileName != null && bundleFileName.endsWith(".jar")) { ! return bundleFileName; ! } ! return null; ! } ! ! public String jmodFileName() { ! if (bundleFileName != null && bundleFileName.endsWith(".jmod")) { ! return bundleFileName; ! } ! return null; ! } ! ! public boolean isWithBundleFileName() { ! return bundleFileName != null; } public String moduleVersion() { return moduleVersion; } ! public boolean isWithMainClass() { ! return withMainClass; } @Override public String toString() { StringBuilder sb = new StringBuilder(); ! if (bundleFileName != null) { ! sb.append(bundleFileName).append(':'); } if (moduleName != null) { sb.append(moduleName).append('/'); } if (qualifiedClassName != null) { sb.append(qualifiedClassName); } ! if (withMainClass) { sb.append('!'); } if (moduleVersion != null) { sb.append('@').append(moduleVersion); }
*** 111,146 **** /** * Create Java application description form encoded string value. * * Syntax of encoded Java application description is ! * [jar_file:][module_name/]qualified_class_name[!][@module_version]. * * E.g.: `duke.jar:com.other/com.other.foo.bar.Buz!@3.7` encodes modular * application. Module name is `com.other`. Main class is * `com.other.foo.bar.Buz`. Module version is `3.7`. Application will be * compiled and packed in `duke.jar` jar file. jar command will set module * version (3.7) and main class (Buz) attributes in the jar file. * * E.g.: `Ciao` encodes non-modular `Ciao` class in the default package. * jar command will not put main class attribute in the jar file. * Default name will be picked for jar file - `hello.jar`. * * @param cmd jpackage command to configure * @param javaAppDesc encoded Java application description */ ! public static JavaAppDesc parse(String javaAppDesc) { JavaAppDesc desc = HelloApp.createDefaltAppDesc(); if (javaAppDesc == null) { return desc; } String moduleNameAndOther = Functional.identity(() -> { String[] components = javaAppDesc.split(":", 2); if (components.length == 2) { ! desc.setJarFileName(components[0]); } return components[components.length - 1]; }).get(); String classNameAndOther = Functional.identity(() -> { --- 125,165 ---- /** * Create Java application description form encoded string value. * * Syntax of encoded Java application description is ! * [(jar_file|jmods_file):][module_name/]qualified_class_name[!][@module_version]. * * E.g.: `duke.jar:com.other/com.other.foo.bar.Buz!@3.7` encodes modular * application. Module name is `com.other`. Main class is * `com.other.foo.bar.Buz`. Module version is `3.7`. Application will be * compiled and packed in `duke.jar` jar file. jar command will set module * version (3.7) and main class (Buz) attributes in the jar file. * + * E.g.: `bar.jmod:com.another/com.another.One` encodes modular + * application. Module name is `com.another`. Main class is + * `com.another.One`. Application will be + * compiled and packed in `bar.jmod` jmod file. + * * E.g.: `Ciao` encodes non-modular `Ciao` class in the default package. * jar command will not put main class attribute in the jar file. * Default name will be picked for jar file - `hello.jar`. * * @param cmd jpackage command to configure * @param javaAppDesc encoded Java application description */ ! public static JavaAppDesc parse(final String javaAppDesc) { JavaAppDesc desc = HelloApp.createDefaltAppDesc(); if (javaAppDesc == null) { return desc; } String moduleNameAndOther = Functional.identity(() -> { String[] components = javaAppDesc.split(":", 2); if (components.length == 2) { ! desc.setBundleFileName(components[0]); } return components[components.length - 1]; }).get(); String classNameAndOther = Functional.identity(() -> {
*** 154,175 **** Functional.identity(() -> { String[] components = classNameAndOther.split("@", 2); if (components[0].endsWith("!")) { components[0] = components[0].substring(0, components[0].length() - 1); ! desc.setJarWithMainClass(true); } desc.setClassName(components[0]); if (components.length == 2) { desc.setModuleVersion(components[1]); } }).run(); return desc; } private String qualifiedClassName; private String moduleName; ! private String jarFileName; private String moduleVersion; ! private boolean jarWithMainClass; } --- 173,200 ---- Functional.identity(() -> { String[] components = classNameAndOther.split("@", 2); if (components[0].endsWith("!")) { components[0] = components[0].substring(0, components[0].length() - 1); ! desc.setWithMainClass(true); } desc.setClassName(components[0]); if (components.length == 2) { desc.setModuleVersion(components[1]); } }).run(); + if (desc.jmodFileName() != null && desc.moduleName() == null) { + throw new IllegalArgumentException(String.format( + "Java Application Descriptor [%s] is invalid. Non modular app can't be packed in .jmod bundle", + javaAppDesc)); + } + return desc; } private String qualifiedClassName; private String moduleName; ! private String bundleFileName; private String moduleVersion; ! private boolean withMainClass; }
< prev index next >