Skip to content

Commit

Permalink
#1228 four levels of deps
Browse files Browse the repository at this point in the history
  • Loading branch information
yegor256 committed Sep 16, 2022
1 parent f82f256 commit 4cb38cd
Show file tree
Hide file tree
Showing 11 changed files with 26 additions and 30 deletions.
3 changes: 2 additions & 1 deletion eo-maven-plugin/src/it/fibonacci/verify.groovy
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,8 @@ String log = new File(basedir, 'build.log').text

[
'--- eo-maven-plugin:',
'org.eolang unpacked to eo-runtime',
'org.eolang:eo-runtime:',
' unpacked to ',
'6th Fibonacci number is 8',
'BUILD SUCCESS',
].each { assert log.contains(it) }
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -116,7 +116,7 @@ public void accept(final Dependency dep, final Path path) {
throw new IllegalStateException(ex);
}
Logger.info(
this, "%s unpacked to %s:%s:%s:%s",
this, "%s:%s:%s:%s unpacked to %s",
dep.getGroupId(), dep.getArtifactId(), dep.getClassifier(), dep.getVersion(),
Save.rel(path)
);
Expand Down
8 changes: 4 additions & 4 deletions eo-maven-plugin/src/main/java/org/eolang/maven/DepDirs.java
Original file line number Diff line number Diff line change
Expand Up @@ -35,8 +35,8 @@

/**
* Walk through directories in a directory and find dep names. Each
* dep is a sub-directory of the third level,
* for example "org.eolang/eo-runtime/0.10.0".
* dep is a subdirectory of the FOURTH level,
* for example "org.eolang/eo-runtime/jar-with-dependencies/0.10.0".
*
* @since 0.13
*/
Expand All @@ -63,12 +63,12 @@ private static List<String> list(final Path dir) throws IOException {
if (Files.exists(dir)) {
final String home = dir.toAbsolutePath().toString();
names.addAll(
Files.find(dir, 3, (t, u) -> true)
Files.find(dir, 4, (t, u) -> true)
.filter(file -> file.toFile().isDirectory())
.map(file -> file.toAbsolutePath().toString())
.filter(name -> !name.equals(home))
.map(name -> name.substring(home.length() + 1))
.filter(name -> name.split(Pattern.quote(File.separator)).length == 3)
.filter(name -> name.split(Pattern.quote(File.separator)).length == 4)
.collect(Collectors.toList())
);
}
Expand Down
7 changes: 3 additions & 4 deletions eo-maven-plugin/src/main/java/org/eolang/maven/FtCached.java
Original file line number Diff line number Diff line change
Expand Up @@ -102,11 +102,10 @@ public void save(final String program, final String ext, final Scalar<String> co
final Path target = new Place(program).make(this.main, ext);
final String text;
if (cached.toFile().exists()) {
Logger.info(
Logger.debug(
this,
"Program %s found in cache: %s",
program,
cached
"Program %s.%s found in cache: %s",
program, ext, cached
);
text = this.load(program, ext);
} else {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ public String hash() {
)
);
}
Logger.info(this, "Git sha of %s is %s", this.tag, result);
Logger.debug(this, "Git sha of %s is %s", this.tag, result);
return result;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ public void exec() throws IOException {
if (!Files.exists(sub)) {
continue;
}
final String ver = dep.split(Pattern.quote(File.separator))[2];
final String ver = dep.split(Pattern.quote(File.separator))[3];
found += this.scan(sub, ver);
}
Logger.info(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -164,7 +164,7 @@ private void parse(final Tojo tojo) throws IOException {
)
).applyQuietly(new XMLDocument(baos.toByteArray()).node())
).toString();
Logger.info(
Logger.debug(
this,
"Parsed program %s:\n %s",
name,
Expand Down
20 changes: 8 additions & 12 deletions eo-maven-plugin/src/main/java/org/eolang/maven/ResolveMojo.java
Original file line number Diff line number Diff line change
Expand Up @@ -104,19 +104,15 @@ public void exec() throws IOException {
final Collection<Dependency> deps = this.deps();
for (final Dependency dep : deps) {
final String coords = ResolveMojo.coords(dep);
final Path dest;
if (dep.getClassifier().isEmpty()) {
dest = this.targetDir.toPath().resolve(ResolveMojo.DIR)
.resolve(dep.getGroupId())
.resolve(dep.getArtifactId())
.resolve(dep.getVersion());
} else {
dest = this.targetDir.toPath().resolve(ResolveMojo.DIR)
.resolve(dep.getGroupId())
.resolve(dep.getArtifactId())
.resolve(dep.getClassifier())
.resolve(dep.getVersion());
String classifier = dep.getClassifier();
if (classifier.isEmpty()) {
classifier = "-";
}
final Path dest = this.targetDir.toPath().resolve(ResolveMojo.DIR)
.resolve(dep.getGroupId())
.resolve(dep.getArtifactId())
.resolve(classifier)
.resolve(dep.getVersion());
if (Files.exists(dest)) {
Logger.debug(
this, "Dependency %s already resolved to %s",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ void findsDirs(@TempDir final Path temp) throws IOException {
new Save("", temp.resolve("a/g")).save();
MatcherAssert.assertThat(
new DepDirs(temp),
Matchers.contains(String.format("a%sb%1$sc", File.separator))
Matchers.contains(String.format("a%sb%1$sc%1$sf", File.separator))
);
MatcherAssert.assertThat(
new DepDirs(temp),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ void extendForeignWithNewObjects(@TempDir final Path temp) throws Exception {
final Path bins = temp.resolve(ResolveMojo.DIR);
new Save(
"hi",
bins.resolve(String.format("foo/hello/0.1.8/%s/foo/bar.eo", CopyMojo.DIR))
bins.resolve(String.format("foo/hello/-/0.1.8/%s/foo/bar.eo", CopyMojo.DIR))
).save();
final Path foreign = temp.resolve("placed.json");
new Moja<>(MarkMojo.class)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,9 +41,9 @@ final class PlaceMojoTest {
void placesBinaries(@TempDir final Path temp) throws Exception {
final Path bins = temp.resolve(ResolveMojo.DIR);
final Path classes = temp.resolve("classes");
new Save("x1", bins.resolve("foo/hello/0.1/EObar/x.bin")).save();
new Save("x2", bins.resolve("foo/hello/0.1/org/eolang/f/x.a.class")).save();
new Save("x3", bins.resolve("foo/hello/0.1/org/eolang/t.txt")).save();
new Save("x1", bins.resolve("foo/hello/-/0.1/EObar/x.bin")).save();
new Save("x2", bins.resolve("foo/hello/-/0.1/org/eolang/f/x.a.class")).save();
new Save("x3", bins.resolve("foo/hello/-/0.1/org/eolang/t.txt")).save();
new Moja<>(PlaceMojo.class)
.with("targetDir", temp.toFile())
.with("outputDir", classes.toFile())
Expand Down

0 comments on commit 4cb38cd

Please sign in to comment.