Skip to content

Commit

Permalink
Changed -Apropfile on the property key checker (and its two derivativ…
Browse files Browse the repository at this point in the history
…es, the internationalization checker and the compiler message checker) to use File.pathSeparator to separate property file paths, rather than ':' (as that prevented use of absolute paths like C:\myfile.props on Windows). Updated all the documentation and usages to match.

Fixes typetools#5273
  • Loading branch information
neilccbrown committed Aug 30, 2022
1 parent 2dbf856 commit d3a3e70
Show file tree
Hide file tree
Showing 6 changed files with 9 additions and 6 deletions.
2 changes: 1 addition & 1 deletion checker/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -215,7 +215,7 @@ createCheckTypeTask(project.name, "CompilerMessages",
checkCompilerMessages {
doFirst {
options.compilerArgs += [
'-Apropfiles=' + sourceSets.main.resources.filter { file -> file.name.equals('messages.properties') }.asPath + ":"
'-Apropfiles=' + sourceSets.main.resources.filter { file -> file.name.equals('messages.properties') }.asPath + File.pathSeparator
+ project(':framework').sourceSets.main.resources.filter { file -> file.name.equals('messages.properties') }.asPath
]
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,8 @@
* <li value="1">Properties files: A common method for localization using a properties file,
* mapping the localization keys to localized messages. Programmers pass the property file
* location via {@code propfiles} option (e.g. {@code
* -Apropfiles=/path/to/messages.properties}), separating multiple files by a colon ":".
* -Apropfiles=/path/to/messages.properties}), separating multiple files by {@link
* java.io.File#pathSeparator}.
* <li value="2">{@link ResourceBundle}: The proper recommended mechanism for localization.
* Programmers pass the {@code baseName} name of the bundle via {@code bundlename} (e.g.
* {@code -Abundlename=MyResource}. The checker uses the resource associated with the default
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

import com.sun.source.tree.LiteralTree;
import com.sun.source.tree.Tree;
import java.io.File;
import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.io.InputStream;
Expand Down Expand Up @@ -88,7 +89,7 @@ private Map<String, String> buildLookup() {

if (checker.hasOption("propfiles")) {
String names = checker.getOption("propfiles");
String[] namesArr = names.split(":");
String[] namesArr = names.split(File.pathSeparator);

if (namesArr == null) {
System.err.println("Couldn't parse the properties files: <" + names + ">");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
import com.sun.source.tree.CompoundAssignmentTree;
import com.sun.source.tree.LiteralTree;
import com.sun.source.tree.Tree;
import java.io.File;
import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.io.InputStream;
Expand Down Expand Up @@ -140,7 +141,7 @@ private Set<String> buildLookupKeys() {
}

private Set<String> keysOfPropertyFiles(String names) {
String[] namesArr = names.split(":");
String[] namesArr = names.split(File.pathSeparator);

if (namesArr == null) {
checker.message(Kind.WARNING, "Couldn't parse the properties files: <" + names + ">");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
* <li value="1">Property files: A common method for localization using a property file, mapping
* the keys to values. Programmers pass the property file locations via {@code propfiles}
* option (e.g. {@code -Apropfiles=/path/to/messages.properties}), separating multiple files
* by a colon ":".
* by {@link java.io.File#pathSeparator}.
* <li value="2">{@link ResourceBundle}: Programmers pass the {@code baseName} name of the bundle
* via {@code bundlename} (e.g. {@code -Abundlename=MyResource}. The checker uses the resource
* associated with the default {@link Locale} in the compilation system.
Expand Down
2 changes: 1 addition & 1 deletion docs/manual/propkey-checker.tex
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@
keys to values. The file format is described in
the Javadoc for
\sunjavadoc{java.base/java/util/Properties.html\#load(java.io.Reader)}{Properties.load()}.
Multiple files are separated by colons '\code{:}'.
Multiple files are separated by Java's \sunjavadoc{java.base/java/io/File.html\#pathSeparator}{File.pathSeparator} (semi-colon ''\code{;}' on Windows, colon '\code{:}' on Linux and Mac).

\end{enumerate}

Expand Down

0 comments on commit d3a3e70

Please sign in to comment.