Skip to content

Commit 45eda4c

Browse files
committed
installationPath property type changed from file to string
1 parent 521683f commit 45eda4c

File tree

3 files changed

+19
-17
lines changed

3 files changed

+19
-17
lines changed

src/main/java/io/github/fvarrui/javapackager/model/LinuxConfig.java

+6-5
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
import java.io.File;
44
import java.io.Serializable;
55
import java.util.Arrays;
6+
import java.util.Collections;
67
import java.util.List;
78

89
import org.apache.commons.lang3.ObjectUtils;
@@ -21,7 +22,7 @@ public class LinuxConfig implements Serializable {
2122
private boolean generateAppImage = true;
2223
private File pngFile;
2324
private boolean wrapJar = true;
24-
private File installationPath;
25+
private String installationPath;
2526

2627
public void setCategories(List<String> categories) {
2728
this.categories = categories;
@@ -71,11 +72,11 @@ public void setWrapJar(boolean wrapJar) {
7172
this.wrapJar = wrapJar;
7273
}
7374

74-
public File getInstallationPath() {
75+
public String getInstallationPath() {
7576
return installationPath;
7677
}
7778

78-
public void setInstallationPath(File installationPath) {
79+
public void setInstallationPath(String installationPath) {
7980
this.installationPath = installationPath;
8081
}
8182

@@ -92,8 +93,8 @@ public String toString() {
9293
* @param packager Packager
9394
*/
9495
public void setDefaults(Packager packager) {
95-
this.setCategories((categories == null || categories.isEmpty()) ? Arrays.asList("Utility") : categories);
96-
this.setInstallationPath(ObjectUtils.defaultIfNull(installationPath, new File("/opt")));
96+
this.setCategories((categories == null || categories.isEmpty()) ? Collections.singletonList("Utility") : categories);
97+
this.setInstallationPath(ObjectUtils.defaultIfNull(installationPath, "/opt"));
9798
}
9899

99100
}

src/main/java/io/github/fvarrui/javapackager/packagers/GenerateDeb.java

+3-3
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@
2222
*/
2323
public class GenerateDeb extends ArtifactGenerator<LinuxPackager> {
2424

25-
private Console console;
25+
private final Console console;
2626

2727
public GenerateDeb() {
2828
super("DEB package");
@@ -64,8 +64,8 @@ protected File doApply(LinuxPackager packager) throws Exception {
6464
File executable = packager.getExecutable();
6565
File javaFile = new File(appFolder, jreDirectoryName + "/bin/java");
6666
File mimeXmlFile = packager.getMimeXmlFile();
67-
File installationPath = packager.getLinuxConfig().getInstallationPath();
68-
String appPath = new File(installationPath, name).toPath().normalize().toString();
67+
String installationPath = packager.getLinuxConfig().getInstallationPath();
68+
String appPath = installationPath + "/" + name;
6969

7070
// generates desktop file from velocity template
7171
File desktopFile = new File(assetsFolder, name + ".desktop");

src/main/java/io/github/fvarrui/javapackager/packagers/GenerateRpm.java

+10-9
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
import java.security.NoSuchAlgorithmException;
66
import java.util.ArrayList;
77
import java.util.List;
8+
import java.util.Objects;
89

910
import org.redline_rpm.Builder;
1011
import org.redline_rpm.header.Architecture;
@@ -44,9 +45,9 @@ protected File doApply(LinuxPackager packager) throws Exception {
4445
String jreDirectoryName = packager.getJreDirectoryName();
4546
Architecture arch = packager.getArch().toRpmArchitecture();
4647
File mimeXmlFile = packager.getMimeXmlFile();
47-
File installationPath = packager.getLinuxConfig().getInstallationPath();
48-
String appPath = new File(installationPath, name).toPath().normalize().toString();
49-
48+
String installationPath = packager.getLinuxConfig().getInstallationPath();
49+
String appPath = installationPath + "/" + name;
50+
5051
// generates desktop file from velocity template
5152
File desktopFile = new File(assetsFolder, name + ".desktop");
5253
VelocityUtils.render("linux/desktop.vtl", desktopFile, packager);
@@ -62,7 +63,7 @@ protected File doApply(LinuxPackager packager) throws Exception {
6263
builder.setPackage(name, version, "1");
6364
builder.setPackager(organizationName);
6465
builder.setDescription(description);
65-
builder.setPrefixes("opt");
66+
builder.setPrefixes(installationPath);
6667

6768
// list of files which needs execution permissions
6869
List<File> executionPermissions = new ArrayList<>();
@@ -71,7 +72,7 @@ protected File doApply(LinuxPackager packager) throws Exception {
7172
executionPermissions.add(new File(appFolder, jreDirectoryName + "/lib/jspawnhelper"));
7273

7374
// add all app files
74-
addDirectory(builder, installationPath.getAbsolutePath(), appFolder, executionPermissions);
75+
addDirectory(builder, installationPath, appFolder, executionPermissions);
7576

7677
// link to desktop file
7778
addLink(builder, "/usr/share/applications/" + desktopFile.getName(), appPath + "/" + desktopFile.getName());
@@ -86,13 +87,13 @@ protected File doApply(LinuxPackager packager) throws Exception {
8687
addLink(builder, "/usr/local/bin/" + executable.getName(), appPath + "/" + executable.getName());
8788

8889
// add all app files
89-
addDirectory(builder, "/opt", appFolder, executionPermissions);
90+
addDirectory(builder, installationPath, appFolder, executionPermissions);
9091

9192
// build RPM file
9293
builder.build(outputDirectory);
9394

94-
// renames genewrated RPM file if created
95-
String suffix = "-1." + arch.name().toLowerCase() + ".rpm";
95+
// renames generated RPM file if created
96+
String suffix = "-1." + arch + ".rpm";
9697
File originalRpm = new File(outputDirectory, name + "-" + version + suffix);
9798
File rpm = null;
9899
if (originalRpm.exists()) {
@@ -119,7 +120,7 @@ private void addDirectory(Builder builder, String parentPath, File directory, Li
119120
String dirPath = parentPath + "/" + directory.getName();
120121
Logger.info("Adding directory '" + directory + "' to RPM builder as '" + dirPath + "'");
121122
builder.addDirectory(dirPath);
122-
for (File f : directory.listFiles()) {
123+
for (File f : Objects.requireNonNull(directory.listFiles())) {
123124
if (f.isDirectory())
124125
addDirectory(builder, dirPath, f, executionPermissions);
125126
else {

0 commit comments

Comments
 (0)