Skip to content

Commit

Permalink
Fixed description processing, packaging NPE and empty dirs
Browse files Browse the repository at this point in the history
*    Package descritption processing conserves empty lines and trims leading spaces
*    Fixed NPE when autoDependencies set to false and no package attributes provided
*    Version of snapshot (byyyyMMddHHmmss) packages use UTC time
*    No empty directory `/usr/share/<package>` during dependency processing is created
     if package has no dependencies.
  • Loading branch information
muter committed Sep 29, 2018
1 parent 56c3083 commit 38568e4
Show file tree
Hide file tree
Showing 4 changed files with 29 additions and 10 deletions.
2 changes: 1 addition & 1 deletion README.MD
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ the pom file.
<plugin>
<groupId>io.solit.maven</groupId>
<artifactId>deb-maven-plugin</artifactId>
<version>0.5</version>
<version>1.0-RC2</version>
<extensions>true</extensions>
</plugin>
</plugins>
Expand Down
13 changes: 12 additions & 1 deletion changelog.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,18 @@ All notable changes to this project will be documented in this file.
The format is based on [Keep a Changelog](http://keepachangelog.com/en/1.0.0/)
and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.html).

## Unreleased
## [Unreleased]

## [1.0-RC2] - 2018-09-30
### Fixed
* `package` goal failed with npe if `autoDependencies` set to false and no
`packageAttributes` present in configuration
* empty lines were ignored in package description
* snapshot package version is based was base on local time instead of UTC
* `populate` goal created empty '/usr/share/<package>' directory if project
has no runtime dependencies

## [1.0-RC1] - 2018-03-18
### Added
* `man` goal to generate roff man pages from markdown
* `changelog` goal to generate changelog.gz from markdown
Expand Down
19 changes: 14 additions & 5 deletions src/main/java/io/solit/plugin/maven/deb/pack/PackageMojo.java
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,9 @@
import java.security.MessageDigest;
import java.security.NoSuchAlgorithmException;
import java.time.LocalDateTime;
import java.time.ZoneId;
import java.time.ZoneOffset;
import java.time.ZonedDateTime;
import java.time.format.DateTimeFormatter;
import java.util.ArrayList;
import java.util.Arrays;
Expand Down Expand Up @@ -301,7 +304,7 @@ private Control createControl() {
String version = this.version, revision = this.revision;
if (version.endsWith(SNAPSHOT)) {
version = version.substring(0, version.length() - SNAPSHOT.length());
version += "+b" + LocalDateTime.now().format(DateTimeFormatter.ofPattern("yyyyMMddHHmmss"));
version += "+b" + ZonedDateTime.now(ZoneOffset.UTC).format(DateTimeFormatter.ofPattern("yyyyMMddHHmmss"));
}
String maintainer = this.maintainer;
if (maintainer == null)
Expand All @@ -312,7 +315,7 @@ private Control createControl() {
control.setDescription(processDescription());
if (packageAttributes != null)
packageAttributes.fillControl(control);
if (autoDependencies && packageAttributes == null || packageAttributes.getDepends() == null)
if (autoDependencies && (packageAttributes == null || packageAttributes.getDepends() == null))
fillAutoDependencies(control);
if (homepage != null)
control.setHomepage(homepage);
Expand All @@ -333,7 +336,8 @@ private String processDescription() {
while(scanner.hasNextLine()) {
String line = scanner.nextLine();
if (result.length() == 0) { //first line is trimmed by maven
result.append(line.trim()).append('\n');
line = line.substring(countWhitespaces(line)); // trim leading spaces just in case
result.append(line);
continue;
}
int ws = countWhitespaces(line);
Expand All @@ -342,8 +346,13 @@ private String processDescription() {
lines.add(line);
}
for (String line: lines)
if (line.length() > maxWhitespaces) // empty lines left as is
result.append(line.substring(maxWhitespaces)).append('\n');
if (line.length() > maxWhitespaces) // short lines considered empty
result.append('\n').append(line.substring(maxWhitespaces));
else
result.append('\n');
for (int i = result.length(); i > 0; i--)
if (result.charAt(i - 1) != '\n')
return result.substring(0, i);
return result.toString();
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,8 @@ protected void processDependency(DependencyArtifact node, Void nothing, File dep
return;
else
throw new MojoExecutionException("Unresolved dependency: " + node.getArtifact().toString());
if (!dependencyDir.isDirectory() && !dependencyDir.mkdirs())
throw new MojoExecutionException("Unable to create directory " + dependencyDir.toString());
Path target = new File(dependencyDir, src.getName()).toPath();
if (Files.exists(target))
return;
Expand All @@ -48,9 +50,6 @@ protected void processDependency(DependencyArtifact node, Void nothing, File dep

@Override
public void execute() throws MojoExecutionException, MojoFailureException {
File dependencyDir = getDependencyDirectory();
if (!dependencyDir.isDirectory() && !dependencyDir.mkdirs())
throw new MojoExecutionException("Unable to create directory " + dependencyDir.toString());
traverseDependencies(null);
}

Expand Down

0 comments on commit 38568e4

Please sign in to comment.