-
Notifications
You must be signed in to change notification settings - Fork 2.7k
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
[MNG-7836] Support alternative syntaxes for POMs #1197
[MNG-7836] Support alternative syntaxes for POMs #1197
Conversation
c873f5b
to
3385569
Compare
api/maven-api-core/src/main/java/org/apache/maven/api/services/Source.java
Outdated
Show resolved
Hide resolved
api/maven-api-core/src/main/java/org/apache/maven/api/services/Source.java
Outdated
Show resolved
Hide resolved
api/maven-api-core/src/main/java/org/apache/maven/api/services/Source.java
Outdated
Show resolved
Hide resolved
api/maven-api-spi/src/main/java/org/apache/maven/api/spi/ModelParser.java
Outdated
Show resolved
Hide resolved
api/maven-api-spi/src/main/java/org/apache/maven/api/spi/ModelParser.java
Outdated
Show resolved
Hide resolved
...e/src/main/java/org/apache/maven/internal/transformation/ConsumerPomArtifactTransformer.java
Outdated
Show resolved
Hide resolved
maven-model-builder/src/main/java/org/apache/maven/model/building/DefaultModelProcessor.java
Outdated
Show resolved
Hide resolved
maven-model-builder/src/main/java/org/apache/maven/model/building/DefaultModelProcessor.java
Show resolved
Hide resolved
maven-model-builder/src/main/java/org/apache/maven/model/building/DefaultModelProcessor.java
Show resolved
Hide resolved
maven-model-builder/src/main/java/org/apache/maven/model/building/FileSource.java
Outdated
Show resolved
Hide resolved
eff9877
to
709e9d6
Compare
709e9d6
to
2e669bb
Compare
e423eb1
to
b757bb5
Compare
api/maven-api-spi/src/main/java/org/apache/maven/api/spi/ModelParser.java
Outdated
Show resolved
Hide resolved
b757bb5
to
97c11dd
Compare
api/maven-api-core/src/main/java/org/apache/maven/api/services/Source.java
Outdated
Show resolved
Hide resolved
api/maven-api-spi/src/main/java/org/apache/maven/api/spi/ModelParser.java
Show resolved
Hide resolved
api/maven-api-spi/src/main/java/org/apache/maven/api/spi/ModelParser.java
Show resolved
Hide resolved
dca4063
to
c7662cb
Compare
The IT associated with this PR is using the Maven model to generate a hocon POM parser. This requires the maven-api-model module to attach the POM as an artifact, and the maven.yml change so that the model is present in the local repository.
c7662cb
to
2890d61
Compare
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'll move this to a comment instead of a request changes, but I still think there are pretty serious issues between checked and runtime exceptions here, and those need to be resolved ASAP, and certainly before the 4.0 API is locked down and ships.
import org.apache.maven.api.services.MavenException; | ||
|
||
@Experimental | ||
public class ModelParserException extends MavenException { |
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'm tempted to say that either this shouldn't extend MavenException then, or that this PR should wait ion resolving that issue. It's a pretty serious API design problem. This is a new exception in 4.0, right?
.filter(Objects::nonNull) | ||
.findFirst() | ||
.orElseGet( | ||
() -> modelLocator.locatePom(projectDirectory.toFile()).toPath()); | ||
if (!pom.equals(projectDirectory) && !pom.getParent().equals(projectDirectory)) { | ||
throw new IllegalArgumentException("The POM found does not belong to the given directory: " + pom); |
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'm not sure this is the right exception here. This isn't necessarily a problem with he argument itself. It's more akin to a checked IOException, again arising from conditions external to the program itself.
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 strongly disagree. This is a health check on the response. Both ModelLocator#locatePom
and ModelParser#locate
are supposed to return a file in the provided directory or the directory itself. This is quite explicit in their respective javadoc. So it's a programming error and can not be recovered.
.filter(Objects::nonNull) | ||
.findFirst() | ||
.orElseGet(() -> { | ||
File f = modelLocator.locateExistingPom(projectDirectory.toFile()); |
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.
probably don't need to convert to a File here, just use the 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.
ModelLocator
is part of the Maven 3 public api and uses the File
instead of Path
.
The Maven 4 api uses Path
and not File
, but I don't think that's a good idea to start modifying the Maven 3 api in incompatible ways, or even to duplicate all the methods to leverage the nio API at this point.
So I'm not really sure what can be done here.
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.
Fair enough, on File then. That makes sense.
On the exception, whether it can be recovered is not relevant. That is not the determining factor in whether a checked exception is appropriate.
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 know this is a common belief, but it's not how exceptions in Java were designed and it doesn't work in practice.
I don't think there are issues at this point, as this was a concious design decision. A change can be discussed, feel free to start a discussion and make your point. |
JIRA issue: https://issues.apache.org/jira/browse/MNG-7836
IT PR: apache/maven-integration-testing#276