Skip to content

Commit

Permalink
šŸµšŸ¶šŸ»
Browse files Browse the repository at this point in the history
  • Loading branch information
alexsuter committed Jul 22, 2024
1 parent e7ffd63 commit 1a4decd
Show file tree
Hide file tree
Showing 4 changed files with 17 additions and 21 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -227,7 +227,7 @@ protected final boolean checkSkip() {
return false;
}

protected final File createDeployOptionsFile(DeploymentOptionsFileFactory optionsFileFactory)
protected final Path createDeployOptionsFile(DeploymentOptionsFileFactory optionsFileFactory)
throws MojoExecutionException {
if (deployOptionsFile != null) {
return optionsFileFactory.createFromTemplate(deployOptionsFile, project, session, fileFilter);
Expand All @@ -236,16 +236,20 @@ protected final File createDeployOptionsFile(DeploymentOptionsFileFactory option
try {
String yamlOptions = YamlOptionsFactory.toYaml(this);
if (StringUtils.isNotBlank(yamlOptions)) {
return optionsFileFactory.createFromConfiguration(yamlOptions).toFile();
return optionsFileFactory.createFromConfiguration(yamlOptions);
}
} catch (IOException ex) {
throw new MojoExecutionException("Failed to generate YAML option", ex);
}
return null;
}

protected static final void removeTemporaryDeploymentOptionsFile(File deploymentOptionsFile) {
FileUtils.deleteQuietly(deploymentOptionsFile);
protected static final void removeTemporaryDeploymentOptionsFile(Path deploymentOptionsFile) {
FileUtils.deleteQuietly(toFile(deploymentOptionsFile));
}

private static File toFile(Path file) {
return file == null ? null : file.toFile();
}

protected final void deployToDirectory(Path resolvedOptionsFile, Path deployDir)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -145,7 +145,7 @@ public void execute() throws MojoExecutionException, MojoFailureException {
}
}

private void deployWithOptions(File resolvedOptionsFile) throws MojoExecutionException {
private void deployWithOptions(Path resolvedOptionsFile) throws MojoExecutionException {
getLog().info("Deploying project " + deployFile.getFileName());
if (DeployMethod.DIRECTORY.equals(deployMethod)) {
deployToDirectory(resolvedOptionsFile);
Expand All @@ -158,7 +158,7 @@ private void deployWithOptions(File resolvedOptionsFile) throws MojoExecutionExc
}
}

private void deployToDirectory(File resolvedOptionsFile) throws MojoExecutionException {
private void deployToDirectory(Path resolvedOptionsFile) throws MojoExecutionException {
var deployDir = getDeployDirectory();
if (deployEngineDirectory == null) {
getLog().warn("Skipping deployment, target engine could not be evaluated." +
Expand All @@ -172,22 +172,18 @@ private void deployToDirectory(File resolvedOptionsFile) throws MojoExecutionExc
return;
}
checkDirParams();
deployToDirectory(toPath(resolvedOptionsFile), deployDir.toPath());
deployToDirectory(resolvedOptionsFile, deployDir.toPath());
}

private Path toPath(File file) {
return file == null ? null : file.toPath();
}

private void deployToRestService(File resolvedOptionsFile) throws MojoExecutionException {
private void deployToRestService(Path resolvedOptionsFile) throws MojoExecutionException {
checkHttpParams();

Server server = session.getSettings().getServer(deployServerId);
if (server == null) {
getLog().warn("Can not load credentials from settings.xml because server '" + deployServerId
+ "' is not definied. Try to deploy with default username, password");
}
var httpDeployer = new HttpDeployer(secDispatcher, server, deployEngineUrl, deployToEngineApplication, deployFile, resolvedOptionsFile.toPath());
var httpDeployer = new HttpDeployer(secDispatcher, server, deployEngineUrl, deployToEngineApplication, deployFile, resolvedOptionsFile);
httpDeployer.deploy(getLog());
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -151,16 +151,12 @@ static Optional<Path> findPackedIar(File dep) throws IOException {
}

private void deployTestApp() throws MojoExecutionException {
File resolvedOptionsFile = createDeployOptionsFile(new DeploymentOptionsFileFactory(deployFile));
var resolvedOptionsFile = createDeployOptionsFile(new DeploymentOptionsFileFactory(deployFile));
try {
var deployDir = getEngineDir(project).toPath().resolve(DeployToEngineMojo.DEPLOY_DEFAULT);
deployToDirectory(toPath(resolvedOptionsFile), deployDir);
deployToDirectory(resolvedOptionsFile, deployDir);
} finally {
removeTemporaryDeploymentOptionsFile(resolvedOptionsFile);
}
}

private Path toPath(File file) {
return file == null ? null : file.toPath();
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ public DeploymentOptionsFileFactory(Path deployableArtifact) {
this.deployableArtifact = deployableArtifact;
}

public File createFromTemplate(Path optionsFile, MavenProject project, MavenSession session,
public Path createFromTemplate(Path optionsFile, MavenProject project, MavenSession session,
MavenFileFilter fileFilter) throws MojoExecutionException {
if (!isOptionsFile(optionsFile.toFile())) {
return null;
Expand All @@ -36,7 +36,7 @@ public File createFromTemplate(Path optionsFile, MavenProject project, MavenSess
} catch (MavenFilteringException ex) {
throw new MojoExecutionException("Failed to resolve templates in options file", ex);
}
return targetFile.toFile();
return targetFile;
}

private static boolean isOptionsFile(File optionsFile) {
Expand Down

0 comments on commit 1a4decd

Please sign in to comment.