Lines 20-31
Link Here
|
20 |
import java.io.File; |
20 |
import java.io.File; |
21 |
import java.io.IOException; |
21 |
import java.io.IOException; |
22 |
import java.rmi.Remote; |
22 |
import java.rmi.Remote; |
|
|
23 |
import java.util.Iterator; |
23 |
import java.util.Vector; |
24 |
import java.util.Vector; |
24 |
import org.apache.tools.ant.BuildException; |
25 |
import org.apache.tools.ant.BuildException; |
25 |
import org.apache.tools.ant.DirectoryScanner; |
26 |
import org.apache.tools.ant.DirectoryScanner; |
26 |
import org.apache.tools.ant.Project; |
27 |
import org.apache.tools.ant.Project; |
27 |
import org.apache.tools.ant.taskdefs.rmic.RmicAdapter; |
28 |
import org.apache.tools.ant.taskdefs.rmic.RmicAdapter; |
28 |
import org.apache.tools.ant.taskdefs.rmic.RmicAdapterFactory; |
29 |
import org.apache.tools.ant.taskdefs.rmic.RmicAdapterFactory; |
|
|
30 |
import org.apache.tools.ant.types.FileSet; |
29 |
import org.apache.tools.ant.types.FilterSetCollection; |
31 |
import org.apache.tools.ant.types.FilterSetCollection; |
30 |
import org.apache.tools.ant.types.Path; |
32 |
import org.apache.tools.ant.types.Path; |
31 |
import org.apache.tools.ant.types.Reference; |
33 |
import org.apache.tools.ant.types.Reference; |
Lines 83-88
Link Here
|
83 |
= "Rmic failed; see the compiler error output for details."; |
85 |
= "Rmic failed; see the compiler error output for details."; |
84 |
|
86 |
|
85 |
private File baseDir; |
87 |
private File baseDir; |
|
|
88 |
private File destDir; |
89 |
private Vector filesets = new Vector(); |
90 |
|
86 |
private String classname; |
91 |
private String classname; |
87 |
private File sourceBase; |
92 |
private File sourceBase; |
88 |
private String stubVersion; |
93 |
private String stubVersion; |
Lines 98-103
Link Here
|
98 |
private boolean debug = false; |
103 |
private boolean debug = false; |
99 |
private boolean includeAntRuntime = true; |
104 |
private boolean includeAntRuntime = true; |
100 |
private boolean includeJavaRuntime = false; |
105 |
private boolean includeJavaRuntime = false; |
|
|
106 |
private boolean sourcesOnClasspath = true; |
101 |
|
107 |
|
102 |
private Vector compileList = new Vector(); |
108 |
private Vector compileList = new Vector(); |
103 |
|
109 |
|
Lines 137-142
Link Here
|
137 |
} |
143 |
} |
138 |
|
144 |
|
139 |
/** |
145 |
/** |
|
|
146 |
* Sets the base directory to output the generated files. |
147 |
* @param destdir the base directory to output the generated files. |
148 |
*/ |
149 |
public void setDestdir(File destdir) { |
150 |
this.destDir = destdir; |
151 |
} |
152 |
|
153 |
/** |
154 |
* Gets the base directory to output the generated files. |
155 |
* @return the base directory to output the generated files. |
156 |
*/ |
157 |
public File getDestdir() { |
158 |
return this.destDir; |
159 |
} |
160 |
|
161 |
/** |
162 |
* Gets the base directory to output the generated files, |
163 |
* favoring destdir if set, otherwise defaulting to basedir. |
164 |
*/ |
165 |
public File getOutputDir(){ |
166 |
if (getDestdir() != null) return getDestdir(); |
167 |
return getBase(); |
168 |
} |
169 |
|
170 |
/** |
171 |
* Adds a set of files to generate stubs for. |
172 |
*/ |
173 |
public void addFileset(FileSet set) { |
174 |
filesets.addElement(set); |
175 |
} |
176 |
|
177 |
/** |
140 |
* Sets the class to run <code>rmic</code> against; |
178 |
* Sets the class to run <code>rmic</code> against; |
141 |
* optional |
179 |
* optional |
142 |
* @param classname the name of the class for rmic to create code for |
180 |
* @param classname the name of the class for rmic to create code for |
Lines 395-400
Link Here
|
395 |
} |
433 |
} |
396 |
|
434 |
|
397 |
/** |
435 |
/** |
|
|
436 |
* Sets whether source folders are automatically included in the compile |
437 |
* classpath; optional, defaults to false |
438 |
* @param include true to include source folders |
439 |
*/ |
440 |
public void setSourcesOnClasspath(boolean include) { |
441 |
sourcesOnClasspath = include; |
442 |
} |
443 |
|
444 |
/** |
445 |
* Sets whether source folders are automatically included in the compile |
446 |
* classpath |
447 |
* @param true if source folders are automatically included |
448 |
*/ |
449 |
public boolean getSourcesOnClasspath() { |
450 |
return sourcesOnClasspath; |
451 |
} |
452 |
|
453 |
/** |
398 |
* Sets the extension directories that will be used during the |
454 |
* Sets the extension directories that will be used during the |
399 |
* compilation; optional. |
455 |
* compilation; optional. |
400 |
* @param extDirs the extension directories to be used |
456 |
* @param extDirs the extension directories to be used |
Lines 484-500
Link Here
|
484 |
* class and getting to do the work |
540 |
* class and getting to do the work |
485 |
*/ |
541 |
*/ |
486 |
public void execute() throws BuildException { |
542 |
public void execute() throws BuildException { |
487 |
if (baseDir == null) { |
543 |
if(compileList.size() > 0){ |
488 |
throw new BuildException("base attribute must be set!", getLocation()); |
544 |
compileList.removeAllElements(); |
489 |
} |
|
|
490 |
if (!baseDir.exists()) { |
491 |
throw new BuildException("base does not exist!", getLocation()); |
492 |
} |
545 |
} |
493 |
|
546 |
|
|
|
547 |
File outputDir = getOutputDir(); |
548 |
if (outputDir == null) { |
549 |
throw new BuildException("base or destdir attribute must be set!", getLocation()); |
550 |
} |
551 |
if (!outputDir.exists() || (baseDir != null && !baseDir.exists()) ) { |
552 |
throw new BuildException("base or destdir location does not exist!", getLocation()); |
553 |
} |
494 |
if (verify) { |
554 |
if (verify) { |
495 |
log("Verify has been turned on.", Project.MSG_VERBOSE); |
555 |
log("Verify has been turned on.", Project.MSG_VERBOSE); |
496 |
} |
556 |
} |
497 |
|
557 |
|
|
|
558 |
if (getBase() != null) { |
559 |
FileSet implicitFs = getImplicitFileSet(); |
560 |
implicitFs.setDir(getBase()); |
561 |
filesets.add(implicitFs); |
562 |
} |
563 |
|
564 |
// Must be performed before the loader's classpath is set so any |
565 |
// classpaths can be used by isValidRmiRemote() (which occurs deep |
566 |
// within populateFilesToProcess(...). |
567 |
processSourcesOnClasspath(); |
568 |
|
498 |
RmicAdapter adapter = RmicAdapterFactory.getRmic(getCompiler(), this); |
569 |
RmicAdapter adapter = RmicAdapterFactory.getRmic(getCompiler(), this); |
499 |
|
570 |
|
500 |
// now we need to populate the compiler adapter |
571 |
// now we need to populate the compiler adapter |
Lines 503-528
Link Here
|
503 |
Path classpath = adapter.getClasspath(); |
574 |
Path classpath = adapter.getClasspath(); |
504 |
loader = getProject().createClassLoader(classpath); |
575 |
loader = getProject().createClassLoader(classpath); |
505 |
|
576 |
|
506 |
try { |
577 |
populateFilesToProcess(adapter.getMapper()); |
507 |
// scan base dirs to build up compile lists only if a |
|
|
508 |
// specific classname is not given |
509 |
if (classname == null) { |
510 |
DirectoryScanner ds = this.getDirectoryScanner(baseDir); |
511 |
String[] files = ds.getIncludedFiles(); |
512 |
scanDir(baseDir, files, adapter.getMapper()); |
513 |
} else { |
514 |
// otherwise perform a timestamp comparison - at least |
515 |
scanDir(baseDir, |
516 |
new String[] {classname.replace('.', |
517 |
File.separatorChar) |
518 |
+ ".class"}, |
519 |
adapter.getMapper()); |
520 |
} |
521 |
|
578 |
|
522 |
int fileCount = compileList.size(); |
579 |
int fileCount = compileList.size(); |
523 |
if (fileCount > 0) { |
580 |
if (fileCount > 0) { |
524 |
log("RMI Compiling " + fileCount |
581 |
log("RMI Compiling " + fileCount |
525 |
+ " class" + (fileCount > 1 ? "es" : "") + " to " + baseDir, |
582 |
+ " class" + (fileCount > 1 ? "es" : "") + " to " + outputDir, |
526 |
Project.MSG_INFO); |
583 |
Project.MSG_INFO); |
527 |
|
584 |
|
528 |
// finally, lets execute the compiler!! |
585 |
// finally, lets execute the compiler!! |
Lines 536-542
Link Here
|
536 |
* base directory and sourcebase are the same, the generated |
593 |
* base directory and sourcebase are the same, the generated |
537 |
* sources are already in place. |
594 |
* sources are already in place. |
538 |
*/ |
595 |
*/ |
539 |
if (null != sourceBase && !baseDir.equals(sourceBase) |
596 |
if (null != sourceBase && !outputDir.equals(sourceBase) |
540 |
&& fileCount > 0) { |
597 |
&& fileCount > 0) { |
541 |
if (idl) { |
598 |
if (idl) { |
542 |
log("Cannot determine sourcefiles in idl mode, ", |
599 |
log("Cannot determine sourcefiles in idl mode, ", |
Lines 545-558
Link Here
|
545 |
Project.MSG_WARN); |
602 |
Project.MSG_WARN); |
546 |
} else { |
603 |
} else { |
547 |
for (int j = 0; j < fileCount; j++) { |
604 |
for (int j = 0; j < fileCount; j++) { |
548 |
moveGeneratedFile(baseDir, sourceBase, |
605 |
moveGeneratedFile(outputDir, sourceBase, |
549 |
(String) compileList.elementAt(j), |
606 |
(String) compileList.elementAt(j), |
550 |
adapter); |
607 |
adapter); |
551 |
} |
608 |
} |
552 |
} |
609 |
} |
553 |
} |
610 |
} |
554 |
} finally { |
611 |
} |
555 |
compileList.removeAllElements(); |
612 |
|
|
|
613 |
protected void processSourcesOnClasspath() { |
614 |
// Moved from DefaultRmicAdapter, so that multiple |
615 |
// locations can be added. |
616 |
if(compileClasspath == null){ |
617 |
compileClasspath = new Path(getProject()); |
618 |
} |
619 |
|
620 |
if (getSourcesOnClasspath()) { |
621 |
for (Iterator iter = filesets.iterator(); iter.hasNext();) { |
622 |
FileSet fs = (FileSet) iter.next(); |
623 |
File fsBaseDir = fs.getDir(getProject()); |
624 |
compileClasspath.setLocation(fsBaseDir); |
625 |
} |
626 |
} |
627 |
} |
628 |
|
629 |
protected void populateFilesToProcess (FileNameMapper mapper) { |
630 |
for (Iterator iter = filesets.iterator(); iter.hasNext();) { |
631 |
FileSet fs = (FileSet) iter.next(); |
632 |
File fsBaseDir = fs.getDir(getProject()); |
633 |
String[] files; |
634 |
|
635 |
// scan base dirs to build up compile lists only if a |
636 |
// specific classname is not given |
637 |
if (classname == null) { |
638 |
DirectoryScanner ds = fs.getDirectoryScanner(getProject()); |
639 |
files = ds.getIncludedFiles(); |
640 |
} else { |
641 |
// otherwise perform a timestamp comparison - at least |
642 |
files = new String[] {classname.replace('.', |
643 |
File.separatorChar) + ".class"}; |
644 |
} |
645 |
|
646 |
scanDir(fsBaseDir, files, mapper); |
556 |
} |
647 |
} |
557 |
} |
648 |
} |
558 |
|
649 |
|
Lines 628-634
Link Here
|
628 |
Project.MSG_VERBOSE); |
719 |
Project.MSG_VERBOSE); |
629 |
} else { |
720 |
} else { |
630 |
SourceFileScanner sfs = new SourceFileScanner(this); |
721 |
SourceFileScanner sfs = new SourceFileScanner(this); |
631 |
newFiles = sfs.restrict(files, baseDir, baseDir, mapper); |
722 |
newFiles = sfs.restrict(files, baseDir, getOutputDir(), mapper); |
632 |
} |
723 |
} |
633 |
|
724 |
|
634 |
for (int i = 0; i < newFiles.length; i++) { |
725 |
for (int i = 0; i < newFiles.length; i++) { |