1
- package net . sf . j2s .core ;
1
+ package j2s .core ;
2
2
3
+ import j2s .CorePlugin ;
3
4
import java .util .ArrayList ;
4
5
import java .util .Date ;
5
6
@@ -48,13 +49,15 @@ public boolean isActive(IJavaProject project) {
48
49
// happens when comparing to team...show history item
49
50
return false ;
50
51
}
51
- boolean isj2s = Java2ScriptCompiler .isActive (project );
52
+ String j2sFileName = Java2ScriptCompiler .getJ2SConfigName (project );
53
+ boolean isj2s = (j2sFileName != null );
52
54
String loc = " " + project .getProject ().getLocation () + " " ;
53
55
// 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 ;
58
61
}
59
62
return isj2s ;
60
63
}
@@ -76,7 +79,7 @@ public boolean isActive(IJavaProject project) {
76
79
*/
77
80
@ Override
78
81
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());
80
83
if (contexts == null )
81
84
contexts = new ArrayList <>();
82
85
return READY_FOR_BUILD ;
@@ -92,7 +95,7 @@ public int aboutToBuild(IJavaProject project) {
92
95
*/
93
96
@ Override
94
97
public void cleanStarting (IJavaProject project ) {
95
- System .out .println ("J2S cleanStarting " + project .getProject ().getLocation ());
98
+ // System.out.println("J2S cleanStarting " + project.getProject().getLocation());
96
99
isCleanBuild = true ;
97
100
}
98
101
@@ -128,9 +131,9 @@ public void buildStarting(BuildContext[] files, boolean isBatch) {
128
131
@ Override
129
132
public void buildFinished (IJavaProject project ) {
130
133
if (contexts != null && contexts .size () > 0 ) {
131
- Java2ScriptCompiler j2sCompiler = new Java2ScriptCompiler ( );
134
+ Java2ScriptCompiler j2sCompiler = Java2ScriptCompiler . newCompiler ( project );
132
135
j2sCompiler .startBuild (isCleanBuild );
133
- if (!j2sCompiler .initializeProject (project , true )) {
136
+ if (!j2sCompiler .initializeProject (project )) {
134
137
System .out .println ("J2S .j2s disabled" );
135
138
return ;
136
139
}
@@ -141,27 +144,18 @@ public void buildFinished(IJavaProject project) {
141
144
for (int j = 0 ; j < contexts .size (); j ++) {
142
145
BuildContext [] files = contexts .get (j );
143
146
System .out .println ("J2S building JavaScript for " + files .length + " file" + plural (files .length ));
144
-
147
+ String trailer = CorePlugin . VERSION + " " + new Date ();
145
148
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
- //
157
149
IFile f = files [i ].getFile ();
158
150
String filePath = f .getLocation ().toString ();
159
151
if (j2sCompiler .excludeFile (f )) {
152
+ if (j2sCompiler .isDebugging )
160
153
System .out .println ("J2S excluded " + filePath );
161
154
} else {
155
+ if (j2sCompiler .isDebugging )
162
156
System .out .println ("J2S transpiling (" + (i + 1 ) + "/" + n + ") " + filePath );
163
157
try {
164
- if (j2sCompiler .compileToJavaScript (f )) {
158
+ if (j2sCompiler .compileToJavaScript (f , trailer )) {
165
159
ntotal ++;
166
160
} else {
167
161
nerror ++;
@@ -186,7 +180,7 @@ public void buildFinished(IJavaProject project) {
186
180
isCleanBuild = false ;
187
181
}
188
182
189
- static String plural (int n ) {
183
+ public static String plural (int n ) {
190
184
return (n == 1 ? "" : "s" );
191
185
}
192
186
0 commit comments