use of com.faforever.api.config.FafApiProperties.Deployment in project faf-java-api by FAForever.
the class LegacyFeaturedModDeploymentTaskTest method setUp.
@Before
public void setUp() throws Exception {
properties = new FafApiProperties();
Deployment deployment = properties.getDeployment();
deployment.setRepositoriesDirectory(repositoriesFolder.getRoot().getAbsolutePath());
deployment.setFeaturedModsTargetDirectory(targetFolder.getRoot().getAbsolutePath());
instance = new LegacyFeaturedModDeploymentTask(gitWrapper, featuredModService, properties);
}
use of com.faforever.api.config.FafApiProperties.Deployment in project faf-java-api by FAForever.
the class LegacyFeaturedModDeploymentTask method run.
@Override
@SneakyThrows
@Transactional(TxType.MANDATORY)
public void run() {
Assert.state(featuredMod != null, "Configuration must be set");
String modName = featuredMod.getTechnicalName();
Assert.state(featuredModService.getFeaturedMods().stream().anyMatch(featuredMod -> Objects.equals(featuredMod.getTechnicalName(), modName)), "Unknown mod: " + modName);
String repositoryUrl = featuredMod.getGitUrl();
String branch = featuredMod.getGitBranch();
boolean allowOverride = Optional.ofNullable(featuredMod.isAllowOverride()).orElse(false);
String modFilesExtension = featuredMod.getFileExtension();
Map<String, Short> fileIds = featuredModService.getFileIds(modName);
log.info("Starting deployment of '{}' from '{}', branch '{}', allowOverride '{}', modFilesExtension '{}'", modName, repositoryUrl, branch, allowOverride, modFilesExtension);
Path repositoryDirectory = buildRepositoryDirectoryPath(repositoryUrl);
checkoutCode(repositoryDirectory, repositoryUrl, branch);
short version = readModVersion(repositoryDirectory);
verifyVersion(version, allowOverride, modName);
Deployment deployment = apiProperties.getDeployment();
Path targetFolder = Paths.get(deployment.getFeaturedModsTargetDirectory(), String.format(deployment.getFilesDirectoryFormat(), modName));
List<StagedFile> files = packageDirectories(repositoryDirectory, version, fileIds, targetFolder);
createPatchedExe(version, fileIds, targetFolder).ifPresent(files::add);
if (files.isEmpty()) {
log.warn("Could not find any files to deploy. Is the configuration correct?");
return;
}
files.forEach(this::finalizeFile);
updateDatabase(files, version, modName);
log.info("Deployment of '{}' version '{}' was successful", modName, version);
}
Aggregations