diff --git a/eo-maven-plugin/pom.xml b/eo-maven-plugin/pom.xml index 80cae9fbd..790a7f3e0 100644 --- a/eo-maven-plugin/pom.xml +++ b/eo-maven-plugin/pom.xml @@ -70,6 +70,16 @@ SOFTWARE. jcabi-manifests + + com.jcabi + jcabi-aspects + 0.26.0 + + + org.aspectj + aspectjrt + 1.9.21 + net.sf.saxon Saxon-HE @@ -268,6 +278,18 @@ SOFTWARE. + + com.jcabi + jcabi-maven-plugin + 0.17.0 + + + + ajc + + + + maven-invoker-plugin diff --git a/eo-maven-plugin/src/main/java/org/eolang/maven/dependencies/DcsWithRuntime.java b/eo-maven-plugin/src/main/java/org/eolang/maven/dependencies/DcsWithRuntime.java index 67283e0dd..5502c3d3e 100644 --- a/eo-maven-plugin/src/main/java/org/eolang/maven/dependencies/DcsWithRuntime.java +++ b/eo-maven-plugin/src/main/java/org/eolang/maven/dependencies/DcsWithRuntime.java @@ -23,10 +23,12 @@ */ package org.eolang.maven.dependencies; +import com.jcabi.aspects.RetryOnFailure; import com.jcabi.xml.XMLDocument; import java.io.IOException; import java.net.URL; import java.util.Iterator; +import java.util.concurrent.TimeUnit; import org.apache.maven.model.Dependency; import org.cactoos.list.ListOf; import org.cactoos.scalar.Sticky; @@ -104,6 +106,7 @@ public final class DcsWithRuntime implements Iterable { * * @return Runtime dependency from Maven Central. */ + @RetryOnFailure(delay = 1L, unit = TimeUnit.SECONDS) private static Unchecked mavenDependency() { final String url = String.format( "https://repo.maven.apache.org/maven2/%s/maven-metadata.xml", diff --git a/eo-maven-plugin/src/main/java/org/eolang/maven/hash/CommitHashesText.java b/eo-maven-plugin/src/main/java/org/eolang/maven/hash/CommitHashesText.java index d09128fa8..1e3465021 100644 --- a/eo-maven-plugin/src/main/java/org/eolang/maven/hash/CommitHashesText.java +++ b/eo-maven-plugin/src/main/java/org/eolang/maven/hash/CommitHashesText.java @@ -23,9 +23,14 @@ */ package org.eolang.maven.hash; +import com.jcabi.aspects.RetryOnFailure; +import java.net.URL; +import java.util.concurrent.TimeUnit; import org.cactoos.Text; +import org.cactoos.scalar.Unchecked; import org.cactoos.text.Sticky; import org.cactoos.text.TextEnvelope; +import org.cactoos.text.TextOf; /** * Commit hashes table as text from objectionary. @@ -36,23 +41,35 @@ import org.cactoos.text.TextEnvelope; */ final class CommitHashesText extends TextEnvelope { + /** + * Tags. + */ + private static final String HOME = "https://home.objectionary.com/tags.txt"; + /** * Cache. */ - private static final Text CACHE = new Sticky(new ObjectionaryCommitHashes()); + private static final Text CACHE = new Sticky( + CommitHashesText.asText(CommitHashesText.HOME) + ); /** * Constructor. */ CommitHashesText() { - this(CommitHashesText.CACHE); + super(CommitHashesText.CACHE); } /** - * Constructor. - * @param text The text to of commit hashes. + * Download from the URL and return the content. + * @param url The URL with tags + * @return The body of the web page */ - private CommitHashesText(final Text text) { - super(text); + @RetryOnFailure(delay = 1L, unit = TimeUnit.SECONDS) + private static Text asText(final String url) { + final String body = new Unchecked<>( + () -> new TextOf(new URL(url)).asString() + ).value(); + return new TextOf(body); } } diff --git a/eo-maven-plugin/src/main/java/org/eolang/maven/objectionary/ObjectsIndex.java b/eo-maven-plugin/src/main/java/org/eolang/maven/objectionary/ObjectsIndex.java index 7e0d6b8bf..3fca86a14 100644 --- a/eo-maven-plugin/src/main/java/org/eolang/maven/objectionary/ObjectsIndex.java +++ b/eo-maven-plugin/src/main/java/org/eolang/maven/objectionary/ObjectsIndex.java @@ -23,13 +23,16 @@ */ package org.eolang.maven.objectionary; +import com.jcabi.aspects.RetryOnFailure; import java.net.URL; import java.util.Set; +import java.util.concurrent.TimeUnit; import org.cactoos.Scalar; import org.cactoos.Text; import org.cactoos.iterable.Mapped; import org.cactoos.scalar.ScalarOf; import org.cactoos.scalar.Sticky; +import org.cactoos.scalar.Unchecked; import org.cactoos.set.SetOf; import org.cactoos.text.Split; import org.cactoos.text.TextOf; @@ -42,6 +45,11 @@ import org.cactoos.text.TextOf; */ final class ObjectsIndex { + /** + * Tags. + */ + private static final String HOME = "https://home.objectionary.com/objectionary.lst"; + /** * Cached objects index. */ @@ -59,9 +67,7 @@ final class ObjectsIndex { new Mapped<>( Text::asString, new Split( - new TextOf( - new URL("https://home.objectionary.com/objectionary.lst") - ), + ObjectsIndex.asText(new URL(ObjectsIndex.HOME)), "\n" ) ) @@ -102,4 +108,15 @@ final class ObjectsIndex { .replace('/', '.') .substring(name.indexOf('/') + 1); } + + /** + * Download from the URL and return the content. + * @param url The URL with tags + * @return The body of the web page + */ + @RetryOnFailure(delay = 1L, unit = TimeUnit.SECONDS) + private static Text asText(final URL url) { + final String body = new Unchecked<>(() -> new TextOf(url).asString()).value(); + return new TextOf(body); + } } diff --git a/eo-maven-plugin/src/main/java/org/eolang/maven/objectionary/OyRemote.java b/eo-maven-plugin/src/main/java/org/eolang/maven/objectionary/OyRemote.java index 47ff1d7ee..bf09e2c0f 100644 --- a/eo-maven-plugin/src/main/java/org/eolang/maven/objectionary/OyRemote.java +++ b/eo-maven-plugin/src/main/java/org/eolang/maven/objectionary/OyRemote.java @@ -23,11 +23,13 @@ */ package org.eolang.maven.objectionary; +import com.jcabi.aspects.RetryOnFailure; import com.jcabi.log.Logger; import java.io.IOException; import java.net.HttpURLConnection; import java.net.MalformedURLException; import java.net.URL; +import java.util.concurrent.TimeUnit; import org.cactoos.Input; import org.cactoos.io.InputOf; import org.cactoos.io.InputWithFallback; @@ -85,6 +87,7 @@ public final class OyRemote implements Objectionary { } @Override + @RetryOnFailure(delay = 1L, unit = TimeUnit.SECONDS) public boolean contains(final String name) throws IOException { final int code = ((HttpURLConnection) this.template.value(name).openConnection()) .getResponseCode(); diff --git a/eo-maven-plugin/src/main/java/org/eolang/maven/hash/ObjectionaryCommitHashes.java b/eo-maven-plugin/src/test/java/org/eolang/maven/hash/CommitHashesTextTest.java similarity index 57% rename from eo-maven-plugin/src/main/java/org/eolang/maven/hash/ObjectionaryCommitHashes.java rename to eo-maven-plugin/src/test/java/org/eolang/maven/hash/CommitHashesTextTest.java index 0e5f73134..f9b454d8a 100644 --- a/eo-maven-plugin/src/main/java/org/eolang/maven/hash/ObjectionaryCommitHashes.java +++ b/eo-maven-plugin/src/test/java/org/eolang/maven/hash/CommitHashesTextTest.java @@ -23,43 +23,26 @@ */ package org.eolang.maven.hash; -import java.net.URL; -import org.cactoos.scalar.Unchecked; -import org.cactoos.text.TextEnvelope; -import org.cactoos.text.TextOf; +import com.yegor256.WeAreOnline; +import org.hamcrest.MatcherAssert; +import org.hamcrest.Matchers; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.extension.ExtendWith; /** - * CommitHashes which we download from Objectionary. + * Test case for {@link CommitHashesText}. * - * @since 0.30 + * @since 0.37.0 */ -final class ObjectionaryCommitHashes extends TextEnvelope { +final class CommitHashesTextTest { - /** - * Tags. - */ - private static final String HOME = "https://home.objectionary.com/tags.txt"; - - /** - * Constructor. - */ - ObjectionaryCommitHashes() { - this(ObjectionaryCommitHashes.HOME); - } - - /** - * Constructor. - * @param tags The url from which to download tags list. - */ - private ObjectionaryCommitHashes(final String tags) { - this(new Unchecked<>(() -> new URL(tags)).value()); - } - - /** - * Constructor. - * @param tags The url from which to download tags list. - */ - private ObjectionaryCommitHashes(final URL tags) { - super(new TextOf(tags)); + @Test + @ExtendWith(WeAreOnline.class) + void downloadsDefaultList() throws Exception { + MatcherAssert.assertThat( + "CommitHashesText downloads the default list of hashes from Objectionary", + new CommitHashesText().asString(), + Matchers.containsString("master") + ); } } diff --git a/eo-maven-plugin/src/test/java/org/eolang/maven/objectionary/OyRemoteTest.java b/eo-maven-plugin/src/test/java/org/eolang/maven/objectionary/OyRemoteTest.java index b46c0b1cf..8048fd122 100644 --- a/eo-maven-plugin/src/test/java/org/eolang/maven/objectionary/OyRemoteTest.java +++ b/eo-maven-plugin/src/test/java/org/eolang/maven/objectionary/OyRemoteTest.java @@ -46,7 +46,7 @@ final class OyRemoteTest { @Test void buildsCorrectUrl() throws Exception { MatcherAssert.assertThat( - "TO ADD ASSERTION MESSAGE", + "OyRemove.UrlOy generates correct URL", new OyRemote.UrlOy( "https://raw/objectionary/home/%s/objects/%s.eo", "abcde" @@ -74,7 +74,7 @@ final class OyRemoteTest { final CommitHash hash = new ChRemote("master"); final Objectionary objectionary = new OyRemote(hash); MatcherAssert.assertThat( - "TO ADD ASSERTION MESSAGE", + "OyRemote positively checks the presence of the object in Objectionary", objectionary.contains("org.eolang.io.stdout"), Matchers.is(true) ); diff --git a/eo-runtime/src/main/eo/org/eolang/cti.eo b/eo-runtime/src/main/eo/org/eolang/cti.eo index b0f0edde7..a79d6e034 100644 --- a/eo-runtime/src/main/eo/org/eolang/cti.eo +++ b/eo-runtime/src/main/eo/org/eolang/cti.eo @@ -1,6 +1,6 @@ # The MIT License (MIT) # -# 2016-2023 Objectionary.com +# Copyright (c) 2016-2024 Objectionary.com # # Permission is hereby granted, free of charge, to any person obtaining a copy # of this software and associated documentation files (the "Software"), to deal