Mentions légales du service

Skip to content
Snippets Groups Projects
Commit cb3bd4b3 authored by Achraf Achkari's avatar Achraf Achkari
Browse files

[GOC-194] Retrieve Archetype from Remote

parent c1d2c79d
No related branches found
No related tags found
2 merge requests!2Release GOC,!1Release GOC
......@@ -20,7 +20,7 @@ public class ValidatorInstantiator {
if(javaHome != null && !javaHome.isEmpty()){
javaEnv = "env $JAVA_HOME=\""+javaHome+"\" ";
}
return CD_COMMAND + workspacePath + "\"\n" + javaEnv + mvnExecPath + " archetype:generate -B " +
return CD_COMMAND + workspacePath + "\"\n" + javaEnv + mvnExecPath + " org.apache.maven.plugins:maven-archetype-plugin:2.3:generate -B " +
"-DarchetypeGroupId=net.ihe.gazelle.goc " +
"-DarchetypeArtifactId=validator-archetype " +
"-DarchetypeVersion=" + getVersion() + " " +
......
......@@ -22,8 +22,9 @@ public class ArchetypeInstantiatorMaven implements ArchetypeInstantiator {
private static org.slf4j.Logger log = LoggerFactory.getLogger(ArchetypeInstantiatorMaven.class);
//this is supposed to be the version of the packager artifact. It is for now used as artifact version. See what we will use
private static final String gocVersion = "2.0.0";
private static final String gocVersion = "3.0.0";
private static final String CD_COMMAND = "cd \"";
private static final String REPOSITORY = "https://gazelle.ihe.net/nexus/content/groups/public/";
private String workspacesRoot;
private String mvnExecutionPath;
......@@ -112,20 +113,22 @@ public class ArchetypeInstantiatorMaven implements ArchetypeInstantiator {
*/
public void createValidatorArtifact(Workspace workspace, ValidatorConfiguration validatorConfiguration)
throws ArchetypeInstantiationException {
if(!checkIfArchetypeInstalled()){
throw new ArchetypeInstantiationException("Archtype not installed, generation will end, please refere to: https://gitlab.inria.fr/gazelle/library/archetypes/generated-validator to install it");
}
String workspacePath = getWorkspacesRoot() + workspace.getName();
String configuration = System.getProperty("HL7TEMP_CDACONFFOLDERNAME", "cdabasic");
String createArtifactCommand = ValidatorInstantiator.generateArchetype(workspacePath, getMvnExecutionPath(), gocVersion,
String createArchetypeCommand = ValidatorInstantiator.generateArchetype(workspacePath, getMvnExecutionPath(), gocVersion,
validatorConfiguration.getProjectNaming().getProjectName(), validatorConfiguration.getProjectNaming().getProjectNameUpperCase(), configuration,
validatorConfiguration.getProjectNaming().getProjectNameCapitalized(), validatorConfiguration.getServiceName(), workspacePath,
validatorConfiguration.ignoreCdaBasicRequirements().toString(),System.getProperty("JAVA_EXEC"));
log.warn("Command executed to generate model artifact : \n" + createArtifactCommand);
try {
processExecutor.executeProcess(createArtifactCommand);
} catch (IOException e){
throw new ArchetypeInstantiationException("Cannot generate validator artifact !", e);
log.warn("Command executed to generate model artifact : \n" + createArchetypeCommand);
log.info("Trying to look for archetype in local repository...");
if(!generateArchetypeFromRepository(createArchetypeCommand,null)){
log.warn("Archetype not found locally, retrieving from remote repository {} ",REPOSITORY);
if(!generateArchetypeFromRepository(createArchetypeCommand,REPOSITORY)){
log.error("Could not find archetype in remote repository: {}", REPOSITORY);
throw new ArchetypeInstantiationException("Cannot generate validator artifact !");
}
}
gocLogger.logSeparator("Extracting Value-sets","Extract Value-sets from the ValidatorConfiguration and put them in project resources");
......@@ -174,18 +177,18 @@ public class ArchetypeInstantiatorMaven implements ArchetypeInstantiator {
}
//TODO: 28/09/2021 make installation of archetype automatic
// protected void installArchetypeProject(){
// FolderCreator folderCreator = new FolderCreatorImpl();
// try {
// folderCreator.createFolder(getWorkspacesRoot()+"archetype");
// String command = CD_COMMAND + getWorkspacesRoot() + "\"archetype\"" + System.lineSeparator()
// + "git clone "
// } catch (IOException e) {
// log.error("failed creating archetype folder {}",e);
// }
// }
private boolean generateArchetypeFromRepository(String createArtifactCommand, String repository){
try {
if(repository != null && !repository.isEmpty()){
createArtifactCommand += " -DarchetypeRepository=\""+repository+"\"";
}
processExecutor.executeProcess(createArtifactCommand);
return true;
} catch (IOException e) {
return false;
}
}
......
......@@ -151,7 +151,7 @@ public class GOCLoggerImpl implements GOCLogger {
long milliseconds = (elapsedTime/1000000)%1000;
long seconds = (elapsedTime/(1000000*1000))%60;
long minutes = elapsedTime/(1000000000L *60);
String stringToLog = this.previousAction+" takes [ "+minutes+"m "+seconds+"s "+milliseconds+"ms ] to complete";
String stringToLog = this.previousAction+" took [ '"+minutes+"m "+seconds+"s "+milliseconds+"ms' ] to complete";
//log to detailed log file
log.info(stringToLog+"\n");
......@@ -176,10 +176,10 @@ public class GOCLoggerImpl implements GOCLogger {
BufferedWriter bufferedWriter = new BufferedWriter(new FileWriter(file,true));
bufferedWriter.write("==========================\n");
if(descriptor.equals(Descriptor.STDOUT)){
bufferedWriter.write("STDOUT of executing: "+command);
bufferedWriter.write("STDOUT of executing: "+command+"\n\n");
}
else{
bufferedWriter.write("STDERR of executing: "+command);
bufferedWriter.write("STDERR of executing: "+command+"\n\n");
}
while ((line = in.readLine()) != null) {
line += System.lineSeparator();
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment