* [gentoo-commits] proj/java-ebuilder:master commit in: src/main/java/org/gentoo/java/ebuilder/maven/, ...
@ 2019-10-30 19:26 Miroslav Šulc
0 siblings, 0 replies; 6+ messages in thread
From: Miroslav Šulc @ 2019-10-30 19:26 UTC (permalink / raw
To: gentoo-commits
commit: e71822f64bdddf72820cdbda93a3339946a2f9e3
Author: Miroslav Šulc <fordfrog <AT> gentoo <DOT> org>
AuthorDate: Wed Oct 30 19:22:19 2019 +0000
Commit: Miroslav Šulc <fordfrog <AT> gentoo <DOT> org>
CommitDate: Wed Oct 30 19:22:30 2019 +0000
URL: https://gitweb.gentoo.org/proj/java-ebuilder.git/commit/?id=e71822f6
added header to the cache file
Signed-off-by: Miroslav Šulc <fordfrog <AT> gentoo.org>
src/main/java/org/gentoo/java/ebuilder/maven/MavenCache.java | 2 +-
src/main/java/org/gentoo/java/ebuilder/portage/PortageParser.java | 3 ++-
2 files changed, 3 insertions(+), 2 deletions(-)
diff --git a/src/main/java/org/gentoo/java/ebuilder/maven/MavenCache.java b/src/main/java/org/gentoo/java/ebuilder/maven/MavenCache.java
index 9d91528..4772e61 100644
--- a/src/main/java/org/gentoo/java/ebuilder/maven/MavenCache.java
+++ b/src/main/java/org/gentoo/java/ebuilder/maven/MavenCache.java
@@ -112,7 +112,7 @@ public class MavenCache {
line = reader.readLine();
while (line != null) {
- if (!line.isEmpty()) {
+ if (!line.isEmpty() && line.charAt(0) != '#') {
addCacheItem(new CacheItem(line));
}
diff --git a/src/main/java/org/gentoo/java/ebuilder/portage/PortageParser.java b/src/main/java/org/gentoo/java/ebuilder/portage/PortageParser.java
index 095e001..12422c2 100644
--- a/src/main/java/org/gentoo/java/ebuilder/portage/PortageParser.java
+++ b/src/main/java/org/gentoo/java/ebuilder/portage/PortageParser.java
@@ -386,7 +386,8 @@ public class PortageParser {
StandardOpenOption.TRUNCATE_EXISTING),
Charset.forName("UTF-8"))) {
writer.write(CACHE_VERSION);
- writer.write('\n');
+ writer.write("\n#category:pkg:version:slot:useFlag:groupId:"
+ + "artifactId:mavenVersion\n");
for (final CacheItem cacheItem : cacheItems) {
writer.write(cacheItem.getCategory());
^ permalink raw reply related [flat|nested] 6+ messages in thread
* [gentoo-commits] proj/java-ebuilder:master commit in: src/main/java/org/gentoo/java/ebuilder/maven/, ...
@ 2019-10-30 19:26 Miroslav Šulc
0 siblings, 0 replies; 6+ messages in thread
From: Miroslav Šulc @ 2019-10-30 19:26 UTC (permalink / raw
To: gentoo-commits
commit: 6997747f61ccd821b0f31a1f0228a57ba9a2ded6
Author: Miroslav Šulc <fordfrog <AT> gentoo <DOT> org>
AuthorDate: Wed Oct 30 19:26:31 2019 +0000
Commit: Miroslav Šulc <fordfrog <AT> gentoo <DOT> org>
CommitDate: Wed Oct 30 19:26:31 2019 +0000
URL: https://gitweb.gentoo.org/proj/java-ebuilder.git/commit/?id=6997747f
reformatted
Signed-off-by: Miroslav Šulc <fordfrog <AT> gentoo.org>
src/main/java/org/gentoo/java/ebuilder/maven/MavenCache.java | 4 ++--
.../java/org/gentoo/java/ebuilder/portage/PortageParser.java | 11 ++++++-----
2 files changed, 8 insertions(+), 7 deletions(-)
diff --git a/src/main/java/org/gentoo/java/ebuilder/maven/MavenCache.java b/src/main/java/org/gentoo/java/ebuilder/maven/MavenCache.java
index 4772e61..0aa33c5 100644
--- a/src/main/java/org/gentoo/java/ebuilder/maven/MavenCache.java
+++ b/src/main/java/org/gentoo/java/ebuilder/maven/MavenCache.java
@@ -98,8 +98,8 @@ public class MavenCache {
cache.clear();
- try (final BufferedReader reader = new BufferedReader(new FileReader(
- config.getCacheFile().toFile()))) {
+ try (final BufferedReader reader = new BufferedReader(
+ new FileReader(config.getCacheFile().toFile()))) {
String line = reader.readLine();
if (!PortageParser.CACHE_VERSION.equals(line)) {
diff --git a/src/main/java/org/gentoo/java/ebuilder/portage/PortageParser.java b/src/main/java/org/gentoo/java/ebuilder/portage/PortageParser.java
index 6b0ae3c..d504b2c 100644
--- a/src/main/java/org/gentoo/java/ebuilder/portage/PortageParser.java
+++ b/src/main/java/org/gentoo/java/ebuilder/portage/PortageParser.java
@@ -174,7 +174,8 @@ public class PortageParser {
*/
private void parseEbuild(final File ebuild) {
final String filename = ebuild.getName().replaceAll("\\.ebuild$", "");
- final String category = ebuild.getParentFile().getParentFile().getName();
+ final String category
+ = ebuild.getParentFile().getParentFile().getName();
final String pkg = ebuild.getParentFile().getName();
final String version = filename.substring(pkg.length() + 1);
final Map<String, String> variables = new HashMap<>(20);
@@ -206,8 +207,8 @@ public class PortageParser {
final Matcher matcher = PATTERN_VARIABLE.matcher(line);
if (matcher.matches()) {
- variables.put(matcher.group(1), matcher.group(2).
- replaceAll("(^\"|\"$)", ""));
+ variables.put(matcher.group(1),
+ matcher.group(2).replaceAll("(^\"|\"$)", ""));
}
if (line.startsWith("inherit ")) {
@@ -336,8 +337,8 @@ public class PortageParser {
}
if (result.indexOf('$') != -1) {
- final Matcher matcher = PATTERN_SLOT_VERSION_COMPOPONENT_RANGE.
- matcher(result);
+ final Matcher matcher
+ = PATTERN_SLOT_VERSION_COMPOPONENT_RANGE.matcher(result);
if (matcher.matches()) {
final int start = Integer.parseInt(matcher.group(1), 10);
^ permalink raw reply related [flat|nested] 6+ messages in thread
* [gentoo-commits] proj/java-ebuilder:master commit in: src/main/java/org/gentoo/java/ebuilder/maven/, ...
@ 2019-11-02 21:32 Miroslav Šulc
0 siblings, 0 replies; 6+ messages in thread
From: Miroslav Šulc @ 2019-11-02 21:32 UTC (permalink / raw
To: gentoo-commits
commit: 1673958029040f3368d310341832db6d03c18c9c
Author: Miroslav Šulc <fordfrog <AT> gentoo <DOT> org>
AuthorDate: Sat Nov 2 21:32:16 2019 +0000
Commit: Miroslav Šulc <fordfrog <AT> gentoo <DOT> org>
CommitDate: Sat Nov 2 21:32:16 2019 +0000
URL: https://gitweb.gentoo.org/proj/java-ebuilder.git/commit/?id=16739580
added option for dumping parsed projects
Signed-off-by: Miroslav Šulc <fordfrog <AT> gentoo.org>
src/main/java/org/gentoo/java/ebuilder/Config.java | 22 +++++++
src/main/java/org/gentoo/java/ebuilder/Main.java | 28 ++++++++
.../gentoo/java/ebuilder/maven/MavenProject.java | 75 ++++++++++++++++++++++
src/main/resources/usage.txt | 2 +
4 files changed, 127 insertions(+)
diff --git a/src/main/java/org/gentoo/java/ebuilder/Config.java b/src/main/java/org/gentoo/java/ebuilder/Config.java
index 9bc98f8..3bf8cb8 100644
--- a/src/main/java/org/gentoo/java/ebuilder/Config.java
+++ b/src/main/java/org/gentoo/java/ebuilder/Config.java
@@ -24,6 +24,10 @@ public class Config {
* URI that goes to SRC_URI.
*/
private URI downloadUri;
+ /**
+ * Whether to output information about parsed projects.
+ */
+ private boolean dumpProjects;
/**
* Path to ebuild file that should be generated.
*/
@@ -327,6 +331,24 @@ public class Config {
this.workdir = workdir;
}
+ /**
+ * Getter for {@link #dumpProjects}.
+ *
+ * @return {@link #dumpProjects}
+ */
+ public boolean isDumpProjects() {
+ return dumpProjects;
+ }
+
+ /**
+ * Setter for {@link #dumpProjects}.
+ *
+ * @param dumpProjects {@link #dumpProjects}
+ */
+ public void setDumpProjects(final boolean dumpProjects) {
+ this.dumpProjects = dumpProjects;
+ }
+
/**
* Getter for {@link #generateEbuild}.
*
diff --git a/src/main/java/org/gentoo/java/ebuilder/Main.java b/src/main/java/org/gentoo/java/ebuilder/Main.java
index bb6fbd7..871ac2a 100644
--- a/src/main/java/org/gentoo/java/ebuilder/Main.java
+++ b/src/main/java/org/gentoo/java/ebuilder/Main.java
@@ -126,6 +126,9 @@ public class Main {
} else if (config.getDownloadUri() != null) {
config.getErrorWriter().println("WARNING: Download URI is used "
+ "only when generating ebuild.");
+ } else if (config.isDumpProjects()) {
+ config.getErrorWriter().println("WARNING: Dumping of projects can "
+ + "be used only when generating ebuild.");
} else if (config.getEbuild() != null) {
config.getErrorWriter().println(
"WARNING: Ebuild is used only when "
@@ -155,6 +158,23 @@ public class Main {
}
}
+ private static void dumpMavenProjects(final Config config,
+ final List<MavenProject> mavenProjects) {
+ int i = 0;
+
+ for (final MavenProject mavenProject : mavenProjects) {
+ config.getStdoutWriter().println(MessageFormat.format(
+ "\n===== PROJECT {0} DUMP START =====", i));
+ mavenProject.dump(config.getStdoutWriter());
+ config.getStdoutWriter().println(MessageFormat.format(
+ "===== PROJECT {0} DUMP END =====", i));
+
+ i++;
+ }
+
+ config.getStdoutWriter().println();
+ }
+
/**
* Processed generation of ebuild.
*
@@ -170,6 +190,10 @@ public class Main {
final List<MavenProject> mavenProjects
= mavenParser.parsePomFiles(config, mavenCache);
+ if (config.isDumpProjects()) {
+ dumpMavenProjects(config, mavenProjects);
+ }
+
final MavenEbuilder mavenEbuilder = new MavenEbuilder();
mavenEbuilder.generateEbuild(config, mavenProjects, mavenCache);
}
@@ -197,6 +221,10 @@ public class Main {
+ " is not valid.");
}
+ break;
+ case "--dump-projects":
+ case "-d":
+ config.setDumpProjects(true);
break;
case "--ebuild":
case "-e":
diff --git a/src/main/java/org/gentoo/java/ebuilder/maven/MavenProject.java b/src/main/java/org/gentoo/java/ebuilder/maven/MavenProject.java
index ba575b1..6d0d8ec 100644
--- a/src/main/java/org/gentoo/java/ebuilder/maven/MavenProject.java
+++ b/src/main/java/org/gentoo/java/ebuilder/maven/MavenProject.java
@@ -1,5 +1,6 @@
package org.gentoo.java.ebuilder.maven;
+import java.io.PrintWriter;
import java.nio.file.Path;
import java.util.ArrayList;
import java.util.Collections;
@@ -121,6 +122,80 @@ public class MavenProject {
testResourceDirectories.add(path);
}
+ /**
+ * Outputs project properties to the writer.
+ *
+ * @param writer writer
+ */
+ public void dump(final PrintWriter writer) {
+ writer.print("POM file: ");
+ writer.println(pomFile);
+ writer.print("groupId: ");
+ writer.println(groupId);
+ writer.print("artifactId: ");
+ writer.println(artifactId);
+ writer.print("version: ");
+ writer.println(version);
+ writer.print("description: ");
+ writer.println(description);
+ writer.print("homepage: ");
+ writer.println(homepage);
+ writer.print("mainClass: ");
+ writer.println(mainClass);
+ writer.print("sourceVersion: ");
+ writer.println(sourceVersion);
+ writer.print("targetVersion: ");
+ writer.println(targetVersion);
+ writer.print("sourceEncoding: ");
+ writer.println(sourceEncoding);
+ writer.print("sourceDirectory: ");
+ writer.println(sourceDirectory);
+ writer.print("hasResources: ");
+ writer.println(hasResources);
+
+ writer.print("resourceDirectories:");
+
+ if (resourceDirectories != null) {
+ resourceDirectories.forEach((resourceDirectory) -> {
+ writer.print(" ");
+ writer.println(resourceDirectory);
+ });
+ }
+
+ writer.print("hasTests: ");
+ writer.println(hasTests);
+ writer.print("testSourceDirectory: ");
+ writer.println(testSourceDirectory);
+ writer.print("hasTestResources: ");
+ writer.println(hasTestResources);
+
+ writer.println("testResourceDirectories:");
+
+ testResourceDirectories.forEach((testResourceDirectory) -> {
+ writer.print(" ");
+ writer.println(testResourceDirectory);
+ });
+
+ writer.println("dependencies:");
+
+ if (dependencies != null) {
+ dependencies.forEach((dependency) -> {
+ writer.print("\n groupId: ");
+ writer.println(dependency.getGroupId());
+ writer.print(" artifactId: ");
+ writer.println(dependency.getArtifactId());
+ writer.print(" mavenVersion: ");
+ writer.println(dependency.getMavenVersion());
+ writer.print(" scope: ");
+ writer.println(dependency.getScope());
+ writer.print(" systemDependency: ");
+ writer.println(dependency.getSystemDependency());
+ writer.print(" version: ");
+ writer.println(dependency.getVersion());
+ });
+ }
+ }
+
/**
* Getter for {@link #artifactId}.
*
diff --git a/src/main/resources/usage.txt b/src/main/resources/usage.txt
index 4ad06d7..fc2689f 100644
--- a/src/main/resources/usage.txt
+++ b/src/main/resources/usage.txt
@@ -2,6 +2,8 @@ Usage: java-ebuilder <args>
Generating ebuild:
--download-uri|-u <uri> uri that goes to SRC_URI
+--dump-projects|-d outputs information about parsed projects (useful
+ for debugging)
--ebuild|-e <file> path to ebuild that should be created
--generate-ebuild|-g generates ebuild from pom.xml
--keywords|-k <keywords> arch keywords
^ permalink raw reply related [flat|nested] 6+ messages in thread
* [gentoo-commits] proj/java-ebuilder:master commit in: src/main/java/org/gentoo/java/ebuilder/maven/, ...
@ 2019-11-03 10:12 Miroslav Šulc
0 siblings, 0 replies; 6+ messages in thread
From: Miroslav Šulc @ 2019-11-03 10:12 UTC (permalink / raw
To: gentoo-commits
commit: 19b00d811bf2c5ef67146a8afabed9c7b09e984a
Author: Miroslav Šulc <fordfrog <AT> gentoo <DOT> org>
AuthorDate: Sun Nov 3 10:12:12 2019 +0000
Commit: Miroslav Šulc <fordfrog <AT> gentoo <DOT> org>
CommitDate: Sun Nov 3 10:12:12 2019 +0000
URL: https://gitweb.gentoo.org/proj/java-ebuilder.git/commit/?id=19b00d81
fixed project dump maven version output
Signed-off-by: Miroslav Šulc <fordfrog <AT> gentoo.org>
.../java/org/gentoo/java/ebuilder/maven/MavenProject.java | 2 +-
.../org/gentoo/java/ebuilder/portage/MavenVersion.java | 15 +++++++++++++++
2 files changed, 16 insertions(+), 1 deletion(-)
diff --git a/src/main/java/org/gentoo/java/ebuilder/maven/MavenProject.java b/src/main/java/org/gentoo/java/ebuilder/maven/MavenProject.java
index c3f45f8..6cead37 100644
--- a/src/main/java/org/gentoo/java/ebuilder/maven/MavenProject.java
+++ b/src/main/java/org/gentoo/java/ebuilder/maven/MavenProject.java
@@ -185,7 +185,7 @@ public class MavenProject {
writer.print(" artifactId: ");
writer.println(dependency.getArtifactId());
writer.print(" mavenVersion: ");
- writer.println(dependency.getMavenVersion());
+ writer.println(dependency.getMavenVersion().getVersion());
writer.print(" scope: ");
writer.println(dependency.getScope());
writer.print(" systemDependency: ");
diff --git a/src/main/java/org/gentoo/java/ebuilder/portage/MavenVersion.java b/src/main/java/org/gentoo/java/ebuilder/portage/MavenVersion.java
index 657d3c4..1de54e1 100644
--- a/src/main/java/org/gentoo/java/ebuilder/portage/MavenVersion.java
+++ b/src/main/java/org/gentoo/java/ebuilder/portage/MavenVersion.java
@@ -36,6 +36,10 @@ public class MavenVersion implements Comparable<MavenVersion> {
* Version qualifier.
*/
private final String qualifier;
+ /**
+ * Original version string.
+ */
+ private final String version;
/**
* Creates new instance of MavenVersion.
@@ -43,6 +47,8 @@ public class MavenVersion implements Comparable<MavenVersion> {
* @param version version string
*/
public MavenVersion(final String version) {
+ this.version = version;
+
final Matcher matcherRange = PATTERN_VERSION_RANGE.matcher(version);
final String useVersion;
@@ -115,4 +121,13 @@ public class MavenVersion implements Comparable<MavenVersion> {
public String getQualifier() {
return qualifier;
}
+
+ /**
+ * Getter for {@link #version}.
+ *
+ * @return {@link #version}
+ */
+ public String getVersion() {
+ return version;
+ }
}
^ permalink raw reply related [flat|nested] 6+ messages in thread
* [gentoo-commits] proj/java-ebuilder:master commit in: src/main/java/org/gentoo/java/ebuilder/maven/, ...
@ 2020-08-05 14:31 Miroslav Šulc
0 siblings, 0 replies; 6+ messages in thread
From: Miroslav Šulc @ 2020-08-05 14:31 UTC (permalink / raw
To: gentoo-commits
commit: 6052789c154452e2198ddf57983d626ba870c321
Author: zongyu <zzy2529420793 <AT> gmail <DOT> com>
AuthorDate: Mon Aug 3 13:16:36 2020 +0000
Commit: Miroslav Šulc <fordfrog <AT> gentoo <DOT> org>
CommitDate: Mon Aug 3 14:42:52 2020 +0000
URL: https://gitweb.gentoo.org/proj/java-ebuilder.git/commit/?id=6052789c
initial effort to support multiple testing frameworks
Signed-off-by: zongyu <zzy2529420793 <AT> gmail.com>
src/main/java/org/gentoo/java/ebuilder/Config.java | 40 +++++++
src/main/java/org/gentoo/java/ebuilder/Main.java | 17 ++-
.../gentoo/java/ebuilder/maven/MavenEbuilder.java | 128 +++++++++++++++------
.../gentoo/java/ebuilder/maven/MavenParser.java | 5 +
.../gentoo/java/ebuilder/maven/MavenProject.java | 9 ++
src/main/resources/usage.txt | 1 +
6 files changed, 161 insertions(+), 39 deletions(-)
diff --git a/src/main/java/org/gentoo/java/ebuilder/Config.java b/src/main/java/org/gentoo/java/ebuilder/Config.java
index 27dbc7c..dbfa30b 100644
--- a/src/main/java/org/gentoo/java/ebuilder/Config.java
+++ b/src/main/java/org/gentoo/java/ebuilder/Config.java
@@ -98,6 +98,14 @@ public class Config {
* Writer for standard output.
*/
private final PrintWriter stdoutWriter;
+ /**
+ * URI that goes to *-test-sources.jar distributed by maven central
+ */
+ private URI testSrcUri;
+ /**
+ * whether testSrcUri is set and whether the pkg is from maven central.
+ */
+ private boolean testSrcUriExists;
/**
* Path to workdir.
*/
@@ -377,6 +385,35 @@ public class Config {
return stdoutWriter;
}
+ /**
+ * Getter for {@link #testSrcUri}.
+ *
+ * @return {@link #testSrcUri}
+ */
+ public URI getTestSrcUri() {
+ return testSrcUri;
+ }
+
+ /**
+ * Getter for {@link #testSrcUriExists}.
+ *
+ * @return {@link #testSrcUriExists}
+ */
+ public boolean hasTestSrcUri() {
+ return testSrcUriExists;
+ }
+
+ /**
+ * Setter for {@link #testSrcUri}.
+ *
+ * @param testSrcUri {@link #testSrcUri}
+ */
+ public void setTestSrcUri(final URI testSrcUri) {
+ this.testSrcUri = testSrcUri;
+ if (isFromMavenCentral()) {
+ this.testSrcUriExists = true;
+ }
+ }
/**
* Getter for {@link #workdir}.
*
@@ -429,6 +466,9 @@ public class Config {
*/
public void setFromMavenCentral(final boolean fromMavenCentral) {
this.fromMavenCentral = fromMavenCentral;
+ if (getTestSrcUri() != null) {
+ this.testSrcUriExists = true;
+ }
}
/**
diff --git a/src/main/java/org/gentoo/java/ebuilder/Main.java b/src/main/java/org/gentoo/java/ebuilder/Main.java
index 72e0a04..49f6a49 100644
--- a/src/main/java/org/gentoo/java/ebuilder/Main.java
+++ b/src/main/java/org/gentoo/java/ebuilder/Main.java
@@ -219,7 +219,9 @@ public class Main {
try {
config.setBinjarUri(new URI(args[i]));
} catch (final URISyntaxException ex) {
- config.getErrorWriter().println("ERROR: BINJAR_URI " + args[i]
+ config.getErrorWriter().println(
+ "ERROR: URI goes to binary jar "
+ + args[i]
+ " is not valid.");
}
@@ -291,6 +293,19 @@ public class Main {
case "-s":
i++;
config.setSlot(args[i]);
+ break;
+ case "--test-src-uri":
+ i++;
+
+ try {
+ config.setTestSrcUri(new URI(args[i]));
+ } catch (final URISyntaxException ex) {
+ config.getErrorWriter().println(
+ "ERROR: URI that goes to src code for testing"
+ + args[i]
+ + " is not valid.");
+ }
+
break;
case "--workdir":
case "-w":
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 857d6c1..b9778ef 100644
--- a/src/main/java/org/gentoo/java/ebuilder/maven/MavenEbuilder.java
+++ b/src/main/java/org/gentoo/java/ebuilder/maven/MavenEbuilder.java
@@ -6,9 +6,11 @@ import java.io.PrintWriter;
import java.nio.file.Path;
import java.time.LocalDate;
import java.util.ArrayList;
+import java.util.HashSet;
import java.util.List;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
+import java.util.Set;
import org.gentoo.java.ebuilder.Config;
/**
@@ -29,6 +31,14 @@ public class MavenEbuilder {
private static final String defaultHomepage
= "https://wiki.gentoo.org/wiki/No_homepage";
+ /**
+ * The extra dependency for framework "pkgdiff"
+ */
+ private static final String dependencyForPkgdiff
+ = "\n\t\tamd64? (\n\t\t\tdev-util/pkgdiff"
+ + "\n\t\t\tdev-util/japi-compliance-checker"
+ + "\n\t\t)";
+
/**
* EAPI version.
*/
@@ -42,7 +52,13 @@ public class MavenEbuilder {
* Pattern for checking whether download tarball name matches expected name.
*/
private static final Pattern PATTERN_TARBALL_NAME
- = Pattern.compile("^.*/\\$\\{P\\}-sources.((?:\\.tar)\\.\\S+|(?:\\.jar))$");
+ = Pattern.compile("^.*/\\$\\{P\\}-sources((?:\\.tar)\\.\\S+|(?:\\.jar))$");
+
+ /**
+ * Pattern for checking whether download tarball for testing name matches expected name.
+ */
+ private static final Pattern PATTERN_TEST_TARBALL_NAME
+ = Pattern.compile("^.*/\\$\\{P\\}-test-sources\\.jar$");
/**
* Pattern for checking whether the dependency is specifying versions.
@@ -139,9 +155,10 @@ public class MavenEbuilder {
* @return testing framework name or null
*/
private String determineTestingFramework(
- final List<MavenProject> mavenProjects) {
+ final List<MavenProject> mavenProjects, final Config config) {
for (final MavenProject mavenProject : mavenProjects) {
- final String result = determineTestingFramework(mavenProject);
+ final String result
+ = determineTestingFramework(mavenProject, config);
if (result != null) {
return result;
@@ -158,24 +175,61 @@ public class MavenEbuilder {
*
* @return testing framework name or null
*/
- private String determineTestingFramework(final MavenProject mavenProject) {
+ private String determineTestingFramework(
+ final MavenProject mavenProject, final Config config) {
+ Set<String> frameworks = new HashSet<>(10);
+
for (final MavenDependency dependency : mavenProject.
getTestDependencies()) {
- if ("junit".equals(dependency.getGroupId())
- && "junit".equals(dependency.getArtifactId())) {
- return "junit";
- }
+ frameworks.add(determineTestingFrameworkByDependency(dependency));
}
for (final MavenDependency dependency : mavenProject.
getCommonDependencies()) {
- if ("junit".equals(dependency.getGroupId())
- && "junit".equals(dependency.getArtifactId())) {
- return "junit";
- }
+ frameworks.add(determineTestingFrameworkByDependency(dependency));
}
- return null;
+ if (config.hasBinjarUri()) {
+ frameworks.add("pkgdiff");
+ }
+
+ frameworks.remove(null);
+
+ if (frameworks.size() == 0) {
+ return null;
+ } else {
+ return String.join(" ", frameworks);
+ }
+ }
+
+ /**
+ * Determines the testing framework based on project dependencies.
+ *
+ * @param mavenProject maven project
+ *
+ * @return testing framework name or null
+ */
+ private String determineTestingFrameworkByDependency(
+ final MavenDependency dependency) {
+ /** TODO: missing support for
+ * "org.junit.vintage:junit-vintage-engine" tests
+ * "POJO" tests
+ * "spock" tests
+ * "cucumber" tests
+ */
+ if ("junit".equals(dependency.getGroupId())
+ && "junit".equals(dependency.getArtifactId())) {
+ return "junit";
+ } else if ("org.testng".equals(dependency.getGroupId())
+ && "testng".equals(dependency.getArtifactId())) {
+ return "testng";
+ } else if ("org.junit.jupiter".equals(dependency.getGroupId())
+ && "junit-jupiter-engine".
+ equals(dependency.getArtifactId())) {
+ return "junit-5";
+ } else {
+ return null;
+ }
}
/**
@@ -275,40 +329,23 @@ public class MavenEbuilder {
}
/**
- * If the tarball name does not match pattern ${P}-test.ext then we will update
- * it to store the tarball as ${P}-test.ext.
+ * If the tarball name does not match pattern ${P}-test-sources.jar
+ * we will update it to store the tarball as ${P}-test-sources.jar.
+ * Note that we only need it for Maven central artifacts, so it is
+ * safe to assume that the extension should be ".jar".
*
* @param TestSrcUri source test URI
*
* @return either original source test URI or updated source test URI
+ */
private String improveTestSrcUri(final String TestSrcUri) {
if (PATTERN_TEST_TARBALL_NAME.matcher(TestSrcUri).matches()) {
return TestSrcUri;
}
- final Matcher matcher = PATTERN_TARBALL_EXTENSION.matcher(TestSrcUri);
-
- /**
- * We do not know how to get the extension so we will leave the tarball
- * name as it is.
- /
- if (!matcher.matches()) {
- return TestSrcUri;
- }
-
- return TestSrcUri + " -> " + "${P}-test" + matcher.group(1);
+ return TestSrcUri + " -> " + "${P}-test-sources.jar";
}
- */
- /**
- * Merges maven project system dependencies of specified type and removed
- * duplicates.
- *
- * @param mavenProjects list of maven projects
- * @param type type of dependencies ("common", "compile", "runtime"
- * and "test")
- *
- * @return list of merged dependencies
/**
* Merges maven project system dependencies of specified type and removed
* duplicates.
@@ -401,6 +438,11 @@ public class MavenEbuilder {
writer.print(config.getBinjarUri());
}
+ if (config.hasTestSrcUri()) {
+ writer.print(" --test-src-uri ");
+ writer.print(config.getTestSrcUri());
+ }
+
if (config.getLicense() != null) {
writer.print(" --license ");
writer.print(config.getLicense());
@@ -526,7 +568,7 @@ public class MavenEbuilder {
writer.println("\t)");
}
- if (!testDependencies.isEmpty()) {
+ if (!testDependencies.isEmpty() || config.hasBinjarUri()) {
writer.println("\ttest? (");
testDependencies.stream().forEach((dependency) -> {
@@ -534,6 +576,11 @@ public class MavenEbuilder {
writer.println(dependency);
});
+ // TODO: check whether amd64 is inside KEYWORDS
+ if (config.hasBinjarUri()) {
+ writer.println(dependencyForPkgdiff);
+ }
+
writer.println("\t)");
}
@@ -734,6 +781,10 @@ public class MavenEbuilder {
writer.print("\n\t" + improveBinjarUri(
replaceWithVars(config.getBinjarUri().toString(), config)));
}
+ if (config.hasTestSrcUri()) {
+ writer.print("\n\t" + improveTestSrcUri(
+ replaceWithVars(config.getTestSrcUri().toString(), config)));
+ }
writer.println('"');
writer.print("LICENSE=\"");
@@ -838,7 +889,8 @@ public class MavenEbuilder {
writer.println("JAVA_BINJAR_FILENAME=\"${P}-bin.jar\"");
}
- final String testingFramework = determineTestingFramework(mavenProject);
+ final String testingFramework
+ = determineTestingFramework(mavenProject, config);
boolean firstTestVar = true;
if (testingFramework != null) {
diff --git a/src/main/java/org/gentoo/java/ebuilder/maven/MavenParser.java b/src/main/java/org/gentoo/java/ebuilder/maven/MavenParser.java
index d487024..73acd6e 100644
--- a/src/main/java/org/gentoo/java/ebuilder/maven/MavenParser.java
+++ b/src/main/java/org/gentoo/java/ebuilder/maven/MavenParser.java
@@ -44,6 +44,7 @@ public class MavenParser {
final MavenProject mavenProject = parsePom(config, mavenCache,
pomFile, effectivePom);
+ // TODO: I suppose they should go to "POJO" tests
if (mavenProject.hasTests()
&& mavenProject.getTestDependencies().isEmpty()) {
mavenProject.addDependency(new MavenDependency(
@@ -51,6 +52,10 @@ public class MavenParser {
mavenCache.getDependency("junit", "junit", "4.11")));
}
+ if (config.hasTestSrcUri()) {
+ mavenProject.setHasTests(true);
+ }
+
result.add(mavenProject);
});
diff --git a/src/main/java/org/gentoo/java/ebuilder/maven/MavenProject.java b/src/main/java/org/gentoo/java/ebuilder/maven/MavenProject.java
index 2fd88de..4ce11b8 100644
--- a/src/main/java/org/gentoo/java/ebuilder/maven/MavenProject.java
+++ b/src/main/java/org/gentoo/java/ebuilder/maven/MavenProject.java
@@ -560,6 +560,15 @@ public class MavenProject {
return hasTests;
}
+ /**
+ * Setter for {@link #hasTests}
+ *
+ * @param hasTests {@link #hasTests}
+ */
+ public void setHasTests(boolean hasTests) {
+ this.hasTests = hasTests;
+ }
+
/**
* Returns dependencies based on the specified scopes.
*
diff --git a/src/main/resources/usage.txt b/src/main/resources/usage.txt
index 78ab745..1ceceeb 100644
--- a/src/main/resources/usage.txt
+++ b/src/main/resources/usage.txt
@@ -3,6 +3,7 @@ Usage: java-ebuilder <args>
Generating ebuild:
--download-uri|-u <uri> uri that goes to SRC_URI
--binjar-uri <uri> uri that goes to binary jar
+--test-src-uri <uri> uri that goes to test-sources from Maven Central
--dump-projects|-d outputs information about parsed projects
(useful for debugging)
--ebuild|-e <file> path to ebuild that should be created
^ permalink raw reply related [flat|nested] 6+ messages in thread
* [gentoo-commits] proj/java-ebuilder:master commit in: src/main/java/org/gentoo/java/ebuilder/maven/, ...
@ 2020-08-05 14:31 Miroslav Šulc
0 siblings, 0 replies; 6+ messages in thread
From: Miroslav Šulc @ 2020-08-05 14:31 UTC (permalink / raw
To: gentoo-commits
commit: 11678b72a491963a8bad6d65c84d6228a0e3ac5a
Author: zongyu <zzy2529420793 <AT> gmail <DOT> com>
AuthorDate: Tue Aug 4 07:10:01 2020 +0000
Commit: Miroslav Šulc <fordfrog <AT> gentoo <DOT> org>
CommitDate: Wed Aug 5 04:05:24 2020 +0000
URL: https://gitweb.gentoo.org/proj/java-ebuilder.git/commit/?id=11678b72
sort KEYWORDS
Signed-off-by: zongyu <zzy2529420793 <AT> gmail.com>
src/main/java/org/gentoo/java/ebuilder/Config.java | 32 ++++++++++++++++----
src/main/java/org/gentoo/java/ebuilder/Main.java | 2 +-
.../gentoo/java/ebuilder/maven/MavenProject.java | 2 +-
.../java/ebuilder/portage/KeywordComparator.java | 35 ++++++++++++++++++++++
src/main/resources/usage.txt | 2 +-
5 files changed, 64 insertions(+), 9 deletions(-)
diff --git a/src/main/java/org/gentoo/java/ebuilder/Config.java b/src/main/java/org/gentoo/java/ebuilder/Config.java
index dbfa30b..4502ab3 100644
--- a/src/main/java/org/gentoo/java/ebuilder/Config.java
+++ b/src/main/java/org/gentoo/java/ebuilder/Config.java
@@ -7,7 +7,10 @@ import java.nio.file.Paths;
import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
+import java.util.SortedSet;
+import java.util.TreeSet;
import org.gentoo.java.ebuilder.maven.JavaVersion;
+import org.gentoo.java.ebuilder.portage.KeywordComparator;
/**
* Container for command line configuration.
@@ -73,7 +76,7 @@ public class Config {
/**
* Arch keywords.
*/
- private String keywords;
+ private SortedSet<String> keywords = new TreeSet<>(new KeywordComparator());
/**
* License name.
*/
@@ -301,16 +304,33 @@ public class Config {
* @return {@link #keywords}
*/
public String getKeywords() {
- return keywords;
+ return String.join(" ", keywords);
}
/**
- * Setter for {@link #keywords}.
+ * add keyword to {@link #keywords}.
*
- * @param keywords {@link #keywords}
+ * @param keyword String that contains one or more keywords
*/
- public void setKeywords(final String keywords) {
- this.keywords = keywords;
+ public void addKeywords(final String keywords) {
+ String[] parts = keywords.split(" ");
+
+ /**
+ * Make "-amd64" replace "amd64 ~amd64"
+ * Make "amd64" replace "~amd64"
+ */
+ for (String part : parts) {
+ if (part.startsWith("-")) {
+ this.keywords.remove(part.substring(1));
+ this.keywords.remove("~" + part.substring(1));
+ this.keywords.add(part);
+ } else if (part.startsWith("~")) {
+ this.keywords.add(part);
+ } else {
+ this.keywords.remove("~" + part);
+ this.keywords.add(part);
+ }
+ }
}
/**
diff --git a/src/main/java/org/gentoo/java/ebuilder/Main.java b/src/main/java/org/gentoo/java/ebuilder/Main.java
index 49f6a49..999f741 100644
--- a/src/main/java/org/gentoo/java/ebuilder/Main.java
+++ b/src/main/java/org/gentoo/java/ebuilder/Main.java
@@ -262,7 +262,7 @@ public class Main {
case "--keywords":
case "-k":
i++;
- config.setKeywords(args[i]);
+ config.addKeywords(args[i]);
break;
case "--license":
case "-l":
diff --git a/src/main/java/org/gentoo/java/ebuilder/maven/MavenProject.java b/src/main/java/org/gentoo/java/ebuilder/maven/MavenProject.java
index e1016a8..51ec844 100644
--- a/src/main/java/org/gentoo/java/ebuilder/maven/MavenProject.java
+++ b/src/main/java/org/gentoo/java/ebuilder/maven/MavenProject.java
@@ -46,7 +46,7 @@ public class MavenProject {
/**
* Lisences.
*/
- private SortedSet<String> licenses = new TreeSet<>(10);
+ private SortedSet<String> licenses = new TreeSet<>();
/**
* Homepage URL.
*/
diff --git a/src/main/java/org/gentoo/java/ebuilder/portage/KeywordComparator.java b/src/main/java/org/gentoo/java/ebuilder/portage/KeywordComparator.java
new file mode 100644
index 0000000..4382cf4
--- /dev/null
+++ b/src/main/java/org/gentoo/java/ebuilder/portage/KeywordComparator.java
@@ -0,0 +1,35 @@
+package org.gentoo.java.ebuilder.portage;
+
+import java.util.Comparator;
+
+/**
+ * a comparator to sort keywords
+ *
+ * @author Zhang Zongyu
+ */
+public class KeywordComparator implements Comparator<String> {
+
+ /**
+ * it is designed to compare KEYWORDS as what repoman will do:
+ * 1) "-amd64", "amd64" and "~amd64" are the same -- they will
+ * not appear at the same time in a TreeSet;
+ * 2) After splitting the strings into two parts by "-", it will
+ * compare the suffixes before it compares the prefixes.
+ */
+ @Override
+ public int compare(String o1, String o2) {
+ // prepend "-0-" to make sure the length of the array is 2
+ final String[] trimmedO1 = (o1 + "-0-").
+ replaceAll("^[-~]", "").
+ split("-", 2);
+ final String[] trimmedO2 = (o2 + "-0-").
+ replaceAll("^[-~]", "").
+ split("-", 2);
+
+ if (trimmedO1[1].compareTo(trimmedO2[1]) == 0) {
+ return trimmedO1[0].compareTo(trimmedO2[0]);
+ } else {
+ return trimmedO1[1].compareTo(trimmedO2[1]);
+ }
+ }
+}
diff --git a/src/main/resources/usage.txt b/src/main/resources/usage.txt
index 1ceceeb..e48e3f9 100644
--- a/src/main/resources/usage.txt
+++ b/src/main/resources/usage.txt
@@ -10,7 +10,7 @@ Generating ebuild:
--force-min-java-version <version> force minimum JDK/JRE version in dependencies
--from-maven-central make java-ebuilder inherit java-pkg-maven.eclass
--generate-ebuild|-g generates ebuild from pom.xml
---keywords|-k <keywords> arch keywords
+--keywords|-k <keywords> arch keywords (can be specified multiple times)
--license|-l <license> license name, if it is not specified,
java-ebuilder will determine LICENSE from pom.xml
--pom|-p <file> path to pom.xml that should be parsed,
^ permalink raw reply related [flat|nested] 6+ messages in thread
end of thread, other threads:[~2020-08-05 14:31 UTC | newest]
Thread overview: 6+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2020-08-05 14:31 [gentoo-commits] proj/java-ebuilder:master commit in: src/main/java/org/gentoo/java/ebuilder/maven/, Miroslav Šulc
-- strict thread matches above, loose matches on Subject: below --
2020-08-05 14:31 Miroslav Šulc
2019-11-03 10:12 Miroslav Šulc
2019-11-02 21:32 Miroslav Šulc
2019-10-30 19:26 Miroslav Šulc
2019-10-30 19:26 Miroslav Šulc
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox