Properties2Java is an Ant task for automatic conversion of java ".properties" files to ".java" files extending the java.util.ListResourceBundle.
Requirements:
Usage:
Dummy.properties:
test.simple=simple
test.quotes="quotes"
test.lf=before\nafter
test.crlf=before\r\nafter
test.tab=before\tafter
=>
Dummy.java:
/*
* DO NOT EDIT!
* Automatic generated java file from original source:
* C:\properties2java\test\simple\source\Dummy.properties
*/
package de.jayefem;
import java.util.ListResourceBundle;
public class Dummy extends ListResourceBundle {
/**
* @see java.util.ListResourceBundle#getContents()
*/
public Object[][] getContents() {
return contents;
}
static final Object[][] contents = {
{"test.simple","simple"},
{"test.quotes","\"quotes\""},
{"test.crlf","before\r\nafter"},
{"test.lf","before\nafter"},
{"test.tab","before\tafter"}
};
}
If you're using an obfuscator which is not able to encode
the contents of an properties file, it would be useful
to convert the properties to java files which can be handled
by an obfuscator easily.
Generally when using that task in combination with an obfuscator,
you have to modify your sourcecode
from:
ResourceBundle.getBundle("de.jayefem.Dummy");
to:
ResourceBundle.getBundle(de.jayefem.Dummy.class.getName());
COMPILATION
Requirements:
Building the project:
Development contribution is HIGHLY APPRECIATED!
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
June 2005, Jan-Friedrich Mutter
p2j@jayefem.de