1- package net . sf . j2s .core ;
1+ package j2s .core ;
22
3+ import j2s .CorePlugin ;
34import java .util .ArrayList ;
45import java .util .Date ;
56
@@ -48,13 +49,15 @@ public boolean isActive(IJavaProject project) {
4849 // happens when comparing to team...show history item
4950 return false ;
5051 }
51- boolean isj2s = Java2ScriptCompiler .isActive (project );
52+ String j2sFileName = Java2ScriptCompiler .getJ2SConfigName (project );
53+ boolean isj2s = (j2sFileName != null );
5254 String loc = " " + project .getProject ().getLocation () + " " ;
5355 // notify only if changed
54- if (isActiveNotified .indexOf (isj2s + loc ) < 0 ) {
55- System .out .println ("J2S isActive " + isj2s + loc );
56- isActiveNotified = isActiveNotified .replace ((!isj2s ) + loc , "" );
57- isActiveNotified += isj2s + loc ;
56+ String key = j2sFileName + "," + isj2s + "," + loc + ";" ;
57+ if (isActiveNotified .indexOf (key ) < 0 ) {
58+ System .out .println ("J2S isActive " + (isj2s ? j2sFileName : "false" ) + loc );
59+ isActiveNotified = isActiveNotified .replace (j2sFileName + (!isj2s ) + loc , "" );
60+ isActiveNotified += key ;
5861 }
5962 return isj2s ;
6063 }
@@ -76,7 +79,7 @@ public boolean isActive(IJavaProject project) {
7679 */
7780 @ Override
7881 public int aboutToBuild (IJavaProject project ) {
79- System .out .println ("J2S aboutToBuild " + project .getProject ().getName () + " " + project .getProject ().getLocation ());
82+ // System.out.println("J2S aboutToBuild " + project.getProject().getName() + " " + project.getProject().getLocation());
8083 if (contexts == null )
8184 contexts = new ArrayList <>();
8285 return READY_FOR_BUILD ;
@@ -92,7 +95,7 @@ public int aboutToBuild(IJavaProject project) {
9295 */
9396 @ Override
9497 public void cleanStarting (IJavaProject project ) {
95- System .out .println ("J2S cleanStarting " + project .getProject ().getLocation ());
98+ // System.out.println("J2S cleanStarting " + project.getProject().getLocation());
9699 isCleanBuild = true ;
97100 }
98101
@@ -128,9 +131,9 @@ public void buildStarting(BuildContext[] files, boolean isBatch) {
128131 @ Override
129132 public void buildFinished (IJavaProject project ) {
130133 if (contexts != null && contexts .size () > 0 ) {
131- Java2ScriptCompiler j2sCompiler = new Java2ScriptCompiler ( );
134+ Java2ScriptCompiler j2sCompiler = Java2ScriptCompiler . newCompiler ( project );
132135 j2sCompiler .startBuild (isCleanBuild );
133- if (!j2sCompiler .initializeProject (project , true )) {
136+ if (!j2sCompiler .initializeProject (project )) {
134137 System .out .println ("J2S .j2s disabled" );
135138 return ;
136139 }
@@ -141,27 +144,18 @@ public void buildFinished(IJavaProject project) {
141144 for (int j = 0 ; j < contexts .size (); j ++) {
142145 BuildContext [] files = contexts .get (j );
143146 System .out .println ("J2S building JavaScript for " + files .length + " file" + plural (files .length ));
144-
147+ String trailer = CorePlugin . VERSION + " " + new Date ();
145148 for (int i = 0 , n = files .length ; i < n ; i ++) {
146- // trying to keep the progess monitor running - didn't work
147- // try {
148- // Thread.currentThread().sleep(1);
149- // } catch (InterruptedException e) {
150- // // ignore
151- // }
152- // System.out.println("J2S file"
153- // + " name=" + files[i].getFile().getName()
154- // + " fullpath=" + files[i].getFile().getFullPath()
155- // + " location=" + files[i].getFile().getLocation());
156- //
157149 IFile f = files [i ].getFile ();
158150 String filePath = f .getLocation ().toString ();
159151 if (j2sCompiler .excludeFile (f )) {
152+ if (j2sCompiler .isDebugging )
160153 System .out .println ("J2S excluded " + filePath );
161154 } else {
155+ if (j2sCompiler .isDebugging )
162156 System .out .println ("J2S transpiling (" + (i + 1 ) + "/" + n + ") " + filePath );
163157 try {
164- if (j2sCompiler .compileToJavaScript (f )) {
158+ if (j2sCompiler .compileToJavaScript (f , trailer )) {
165159 ntotal ++;
166160 } else {
167161 nerror ++;
@@ -186,7 +180,7 @@ public void buildFinished(IJavaProject project) {
186180 isCleanBuild = false ;
187181 }
188182
189- static String plural (int n ) {
183+ public static String plural (int n ) {
190184 return (n == 1 ? "" : "s" );
191185 }
192186
0 commit comments