From 0be896a916378caac9dcaa2a77819a71bbab9828 Mon Sep 17 00:00:00 2001 From: l3r8yJ Date: Sun, 8 Dec 2024 05:27:14 +0300 Subject: [PATCH 1/6] feat(#909): move to class; read from resources --- .../eolang/jeo/representation/License.java | 67 +++++++++++++++++++ .../directives/DirectivesProgram.java | 39 +---------- src/main/resources/LICENSE.txt | 21 ++++++ .../jeo/representation/LicenseTest.java | 50 ++++++++++++++ 4 files changed, 140 insertions(+), 37 deletions(-) create mode 100644 src/main/java/org/eolang/jeo/representation/License.java create mode 100644 src/main/resources/LICENSE.txt create mode 100644 src/test/java/org/eolang/jeo/representation/LicenseTest.java diff --git a/src/main/java/org/eolang/jeo/representation/License.java b/src/main/java/org/eolang/jeo/representation/License.java new file mode 100644 index 000000000..95facc980 --- /dev/null +++ b/src/main/java/org/eolang/jeo/representation/License.java @@ -0,0 +1,67 @@ +/* + * The MIT License (MIT) + * + * 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 + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included + * in all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + * SOFTWARE. + */ +package org.eolang.jeo.representation; + +import org.cactoos.Scalar; +import org.cactoos.io.ResourceOf; +import org.cactoos.text.TextOf; + +/** + * Representation of project license. + * + * @since 0.6.27 + */ +public final class License implements Scalar { + + /** + * The name of file with license. + */ + private final String name; + + /** + * Ctor with default value. + */ + public License() { + this("LICENSE.txt"); + } + + /** + * Primary ctor. + * + * @param name The name of file with license. + */ + public License(final String name) { + this.name = name; + } + + @Override + public String value() { + return new TextOf(new ResourceOf(this.name)).toString(); + } + + @Override + public String toString() { + return this.value(); + } +} diff --git a/src/main/java/org/eolang/jeo/representation/directives/DirectivesProgram.java b/src/main/java/org/eolang/jeo/representation/directives/DirectivesProgram.java index 806871814..93d803315 100644 --- a/src/main/java/org/eolang/jeo/representation/directives/DirectivesProgram.java +++ b/src/main/java/org/eolang/jeo/representation/directives/DirectivesProgram.java @@ -28,6 +28,7 @@ import java.time.ZonedDateTime; import java.time.format.DateTimeFormatter; import java.util.Iterator; +import org.eolang.jeo.representation.License; import org.xembly.Directive; import org.xembly.Directives; @@ -117,7 +118,7 @@ public Iterator iterator() { .add("listing") .set(this.listing) .up() - .add("license").set(DirectivesProgram.license()).up() + .add("license").set(new License()).up() .append(this.metas) .attr("ms", this.milliseconds) .add("objects"); @@ -125,40 +126,4 @@ public Iterator iterator() { directives.up(); return directives.iterator(); } - - /** - * Text of the license. - * @return License text. - * @todo #850 Retrieve License From The File. - * We use license as a file in the project root. - * See LICENSE.txt file. - * It's better to read this file and return its content. - * Otherwise, we have to maintain the license in two places. - */ - private static String license() { - return String.join( - "\n", - "The MIT License (MIT)", - "", - "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", - "in the Software without restriction, including without limitation the rights", - "to use, copy, modify, merge, publish, distribute, sublicense, and/or sell", - "copies of the Software, and to permit persons to whom the Software is", - "furnished to do so, subject to the following conditions:", - "", - "The above copyright notice and this permission notice shall be included", - "in all copies or substantial portions of the Software.", - "", - "THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR", - "IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,", - "FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT. IN NO EVENT SHALL THE", - "AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER", - "LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,", - "OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE", - "SOFTWARE." - ); - } } diff --git a/src/main/resources/LICENSE.txt b/src/main/resources/LICENSE.txt new file mode 100644 index 000000000..879402bb7 --- /dev/null +++ b/src/main/resources/LICENSE.txt @@ -0,0 +1,21 @@ +The MIT License (MIT) + +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 +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included +in all copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +SOFTWARE. diff --git a/src/test/java/org/eolang/jeo/representation/LicenseTest.java b/src/test/java/org/eolang/jeo/representation/LicenseTest.java new file mode 100644 index 000000000..89d1940de --- /dev/null +++ b/src/test/java/org/eolang/jeo/representation/LicenseTest.java @@ -0,0 +1,50 @@ +/* + * The MIT License (MIT) + * + * 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 + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included + * in all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + * SOFTWARE. + */ +package org.eolang.jeo.representation; + +import org.cactoos.text.FormattedText; +import org.hamcrest.MatcherAssert; +import org.hamcrest.Matchers; +import org.junit.jupiter.api.Test; + +/** + * Test suite for {@link License}. + * + * @since 0.6.27 + */ +final class LicenseTest { + + @Test + void readsLicenseFileCorrectly() throws Exception { + final String name = "LICENSE.txt"; + MatcherAssert.assertThat( + new FormattedText( + "Unexpected file:'%s' content", + name + ).asString(), + new License(name).value(), + Matchers.containsString("MIT") + ); + } +} From 9c5dce1c7b9d8e4b4c76db66976890bc088c54a8 Mon Sep 17 00:00:00 2001 From: l3r8yJ Date: Mon, 9 Dec 2024 16:06:17 +0300 Subject: [PATCH 2/6] feat(#909): fetch license from github --- pom.xml | 11 ++++++ .../eolang/jeo/representation/License.java | 36 ++++++++++++++----- .../directives/DirectivesProgram.java | 3 +- src/main/resources/LICENSE.txt | 21 ----------- .../jeo/representation/LicenseTest.java | 7 ++-- 5 files changed, 45 insertions(+), 33 deletions(-) delete mode 100644 src/main/resources/LICENSE.txt diff --git a/pom.xml b/pom.xml index d5e0aff91..650d3b854 100644 --- a/pom.xml +++ b/pom.xml @@ -196,6 +196,17 @@ SOFTWARE. jhome 0.0.5 + + com.jcabi + jcabi-http + 2.0.0 + + + com.yegor256 + jping + 0.0.3 + test + org.hamcrest hamcrest diff --git a/src/main/java/org/eolang/jeo/representation/License.java b/src/main/java/org/eolang/jeo/representation/License.java index 95facc980..a2d5f7482 100644 --- a/src/main/java/org/eolang/jeo/representation/License.java +++ b/src/main/java/org/eolang/jeo/representation/License.java @@ -23,9 +23,12 @@ */ package org.eolang.jeo.representation; +import com.jcabi.http.request.JdkRequest; +import jakarta.ws.rs.HttpMethod; +import jakarta.ws.rs.core.HttpHeaders; +import java.io.IOException; import org.cactoos.Scalar; -import org.cactoos.io.ResourceOf; -import org.cactoos.text.TextOf; +import org.cactoos.text.FormattedText; /** * Representation of project license. @@ -35,29 +38,44 @@ public final class License implements Scalar { /** - * The name of file with license. + * Request url. */ - private final String name; + private final String url; /** * Ctor with default value. */ public License() { - this("LICENSE.txt"); + this( + new FormattedText( + "%s://%s%s", + "https", + "raw.githubusercontent.com", + "/objectionary/jeo-maven-plugin/refs/heads/master/LICENSE.txt" + ).toString() + ); } /** * Primary ctor. * - * @param name The name of file with license. + * @param url The url to fetch the license. */ - public License(final String name) { - this.name = name; + public License(final String url) { + this.url = url; } @Override public String value() { - return new TextOf(new ResourceOf(this.name)).toString(); + try { + return new JdkRequest(this.url) + .method(HttpMethod.GET) + .header(HttpHeaders.ACCEPT, "text/html") + .fetch() + .body(); + } catch (final IOException exc) { + throw new IllegalStateException("Can't fetch the license", exc); + } } @Override diff --git a/src/main/java/org/eolang/jeo/representation/directives/DirectivesProgram.java b/src/main/java/org/eolang/jeo/representation/directives/DirectivesProgram.java index 93d803315..368bd4032 100644 --- a/src/main/java/org/eolang/jeo/representation/directives/DirectivesProgram.java +++ b/src/main/java/org/eolang/jeo/representation/directives/DirectivesProgram.java @@ -28,6 +28,7 @@ import java.time.ZonedDateTime; import java.time.format.DateTimeFormatter; import java.util.Iterator; +import org.cactoos.scalar.Sticky; import org.eolang.jeo.representation.License; import org.xembly.Directive; import org.xembly.Directives; @@ -118,7 +119,7 @@ public Iterator iterator() { .add("listing") .set(this.listing) .up() - .add("license").set(new License()).up() + .add("license").set(new Sticky<>(new License())).up() .append(this.metas) .attr("ms", this.milliseconds) .add("objects"); diff --git a/src/main/resources/LICENSE.txt b/src/main/resources/LICENSE.txt deleted file mode 100644 index 879402bb7..000000000 --- a/src/main/resources/LICENSE.txt +++ /dev/null @@ -1,21 +0,0 @@ -The MIT License (MIT) - -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 -in the Software without restriction, including without limitation the rights -to use, copy, modify, merge, publish, distribute, sublicense, and/or sell -copies of the Software, and to permit persons to whom the Software is -furnished to do so, subject to the following conditions: - -The above copyright notice and this permission notice shall be included -in all copies or substantial portions of the Software. - -THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT. IN NO EVENT SHALL THE -AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, -OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE -SOFTWARE. diff --git a/src/test/java/org/eolang/jeo/representation/LicenseTest.java b/src/test/java/org/eolang/jeo/representation/LicenseTest.java index 89d1940de..0fcd617d7 100644 --- a/src/test/java/org/eolang/jeo/representation/LicenseTest.java +++ b/src/test/java/org/eolang/jeo/representation/LicenseTest.java @@ -23,16 +23,19 @@ */ package org.eolang.jeo.representation; +import com.yegor256.WeAreOnline; import org.cactoos.text.FormattedText; import org.hamcrest.MatcherAssert; import org.hamcrest.Matchers; import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.extension.ExtendWith; /** * Test suite for {@link License}. * * @since 0.6.27 */ +@ExtendWith(WeAreOnline.class) final class LicenseTest { @Test @@ -40,10 +43,10 @@ void readsLicenseFileCorrectly() throws Exception { final String name = "LICENSE.txt"; MatcherAssert.assertThat( new FormattedText( - "Unexpected file:'%s' content", + "Unexpected license content", name ).asString(), - new License(name).value(), + new License().value(), Matchers.containsString("MIT") ); } From 94aef76eb2f3df867c79260dbdcc95d11fb4a5b2 Mon Sep 17 00:00:00 2001 From: l3r8yJ Date: Wed, 11 Dec 2024 00:50:19 +0300 Subject: [PATCH 3/6] Revert "feat(#909): fetch license from github" This reverts commit 9c5dce1c7b9d8e4b4c76db66976890bc088c54a8. --- pom.xml | 11 ------ .../eolang/jeo/representation/License.java | 36 +++++-------------- .../directives/DirectivesProgram.java | 3 +- src/main/resources/LICENSE.txt | 21 +++++++++++ .../jeo/representation/LicenseTest.java | 7 ++-- 5 files changed, 33 insertions(+), 45 deletions(-) create mode 100644 src/main/resources/LICENSE.txt diff --git a/pom.xml b/pom.xml index 650d3b854..d5e0aff91 100644 --- a/pom.xml +++ b/pom.xml @@ -196,17 +196,6 @@ SOFTWARE. jhome 0.0.5 - - com.jcabi - jcabi-http - 2.0.0 - - - com.yegor256 - jping - 0.0.3 - test - org.hamcrest hamcrest diff --git a/src/main/java/org/eolang/jeo/representation/License.java b/src/main/java/org/eolang/jeo/representation/License.java index a2d5f7482..95facc980 100644 --- a/src/main/java/org/eolang/jeo/representation/License.java +++ b/src/main/java/org/eolang/jeo/representation/License.java @@ -23,12 +23,9 @@ */ package org.eolang.jeo.representation; -import com.jcabi.http.request.JdkRequest; -import jakarta.ws.rs.HttpMethod; -import jakarta.ws.rs.core.HttpHeaders; -import java.io.IOException; import org.cactoos.Scalar; -import org.cactoos.text.FormattedText; +import org.cactoos.io.ResourceOf; +import org.cactoos.text.TextOf; /** * Representation of project license. @@ -38,44 +35,29 @@ public final class License implements Scalar { /** - * Request url. + * The name of file with license. */ - private final String url; + private final String name; /** * Ctor with default value. */ public License() { - this( - new FormattedText( - "%s://%s%s", - "https", - "raw.githubusercontent.com", - "/objectionary/jeo-maven-plugin/refs/heads/master/LICENSE.txt" - ).toString() - ); + this("LICENSE.txt"); } /** * Primary ctor. * - * @param url The url to fetch the license. + * @param name The name of file with license. */ - public License(final String url) { - this.url = url; + public License(final String name) { + this.name = name; } @Override public String value() { - try { - return new JdkRequest(this.url) - .method(HttpMethod.GET) - .header(HttpHeaders.ACCEPT, "text/html") - .fetch() - .body(); - } catch (final IOException exc) { - throw new IllegalStateException("Can't fetch the license", exc); - } + return new TextOf(new ResourceOf(this.name)).toString(); } @Override diff --git a/src/main/java/org/eolang/jeo/representation/directives/DirectivesProgram.java b/src/main/java/org/eolang/jeo/representation/directives/DirectivesProgram.java index 368bd4032..93d803315 100644 --- a/src/main/java/org/eolang/jeo/representation/directives/DirectivesProgram.java +++ b/src/main/java/org/eolang/jeo/representation/directives/DirectivesProgram.java @@ -28,7 +28,6 @@ import java.time.ZonedDateTime; import java.time.format.DateTimeFormatter; import java.util.Iterator; -import org.cactoos.scalar.Sticky; import org.eolang.jeo.representation.License; import org.xembly.Directive; import org.xembly.Directives; @@ -119,7 +118,7 @@ public Iterator iterator() { .add("listing") .set(this.listing) .up() - .add("license").set(new Sticky<>(new License())).up() + .add("license").set(new License()).up() .append(this.metas) .attr("ms", this.milliseconds) .add("objects"); diff --git a/src/main/resources/LICENSE.txt b/src/main/resources/LICENSE.txt new file mode 100644 index 000000000..879402bb7 --- /dev/null +++ b/src/main/resources/LICENSE.txt @@ -0,0 +1,21 @@ +The MIT License (MIT) + +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 +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included +in all copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +SOFTWARE. diff --git a/src/test/java/org/eolang/jeo/representation/LicenseTest.java b/src/test/java/org/eolang/jeo/representation/LicenseTest.java index 0fcd617d7..89d1940de 100644 --- a/src/test/java/org/eolang/jeo/representation/LicenseTest.java +++ b/src/test/java/org/eolang/jeo/representation/LicenseTest.java @@ -23,19 +23,16 @@ */ package org.eolang.jeo.representation; -import com.yegor256.WeAreOnline; import org.cactoos.text.FormattedText; import org.hamcrest.MatcherAssert; import org.hamcrest.Matchers; import org.junit.jupiter.api.Test; -import org.junit.jupiter.api.extension.ExtendWith; /** * Test suite for {@link License}. * * @since 0.6.27 */ -@ExtendWith(WeAreOnline.class) final class LicenseTest { @Test @@ -43,10 +40,10 @@ void readsLicenseFileCorrectly() throws Exception { final String name = "LICENSE.txt"; MatcherAssert.assertThat( new FormattedText( - "Unexpected license content", + "Unexpected file:'%s' content", name ).asString(), - new License().value(), + new License(name).value(), Matchers.containsString("MIT") ); } From ff939721e0a4e19a14966179979dc812031baf06 Mon Sep 17 00:00:00 2001 From: l3r8yJ Date: Wed, 11 Dec 2024 00:54:57 +0300 Subject: [PATCH 4/6] build(#909): add plugin to copy license from root --- pom.xml | 24 ++++++++++++++++++++++++ src/main/resources/LICENSE.txt | 21 --------------------- 2 files changed, 24 insertions(+), 21 deletions(-) delete mode 100644 src/main/resources/LICENSE.txt diff --git a/pom.xml b/pom.xml index d5e0aff91..9891dc27a 100644 --- a/pom.xml +++ b/pom.xml @@ -250,6 +250,30 @@ SOFTWARE. + + maven-resources-plugin + 3.3.1 + + + copy-resources + compile + + copy-resources + + + ${project.build.outputDirectory} + + + ${project.basedir} + + LICENSE.txt + + + + + + + maven-compiler-plugin diff --git a/src/main/resources/LICENSE.txt b/src/main/resources/LICENSE.txt deleted file mode 100644 index 879402bb7..000000000 --- a/src/main/resources/LICENSE.txt +++ /dev/null @@ -1,21 +0,0 @@ -The MIT License (MIT) - -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 -in the Software without restriction, including without limitation the rights -to use, copy, modify, merge, publish, distribute, sublicense, and/or sell -copies of the Software, and to permit persons to whom the Software is -furnished to do so, subject to the following conditions: - -The above copyright notice and this permission notice shall be included -in all copies or substantial portions of the Software. - -THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT. IN NO EVENT SHALL THE -AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, -OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE -SOFTWARE. From c3f5fd69d34b25562568bd473bf85ed5bbdf6396 Mon Sep 17 00:00:00 2001 From: l3r8yJ Date: Wed, 11 Dec 2024 13:39:01 +0300 Subject: [PATCH 5/6] feat(#909): add cache --- .../java/org/eolang/jeo/representation/License.java | 12 +++++++----- .../representation/directives/DirectivesProgram.java | 8 +++++++- 2 files changed, 14 insertions(+), 6 deletions(-) diff --git a/src/main/java/org/eolang/jeo/representation/License.java b/src/main/java/org/eolang/jeo/representation/License.java index 95facc980..71b8047c3 100644 --- a/src/main/java/org/eolang/jeo/representation/License.java +++ b/src/main/java/org/eolang/jeo/representation/License.java @@ -24,7 +24,9 @@ package org.eolang.jeo.representation; import org.cactoos.Scalar; +import org.cactoos.Text; import org.cactoos.io.ResourceOf; +import org.cactoos.text.Sticky; import org.cactoos.text.TextOf; /** @@ -37,7 +39,7 @@ public final class License implements Scalar { /** * The name of file with license. */ - private final String name; + private final Text content; /** * Ctor with default value. @@ -49,15 +51,15 @@ public License() { /** * Primary ctor. * - * @param name The name of file with license. + * @param content The name of file with license. */ - public License(final String name) { - this.name = name; + public License(final String content) { + this.content = new Sticky(new TextOf(new ResourceOf(content))); } @Override public String value() { - return new TextOf(new ResourceOf(this.name)).toString(); + return this.content.toString(); } @Override diff --git a/src/main/java/org/eolang/jeo/representation/directives/DirectivesProgram.java b/src/main/java/org/eolang/jeo/representation/directives/DirectivesProgram.java index 93d803315..58611e3fa 100644 --- a/src/main/java/org/eolang/jeo/representation/directives/DirectivesProgram.java +++ b/src/main/java/org/eolang/jeo/representation/directives/DirectivesProgram.java @@ -28,6 +28,7 @@ import java.time.ZonedDateTime; import java.time.format.DateTimeFormatter; import java.util.Iterator; +import org.cactoos.Scalar; import org.eolang.jeo.representation.License; import org.xembly.Directive; import org.xembly.Directives; @@ -38,6 +39,11 @@ */ public final class DirectivesProgram implements Iterable { + /** + * The license of project. + */ + private static final Scalar LICENSE = new License(); + /** * Program listing. */ @@ -118,7 +124,7 @@ public Iterator iterator() { .add("listing") .set(this.listing) .up() - .add("license").set(new License()).up() + .add("license").set(DirectivesProgram.LICENSE).up() .append(this.metas) .attr("ms", this.milliseconds) .add("objects"); From ffa2e4e9718899bcc66ebb51e2a72c826e6bbc6e Mon Sep 17 00:00:00 2001 From: l3r8yJ Date: Wed, 18 Dec 2024 05:39:52 +0300 Subject: [PATCH 6/6] ci(#909): remove java 8; add puzzle to bring it back --- .github/workflows/maven.test.yaml | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/.github/workflows/maven.test.yaml b/.github/workflows/maven.test.yaml index d66afac49..2d3d0fef3 100644 --- a/.github/workflows/maven.test.yaml +++ b/.github/workflows/maven.test.yaml @@ -13,7 +13,12 @@ jobs: strategy: matrix: os: [ ubuntu-20.04, macos-14, windows-2022 ] - java: [ 8, 11, 21 ] +# @todo #909:60min Add 8 version of Java to matrix. +# For now we're getting an infinite qulice check on +# Java 8. To fix this you need to set Java 8 version +# in your Maven configuration, after that you need to +# run `mvn clean install -Pqulice`. + java: [ 11, 21 ] runs-on: ${{ matrix.os }} steps: - uses: actions/checkout@v4