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 1a4decd commit 5f657d3
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 11 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@

package ch.ivyteam.ivy.maven.deploy;

import java.io.File;
import java.nio.file.Files;
import java.nio.file.Path;
import java.nio.file.Paths;

Expand Down Expand Up @@ -166,13 +166,13 @@ private void deployToDirectory(Path resolvedOptionsFile) throws MojoExecutionExc
return;
}

if (!deployDir.exists()) {
if (!Files.exists(deployDir)) {
getLog().warn("Skipping deployment to engine '" + deployEngineDirectory + "'. The directory '"
+ deployDir + "' does not exist.");
return;
}
checkDirParams();
deployToDirectory(resolvedOptionsFile, deployDir.toPath());
deployToDirectory(resolvedOptionsFile, deployDir);
}

private void deployToRestService(Path resolvedOptionsFile) throws MojoExecutionException {
Expand Down Expand Up @@ -213,14 +213,14 @@ private void logParameterIgnoredByMethod(String parameter, String value, String
+ " deployment.");
}

private File getDeployDirectory() throws MojoExecutionException {
private Path getDeployDirectory() throws MojoExecutionException {
if (deployEngineDirectory == null || engineToTarget()) { // re-use engine used to build
deployEngineDirectory = getEngineDir(project).toPath();
}
if (Paths.get(deployDirectory).isAbsolute()) {
return new File(deployDirectory);
return Paths.get(deployDirectory);
}
return new File(deployEngineDirectory.toFile(), deployDirectory);
return deployEngineDirectory.resolve(deployDirectory);
}

public static interface DefaultDeployOptions {
Expand All @@ -234,5 +234,4 @@ public static interface DeployMethod {
String DIRECTORY = "DIRECTORY";
String HTTP = "HTTP";
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -123,7 +123,7 @@ Path createFullAppZip(List<Path> deps) throws ArchiverException, IOException {
if (d.isFile() && d.getName().endsWith("iar")) {
appZipper.addFile(d, d.getName());
} else if (d.isDirectory()) {
Optional<Path> packedIar = findPackedIar(d);
Optional<Path> packedIar = findPackedIar(dep);
if (packedIar.isPresent()) {
File iar = packedIar.get().toFile();
appZipper.addFile(iar, iar.getName());
Expand All @@ -139,8 +139,8 @@ Path createFullAppZip(List<Path> deps) throws ArchiverException, IOException {
return appZip.toPath();
}

static Optional<Path> findPackedIar(File dep) throws IOException {
Path target = dep.toPath().resolve("target");
static Optional<Path> findPackedIar(Path dep) throws IOException {
var target = dep.resolve("target");
if (!Files.isDirectory(target)) {
return Optional.empty();
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ public void autoAppZip() throws ArchiverException, IOException {
reactorProject,
builtTarget.getParent()));
assertThat(appZip.getFileName().toString()).isEqualTo("myApp-app.zip");
assertThat(DeployToTestEngineMojo.findPackedIar(builtTarget.getParent().toFile())).isPresent();
assertThat(DeployToTestEngineMojo.findPackedIar(builtTarget.getParent())).isPresent();
assertThat(getRootFiles(appZip))
.containsOnly("demo.iar", "demoTest.iar", "myReactorProject", "alreadyPacked.iar");
}
Expand Down

0 comments on commit 5f657d3

Please sign in to comment.