[Git][java-team/maven-debian-helper][master] 5 commits: Moved the email cleaning code of GenerateDebianFilesMojo into a separate method
Emmanuel Bourg
gitlab at salsa.debian.org
Wed Jun 27 10:54:28 BST 2018
Emmanuel Bourg pushed to branch master at Debian Java Maintainers / maven-debian-helper
Commits:
1035ce62 by Emmanuel Bourg at 2018-06-27T09:50:45+02:00
Moved the email cleaning code of GenerateDebianFilesMojo into a separate method
- - - - -
78e44799 by Emmanuel Bourg at 2018-06-27T09:53:04+02:00
Ask the questions first in the execute() method of GenerateDebianFilesMojo
- - - - -
bab5974b by Emmanuel Bourg at 2018-06-27T09:54:38+02:00
Removed the projectVersion variable in GenerateDebianFilesMojo
- - - - -
54d9590d by Emmanuel Bourg at 2018-06-27T09:57:02+02:00
Simplified GenerateDebianFilesMojo by using a Set to hold the dependencies
- - - - -
d42c6a35 by Emmanuel Bourg at 2018-06-27T09:58:14+02:00
Minor simplification when checking the developers in GenerateDebianFilesMojo
- - - - -
1 changed file:
- maven-packager-utils/src/main/java/org/debian/maven/packager/GenerateDebianFilesMojo.java
Changes:
=====================================
maven-packager-utils/src/main/java/org/debian/maven/packager/GenerateDebianFilesMojo.java
=====================================
--- a/maven-packager-utils/src/main/java/org/debian/maven/packager/GenerateDebianFilesMojo.java
+++ b/maven-packager-utils/src/main/java/org/debian/maven/packager/GenerateDebianFilesMojo.java
@@ -164,9 +164,14 @@ public class GenerateDebianFilesMojo extends AbstractMojo {
private LicensesScanner licensesScanner = new LicensesScanner();
public void execute() throws MojoExecutionException {
- // #638788: clean up email
- if (email != null && email.indexOf('<') >= 0 && email.indexOf('>') >= 0) {
- email = email.substring(email.indexOf('<') + 1, email.indexOf('>') - 1);
+ if (project.getName() == null || project.getName().isEmpty()) {
+ project.setName(new SimpleQuestion("POM does not contain the project name. Please enter the name of the project:").ask());
+ }
+ if (project.getUrl() == null || project.getUrl().isEmpty()) {
+ project.setUrl(new SimpleQuestion("POM does not contain the project URL. Please enter the URL of the project:").ask());
+ }
+ if (project.getDescription() == null || project.getDescription().trim().isEmpty()) {
+ project.setDescription(new MultilineQuestion("Please enter a short description of the project (press Enter twice to stop):").ask());
}
try {
@@ -179,19 +184,12 @@ public class GenerateDebianFilesMojo extends AbstractMojo {
context.put("packageType", packageType);
context.put("binPackage", binPackageName);
context.put("packager", packager);
- context.put("packagerEmail", email);
+ context.put("packagerEmail", extractEmail(email));
context.put("project", project);
context.put("collectedProjects", wrapMavenProjects(collectedProjects));
context.put("runTests", Boolean.valueOf(runTests));
context.put("generateJavadoc", Boolean.valueOf(generateJavadoc));
- if (project.getName() == null || project.getName().isEmpty()) {
- project.setName(new SimpleQuestion("POM does not contain the project name. Please enter the name of the project:").ask());
- }
- if (project.getUrl() == null || project.getUrl().isEmpty()) {
- project.setUrl(new SimpleQuestion("POM does not contain the project URL. Please enter the URL of the project:").ask());
- }
-
Set<String> licenses = licensesScanner.discoverLicenses(project.getLicenses());
context.put("licenses", licenses);
@@ -216,12 +214,11 @@ public class GenerateDebianFilesMojo extends AbstractMojo {
projectTeam = project.getOrganization().getName() + " developers";
}
if (copyrightOwner == null || copyrightOwner.isEmpty()) {
- Iterator<Developer> devs = project.getDevelopers().iterator();
- if (devs.hasNext()) {
- Developer dev = devs.next();
- copyrightOwner = dev.getName();
- if (dev.getEmail() != null && !dev.getEmail().isEmpty()) {
- copyrightOwner += " <" + dev.getEmail() + ">";
+ if (!project.getDevelopers().isEmpty()) {
+ Developer developer = project.getDevelopers().get(0);
+ copyrightOwner = developer.getName();
+ if (developer.getEmail() != null && !developer.getEmail().isEmpty()) {
+ copyrightOwner += " <" + developer.getEmail() + ">";
}
}
}
@@ -247,21 +244,17 @@ public class GenerateDebianFilesMojo extends AbstractMojo {
}
context.put("copyrightYear", copyrightYear);
context.put("currentYear", currentYear);
-
- if (project.getDescription() == null || project.getDescription().trim().isEmpty()) {
- project.setDescription(new MultilineQuestion("Please enter a short description of the project, press Enter twice to stop.").ask());
- }
context.put("description", formatDescription(project.getDescription()));
File substvarsFile = new File(outputDirectory, binPackageName + ".substvars");
if (substvarsFile.exists()) {
Properties substvars = new Properties();
substvars.load(new FileReader(substvarsFile));
- List<String> compileDepends = new ArrayList<String>();
+ Set<String> compileDepends = new TreeSet<String>();
compileDepends.addAll(split(substvars.getProperty("maven.CompileDepends")));
compileDepends.addAll(split(substvars.getProperty("maven.Depends")));
- List<String> buildDepends = new ArrayList<String>(compileDepends);
- List<String> testDepends = new ArrayList<String>(split(substvars.getProperty("maven.TestDepends")));
+ Set<String> buildDepends = new TreeSet<String>(compileDepends);
+ Set<String> testDepends = new TreeSet<String>(split(substvars.getProperty("maven.TestDepends")));
if (runTests) {
buildDepends.addAll(testDepends);
}
@@ -270,7 +263,6 @@ public class GenerateDebianFilesMojo extends AbstractMojo {
buildDepends.addAll(split(substvars.getProperty("maven.DocOptionalDepends")));
}
if ("maven".equals(packageType)) {
- boolean seenJavadocPlugin = false;
// Remove dependencies that are implied by maven-debian-helper
for (Iterator<String> i = buildDepends.iterator(); i.hasNext();) {
String dependency = i.next();
@@ -283,11 +275,9 @@ public class GenerateDebianFilesMojo extends AbstractMojo {
dependency.startsWith("velocity") ||
dependency.startsWith("libplexus-velocity-java")) {
i.remove();
- } else if (dependency.startsWith("libmaven-javadoc-plugin-java")) {
- seenJavadocPlugin = true;
}
}
- if (generateJavadoc && !seenJavadocPlugin) {
+ if (generateJavadoc) {
buildDepends.add("libmaven-javadoc-plugin-java");
}
} else if ("ant".equals(packageType)) {
@@ -342,7 +332,6 @@ public class GenerateDebianFilesMojo extends AbstractMojo {
}
}
- String projectVersion = project.getVersion();
int downloadType = DownloadType.UNKNOWN;
if (downloadUrl == null) {
@@ -353,7 +342,7 @@ public class GenerateDebianFilesMojo extends AbstractMojo {
if (downloadUrl != null && downloadUrl.startsWith("scm:svn:")) {
downloadType = DownloadType.SVN;
downloadUrl = downloadUrl.substring("scm:svn:".length());
- String tag = projectVersion;
+ String tag = project.getVersion();
int tagPos = downloadUrl.indexOf(tag);
String baseUrl = null;
String suffixUrl = null;
@@ -418,7 +407,7 @@ public class GenerateDebianFilesMojo extends AbstractMojo {
generateFile(context, "compat.vm", outputDirectory, "compat");
generateFile(context, rulesTemplate, outputDirectory, "rules", true);
- context.put("version.vm", mangleVersion(projectVersion) + "-1");
+ context.put("version.vm", mangleVersion(project.getVersion()) + "-1");
generateFile(context, rulesTemplate, new File("."), ".debianVersion");
@@ -471,6 +460,18 @@ public class GenerateDebianFilesMojo extends AbstractMojo {
}
/**
+ * Returns the email enclosed in < ... >.
+ *
+ * @see <a href="https://bugs.debian.org/638788">Bug #638788</a>
+ */
+ private String extractEmail(String email) {
+ if (email != null && email.indexOf('<') >= 0 && email.indexOf('>') >= 0) {
+ email = email.substring(email.indexOf('<') + 1, email.indexOf('>') - 1);
+ }
+ return email;
+ }
+
+ /**
* Normalizes the project version for use as a Debian package version.
*/
private String mangleVersion(String projectVersion) {
View it on GitLab: https://salsa.debian.org/java-team/maven-debian-helper/compare/2d1010b82bca4b33f9146674962d946455f12df9...d42c6a35427380ed906193cf0c9f4a5766727281
--
View it on GitLab: https://salsa.debian.org/java-team/maven-debian-helper/compare/2d1010b82bca4b33f9146674962d946455f12df9...d42c6a35427380ed906193cf0c9f4a5766727281
You're receiving this email because of your account on salsa.debian.org.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://alioth-lists.debian.net/pipermail/pkg-java-commits/attachments/20180627/116786c5/attachment.html>
More information about the pkg-java-commits
mailing list