Skip to content

Commit

Permalink
Fixed bug where the gradle wrapper jar is not copied from the console…
Browse files Browse the repository at this point in the history
… jar.
  • Loading branch information
AlexandrouR committed Sep 27, 2019
1 parent 990bfe9 commit 86c6bb6
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 9 deletions.
10 changes: 7 additions & 3 deletions src/main/java/org/web3j/console/project/ProjectWriter.java
Original file line number Diff line number Diff line change
Expand Up @@ -14,10 +14,10 @@

import java.io.File;
import java.io.IOException;
import java.io.InputStream;
import java.nio.file.Files;
import java.nio.file.Paths;
import java.nio.file.StandardCopyOption;
import java.util.Objects;

class ProjectWriter {

Expand All @@ -31,9 +31,13 @@ private byte[] getBytes(final String file) {
return file.getBytes();
}

final void copyResourceFile(final InputStream file, final String destinationPath)
final void copyResourceFile(final String file, final String destinationPath)
throws IOException {
Files.copy(file, Paths.get(destinationPath), StandardCopyOption.REPLACE_EXISTING);

Files.copy(
Objects.requireNonNull(getClass().getClassLoader().getResourceAsStream(file)),
Paths.get(destinationPath),
StandardCopyOption.REPLACE_EXISTING);
}

final void importSolidityProject(final File file, final String destination) throws IOException {
Expand Down
12 changes: 6 additions & 6 deletions src/main/java/org/web3j/console/project/TemplateProvider.java
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ public class TemplateProvider {
private final String gradlewWrapperSettings;
private final String gradlewBatScript;
private final String gradlewScript;
private final InputStream gradlewJar;
private final String gradlewJar;

private TemplateProvider(
final String mainJavaClass,
Expand All @@ -36,7 +36,7 @@ private TemplateProvider(
final String gradlewWrapperSettings,
final String gradlewBatScript,
final String gradlewScript,
final InputStream gradlewJar) {
final String gradlewJar) {
this.mainJavaClass = mainJavaClass;
this.solidityProject = solidityProject;
this.gradleBuild = gradleBuild;
Expand Down Expand Up @@ -75,7 +75,7 @@ String getGradlewScript() {
return gradlewScript;
}

InputStream getGradlewJar() {
String getGradlewJar() {
return gradlewJar;
}

Expand All @@ -87,7 +87,7 @@ public static class Builder {
private String gradlewBatScript;
private String gradlewScript;
private String solidityProject;
private InputStream gradlewJar;
private String gradlewWraperJar;
private Function<String, String> packageNameReplacement = s -> s;
private Function<String, String> projectNameReplacement = s -> s;

Expand Down Expand Up @@ -133,7 +133,7 @@ public Builder loadGradlewScript(final String name) throws IOException {
}

public Builder loadGradleJar(final String name) {
this.gradlewJar = getClass().getClassLoader().getResourceAsStream(name);
this.gradlewWraperJar = name;
return this;
}

Expand All @@ -158,7 +158,7 @@ TemplateProvider build() {
gradlewWrapperSettings,
gradlewBatScript,
gradlewScript,
gradlewJar);
gradlewWraperJar);
}

private String readFile(final String name) throws IOException {
Expand Down

0 comments on commit 86c6bb6

Please sign in to comment.