Skip to content

Commit

Permalink
fix conflict
Browse files Browse the repository at this point in the history
  • Loading branch information
Karina5005 committed Sep 16, 2022
2 parents 8c70fc6 + 2bb6d7d commit f82f256
Show file tree
Hide file tree
Showing 37 changed files with 748 additions and 88 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/latexmk.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ jobs:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- uses: yegor256/latexmk-action@0.4.0
- uses: yegor256/latexmk-action@0.5.0
with:
path: paper
opts: -pdf
Expand Down
3 changes: 2 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
target/
.idea
.vscode/
.idea/
.DS_Store
*.iml
.project
Expand Down
2 changes: 2 additions & 0 deletions eo-maven-plugin/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -86,6 +86,8 @@ one after another:
the source code in a plain text format and parses into XML document,
using [ANTLR4](https://www.antlr.org/) and [Xembly](https://www.xembly.org).
The output of the parser you can find in the `target/eo/parse` directory.
Parsed objects which are versioned (normally pulled from
[Objectionary](https://github.com/objectionary/home)) are cached in `.eo/parsed` folder.

* **Optimization**.
There are a number of [XSL transformations](https://en.wikipedia.org/wiki/XSLT)
Expand Down
14 changes: 14 additions & 0 deletions eo-maven-plugin/src/main/java/org/eolang/maven/AssembleMojo.java
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@
import java.io.File;
import java.io.IOException;
import java.nio.file.Path;
import java.nio.file.Paths;
import java.util.Collection;
import java.util.LinkedList;
import java.util.function.BiConsumer;
Expand Down Expand Up @@ -99,6 +100,11 @@ public final class AssembleMojo extends SafeMojo {
*/
public static final String ATTR_TRANSPILED = "transpiled";

/**
* Tojo ATTR.
*/
public static final String ATTR_HASH = "hash";

/**
* Output.
* @checkstyle MemberNameCheck (7 lines)
Expand Down Expand Up @@ -174,6 +180,14 @@ public final class AssembleMojo extends SafeMojo {
defaultValue = "true")
private boolean failOnError = true;

/**
* Parsed cache directory.
* @checkstyle MemberNameCheck (7 lines)
*/
@Parameter(property = "eo.cache")
@SuppressWarnings("PMD.ImmutableField")
private Path cache = Paths.get(System.getProperty("user.home")).resolve(".eo");

@Override
public void exec() throws IOException {
if (this.central == null) {
Expand Down
53 changes: 53 additions & 0 deletions eo-maven-plugin/src/main/java/org/eolang/maven/Footprint.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
/*
* The MIT License (MIT)
*
* Copyright (c) 2016-2022 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.maven;

import java.io.IOException;
import org.cactoos.Scalar;

/**
* Program footprint of EO compilation process.
* @since 1.0
*/
public interface Footprint {

/**
* Get program content of a specific type.
* @param program Program name
* @param ext File extension which defines the type
* @return Content of a file
* @throws IOException In case of IO issue.
*/
String load(String program, String ext) throws IOException;

/**
* Save content.
* @param program Program name
* @param ext File extension
* @param content File content
* @throws IOException In case of IO issues
*/
void save(String program, String ext, Scalar<String> content)
throws IOException;
}
118 changes: 118 additions & 0 deletions eo-maven-plugin/src/main/java/org/eolang/maven/FtCached.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,118 @@
/*
* The MIT License (MIT)
*
* Copyright (c) 2016-2022 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.maven;

import com.jcabi.log.Logger;
import java.io.IOException;
import java.nio.file.Path;
import org.cactoos.Scalar;
import org.cactoos.scalar.IoChecked;
import org.cactoos.text.IoCheckedText;
import org.cactoos.text.TextOf;

/**
* Program footprint of EO compilation process.
* <p/>The footprint consists of file in {@link #main} folder and optionally cached
* file in {@link #cache} folder.
* Caching is applied if {@link #hash} is not empty otherwise caching is ignored.
* <p/>Usage example:
* <code>
* <pre>
* final Footprint footprint = new Footprint(
* hash,
* targetRoot,
* cacheRoot
* ).save(program, ext);
*
* String content = footprint.content(program, ext);
* </pre>
* </code>
* @since 1.0
*/
public final class FtCached implements Footprint {
/**
* Path to target root.
*/
private final Path main;

/**
* Version tag.
*/
private final String hash;

/**
* Path to cache root.
*/
private final Path cache;

/**
* Ctor.
* @param hash Version tag
* @param main Main root
* @param cache Cache root
*/
public FtCached(final String hash, final Path main, final Path cache) {
this.hash = hash;
this.main = main;
this.cache = cache;
}

@Override
public String load(final String program, final String ext) throws IOException {
final Path cached = new Place(program).make(this.cache.resolve(this.hash), ext);
final Path target = new Place(program).make(this.main, ext);
final IoCheckedText content;
if (cached.toFile().exists()) {
content = new IoCheckedText(
new TextOf(cached)
);
} else {
content = new IoCheckedText(
new TextOf(target)
);
}
return content.asString();
}

@Override
public void save(final String program, final String ext, final Scalar<String> content)
throws IOException {
final Path cached = new Place(program).make(this.cache.resolve(this.hash), ext);
final Path target = new Place(program).make(this.main, ext);
final String text;
if (cached.toFile().exists()) {
Logger.info(
this,
"Program %s found in cache: %s",
program,
cached
);
text = this.load(program, ext);
} else {
text = new IoChecked<>(content).value();
new Save(text, cached).save();
}
new Save(text, target).save();
}
}
69 changes: 69 additions & 0 deletions eo-maven-plugin/src/main/java/org/eolang/maven/FtDefault.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,69 @@
/*
* The MIT License (MIT)
*
* Copyright (c) 2016-2022 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.maven;

import java.io.IOException;
import java.nio.file.Path;
import org.cactoos.Scalar;
import org.cactoos.scalar.IoChecked;
import org.cactoos.text.IoCheckedText;
import org.cactoos.text.TextOf;

/**
* Default implementation of a Footprint.
* @since 1.0
*/
public final class FtDefault implements Footprint {

/**
* Path to main location.
*/
private final Path main;

/**
* Ctor.
* @param main Main location.
*/
public FtDefault(final Path main) {
this.main = main;
}

@Override
public String load(final String program, final String ext) throws IOException {
return new IoCheckedText(
new TextOf(
new Place(program).make(this.main, ext)
)
).asString();
}

@Override
public void save(final String program, final String ext, final Scalar<String> content)
throws IOException {
new Save(
new IoChecked<>(content).value(),
new Place(program).make(this.main, ext)
).save();
}
}
6 changes: 5 additions & 1 deletion eo-maven-plugin/src/main/java/org/eolang/maven/GmiMojo.java
Original file line number Diff line number Diff line change
Expand Up @@ -330,6 +330,7 @@ private int render(final Path xmir, final Path gmi) throws IOException {
.pass(after)
.xpath("/text/text()")
.get(0);
Logger.debug(this, "GMIs:\n%s", instructions);
new Save(instructions, gmi).save();
if (this.generateGmiXmlFiles) {
new Save(
Expand Down Expand Up @@ -378,8 +379,11 @@ private void makeGraph(final String xembly, final Path gmi) throws IOException {
gmi.resolveSibling(String.format("%s.graph", gmi.getFileName()))
).save();
if (this.generateDotFiles) {
final String dot = new Xsline(GmiMojo.TO_DOT)
.pass(graph).xpath("//dot/text()").get(0);
Logger.debug(this, "Dot:\n%s", dot);
new Save(
new Xsline(GmiMojo.TO_DOT).pass(graph).xpath("//dot/text()").get(0),
dot,
gmi.resolveSibling(String.format("%s.dot", gmi.getFileName()))
).save();
}
Expand Down
8 changes: 8 additions & 0 deletions eo-maven-plugin/src/main/java/org/eolang/maven/HashOfTag.java
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,14 @@ public String hash() {
return result;
}

/**
* Short version of hash.
* @return SHA of commit
*/
public String narrow() {
return this.hash().substring(0, 7);
}

/**
* Load all hashes and tags.
* @return Map of them (hash -> tag)
Expand Down
4 changes: 4 additions & 0 deletions eo-maven-plugin/src/main/java/org/eolang/maven/MarkMojo.java
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,10 @@ public void exec() throws IOException {
* @param version The version of the JAR
* @return How many registered
* @throws IOException If fails
* @todo #1062:30min The mojo doesn't update program version if it exists.
* This causes versions like `*.*.*` and `0.0.0` are not updated and remain
* in foreign catalog. This needs to be updated: version must be overridden to
* correct value.
*/
private int scan(final Path dir, final String version) throws IOException {
final Unplace unplace = new Unplace(dir);
Expand Down
Loading

0 comments on commit f82f256

Please sign in to comment.