@@ -38,7 +38,9 @@ class Java2ScriptCompiler {
3838 /**
3939 * The name of the J2S options file, aka as the "Dot-j2s" file.
4040 */
41- private static final String J2S_OPTIONS_FILE_NAME = System .getProperty ("net.sf.j2s.core.j2sFileName" ,".j2s" );
41+ private static final String J2S_OPTIONS_FILE_NAME = ".j2s" ;
42+
43+ private static final String J2S_OPTIONS_ALT_FILE_CONF = "j2s.config.altfileproperty" ;
4244
4345 private int nResources , nSources , nJS , nHTML ;
4446
@@ -218,7 +220,51 @@ boolean initializeProject(IJavaProject project, boolean isCompilationParticipant
218220 props = new Properties ();
219221 try {
220222 File j2sFile = new File (projectFolder , J2S_OPTIONS_FILE_NAME );
221- props .load (new FileInputStream (j2sFile ));
223+ Properties j2sProps = new Properties ();
224+ j2sProps .load (new FileInputStream (j2sFile ));
225+ boolean j2sAltFileUsed = false ;
226+ if (j2sProps .getProperty (J2S_OPTIONS_ALT_FILE_CONF ) != null ) {
227+ String j2sAltFileProperty = j2sProps
228+ .getProperty (J2S_OPTIONS_ALT_FILE_CONF );
229+ System .out .println (
230+ "Alternative J2S configuration file property is set to '"
231+ + j2sAltFileProperty + "'" );
232+ String j2sAltFileName = System .getProperty (j2sAltFileProperty );
233+ System .out
234+ .println ("Alternative J2S configuration file is set to '"
235+ + j2sAltFileName + "'" );
236+ if (j2sAltFileName != null ) {
237+ File j2sAltFile = new File (projectFolder , j2sAltFileName );
238+ if (j2sAltFile .exists ()) {
239+ System .out
240+ .println ("Using alternative J2S configuration file '"
241+ + j2sAltFileName + "'" );
242+ props .load (new FileInputStream (j2sAltFile ));
243+ j2sAltFileUsed = true ;
244+ } else {
245+ System .err .println (
246+ "Alternative J2S configuration file property '"
247+ + j2sAltFileProperty + "' is set to '"
248+ + j2sAltFileName
249+ + "' but this file does not exist. Using original '"
250+ + J2S_OPTIONS_FILE_NAME + "' file." );
251+ }
252+ } else {
253+ System .out .println (
254+ "J2S did not find property value for j2s alt file property '"
255+ + j2sAltFileProperty + "'" );
256+ }
257+ if (!j2sAltFileUsed ) {
258+ j2sProps .remove (J2S_OPTIONS_ALT_FILE_CONF );
259+ props = j2sProps ;
260+ }
261+ } else {
262+ System .out .println ("J2S did not find configuration for '"
263+ + J2S_OPTIONS_ALT_FILE_CONF + "' in "
264+ + j2sFile .getPath ());
265+ props = j2sProps ;
266+ }
267+
222268 String status = getProperty (J2S_COMPILER_STATUS , J2S_COMPILER_STATUS_ENABLED );
223269 if (!J2S_COMPILER_STATUS_ENABLE .equalsIgnoreCase (status )
224270 && !J2S_COMPILER_STATUS_ENABLED .equalsIgnoreCase (status )) {
0 commit comments