-
Notifications
You must be signed in to change notification settings - Fork 123
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
#1361 Add eo-runtime dependency even if foreign dependencies are absent #1357
#1361 Add eo-runtime dependency even if foreign dependencies are absent #1357
Conversation
@volodya-lombrozo can we squash commits? |
@volodya-lombrozo please run the build with Qulice locally. |
|
/** | ||
* Check if runtime dependency is absent. | ||
* @param deps Dependencies | ||
* fixme: We are using hardcoded version of RuntimeDependency. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@volodya-lombrozo I suppose this needs to be a puzzle?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I've tried to create a puzzle, but it complains that I have to link to some issue. As far as I know, I have to put current issue #35, but we are not in
eoc
repository.eo
repository has it's own #35 issue.
In this case we must create new issue within eo
repository since it is a fix for EO. And link this PR to EO issue.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
New issue #1361 in eo
repo
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Fixed
@@ -194,6 +194,7 @@ private Collection<Dependency> deps() throws IOException { | |||
tojo.set(AssembleMojo.ATTR_JAR, coords); | |||
} | |||
this.checkConflicts(deps); | |||
addRuntimeDependency(deps); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@volodya-lombrozo wrong style - should be called via class name.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Fixed
* | ||
* @since 0.28.11 | ||
*/ | ||
final class RuntimeDependency { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@volodya-lombrozo Since it's specific to EO runtime - I would call it EoRuntime
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Renamed to EoRuntimeDependency
* @param other Other dependency | ||
* @return True if other dependency is the eo-runtime dependency | ||
*/ | ||
boolean theSameAs(final Dependency other) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@volodya-lombrozo Could be simplified to same
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Renamed
* | ||
* @return Maven Dependency | ||
*/ | ||
Dependency toDependency() { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@volodya-lombrozo Could be simplified to dependency
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Renamed
fix(objectionary#35): add RuntimeDependency to classpath if it's absent fix(objectionary#35): add test for empty dependencies situation fix(objectionary#35): make all tests pass fix(objectionary#35): add todo mark for hardcoded version of RuntimeLibrary fix(objectionary#35): move all binary expressions to start of a line fix(objectionary#35): don't align chained method calls fix(objectionary#35): fix all linter mistakes in ResolveMojoTest fix(objectionary#35): fix some linter mistakes in MockMavenCentral fix(objectionary#35): fix all linter mistakes in MockMavenCentral fix(objectionary#35): fix all linter mistakes in ResolveMojo fix(objectionary#35): fix all linter mistakes in RuntimeDependency fix(objectionary#35): correct todo for pdd feat(objectionary#35): fix linter problems in comments feat(objectionary#35): fix all codacy complains
eb19c79
to
0e81929
Compare
Done |
toDependency -> dependency theSameAs -> same RuntimeDependency -> EoRuntimeDependency RuntimeDependency -> EoRuntimeDependency use classname for static function call
* @param dependency Dependency | ||
* @return True if dependency is runtime dependency | ||
*/ | ||
private static boolean isRuntimeDependency(final Dependency dependency) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@volodya-lombrozo This can be inlined. I believe no need in separate static method.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done
* @return True if dependency is runtime dependency | ||
*/ | ||
private static boolean isRuntimeDependency(final Dependency dependency) { | ||
return new EoRuntimeDependency().same(dependency); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@volodya-lombrozo May we create only one instance of EoRuntimeDependency
and reuse it?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done
@volodya-lombrozo looks good to me. |
@volod looks very good, but I have a few questions. First, why do we need to create a new class Second, |
@yegor256 pls, take a loot at the last changes. I’ve change As for Also, it’s a quite dangerous to use |
@@ -194,6 +194,7 @@ private Collection<Dependency> deps() throws IOException { | |||
tojo.set(AssembleMojo.ATTR_JAR, coords); | |||
} | |||
this.checkConflicts(deps); | |||
ResolveMojo.addRuntimeDependency(deps); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
In order to obrain the issue I had to add a few private static classes. Please, take a look at AllDependencies
and UniqueDependencies
classes.
* or from config files. | ||
*/ | ||
private static void addRuntimeDependency(final Collection<Dependency> deps) { | ||
final RuntimeDependencyEquality runtime = new RuntimeDependencyEquality(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Fixed
@volodya-lombrozo please, forgive me for being picky. I think that What you are doing now with encapsulating mutable structures in |
I've removed |
* | ||
* @since 0.28.11 | ||
*/ | ||
final class LastPathSame extends TypeSafeMatcher<Path> { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@volodya-lombrozo this class is redundant now, right?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, I've just forgot to remove the class. Done.
* | ||
* @since 0.28.11 | ||
*/ | ||
final class LastDependencySame extends TypeSafeMatcher<Dependency> { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@volodya-lombrozo this class is not needed anymore, right?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, I've just forgot to remove the class. Done.
@volodya-lombrozo check again, please. Looks like these two matchers are not needed anymore. |
@yegor256 can you merge the PR, please? If everything is fine, of course. |
# Conflicts: # eo-maven-plugin/src/test/java/org/eolang/maven/ResolveMojoTest.java
# Conflicts: # eo-maven-plugin/src/main/java/org/eolang/maven/ResolveMojo.java
prepare for refactoring add DcsNoOneTransitive make all tests pass clean ResolveMojo add puzzle for tests for DcsNoOneHasTransitive refactor DcsNoOneHasTransitive fix some linter mistakes fix some linter mistakes fix some linter mistakes fix some linter mistakes
Updates for that PRSine we implemented
@mximp @yegor256 please, check and merge if you don't have any objections. |
final Dependencies delegate, | ||
final Func<Dependency, Dependencies> transitive | ||
) { | ||
this.ignore = ignore; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@yegor256 fixed.
* | ||
* @since 0.28.11 | ||
*/ | ||
final class DcsOf implements Dependencies { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@volodya-lombrozo what this class is for? Where and why Collection<Dependency>
is not good enough?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I wanted to make it more obvious. We can't use it directly in the next construction:
new DcsNoOneHasTransitive(
this.ignoreTransitive,
dcs,
....
)
because Collection<org.apache.maven.model.Dependency>
!= Dependencies
. But, of course, we can use it this way:
new DcsNoOneHasTransitive(
this.ignoreTransitive,
dcs::iterator,
....
)
I will fix it. Thank you.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@yegor256 fixed.
import org.apache.maven.model.Dependency; | ||
|
||
/** | ||
* RuntimeDependencyEquality is a class for checking if dependency is a runtime dependency. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@volodya-lombrozo are you sure this is an accurate description of functionality here? It looks wrong to me.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@yegor256 fixed.
); | ||
} catch (final IOException ex) { | ||
throw new IllegalStateException( | ||
String.format("DummyCentral can't save dependency %s by path %s", dependency, path), |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@volodya-lombrozo the information about the originator of the exception is in stacktrace. No need to add this noise. Just say "Can't save '%s' to '%s'"
. In general, the shorter your messages, the better. They must be short, but contain maximum information.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@volodya-lombrozo moreover, if I remove this class tomorrow, I most probably will forget to rename it in the text
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@yegor256 fixed
make exception description shorter change the description of RuntimeDependencyEquality remove redundant class don't use configurable objects fix all linter mistakes
@SuppressWarnings("PMD.AvoidCatchingGenericException") | ||
private boolean hasTransitive(final Dependency dep) { | ||
try { | ||
return new LengthOf( |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@volodya-lombrozo use Unchecked
from Cactoos, to avoid exception catching
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@yegor256 fixed.
) | ||
); | ||
if (!conflicts.isEmpty()) { | ||
final String msg = String.format( |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@volodya-lombrozo this is a bad practice: to do both logging and throwing. Pick one.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@yegor256 I've chosen the exception. Done.
private Dependencies dependenciesOf(final Collection<Dependency> all) { | ||
final Dependencies dependencies; | ||
if (this.ignoreTransitive && this.ignoreVersionConflicts) { | ||
dependencies = new DcsWithRuntime(all::iterator); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@volodya-lombrozo looks like code duplication to me. You use DcsWithRuntime
everywhere in each if
. Maybe it's better to make dependencies
mutable?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@yegor256 done.
Files.createDirectories(path); | ||
Files.createFile( | ||
path.resolve( | ||
String.format("%s-%s.jar", dependency.getArtifactId(), dependency.getVersion()) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@volodya-lombrozo you ignore dependency.getClassifier()
, why? maybe it's better to use it too?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@yegor256 added.
@volodya-lombrozo a few more comments from me, see above |
use unchecked classes inside DcsNoOneHashTransitive use unchecked classes inside DcsNoOneHashTransitive remove duplicated logging remove code duplication inside ResolveMojo use classifier for jar name in DummyCentral
@yegor256 I've applied all your suggestions above. Please, merge if you don't have any objections. |
@rultor merge |
Closes: #1361
I've added one more step in
ResolveMojo
. It adds runtime dependency if it is absent.That solution allows build EO programs without foreing objects.