Skip to content

Commit

Permalink
Merge branch '__rultor'
Browse files Browse the repository at this point in the history
  • Loading branch information
rultor committed Jul 19, 2023
2 parents 2cec3a0 + 2fb1607 commit 17ea209
Show file tree
Hide file tree
Showing 3 changed files with 27 additions and 15 deletions.
4 changes: 3 additions & 1 deletion eo-maven-plugin/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,9 @@ SOFTWARE.
<groupId>net.sf.saxon</groupId>
<artifactId>Saxon-HE</artifactId>
<!-- version from parent POM -->
<scope>runtime</scope>
<!-- We need Saxon library in compile time
in order to use XPath 2.0 specific features -->
<scope>compile</scope>
</dependency>
<dependency>
<groupId>com.jcabi</groupId>
Expand Down
17 changes: 13 additions & 4 deletions eo-maven-plugin/src/main/java/org/eolang/maven/DiscoverMojo.java
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@
package org.eolang.maven;

import com.jcabi.log.Logger;
import com.jcabi.xml.SaxonDocument;
import com.jcabi.xml.XML;
import com.jcabi.xml.XMLDocument;
import java.io.FileNotFoundException;
Expand All @@ -37,6 +38,8 @@
import org.cactoos.iterable.Filtered;
import org.cactoos.list.ListOf;
import org.cactoos.set.SetOf;
import org.cactoos.text.TextOf;
import org.cactoos.text.UncheckedText;
import org.eolang.maven.tojos.ForeignTojo;
import org.eolang.maven.util.Rel;

Expand Down Expand Up @@ -93,17 +96,23 @@ public void exec() throws FileNotFoundException {
* @param file The .xmir file
* @return List of foreign objects found
* @throws FileNotFoundException If not found
* @todo #2266:30min Use more convenient constructor for SaxonDocument.
* The current constructor for SaxonDocument is not convenient and requires a lot of
* code. It would be better to create SaxonDocument right from the file.
* When the related issue will be implemented in jcabi-xml (you can check the progress
* <a href="https://github.com/jcabi/jcabi-xml/issues/215">here</a>)
* We have to change the constructor for SaxonDocument in this class and remove that puzzle.
*/
private Collection<String> discover(final Path file)
throws FileNotFoundException {
final XML xml = new XMLDocument(file);
final Collection<String> names = DiscoverMojo.names(xml, this.xpath(false));
final XML saxon = new SaxonDocument(new UncheckedText(new TextOf(file)).asString());
final Collection<String> names = DiscoverMojo.names(saxon, this.xpath(false));
if (this.withVersions) {
names.addAll(
DiscoverMojo.names(xml, this.xpath(true))
DiscoverMojo.names(saxon, this.xpath(true))
);
}
if (!xml.nodes("//o[@vararg]").isEmpty()) {
if (!new XMLDocument(file).nodes("//o[@vararg]").isEmpty()) {
names.add("org.eolang.tuple");
}
if (names.isEmpty()) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,12 +32,12 @@
import java.util.Map;
import java.util.stream.Collectors;
import org.cactoos.io.ResourceOf;
import org.eolang.maven.hash.CommitHash;
import org.eolang.maven.hash.CommitHashesMap;
import org.eolang.maven.tojos.ForeignTojo;
import org.eolang.maven.tojos.ForeignTojos;
import org.hamcrest.MatcherAssert;
import org.hamcrest.Matchers;
import org.junit.jupiter.api.Disabled;
import org.junit.jupiter.api.Test;
import org.junit.jupiter.api.io.TempDir;
import org.junit.jupiter.params.ParameterizedTest;
Expand All @@ -47,12 +47,6 @@
* Test case for {@link DiscoverMojo}.
*
* @since 0.28.11
* @todo #2259:30min Enable discoversWithSeveralObjectsWithDifferentVersions test.
* The discoversWithSeveralObjectsWithDifferentVersions test is disabled because we have found
* a bug in jcabi-xml library. You can read more about the bug
* <a href="https://github.com/jcabi/jcabi-xml/issues/211">here</a>
* When the bug will be fixed, we have to enable discoversWithSeveralObjectsWithDifferentVersions
* test.
*/
final class DiscoverMojoTest {

Expand Down Expand Up @@ -149,12 +143,13 @@ void discoversWithVersions(@TempDir final Path tmp) throws IOException {
}

@Test
@Disabled
void discoversWithSeveralObjectsWithDifferentVersions(
@TempDir final Path tmp
) throws IOException {
final Map<String, CommitHash> hashes = new CommitHashesMap.Fake();
final FakeMaven maven = new FakeMaven(tmp)
.with("withVersions", true)
.with("hashes", hashes)
.withProgram(
"+alias org.eolang.txt.sprintf\n",
"[] > main",
Expand All @@ -170,8 +165,14 @@ void discoversWithSeveralObjectsWithDifferentVersions(
" nop"
)
.execute(new FakeMaven.Discover());
final String first = "org.eolang.txt.sprintf|0.28.1";
final String second = "org.eolang.txt.sprintf|0.28.2";
final String first = String.format(
"org.eolang.txt.sprintf|%s",
hashes.get("0.28.1").value()
);
final String second = String.format(
"org.eolang.txt.sprintf|%s",
hashes.get("0.28.2").value()
);
final ForeignTojos tojos = maven.externalTojos();
MatcherAssert.assertThat(
String.format(DiscoverMojoTest.SHOULD_CONTAIN, first),
Expand Down

2 comments on commit 17ea209

@0pdd
Copy link

@0pdd 0pdd commented on 17ea209 Jul 19, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Puzzle 2259-d6c8796f disappeared from eo-maven-plugin/src/test/java/org/eolang/maven/DiscoverMojoTest.java), that's why I closed #2266. Please, remember that the puzzle was not necessarily removed in this particular commit. Maybe it happened earlier, but we discovered this fact only now.

@0pdd
Copy link

@0pdd 0pdd commented on 17ea209 Jul 19, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Puzzle 2266-814f3bb5 discovered in eo-maven-plugin/src/main/java/org/eolang/maven/DiscoverMojo.java) and submitted as #2278. Please, remember that the puzzle was not necessarily added in this particular commit. Maybe it was added earlier, but we discovered it only now.

Please sign in to comment.