source: release-kits/wirk2/src/wirk2.cpp@ 16087

Last change on this file since 16087 was 16087, checked in by oranfry, 16 years ago

did the bulk of the work on the windows release kit for greenstone2

File size: 5.3 KB
Line 
1#include <windows.h>
2
3#include <fstream>
4#include <iostream>
5#include <string>
6
7using namespace std;
8
9void replace_all ( std::string & str, std::string const & pattern, std::string const & replacement ) {
10
11 std::string::size_type start = str.find( pattern, 0 );
12
13 while ( start != str.npos ) {
14 str.replace( start, pattern.size(), replacement );
15 start = str.find( pattern, start+replacement.size() );
16 }
17
18}
19
20int main(int argc, char** argv ) {
21
22 string classpath, command;
23
24 //influential environment variables
25 string JAVA_HOME = getenv( "JAVA_HOME" );
26 string WIRK2_HOME = getenv( "WIRK2_HOME" );
27 //string PWD = getenv( "CD" );
28
29 //get the pwd
30 string pwd;
31 system( "CD > cd.dat" );
32 ifstream file( "cd.dat" ) ;
33 getline(file, pwd);
34 file.close();
35 system( "del cd.dat" );
36
37
38 //set the classpath
39 classpath = pwd + "\\installer;" + JAVA_HOME + "\\lib\\tools.jar;" + WIRK2_HOME + "\\lib\\serializer.jar;" + WIRK2_HOME + "\\lib\\xalan.jar;" + WIRK2_HOME + "\\lib\\xercesImpl.jar;" + WIRK2_HOME + "\\lib\\xml-apis.jar;" + WIRK2_HOME + "\\bin\\apache-ant-1.6.5\\lib\\ant-antlr.jar;" + WIRK2_HOME + "\\bin\\apache-ant-1.6.5\\lib\\ant-apache-bcel.jar;" + WIRK2_HOME + "\\bin\\apache-ant-1.6.5\\lib\\ant-apache-bsf.jar;" + WIRK2_HOME + "\\bin\\apache-ant-1.6.5\\lib\\ant-apache-log4j.jar;" + WIRK2_HOME + "\\bin\\apache-ant-1.6.5\\lib\\ant-apache-oro.jar;" + WIRK2_HOME + "\\bin\\apache-ant-1.6.5\\lib\\ant-apache-regexp.jar;" + WIRK2_HOME + "\\bin\\apache-ant-1.6.5\\lib\\ant-apache-resolver.jar;" + WIRK2_HOME + "\\bin\\apache-ant-1.6.5\\lib\\ant-commons-logging.jar;" + WIRK2_HOME + "\\bin\\apache-ant-1.6.5\\lib\\ant-commons-net.jar;" + WIRK2_HOME + "\\bin\\apache-ant-1.6.5\\lib\\ant-icontract.jar;" + WIRK2_HOME + "\\bin\\apache-ant-1.6.5\\lib\\ant-jai.jar;" + WIRK2_HOME + "\\bin\\apache-ant-1.6.5\\lib\\ant.jar;" + WIRK2_HOME + "\\bin\\apache-ant-1.6.5\\lib\\ant-javamail.jar;" + WIRK2_HOME + "\\bin\\apache-ant-1.6.5\\lib\\ant-jdepend.jar;" + WIRK2_HOME + "\\bin\\apache-ant-1.6.5\\lib\\ant-jmf.jar;" + WIRK2_HOME + "\\bin\\apache-ant-1.6.5\\lib\\ant-jsch.jar;" + WIRK2_HOME + "\\bin\\apache-ant-1.6.5\\lib\\ant-junit.jar;" + WIRK2_HOME + "\\bin\\apache-ant-1.6.5\\lib\\ant-launcher.jar;" + WIRK2_HOME + "\\bin\\apache-ant-1.6.5\\lib\\ant-netrexx.jar;" + WIRK2_HOME + "\\bin\\apache-ant-1.6.5\\lib\\ant-nodeps.jar;" + WIRK2_HOME + "\\bin\\apache-ant-1.6.5\\lib\\ant-starteam.jar;" + WIRK2_HOME + "\\bin\\apache-ant-1.6.5\\lib\\ant-stylebook.jar;" + WIRK2_HOME + "\\bin\\apache-ant-1.6.5\\lib\\ant-swing.jar;" + WIRK2_HOME + "\\bin\\apache-ant-1.6.5\\lib\\ant-trax.jar;" + WIRK2_HOME + "\\bin\\apache-ant-1.6.5\\lib\\ant-vaj.jar;" + WIRK2_HOME + "\\bin\\apache-ant-1.6.5\\lib\\ant-weblogic.jar;" + WIRK2_HOME + "\\bin\\apache-ant-1.6.5\\lib\\ant-xalan1.jar;" + WIRK2_HOME + "\\bin\\apache-ant-1.6.5\\lib\\ant-xslp.jar;" + WIRK2_HOME + "\\bin\\apache-ant-1.6.5\\lib\\xercesImpl.jar;" + WIRK2_HOME + "\\bin\\apache-ant-1.6.5\\lib\\xml-apis.jar;" + WIRK2_HOME + "\\bin\\ant-installer\\lib\\ai-icons-amaranth.jar;" + WIRK2_HOME + "\\bin\\ant-installer\\lib\\ai-icons-bluecurve.jar;" + WIRK2_HOME + "\\bin\\ant-installer\\lib\\ai-icons-crystalsvg.jar;" + WIRK2_HOME + "\\bin\\ant-installer\\lib\\ai-icons-eclipse.jar;" + WIRK2_HOME + "\\bin\\ant-installer\\lib\\ai-icons-krystaline.jar;" + WIRK2_HOME + "\\bin\\ant-installer\\lib\\ant-installer-ext.jar;" + WIRK2_HOME + "\\bin\\ant-installer\\lib\\ant-installer.jar;" + WIRK2_HOME + "\\bin\\ant-installer\\lib\\jgoodies-edited-1_2_2.jar;" + WIRK2_HOME + "\\bin\\ant-installer\\lib\\xercesImpl.jar;" + WIRK2_HOME + "\\bin\\ant-installer\\lib\\xml-apis.jar;" + WIRK2_HOME + "\\bin\\ant-installer\\classes";
40 putenv( ("CLASSPATH=" + classpath).c_str() );
41
42 //check that it worked
43 //string changed_classpath = getenv("CLASSPATH");
44 //cout << "classpath: " << changed_classpath << endl;
45
46 //create the command
47 command = WIRK2_HOME + "\\bin\\apache-ant-1.6.5\\bin\\ant.bat -f " + WIRK2_HOME + "\\ant-scripts\\build.xml -Dwirk2.home=" + WIRK2_HOME;
48 //pass on the arguments
49 string a;
50 for ( int i=0; i < argc; i++ ) {
51 a = argv[i];
52
53 if ( a.compare("-help") == 0 ) {
54 //show_help();
55 return 0;
56
57 } else if ( a.compare("-cp") == 0) {
58 cout << classpath;
59 return 0;
60
61 } else if ( a.compare("-sim") == 0 ) {
62 command += " -Dexecute=false";
63
64 } else if ( a.compare("-descend") == 0 ) {
65 command += " -Dresume.mode=descend";
66
67 } else if ( a.compare("-from") == 0 ) {
68 command = command + " -Dresume.from=" + argv[++i];
69 } else if ( a.compare("-to") == 0 ) {
70 command = command + " -Dresume.to=" + argv[++i];
71 } else {
72 command = command + " " + a;
73 }
74
75 }
76
77
78 //use forward slashes for everything else
79 //replace_all( pwd, "\\", "/" );
80
81 //set the basedir in the command
82 command = command + " -Dbasedir=";
83 command = command + pwd;
84
85
86
87 //command = command + ".";
88
89 cout
90 << "O-----------------------------------------O" << endl
91 << "| |" << endl
92 << "| WiRK2 |" << endl
93 << "| Windows Release Kit for Greenstone2 |" << endl
94 << "| |" << endl
95 << "O-----------------------------------------O" << endl
96 ;
97
98 cout << "pwd: " << pwd << endl;
99 cout << "command: " << command << endl;
100
101 system( command.c_str() );
102
103 return 0;
104
105}
Note: See TracBrowser for help on using the repository browser.