Skip to content

Commit

Permalink
#3468 File instead of Path
Browse files Browse the repository at this point in the history
  • Loading branch information
yegor256 committed Nov 7, 2024
1 parent 29ba50f commit e0968db
Show file tree
Hide file tree
Showing 16 changed files with 23 additions and 24 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,7 @@ public void exec() throws IOException {
new Names(this.namesDir.toPath()),
this.targetDir
).exec(this.scopedTojos().withOptimized());
ffis.stream().parallel().forEach(ffi -> ffi.build(this.cache));
ffis.stream().parallel().forEach(ffi -> ffi.build(this.cache.toPath()));
Logger.info(this, "Built in total %d cargo projects", ffis.size());
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -128,7 +128,7 @@ private int optimized(final ForeignTojo tojo, final Optimization optimization)
tojo.withOptimized(
new FpDefault(
src -> optimization.apply(xmir).toString(),
this.cache.resolve(OptimizeMojo.CACHE),
this.cache.toPath().resolve(OptimizeMojo.CACHE),
this.plugin.getVersion(),
new TojoHash(tojo),
base.relativize(target)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -134,7 +134,7 @@ private int parsed(final ForeignTojo tojo) throws Exception {
tojo.withXmir(
new FpDefault(
ParseMojo.parse(name),
this.cache.resolve(ParseMojo.CACHE),
this.cache.toPath().resolve(ParseMojo.CACHE),
this.plugin.getVersion(),
new TojoHash(tojo),
base.relativize(target)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -167,7 +167,7 @@ private Path pulled(final ObjectName object, final Path base, final String hsh)
final String semver = this.plugin.getVersion();
final Path target = new Place(object).make(base, AssembleMojo.EO);
final Supplier<Path> che = new CachePath(
this.cache.resolve(PullMojo.CACHE),
this.cache.toPath().resolve(PullMojo.CACHE),
semver,
hsh,
base.relativize(target)
Expand Down
3 changes: 1 addition & 2 deletions eo-maven-plugin/src/main/java/org/eolang/maven/SafeMojo.java
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,6 @@
import java.io.Closeable;
import java.io.File;
import java.io.IOException;
import java.nio.file.Path;
import java.nio.file.Paths;
import java.util.LinkedHashSet;
import java.util.LinkedList;
Expand Down Expand Up @@ -217,7 +216,7 @@ abstract class SafeMojo extends AbstractMojo {
* @checkstyle VisibilityModifierCheck (10 lines)
*/
@Parameter(property = "eo.cache")
protected Path cache = Paths.get(System.getProperty("user.home")).resolve(".eo");
protected File cache = Paths.get(System.getProperty("user.home")).resolve(".eo").toFile();

/**
* Used for object versioning implementation.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -122,7 +122,7 @@ private int shaken(final ForeignTojo tojo, final Optimization optimization) thro
tojo.withShaken(
new FpDefault(
src -> optimization.apply(xmir).toString(),
this.cache.resolve(ShakeMojo.CACHE),
this.cache.toPath().resolve(ShakeMojo.CACHE),
this.plugin.getVersion(),
new TojoHash(tojo),
base.relativize(target)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -219,7 +219,7 @@ private long transpiled(final ForeignTojo tojo, final Optimization transpilation
rewrite.set(true);
return transpilation.apply(xmir).toString();
},
this.cache.resolve(TranspileMojo.CACHE),
this.cache.toPath().resolve(TranspileMojo.CACHE),
this.plugin.getVersion(),
hsh,
base.relativize(target)
Expand Down Expand Up @@ -255,7 +255,7 @@ private long javaGenerated(final boolean rewrite, final Path target, final Strin
this.generatedDir.toPath(), TranspileMojo.JAVA
);
final Supplier<Path> che = new CachePath(
this.cache.resolve(TranspileMojo.CACHE),
this.cache.toPath().resolve(TranspileMojo.CACHE),
this.plugin.getVersion(),
hsh,
this.generatedDir.toPath().relativize(tgt)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -122,7 +122,7 @@ private int verified(final ForeignTojo tojo, final Optimization optimization) th
tojo.withVerified(
new FpDefault(
src -> optimization.apply(xmir).toString(),
this.cache.resolve(VerifyMojo.CACHE),
this.cache.toPath().resolve(VerifyMojo.CACHE),
this.plugin.getVersion(),
new TojoHash(tojo),
base.relativize(target)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,7 @@ void savesToCache(@TempDir final Path temp) throws IOException {
synchronized (BinarizeMojoTest.class) {
maven = new FakeMaven(temp)
.withProgram(BinarizeMojoTest.SRC.resolve("simple-rust.eo"))
.with("cache", cache);
.with("cache", cache.toFile());
}
final Map<String, Path> res = maven
.execute(new FakeMaven.Binarize())
Expand Down Expand Up @@ -133,7 +133,7 @@ void boostsSecondCompilation(@TempDir final Path temp) throws IOException {
synchronized (BinarizeMojoTest.class) {
maven = new FakeMaven(temp)
.withProgram(BinarizeMojoTest.SRC.resolve("simple-rust.eo"))
.with("cache", cache);
.with("cache", cache.toFile());
}
long start = System.currentTimeMillis();
maven.execute(new FakeMaven.Binarize());
Expand All @@ -158,7 +158,7 @@ void doesNotRecompile(@TempDir final Path temp) throws IOException {
synchronized (BinarizeMojoTest.class) {
maven = new FakeMaven(temp)
.withProgram(BinarizeMojoTest.SRC.resolve("simple-rust.eo"))
.with("cache", cache);
.with("cache", cache.toFile());
}
maven.execute(new FakeMaven.Binarize());
final File executable = cache
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ void makesFullCompilingLifecycleSuccessfully(@TempDir final Path temp) throws IO
.with("includeSources", new SetOf<>("**.eo"))
.with("outputDir", temp.resolve("out").toFile())
.with("placed", temp.resolve("list").toFile())
.with("cache", temp.resolve("cache/parsed"))
.with("cache", temp.resolve("cache/parsed").toFile())
.with("skipZeroVersions", true)
.with("central", Central.EMPTY)
.with("ignoreTransitive", true)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -230,7 +230,7 @@ public <T extends AbstractMojo> FakeMaven execute(final Class<T> mojo) throws IO
);
this.params.putIfAbsent(
"cache",
this.workspace.absolute(Paths.get("eo")).resolve("cache/parsed")
this.workspace.absolute(Paths.get("eo")).resolve("cache/parsed").toFile()
);
this.params.putIfAbsent("generateSodgXmlFiles", true);
this.params.putIfAbsent("generateXemblyFiles", true);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -145,7 +145,7 @@ void getsAlreadyOptimizedResultsFromCache(@TempDir final Path temp) throws Excep
);
new FakeMaven(temp)
.withHelloWorld()
.with("cache", cache)
.with("cache", cache.toFile())
.allTojosWithHash(() -> hash)
.execute(new FakeMaven.Optimize());
MatcherAssert.assertThat(
Expand All @@ -171,7 +171,7 @@ void savesOptimizedResultsToCache(@TempDir final Path temp) throws IOException {
final String hash = "abcdef1";
new FakeMaven(temp)
.withHelloWorld()
.with("cache", cache)
.with("cache", cache.toFile())
.allTojosWithHash(() -> hash)
.execute(new FakeMaven.Optimize());
MatcherAssert.assertThat(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -123,7 +123,7 @@ void parsesWithCache(@TempDir final Path temp) throws Exception {
final Path cache = temp.resolve("cache");
final FakeMaven maven = new FakeMaven(temp)
.withProgram("invalid content")
.with("cache", cache);
.with("cache", cache.toFile());
final String expected = new UncheckedText(
new TextOf(new ResourceOf("org/eolang/maven/main.xmir"))
).asString();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -352,7 +352,7 @@ void savesPulledResultsToCache(@TempDir final Path temp) throws IOException {
);
new FakeMaven(temp)
.withHelloWorld()
.with("cache", cache)
.with("cache", cache.toFile())
.with("hash", hash)
.execute(new FakeMaven.Pull());
MatcherAssert.assertThat(
Expand Down Expand Up @@ -398,7 +398,7 @@ void getsAlreadyPulledResultsFromCache(@TempDir final Path temp) throws Exceptio
" QQ.io.stdout > @"
)
.with("hash", new CommitHash.ChConstant(hash))
.with("cache", cache)
.with("cache", cache.toFile())
.execute(new FakeMaven.Pull());
MatcherAssert.assertThat(
"PullMojo should take source from cache, but it does not",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -107,7 +107,7 @@ void getsAlreadyShakenResultsFromCache(@TempDir final Path temp) throws Exceptio
);
new FakeMaven(temp)
.withHelloWorld()
.with("cache", cache)
.with("cache", cache.toFile())
.allTojosWithHash(() -> hash)
.execute(new FakeMaven.Shake());
MatcherAssert.assertThat(
Expand Down Expand Up @@ -172,7 +172,7 @@ void savesShakenResultsToCache(@TempDir final Path temp) throws IOException {
final String hash = "abcdef1";
new FakeMaven(temp)
.withHelloWorld()
.with("cache", cache)
.with("cache", cache.toFile())
.allTojosWithHash(() -> hash)
.execute(new FakeMaven.Shake());
MatcherAssert.assertThat(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -271,7 +271,7 @@ void savesVerifiedResultsToCache(@TempDir final Path temp) throws IOException {
final String hash = "abcdef1";
new FakeMaven(temp)
.withHelloWorld()
.with("cache", cache)
.with("cache", cache.toFile())
.allTojosWithHash(() -> hash)
.execute(new FakeMaven.Verify());
MatcherAssert.assertThat(
Expand Down Expand Up @@ -311,7 +311,7 @@ void getsAlreadyVerifiedResultsFromCache(@TempDir final Path temp) throws Except
);
new FakeMaven(temp)
.withHelloWorld()
.with("cache", cache)
.with("cache", cache.toFile())
.allTojosWithHash(() -> hash)
.execute(new FakeMaven.Verify());
MatcherAssert.assertThat(
Expand Down

0 comments on commit e0968db

Please sign in to comment.