aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorMiroslav Šulc <fordfrog@gentoo.org>2019-11-27 10:44:05 +0100
committerMiroslav Šulc <fordfrog@gentoo.org>2019-11-27 10:49:19 +0100
commit46bbaf55e2d6924a324fbff3dc0755e4ad8280eb (patch)
tree25cad091a5f9930ff6b11aa0f8a1b33e64ea8049 /src
parentupdated maven plugin version (diff)
downloadjava-ebuilder-46bbaf55e2d6924a324fbff3dc0755e4ad8280eb.tar.gz
java-ebuilder-46bbaf55e2d6924a324fbff3dc0755e4ad8280eb.tar.bz2
java-ebuilder-46bbaf55e2d6924a324fbff3dc0755e4ad8280eb.zip
fixing download tarball name
Signed-off-by: Miroslav Šulc <fordfrog@gentoo.org>
Diffstat (limited to 'src')
-rw-r--r--src/main/java/org/gentoo/java/ebuilder/maven/MavenEbuilder.java42
1 files changed, 40 insertions, 2 deletions
diff --git a/src/main/java/org/gentoo/java/ebuilder/maven/MavenEbuilder.java b/src/main/java/org/gentoo/java/ebuilder/maven/MavenEbuilder.java
index 5ddfd9b..c9ec5b9 100644
--- a/src/main/java/org/gentoo/java/ebuilder/maven/MavenEbuilder.java
+++ b/src/main/java/org/gentoo/java/ebuilder/maven/MavenEbuilder.java
@@ -7,6 +7,8 @@ import java.nio.file.Path;
import java.time.LocalDate;
import java.util.ArrayList;
import java.util.List;
+import java.util.regex.Matcher;
+import java.util.regex.Pattern;
import org.gentoo.java.ebuilder.Config;
/**
@@ -20,6 +22,16 @@ public class MavenEbuilder {
* EAPI version.
*/
private static final String EAPI = "7";
+ /**
+ * Pattern for retrieval of tarball extension.
+ */
+ private static final Pattern PATTERN_TARBALL_EXTENSION = Pattern.compile(
+ "^.*((?:\\.tar)\\.\\S+)$");
+ /**
+ * Pattern for checking whether download tarball name matches expected name.
+ */
+ private static final Pattern PATTERN_TARBALL_NAME
+ = Pattern.compile("^.*/\\$\\{P\\}(?:\\.tar)\\.\\S+$");
/**
* Generates ebuild from the collected information at the specified path.
@@ -195,6 +207,32 @@ public class MavenEbuilder {
}
/**
+ * If the tarball name does not match pattern ${P}.ext then we will update
+ * it to store the tarball as ${P}.ext.
+ *
+ * @param srcUri source URI
+ *
+ * @return either original source URI or updated source URI
+ */
+ private String improveSrcUri(final String srcUri) {
+ if (PATTERN_TARBALL_NAME.matcher(srcUri).matches()) {
+ return srcUri;
+ }
+
+ final Matcher matcher = PATTERN_TARBALL_EXTENSION.matcher(srcUri);
+
+ /**
+ * We do not know how to get the extension so we will leave the tarball
+ * name as it is.
+ */
+ if (!matcher.matches()) {
+ return srcUri;
+ }
+
+ return srcUri + " -> " + "${P}" + matcher.group(1);
+ }
+
+ /**
* Merges maven project system dependencies of specified type and removed
* duplicates.
*
@@ -578,8 +616,8 @@ public class MavenEbuilder {
writer.println('"');
writer.print("SRC_URI=\"");
- writer.print(
- replaceWithVars(config.getDownloadUri().toString(), config));
+ writer.print(improveSrcUri(
+ replaceWithVars(config.getDownloadUri().toString(), config)));
writer.println('"');
writer.print("LICENSE=\"");