private String getCIJobPath(ApplicationInfo appInfo) { StringBuilder builder = new StringBuilder(Utility.getProjectHome()); builder.append(appInfo.getAppDirName()); builder.append(File.separator); builder.append(FOLDER_DOT_PHRESCO); builder.append(File.separator); builder.append(CI_JOB_INFO_NAME); return builder.toString(); }
@Override public void postFeatureConfiguration( ApplicationInfo appInfo, List<Configuration> configs, String featureName) throws PhrescoException { try { String propertyValue = getPropertyValue(appInfo, Constants.POM_PROP_KEY_SQL_FILE_DIR); File featureManifest = new File( Utility.getProjectHome() + appInfo.getAppDirName() + getThirdPartyFolder(appInfo) + File.separator + featureName + File.separator + XML); File featureSqlDir = new File(Utility.getProjectHome() + appInfo.getAppDirName() + propertyValue); if (CollectionUtils.isNotEmpty(configs)) { String envName = configs.get(0).getEnvName(); storeConfigObj(configs, featureManifest, featureSqlDir, envName); } } catch (Exception e) { throw new PhrescoException(e); } }
@Override public PossibleValues getValues(Map<String, Object> map) throws IOException, ParserConfigurationException, SAXException, ConfigurationException, PhrescoException { String rootModulePath = ""; String subModuleName = ""; PossibleValues possibleValues = new PossibleValues(); ApplicationInfo applicationInfo = (ApplicationInfo) map.get(KEY_APP_INFO); String rootModule = (String) map.get(KEY_ROOT_MODULE); if (StringUtils.isNotEmpty(rootModule)) { rootModulePath = Utility.getProjectHome() + rootModule; subModuleName = applicationInfo.getAppDirName(); } else { rootModulePath = Utility.getProjectHome() + applicationInfo.getAppDirName(); } String buildInfoPath = getBuildInfoPath(rootModulePath, subModuleName).toString(); List<BuildInfo> buildInfos = Utility.getBuildInfos(new File(buildInfoPath)); if (buildInfos != null) { for (BuildInfo buildInfo : buildInfos) { Value value = new Value(); value.setValue(Integer.toString(buildInfo.getBuildNo())); String dependency = getDependency(buildInfo.getBuildNo(), rootModulePath, subModuleName); if (!StringUtils.isEmpty(dependency)) { value.setDependency(dependency); } possibleValues.getValue().add(value); } } return possibleValues; }
@Override public void postUpdate( ApplicationInfo appInfo, List<ArtifactGroup> artifactGroups, List<ArtifactGroup> deletedFeatures) throws PhrescoException { File pomFile = new File( Utility.getProjectHome() + appInfo.getAppDirName() + File.separator + Constants.POM_NAME); ProjectUtils projectUtils = new ProjectUtils(); projectUtils.deletePluginExecutionFromPom(pomFile); if (CollectionUtils.isNotEmpty(deletedFeatures)) { projectUtils.removeExtractedFeatures(appInfo, deletedFeatures); } if (CollectionUtils.isNotEmpty(artifactGroups)) { projectUtils.updatePOMWithPluginArtifact(pomFile, artifactGroups); excludeModule(appInfo, artifactGroups); } BufferedReader breader = projectUtils.ExtractFeature(appInfo); try { String line = ""; while ((line = breader.readLine()) != null) { if (line.startsWith("[ERROR]")) { System.err.println(line); } } } catch (IOException e) { throw new PhrescoException(e); } }
@Override public void postConfiguration(ApplicationInfo appInfo, List<Configuration> configurations) throws PhrescoException { String envName = configurations.get(0).getEnvName(); String featureName = configurations.get(0).getProperties().getProperty(Constants.FEATURE_NAME); String propertyValue = getPropertyValue(appInfo, Constants.POM_PROP_KEY_SQL_FILE_DIR); File featureManifest = new File( Utility.getProjectHome() + appInfo.getAppDirName() + getThirdPartyFolder(appInfo) + File.separator + featureName + File.separator + XML); File featureSqlDir = new File(Utility.getProjectHome() + appInfo.getAppDirName() + propertyValue); if (StringUtils.isNotEmpty(featureName)) { storeConfigObj(configurations, featureManifest, featureSqlDir, envName); } }
@Override public List<Configuration> preConfiguration( ApplicationInfo appInfo, String featureName, String envName) throws PhrescoException { File featureManifest = new File( Utility.getProjectHome() + appInfo.getAppDirName() + getThirdPartyFolder(appInfo) + File.separator + featureName + File.separator + XML); List<Configuration> configs = getConfigObjFromXml(featureManifest.getPath()); return configs; }
private void excludeModule(ApplicationInfo appInfo, List<ArtifactGroup> artifactGroups) throws PhrescoException { try { File projectPath = new File( Utility.getProjectHome() + File.separator + appInfo.getAppDirName() + File.separator + Constants.POM_NAME); PomProcessor processor = new PomProcessor(projectPath); StringBuilder exclusionStringBuff = new StringBuilder(); StringBuilder exclusionValueBuff = new StringBuilder(); if (CollectionUtils.isEmpty(artifactGroups)) { return; } for (ArtifactGroup artifactGroup : artifactGroups) { List<CoreOption> appliesTo = artifactGroup.getAppliesTo(); for (CoreOption coreOption : appliesTo) { if (coreOption.isCore()) { exclusionValueBuff.append(artifactGroup.getName().toLowerCase()); exclusionValueBuff.append(","); exclusionStringBuff.append("**\\"); exclusionStringBuff.append(artifactGroup.getName().toLowerCase()); exclusionStringBuff.append("\\**"); exclusionStringBuff.append(","); } } } String exclusionValue = exclusionStringBuff.toString(); if (exclusionValue.lastIndexOf(',') != -1) { exclusionValue = exclusionValue.substring(0, exclusionValue.lastIndexOf(',')); } String exclusiontoolValue = exclusionValueBuff.toString(); if (exclusiontoolValue.lastIndexOf(',') != -1) { exclusiontoolValue = exclusiontoolValue.substring(0, exclusiontoolValue.lastIndexOf(',')); } processor.setProperty("sonar.exclusions", exclusionValue); processor.setProperty("sonar.phpDepend.argumentLine", "--ignore=" + exclusiontoolValue); processor.setProperty("sonar.phpPmd.argumentLine", "--exclude" + exclusiontoolValue); processor.save(); } catch (PhrescoPomException e) { throw new PhrescoException(e); } }
private String getThirdPartyFolder(ApplicationInfo appInfo) throws PhrescoException { File pomPath = new File( Utility.getProjectHome() + appInfo.getAppDirName() + File.separator + Constants.POM_NAME); try { PomProcessor processor = new PomProcessor(pomPath); String property = processor.getProperty(Constants.POM_PROP_KEY_MODULE_SOURCE_DIR); if (StringUtils.isNotEmpty(property)) { return property; } } catch (PhrescoPomException e) { throw new PhrescoException(e); } return ""; }
private String getPropertyValue(ApplicationInfo appInfo, String propertyKey) throws PhrescoException { File pomPath = new File( Utility.getProjectHome() + appInfo.getAppDirName() + File.separator + Constants.POM_NAME); try { PomProcessor processor = new PomProcessor(pomPath); String property = processor.getProperty(propertyKey); if (StringUtils.isNotEmpty(property)) { return property; } } catch (PhrescoPomException e) { throw new PhrescoException(e); } return ""; }
@Override public void postCreate(ApplicationInfo appInfo) throws PhrescoException { File path = new File(Utility.getProjectHome() + appInfo.getAppDirName()); updateDrupalVersion(path, appInfo); }