Skip to content

Commit

Permalink
- Tweaked (from ce319f5) the logic of the "compress" parameter to onl…
Browse files Browse the repository at this point in the history
…y be explicit when it deviates from the default option.

- Clarified the use of the "compress" and "compression" parameters in the documentation.
- Added logging of the makensis call with arguments
  • Loading branch information
Nadahar committed Nov 10, 2023
1 parent 70ffb06 commit 7d53cb8
Show file tree
Hide file tree
Showing 2 changed files with 30 additions and 24 deletions.
6 changes: 3 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -67,9 +67,9 @@ This goal compiles a NSIS script and builds a Windows executable.
|<sub>`attachArtifact`</sub>|<sub>`nsis.attachArtifact`</sub>|<sub>Boolean</sub>|<sub>`true`</sub>|<sub>Whether or not `outputFile` should be attached to the Maven build. You probably want an installer to be attached, but if you build another executable that might not be the case.</sub>|
|<sub>`autoNsisDir`</sub>|<sub>`nsis.auto.nsisdir`</sub>|<sub>Boolean</sub>|<sub>true</sub>|<sub>Whether or not to automatically set the `NSISDIR` environment variable based on the folder where the `makensis` executable is located. Useful when `makensis` is compiled with `NSIS_CONFIG_CONST_DATA_PATH=no`.</sub>|
|<sub>`classifier`</sub>|<sub>`nsis.classifier`</sub>|<sub>String</sub>| |<sub>The classifier to append to `outputFile`'s name.</sub>|
|<sub>`compress`</sub>|<sub>`nsis.compress`</sub>|<sub>Enum</sub>|<sub>`auto`</sub>|<sub>The compress option to apply to `scriptFile`. See [separate definition](#122-compress-options).</sub>|
|<sub>`compression`</sub>|<sub>`nsis.compression`</sub>|<sub>Enum</sub>|<sub>`zlib`</sub>|<sub>The compression type to apply to `scriptFile`. See [separate definition](#123-compression-options).</sub>|
|<sub>`compressionDictSize`</sub>|<sub>`nsis.compression.lzma.dictsize`</sub>|<sub>Integer</sub>|<sub>`8`</sub>|<sub>The dictionary size in MB to use if `compression` is `lzma`.</sub>|
|<sub>`compress`</sub>|<sub>`nsis.compress`</sub>|<sub>Enum</sub>|<sub>`auto`</sub>|<sub>The compress option to use when calling `makensis`. See [separate definition](#122-compress-options).</sub>|
|<sub>`compression`</sub>|<sub>`nsis.compression`</sub>|<sub>Enum</sub>|<sub>`zlib`</sub>|<sub>The compression type to use when calling `makensis`. See [separate definition](#123-compression-options).</sub>|
|<sub>`compressionDictSize`</sub>|<sub>`nsis.compression.lzma.dictsize`</sub>|<sub>Integer</sub>|<sub>`8`</sub>|<sub>The dictionary size in MB to use use when calling `makensis` if `compression` is `lzma`.</sub>|
|<sub>`compressionIsFinal`</sub>|<sub>`nsis.compression.final`</sub>|<sub>Boolean</sub>|<sub>`false`</sub>|<sub>Whether or not the compression defined in `compression` is`FINAL`.</sub>|
|<sub>`compressionIsSolid`</sub>|<sub>`nsis.compression.solid`</sub>|<sub>Boolean</sub>|<sub>`false`</sub>|<sub>Whether or not the compression defined in `compression` is`SOLID`.</sub>|
|<sub>`disabled`</sub>|<sub>`nsis.disabled`</sub>|<sub>Boolean</sub>|<sub>`false`</sub>|<sub>Deactivates all goals.</sub>|
Expand Down
48 changes: 27 additions & 21 deletions src/main/java/org/digitalmediaserver/nsis/MakeMojo.java
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,7 @@ public class MakeMojo extends AbstractMojo implements ProcessOutputConsumer {
* The {@link CompressOption} to apply to {@link #scriptFile}.
*/
@Parameter(property = "nsis.compress")
private CompressOption compress = DEFAULT_COMPRESS;
private CompressOption compress;

/**
* The {@link CompressionType} to apply to {@link #scriptFile}.
Expand Down Expand Up @@ -216,7 +216,8 @@ public void execute() throws MojoExecutionException {

validate();

ProcessBuilder builder = new ProcessBuilder(commandBuilder());
List<String> arguments = commandBuilder();
ProcessBuilder builder = new ProcessBuilder(arguments);
// Set the working directory
if (makeFolder == null) {
builder.directory(project.getBasedir());
Expand Down Expand Up @@ -249,6 +250,11 @@ public void execute() throws MojoExecutionException {

Charset charset = IS_WINDOWS ? Charset.defaultCharset() : StandardCharsets.UTF_8;
try {
StringBuilder sb = new StringBuilder("Executing:");
for (String part : arguments) {
sb.append(' ').append(part);
}
getLog().info(sb.toString());
long start = System.currentTimeMillis();
Process process = builder.start();
ProcessOutputHandler output = new ProcessOutputHandler(process.getInputStream(), this, charset);
Expand Down Expand Up @@ -430,28 +436,28 @@ protected List<String> commandBuilder() throws MojoExecutionException {
result.add(optionPrefix + "V" + verbosityLevel);

// Compress
if (compress != null) {
if (compress != null && compress != DEFAULT_COMPRESS) {
result.add(optionPrefix + "XSetCompress " + compress.name());
}

// Compression
if (compress != CompressOption.off) {
if (
compression != null && (
compression != DEFAULT_COMPRESSION || compressionIsFinal || compressionIsSolid
)) {
StringBuilder setCompressor = new StringBuilder(optionPrefix + "XSetCompressor");
if (compressionIsFinal) {
setCompressor.append(" /FINAL");
}
if (compressionIsSolid) {
setCompressor.append(" /SOLID");
}
setCompressor.append(' ').append(compression.name());
result.add(setCompressor.toString());
// Compression
if (compress != CompressOption.off) {
if (
compression != null && (
compression != DEFAULT_COMPRESSION || compressionIsFinal || compressionIsSolid
)) {
StringBuilder setCompressor = new StringBuilder(optionPrefix + "XSetCompressor");
if (compressionIsFinal) {
setCompressor.append(" /FINAL");
}
if (compressionIsSolid) {
setCompressor.append(" /SOLID");
}
setCompressor.append(' ').append(compression.name());
result.add(setCompressor.toString());

if (compression == CompressionType.lzma && compressionDictSize != DEFAULT_LZMA_DICT_SIZE) {
result.add(optionPrefix + "XSetCompressorDictSize " + compressionDictSize);
}
if (compression == CompressionType.lzma && compressionDictSize != DEFAULT_LZMA_DICT_SIZE) {
result.add(optionPrefix + "XSetCompressorDictSize " + compressionDictSize);
}
}
}
Expand Down

0 comments on commit 7d53cb8

Please sign in to comment.