use of eu.bcvsolutions.idm.tool.exception.ReleaseException in project CzechIdMng by bcvsolutions.
the class AbstractReleaseManager method getCurrentVersion.
protected String getCurrentVersion() {
String currentVersion = null;
// BE
for (String backendModule : getBackendModules(getCurrentBackendModuleVersion(getRootBackendModule()))) {
String moduleVersion = getCurrentBackendModuleVersion(backendModule);
LOG.debug("Backend module [{}] has current version [{}].", backendModule, moduleVersion);
if (StringUtils.isEmpty(moduleVersion)) {
throw new ReleaseException(String.format("Backend module [%s] version cannot be resolved.", backendModule));
}
if (currentVersion == null) {
currentVersion = moduleVersion;
} else if (!currentVersion.equals(moduleVersion)) {
throw new ReleaseException(String.format("Backend module [%s] has wrong version [%s], expected version [%s].", backendModule, moduleVersion, currentVersion));
}
}
// FE
for (String frontendModule : getFrontendModules(currentVersion)) {
String moduleVersion = getCurrentFrontendModuleVersion(frontendModule);
LOG.debug("Frontend module [{}] has current version [{}].", frontendModule, moduleVersion);
if (StringUtils.isEmpty(moduleVersion)) {
throw new ReleaseException(String.format("Frontend module [%s] version cannot be resolved.", moduleVersion));
}
if (currentVersion == null) {
currentVersion = moduleVersion;
} else if (!currentVersion.equalsIgnoreCase(moduleVersion)) {
throw new ReleaseException(String.format("Frontend module [%s] has wrong version [%s], expected version [%s].", frontendModule, moduleVersion, currentVersion.toLowerCase()));
}
}
//
LOG.info("Current product version [{}].", currentVersion);
//
return currentVersion;
}
use of eu.bcvsolutions.idm.tool.exception.ReleaseException in project CzechIdMng by bcvsolutions.
the class AbstractReleaseManager method hasParentModule.
/**
* If module has parent defined.
*
* @param moduleName
* @return true = is submodule.
*/
protected boolean hasParentModule(String moduleName) {
File modulePackage = new File(String.format("%s/pom.xml", getBackendModuleBasePath(moduleName)));
Assert.isTrue(modulePackage.exists(), String.format("Backend module [%s] not found on filesystem.", moduleName));
//
try {
XmlMapper xmlMapper = new XmlMapper();
JsonNode json = xmlMapper.readTree(modulePackage);
//
return json.get("parent") != null;
} catch (Exception ex) {
throw new ReleaseException(ex);
}
}
use of eu.bcvsolutions.idm.tool.exception.ReleaseException in project CzechIdMng by bcvsolutions.
the class AbstractReleaseManager method gitCreateTag.
protected String gitCreateTag(String tagVersion) {
Assert.hasLength(tagVersion, "Tag version (~name) is required.");
//
boolean isSnapshotVersion = false;
if (isSnapshotVersion(tagVersion)) {
LOG.warn("Tag will be created for development version [{}] - it's only for development puprose (should not be pushed to origin).", tagVersion);
isSnapshotVersion = true;
}
String message;
if (isSnapshotVersion) {
ZonedDateTime now = ZonedDateTime.now();
DateTimeFormatter formatter = DateTimeFormatter.ofPattern(ConfigurationService.DEFAULT_APP_DATETIME_WITH_SECONDS_FORMAT);
message = String.format("Snapshot version %s (%s)", tagVersion, formatter.format(now));
} else {
message = String.format("Release version %s", tagVersion);
}
//
try {
git.tag().setName(tagVersion).setMessage(message).call();
} catch (Exception ex) {
throw new ReleaseException("Tag failed", ex);
}
//
if (isSnapshotVersion) {
LOG.info("Snapshot tag [{}] created.", tagVersion);
} else {
LOG.info("Tag [{}] created. Don't forget to push tag to origin if needed.", tagVersion);
}
//
return tagVersion;
}
use of eu.bcvsolutions.idm.tool.exception.ReleaseException in project CzechIdMng by bcvsolutions.
the class AbstractReleaseManager method init.
@Override
public void init() {
mavenManager = new MavenManager(mavenHome);
//
String repositoryRoot = getRepositoryRoot();
LOG.info("Repository location: [{}].", repositoryRoot);
Assert.hasLength(repositoryRoot, "Repository root is required.");
Assert.isTrue(new File(repositoryRoot).exists(), String.format("Repository root [%s] not found.", repositoryRoot));
//
LOG.info("Develop branch: [{}].", getDevelopBranch());
LOG.info("Master branch: [{}].", getMasterBranch());
//
try {
git = Git.open(new File(repositoryRoot));
} catch (Exception ex) {
throw new ReleaseException(String.format("Git repository in folder [%s] cannot be inited.", repositoryRoot), ex);
}
}
use of eu.bcvsolutions.idm.tool.exception.ReleaseException in project CzechIdMng by bcvsolutions.
the class AbstractReleaseManager method gitInitRepository.
/**
* Init repository - usable for tests
*/
protected void gitInitRepository() {
File repositoryRoot = new File(getRepositoryRoot());
Assert.isTrue(repositoryRoot.exists(), "Product root has to exist.");
//
try {
git = Git.init().setDirectory(repositoryRoot).call();
FileUtils.writeStringToFile(new File(repositoryRoot.getPath() + "/README.md"), "test repo", AttachableEntity.DEFAULT_CHARSET);
gitAddAll();
gitCommit("start commit");
} catch (Exception ex) {
throw new ReleaseException("Init repository failed", ex);
}
}
Aggregations