コード例 #1
0
 def createProject(self, dir, projectName, groupId):
     projectDir = dir+"/"+projectName;
     
     SOURCE_MAIN_JAVA = "src/main/java";
     SOURCE_MAIN_RESOURCES = "src/main/resources"
     SOURCE_TEST_JAVA = "src/test/java"
     SOURCE_TEST_RESOURCES = "src/test/resources";
     
     if not os.path.isdir(projectDir):
         os.mkdir(projectDir);
         # create the POM file
         FileGenerator.createPOMFile(projectName, groupId, projectDir);
     
         # create the project directories
     
         os.makedirs(projectDir+"/"+SOURCE_MAIN_JAVA);
         os.makedirs(projectDir+"/"+SOURCE_TEST_JAVA);
         os.makedirs(projectDir+"/"+SOURCE_MAIN_RESOURCES);
         os.makedirs(projectDir+"/"+SOURCE_TEST_RESOURCES);
         os.makedirs(projectDir+"/logs");
 
         packageFolderPathSrc = ProjectGenerator.createPackageFolder(self, projectDir, SOURCE_MAIN_JAVA, groupId);
         packageFolderPathTest = ProjectGenerator.createPackageFolder(self, projectDir, SOURCE_TEST_JAVA, groupId);
         
         ScriptMonitor.message("Creating source folder path: "+packageFolderPathSrc);
         ScriptMonitor.message("Creating test folder path: "+packageFolderPathTest);
             
         #create the MainApplication.java file
         
         FileGenerator.createSourceEntryFile(packageFolderPathSrc, groupId)
         FileGenerator.createLogPropertiesFile(groupId, projectDir+"/"+SOURCE_MAIN_RESOURCES+"/log4j.properties");
 
 
     else:
         print("ERR> Folder : "+projectDir+" exists");
コード例 #2
0
ファイル: FileGenerator.py プロジェクト: raheal/template-104
 def createPOMFile(projectName, groupId, projectDir):
     ScriptMonitor.message("Creating the model file: pom.xml");
     dict = {"{project.name}" : projectName, 
             "{artifact.id}": projectName,
             "{group.id}": groupId,
             "{version}": "1.0",
             "{list-dependencies}" : FileGenerator.readDependencyFile(),
             "{application.entrypoint}" : groupId+".app.MainApplication"};
 
     pomcontent = FileController.readFile("templates/pom.template");
     str = pomcontent;
     for i, j in dict.items():
         str = str.replace(i, j);
     FileController.writeToFile(str, projectDir+"/pom.xml");
コード例 #3
0
ファイル: FileGenerator.py プロジェクト: raheal/template-104
 def createSourceEntryFile(dir, groupId):
     ScriptMonitor.message("Creating sample java class: MainApplication.java");
     content = FileController.readFile("templates/java.template");
     res = content.replace("{package.name}", groupId+".app;")
     FileController.writeToFile(res, dir+"/MainApplication.java");
コード例 #4
0
ファイル: FileGenerator.py プロジェクト: raheal/template-104
 def createLogPropertiesFile(groupId, filepath):
     ScriptMonitor.message("Creating the log4j file: log4j.properties");
     content = FileController.readFile("templates/log.template");
     updatedContent = content.replace("{group.id}", groupId);
     FileController.writeToFile(updatedContent, filepath);
コード例 #5
0
ファイル: run.py プロジェクト: raheal/template-104
def main():
    projectName="";
    dir = "";
    groupId="";
    counter = 1;

    if(len(sys.argv) == 2):
        if(sys.argv[1] == "--help"):
            Utils.helpOutput();
            exit(0);
    else:
        for arg in sys.argv [1:]:
            if (arg == "--projectName"):
                projectName = sys.argv[counter+1];
            elif (arg == "--groupId"):
                groupId = sys.argv[counter+1];
            elif (arg == "--directory"):
                dir = sys.argv[counter+1];
            counter+=1;

    ScriptMonitor.message("********************************************");
    ScriptMonitor.message("Maven Project Builder")
    ScriptMonitor.message("********************************************");
    ScriptMonitor.message("projectName = "+projectName);
    ScriptMonitor.message("groupId = "+groupId);
    ScriptMonitor.message("projectDir = "+dir);
    projectGenerator = ProjectGenerator();
    projectGenerator.createProject(dir, projectName, groupId);
コード例 #6
0
 def __init__ (self):
     ScriptMonitor.message("Generating a project....");