bacoAlunos
ENGSOFT2019
BlueGrey
calm
Elegant
Català-Valencià - Catalan
中文 - Chinese (Simplified)
中文 - Chinese (Traditional)
Česky - Czech
Dansk - Danish
Nederlands - Dutch
English - English
Suomi - Finnish
Français - French
Deutsch - German
עברית - Hebrew
हिंदी - Hindi
Magyar - Hungarian
Bahasa Indonesia - Indonesian
Italiano - Italian
日本語 - Japanese
한국어 - Korean
मराठी - Marathi
Norsk - Norwegian
Polski - Polish
Português - Portuguese
Português - Portuguese (Brazil)
Русский - Russian
Slovenčina - Slovak
Slovenščina - Slovenian
Español - Spanish
Svenska - Swedish
Türkçe - Turkish
Oëzbekcha - Uzbek
Subversion Repositories
bacoAlunos
(root)
/
branches
/
v3
/
impl
/
src
/
java
/
jomm
/
utils
/
DosJarIncludePathGenerator.java
- Rev 1310
Rev
Rev 1306
|
Blame
|
Compare with Previous
|
Last modification
|
View Log
|
RSS feed
package
jomm.utils
;
import
java.io.File
;
import
java.io.FileWriter
;
import
java.io.IOException
;
/**
* @author Jorge Machado
* @date 8/Jul/2008
* @see jomm.utils
*/
public
class
DosJarIncludePathGenerator
{
public
static
final
1.
5
.0/docs/api/java/lang/String.html">
String
SEPARATOR =
"
\\
"
;
public
static
final
1.
5
.0/docs/api/java/lang/String.html">
String
TERMINATOR =
";"
;
public
static
final
1.
5
.0/docs/api/java/lang/String.html">
String
BASE_ENV =
"LIBS_DIR"
;
public
static
final
1.
5
.0/docs/api/java/lang/String.html">
String
BASE_ENV_REF =
"%"
+ BASE_ENV +
"%"
;
public
static
final
1.
5
.0/docs/api/java/lang/String.html">
String
CLASSPATH_ENV =
"LIBS"
;
public
static
void
main
(
1.
5
.0/docs/api/java/lang/String.html">
String
[
]
args
)
throws
1.
5
.0/docs/api/java/io/IOException.html">
IOException
{
if
(
args ==
null
|| args.
length
!
= 4
)
{
1.
5
.0/docs/api/java/lang/System.html">
System
.
out
.
println
(
"USAGE: main <jarsStartDir> <compiledClassesDir> <targetDir> <targetFile>"
)
;
return
;
}
1.
5
.0/docs/api/java/lang/String.html">
String
path = args
[
0
]
;
1.
5
.0/docs/api/java/lang/String.html">
String
classesDir = args
[
1
]
;
1.
5
.0/docs/api/java/lang/String.html">
String
targetDir = args
[
2
]
;
1.
5
.0/docs/api/java/lang/String.html">
String
targetFile = args
[
3
]
;
path = removeDotDot
(
path
)
;
classesDir = removeDotDot
(
classesDir
)
;
1.
5
.0/docs/api/java/lang/String.html">
String
classpath = classesDir +
";"
+ genDir
(
path,
""
)
;
1.
5
.0/docs/api/java/lang/System.html">
System
.
out
.
println
(
classesDir
)
;
1.
5
.0/docs/api/java/lang/System.html">
System
.
out
.
println
(
classpath
)
;
new
1.
5
.0/docs/api/java/io/File.html">
File
(
targetDir
)
.
mkdirs
(
)
;
1.
5
.0/docs/api/java/io/FileWriter.html">
FileWriter
writer =
new
1.
5
.0/docs/api/java/io/FileWriter.html">
FileWriter
(
targetDir + SEPARATOR + targetFile
)
;
writer.
write
(
"set "
+ BASE_ENV +
"="
+ path +
"
\n
"
)
;
writer.
write
(
"set "
+ CLASSPATH_ENV +
"="
+ classpath +
"
\n
"
)
;
writer.
close
(
)
;
}
public
static
1.
5
.0/docs/api/java/lang/String.html">
String
removeDotDot
(
1.
5
.0/docs/api/java/lang/String.html">
String
path
)
{
int
dotdot = path.
indexOf
(
".."
)
;
if
(
dotdot
>
= 0
)
{
1.
5
.0/docs/api/java/lang/String.html">
String
pathBeforeDotDot = path.
substring
(
0,dotdot - 1
)
;
int
lastIndexDotDotOfNewPath = pathBeforeDotDot.
lastIndexOf
(
SEPARATOR
)
;
pathBeforeDotDot = pathBeforeDotDot.
substring
(
0,lastIndexDotDotOfNewPath
)
;
path = pathBeforeDotDot + path.
substring
(
dotdot + 2
)
;
}
return
path
;
}
private
static
1.
5
.0/docs/api/java/lang/String.html">
String
genDir
(
1.
5
.0/docs/api/java/lang/String.html">
String
path,
1.
5
.0/docs/api/java/lang/String.html">
String
relative
)
{
1.
5
.0/docs/api/java/lang/String.html">
String
classpath =
""
;
1.
5
.0/docs/api/java/io/File.html">
File
pathFile =
new
1.
5
.0/docs/api/java/io/File.html">
File
(
path
)
;
1.
5
.0/docs/api/java/io/File.html">
File
[
]
files = pathFile.
listFiles
(
)
;
if
(
files
!
=
null
)
{
for
(
1.
5
.0/docs/api/java/io/File.html">
File
f: files
)
{
if
(
f.
isDirectory
(
)
)
classpath += genDir
(
pathFile + SEPARATOR + f.
getName
(
)
,relative + SEPARATOR + f.
getName
(
)
)
;
else
if
(
f.
getName
(
)
.
endsWith
(
".jar"
)
)
{
classpath += BASE_ENV_REF + relative + SEPARATOR + f.
getName
(
)
+ TERMINATOR
;
}
}
}
return
classpath
;
}
}