You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@maven.apache.org by GitBox <gi...@apache.org> on 2022/03/15 09:27:31 UTC
[GitHub] [maven] laeubi opened a new pull request #695: Quick Fix for https://github.com/quarkusio/quarkus/pull/24285
laeubi opened a new pull request #695:
URL: https://github.com/apache/maven/pull/695
Signed-off-by: Christoph Läubrich <ch...@laeubi-soft.de>
Following this checklist to help us incorporate your
contribution quickly and easily:
- [ ] Make sure there is a [JIRA issue](https://issues.apache.org/jira/browse/MNG) filed
for the change (usually before you start working on it). Trivial changes like typos do not
require a JIRA issue. Your pull request should address just this issue, without
pulling in other changes.
- [ ] Each commit in the pull request should have a meaningful subject line and body.
- [ ] Format the pull request title like `[MNG-XXX] SUMMARY`, where you replace `MNG-XXX`
and `SUMMARY` with the appropriate JIRA issue. Best practice is to use the JIRA issue
title in the pull request title and in the first line of the commit message.
- [ ] Write a pull request description that is detailed enough to understand what the pull request does, how, and why.
- [ ] Run `mvn clean verify` to make sure basic checks pass. A more thorough check will
be performed on your pull request automatically.
- [ ] You have run the [Core IT][core-its] successfully.
If your pull request is about ~20 lines of code you don't need to sign an
[Individual Contributor License Agreement](https://www.apache.org/licenses/icla.pdf) if you are unsure
please ask on the developers list.
To make clear that you license your contribution under
the [Apache License Version 2.0, January 2004](http://www.apache.org/licenses/LICENSE-2.0)
you have to acknowledge this by using the following check-box.
- [ ] I hereby declare this contribution to be licenced under the [Apache License Version 2.0, January 2004](http://www.apache.org/licenses/LICENSE-2.0)
- [ ] In any other case, please file an [Apache Individual Contributor License Agreement](https://www.apache.org/licenses/icla.pdf).
[core-its]: https://maven.apache.org/core-its/core-it-suite/
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: issues-unsubscribe@maven.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [maven] cstamas commented on a change in pull request #695: [MNG-7432] Dependencies from profile not picked up via -P
Posted by GitBox <gi...@apache.org>.
cstamas commented on a change in pull request #695:
URL: https://github.com/apache/maven/pull/695#discussion_r841079559
##########
File path: maven-core/src/main/java/org/apache/maven/internal/aether/MavenChainedWorkspaceReader.java
##########
@@ -0,0 +1,106 @@
+package org.apache.maven.internal.aether;
+
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+import java.io.File;
+import java.util.Collection;
+import java.util.List;
+
+import org.apache.maven.model.Model;
+import org.apache.maven.repository.internal.MavenWorkspaceReader;
+import org.eclipse.aether.artifact.Artifact;
+import org.eclipse.aether.repository.WorkspaceReader;
+import org.eclipse.aether.repository.WorkspaceRepository;
+import org.eclipse.aether.util.repository.ChainedWorkspaceReader;
+
+/**
+ * A maven workspace reader that delegates to a chain of other readers, effectively aggregating their contents.
+ */
+public final class MavenChainedWorkspaceReader
+ implements MavenWorkspaceReader
+{
+
+ private ChainedWorkspaceReader delegate;
+
+ private WorkspaceReader[] readers;
+
+ /**
+ * Creates a new workspace reader by chaining the specified readers.
+ *
+ * @param readers The readers to chain must not be {@code null}.
+ */
+ private MavenChainedWorkspaceReader( WorkspaceReader... readers )
+ {
+ this.delegate = new ChainedWorkspaceReader( readers );
+ this.readers = readers;
+ }
+
+ @Override
+ public Model findModel( Artifact artifact )
+ {
+ for ( WorkspaceReader workspaceReader : readers )
+ {
+ if ( workspaceReader instanceof MavenWorkspaceReader )
+ {
+ Model model = ( (MavenWorkspaceReader) workspaceReader ).findModel( artifact );
+ if ( model != null )
+ {
+ return model;
+ }
+ }
+ }
+ return null;
+ }
+
+ @Override
+ public WorkspaceRepository getRepository()
+ {
+ return delegate.getRepository();
+ }
+
+ @Override
+ public File findArtifact( Artifact artifact )
+ {
+ return delegate.findArtifact( artifact );
+ }
+
+ @Override
+ public List<String> findVersions( Artifact artifact )
+ {
+ return delegate.findVersions( artifact );
+ }
+
+ /**
+ * chains a collection of {@link WorkspaceReader}s
+ * @param workspaceReaderCollection the collection of readers, might be empty but never <code>null</code>
+ * @return if the collection contains only one item returns the single item, otherwise creates a new
+ * {@link MavenChainedWorkspaceReader} chaining all readers in the order of the given collection.
+ */
+ public static WorkspaceReader of( Collection<WorkspaceReader> workspaceReaderCollection )
+ {
+ WorkspaceReader[] readers = workspaceReaderCollection.toArray( new WorkspaceReader[0] );
+ if ( readers.length == 1 )
Review comment:
Still, the check could happen then on collection, not after conversion, no?
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: issues-unsubscribe@maven.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [maven] basil commented on pull request #695: [MNG-7432] Dependencies from profile not picked up via -P
Posted by GitBox <gi...@apache.org>.
basil commented on pull request #695:
URL: https://github.com/apache/maven/pull/695#issuecomment-1073294198
> so if you can provide
Sorry, I lack the time and interest to pursue this further. I have already reverted back to Maven 3.8.4.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: issues-unsubscribe@maven.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [maven] basil commented on pull request #695: [MNG-7432] Dependencies from profile not picked up via -P
Posted by GitBox <gi...@apache.org>.
basil commented on pull request #695:
URL: https://github.com/apache/maven/pull/695#issuecomment-1073174598
I do not really know or care what a workspace reader is. I just want my builds to work again.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: issues-unsubscribe@maven.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [maven] laeubi commented on pull request #695: [MNG-7432] Dependencies from profile not picked up via -P
Posted by GitBox <gi...@apache.org>.
laeubi commented on pull request #695:
URL: https://github.com/apache/maven/pull/695#issuecomment-1073188594
> I think that writing "restoring the old behavior from Maven 3.8.4" should have made it clear that I already knew that.
Sure but if you simply "do not really care" the easiest and fastest way is using 3.8.4. For 3.8.5 support for additional Readers was added because there are people who care, and applying a fix that would only "restoring the old behavior" (that was already broken but probably never noticed) won't help much.
I also don't see that the fix is controversial just that @michael-o want to better understand the cause, so if you can provide additional information why your build fails e.g. by providing a minimal reproducer, integration or unit test or you can confirm that it is the same problem described by @famod then it might help to make more progress here.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: issues-unsubscribe@maven.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [maven] basil commented on pull request #695: [MNG-7432] Dependencies from profile not picked up via -P
Posted by GitBox <gi...@apache.org>.
basil commented on pull request #695:
URL: https://github.com/apache/maven/pull/695#issuecomment-1073123778
A more minimal (and therefore likely less controversial) alternative to the fix proposed in this PR is:
```java
diff --git a/maven-core/src/main/java/org/apache/maven/DefaultMaven.java b/maven-core/src/main/java/org/apache/maven/DefaultMaven.java
index 56a42b724..965345394 100644
--- a/maven-core/src/main/java/org/apache/maven/DefaultMaven.java
+++ b/maven-core/src/main/java/org/apache/maven/DefaultMaven.java
@@ -377,8 +377,15 @@ private void setupWorkspaceReader( MavenSession session, DefaultRepositorySystem
}
workspaceReaders.add( workspaceReader );
}
- WorkspaceReader[] readers = workspaceReaders.toArray( new WorkspaceReader[0] );
- repoSession.setWorkspaceReader( new ChainedWorkspaceReader( readers ) );
+ if ( workspaceReaders.size() == 1 )
+ {
+ repoSession.setWorkspaceReader( workspaceReaders.get( 0 ) );
+ }
+ else
+ {
+ WorkspaceReader[] readers = workspaceReaders.toArray( new WorkspaceReader[0] );
+ repoSession.setWorkspaceReader( new ChainedWorkspaceReader( readers ) );
+ }
}
```
This fixes the problem for me by restoring the old behavior from Maven 3.8.4.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: issues-unsubscribe@maven.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [maven] basil commented on pull request #695: [MNG-7432] Dependencies from profile not picked up via -P
Posted by GitBox <gi...@apache.org>.
basil commented on pull request #695:
URL: https://github.com/apache/maven/pull/695#issuecomment-1073177097
I think that writing "restoring the old behavior from Maven 3.8.4" should have made it clear that I already knew that.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: issues-unsubscribe@maven.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [maven] laeubi edited a comment on pull request #695: [MNG-7432] Dependencies from profile not picked up via -P
Posted by GitBox <gi...@apache.org>.
laeubi edited a comment on pull request #695:
URL: https://github.com/apache/maven/pull/695#issuecomment-1081805771
> If I understand correctly, one or both of
Exactly!
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: issues-unsubscribe@maven.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [maven] laeubi commented on pull request #695: [MNG-7432] Dependencies from profile not picked up via -P
Posted by GitBox <gi...@apache.org>.
laeubi commented on pull request #695:
URL: https://github.com/apache/maven/pull/695#issuecomment-1081853247
> Is there an IT for this? If there would be, I'd check this and add for 3.8.6+.
[The jira](https://issues.apache.org/jira/browse/MNG-7432) has a link [to a reproducer](https://github.com/aloubyansky/playground/tree/maven-3.8.5-profile-activation) maybe this could be integrated an in itest or give a hint how to create one?
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: issues-unsubscribe@maven.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [maven] cstamas commented on a change in pull request #695: [MNG-7432] Dependencies from profile not picked up via -P
Posted by GitBox <gi...@apache.org>.
cstamas commented on a change in pull request #695:
URL: https://github.com/apache/maven/pull/695#discussion_r841077022
##########
File path: maven-core/src/main/java/org/apache/maven/internal/aether/MavenChainedWorkspaceReader.java
##########
@@ -0,0 +1,106 @@
+package org.apache.maven.internal.aether;
+
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+import java.io.File;
+import java.util.Collection;
+import java.util.List;
+
+import org.apache.maven.model.Model;
+import org.apache.maven.repository.internal.MavenWorkspaceReader;
+import org.eclipse.aether.artifact.Artifact;
+import org.eclipse.aether.repository.WorkspaceReader;
+import org.eclipse.aether.repository.WorkspaceRepository;
+import org.eclipse.aether.util.repository.ChainedWorkspaceReader;
+
+/**
+ * A maven workspace reader that delegates to a chain of other readers, effectively aggregating their contents.
+ */
+public final class MavenChainedWorkspaceReader
+ implements MavenWorkspaceReader
+{
+
+ private ChainedWorkspaceReader delegate;
+
+ private WorkspaceReader[] readers;
+
+ /**
+ * Creates a new workspace reader by chaining the specified readers.
+ *
+ * @param readers The readers to chain must not be {@code null}.
+ */
+ private MavenChainedWorkspaceReader( WorkspaceReader... readers )
+ {
+ this.delegate = new ChainedWorkspaceReader( readers );
+ this.readers = readers;
+ }
+
+ @Override
+ public Model findModel( Artifact artifact )
+ {
+ for ( WorkspaceReader workspaceReader : readers )
+ {
+ if ( workspaceReader instanceof MavenWorkspaceReader )
+ {
+ Model model = ( (MavenWorkspaceReader) workspaceReader ).findModel( artifact );
+ if ( model != null )
+ {
+ return model;
+ }
+ }
+ }
+ return null;
+ }
+
+ @Override
+ public WorkspaceRepository getRepository()
+ {
+ return delegate.getRepository();
+ }
+
+ @Override
+ public File findArtifact( Artifact artifact )
+ {
+ return delegate.findArtifact( artifact );
+ }
+
+ @Override
+ public List<String> findVersions( Artifact artifact )
+ {
+ return delegate.findVersions( artifact );
+ }
+
+ /**
+ * chains a collection of {@link WorkspaceReader}s
+ * @param workspaceReaderCollection the collection of readers, might be empty but never <code>null</code>
+ * @return if the collection contains only one item returns the single item, otherwise creates a new
+ * {@link MavenChainedWorkspaceReader} chaining all readers in the order of the given collection.
+ */
+ public static WorkspaceReader of( Collection<WorkspaceReader> workspaceReaderCollection )
+ {
+ WorkspaceReader[] readers = workspaceReaderCollection.toArray( new WorkspaceReader[0] );
+ if ( readers.length == 1 )
Review comment:
I'd personally would just remove this length check, and make it always wrapped (is simpler).
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: issues-unsubscribe@maven.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [maven] laeubi commented on pull request #695: [MNG-7432] Dependencies from profile not picked up via -P
Posted by GitBox <gi...@apache.org>.
laeubi commented on pull request #695:
URL: https://github.com/apache/maven/pull/695#issuecomment-1081326893
@michael-o just wondering inf we can proceed here? If its fine for 3.8.x I'll prepare PRs for 2.9.x and 4.x as well ... I also wonder if it would be suitable to release a 3.8.6 version or do we have to wait for 2.9.0?
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: issues-unsubscribe@maven.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [maven] cstamas commented on a change in pull request #695: [MNG-7432] Dependencies from profile not picked up via -P
Posted by GitBox <gi...@apache.org>.
cstamas commented on a change in pull request #695:
URL: https://github.com/apache/maven/pull/695#discussion_r841077022
##########
File path: maven-core/src/main/java/org/apache/maven/internal/aether/MavenChainedWorkspaceReader.java
##########
@@ -0,0 +1,106 @@
+package org.apache.maven.internal.aether;
+
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+import java.io.File;
+import java.util.Collection;
+import java.util.List;
+
+import org.apache.maven.model.Model;
+import org.apache.maven.repository.internal.MavenWorkspaceReader;
+import org.eclipse.aether.artifact.Artifact;
+import org.eclipse.aether.repository.WorkspaceReader;
+import org.eclipse.aether.repository.WorkspaceRepository;
+import org.eclipse.aether.util.repository.ChainedWorkspaceReader;
+
+/**
+ * A maven workspace reader that delegates to a chain of other readers, effectively aggregating their contents.
+ */
+public final class MavenChainedWorkspaceReader
+ implements MavenWorkspaceReader
+{
+
+ private ChainedWorkspaceReader delegate;
+
+ private WorkspaceReader[] readers;
+
+ /**
+ * Creates a new workspace reader by chaining the specified readers.
+ *
+ * @param readers The readers to chain must not be {@code null}.
+ */
+ private MavenChainedWorkspaceReader( WorkspaceReader... readers )
+ {
+ this.delegate = new ChainedWorkspaceReader( readers );
+ this.readers = readers;
+ }
+
+ @Override
+ public Model findModel( Artifact artifact )
+ {
+ for ( WorkspaceReader workspaceReader : readers )
+ {
+ if ( workspaceReader instanceof MavenWorkspaceReader )
+ {
+ Model model = ( (MavenWorkspaceReader) workspaceReader ).findModel( artifact );
+ if ( model != null )
+ {
+ return model;
+ }
+ }
+ }
+ return null;
+ }
+
+ @Override
+ public WorkspaceRepository getRepository()
+ {
+ return delegate.getRepository();
+ }
+
+ @Override
+ public File findArtifact( Artifact artifact )
+ {
+ return delegate.findArtifact( artifact );
+ }
+
+ @Override
+ public List<String> findVersions( Artifact artifact )
+ {
+ return delegate.findVersions( artifact );
+ }
+
+ /**
+ * chains a collection of {@link WorkspaceReader}s
+ * @param workspaceReaderCollection the collection of readers, might be empty but never <code>null</code>
+ * @return if the collection contains only one item returns the single item, otherwise creates a new
+ * {@link MavenChainedWorkspaceReader} chaining all readers in the order of the given collection.
+ */
+ public static WorkspaceReader of( Collection<WorkspaceReader> workspaceReaderCollection )
+ {
+ WorkspaceReader[] readers = workspaceReaderCollection.toArray( new WorkspaceReader[0] );
+ if ( readers.length == 1 )
Review comment:
I'd personally just remove this length check, and make it always wrapped (is simpler).
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: issues-unsubscribe@maven.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [maven] laeubi commented on pull request #695: [MNG-7432] Dependencies from profile not picked up via -P
Posted by GitBox <gi...@apache.org>.
laeubi commented on pull request #695:
URL: https://github.com/apache/maven/pull/695#issuecomment-1072344466
Not sure, at least this does restores the previous behavior.
The problem is caused by the following (we have noticed something similar in Tycho as well):
1. `MavenWorkspaceReader` has the method `findModel`
2. But the chained reader has not implemented this
3. The reactor reader implement it on the other hand
4. at two places in maven it is explicitly queried for the `MavenWorkspaceReader#findModel` what produces slightly different results:
1. Lets assume we have a dependency build by the current reactor and referenced in another project, then the model might be read again with different outcome (e.g. because of https://www.mojohaus.org/flatten-maven-plugin/plugin-info.html used)
2. When using profiles, it seems to modify the in memory model returned by `MavenWorkspaceReader#findModel`, but if that is read from disk the additions from the profile are missing
The fix do the following:
1. return the ReactorWorspaceReader if it is the only WSR (as in Maven 3.8.4)
2. implement `MavenWorkspaceReader#findModel` in a chained mode
this should fix all this issues.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: issues-unsubscribe@maven.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [maven] laeubi commented on pull request #695: [MNG-7432] Dependencies from profile not picked up via -P
Posted by GitBox <gi...@apache.org>.
laeubi commented on pull request #695:
URL: https://github.com/apache/maven/pull/695#issuecomment-1072265226
@michael-o do you like to review this?
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: issues-unsubscribe@maven.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [maven] laeubi commented on pull request #695: Quick Fix for https://github.com/quarkusio/quarkus/pull/24285
Posted by GitBox <gi...@apache.org>.
laeubi commented on pull request #695:
URL: https://github.com/apache/maven/pull/695#issuecomment-1067752175
I have copied the code from `org.eclipse.aether.util.repository.ChainedWorkspaceReader` because it is a final class.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: issues-unsubscribe@maven.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [maven] laeubi commented on a change in pull request #695: [MNG-7432] Dependencies from profile not picked up via -P
Posted by GitBox <gi...@apache.org>.
laeubi commented on a change in pull request #695:
URL: https://github.com/apache/maven/pull/695#discussion_r841079766
##########
File path: maven-core/src/main/java/org/apache/maven/internal/aether/MavenChainedWorkspaceReader.java
##########
@@ -0,0 +1,106 @@
+package org.apache.maven.internal.aether;
+
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+import java.io.File;
+import java.util.Collection;
+import java.util.List;
+
+import org.apache.maven.model.Model;
+import org.apache.maven.repository.internal.MavenWorkspaceReader;
+import org.eclipse.aether.artifact.Artifact;
+import org.eclipse.aether.repository.WorkspaceReader;
+import org.eclipse.aether.repository.WorkspaceRepository;
+import org.eclipse.aether.util.repository.ChainedWorkspaceReader;
+
+/**
+ * A maven workspace reader that delegates to a chain of other readers, effectively aggregating their contents.
+ */
+public final class MavenChainedWorkspaceReader
+ implements MavenWorkspaceReader
+{
+
+ private ChainedWorkspaceReader delegate;
+
+ private WorkspaceReader[] readers;
+
+ /**
+ * Creates a new workspace reader by chaining the specified readers.
+ *
+ * @param readers The readers to chain must not be {@code null}.
+ */
+ private MavenChainedWorkspaceReader( WorkspaceReader... readers )
+ {
+ this.delegate = new ChainedWorkspaceReader( readers );
+ this.readers = readers;
+ }
+
+ @Override
+ public Model findModel( Artifact artifact )
+ {
+ for ( WorkspaceReader workspaceReader : readers )
+ {
+ if ( workspaceReader instanceof MavenWorkspaceReader )
+ {
+ Model model = ( (MavenWorkspaceReader) workspaceReader ).findModel( artifact );
+ if ( model != null )
+ {
+ return model;
+ }
+ }
+ }
+ return null;
+ }
+
+ @Override
+ public WorkspaceRepository getRepository()
+ {
+ return delegate.getRepository();
+ }
+
+ @Override
+ public File findArtifact( Artifact artifact )
+ {
+ return delegate.findArtifact( artifact );
+ }
+
+ @Override
+ public List<String> findVersions( Artifact artifact )
+ {
+ return delegate.findVersions( artifact );
+ }
+
+ /**
+ * chains a collection of {@link WorkspaceReader}s
+ * @param workspaceReaderCollection the collection of readers, might be empty but never <code>null</code>
+ * @return if the collection contains only one item returns the single item, otherwise creates a new
+ * {@link MavenChainedWorkspaceReader} chaining all readers in the order of the given collection.
+ */
+ public static WorkspaceReader of( Collection<WorkspaceReader> workspaceReaderCollection )
+ {
+ WorkspaceReader[] readers = workspaceReaderCollection.toArray( new WorkspaceReader[0] );
+ if ( readers.length == 1 )
Review comment:
Yes, I just used the "toArray" as we accept a collection and then getting the first element from collection requires to iterate over the collection, but if size is larger requires an toArray as well... in the end it dosn't make much a difference given that this only happens once per maven invocation.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: issues-unsubscribe@maven.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [maven] laeubi commented on a change in pull request #695: [MNG-7432] Dependencies from profile not picked up via -P
Posted by GitBox <gi...@apache.org>.
laeubi commented on a change in pull request #695:
URL: https://github.com/apache/maven/pull/695#discussion_r841078921
##########
File path: maven-core/src/main/java/org/apache/maven/internal/aether/MavenChainedWorkspaceReader.java
##########
@@ -0,0 +1,106 @@
+package org.apache.maven.internal.aether;
+
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+import java.io.File;
+import java.util.Collection;
+import java.util.List;
+
+import org.apache.maven.model.Model;
+import org.apache.maven.repository.internal.MavenWorkspaceReader;
+import org.eclipse.aether.artifact.Artifact;
+import org.eclipse.aether.repository.WorkspaceReader;
+import org.eclipse.aether.repository.WorkspaceRepository;
+import org.eclipse.aether.util.repository.ChainedWorkspaceReader;
+
+/**
+ * A maven workspace reader that delegates to a chain of other readers, effectively aggregating their contents.
+ */
+public final class MavenChainedWorkspaceReader
+ implements MavenWorkspaceReader
+{
+
+ private ChainedWorkspaceReader delegate;
+
+ private WorkspaceReader[] readers;
+
+ /**
+ * Creates a new workspace reader by chaining the specified readers.
+ *
+ * @param readers The readers to chain must not be {@code null}.
+ */
+ private MavenChainedWorkspaceReader( WorkspaceReader... readers )
+ {
+ this.delegate = new ChainedWorkspaceReader( readers );
+ this.readers = readers;
+ }
+
+ @Override
+ public Model findModel( Artifact artifact )
+ {
+ for ( WorkspaceReader workspaceReader : readers )
+ {
+ if ( workspaceReader instanceof MavenWorkspaceReader )
+ {
+ Model model = ( (MavenWorkspaceReader) workspaceReader ).findModel( artifact );
+ if ( model != null )
+ {
+ return model;
+ }
+ }
+ }
+ return null;
+ }
+
+ @Override
+ public WorkspaceRepository getRepository()
+ {
+ return delegate.getRepository();
+ }
+
+ @Override
+ public File findArtifact( Artifact artifact )
+ {
+ return delegate.findArtifact( artifact );
+ }
+
+ @Override
+ public List<String> findVersions( Artifact artifact )
+ {
+ return delegate.findVersions( artifact );
+ }
+
+ /**
+ * chains a collection of {@link WorkspaceReader}s
+ * @param workspaceReaderCollection the collection of readers, might be empty but never <code>null</code>
+ * @return if the collection contains only one item returns the single item, otherwise creates a new
+ * {@link MavenChainedWorkspaceReader} chaining all readers in the order of the given collection.
+ */
+ public static WorkspaceReader of( Collection<WorkspaceReader> workspaceReaderCollection )
+ {
+ WorkspaceReader[] readers = workspaceReaderCollection.toArray( new WorkspaceReader[0] );
+ if ( readers.length == 1 )
Review comment:
I think the complexity is manageable given that in most cases there is only one WSP and we save useless loop calls in that case when it is used across the maven build.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: issues-unsubscribe@maven.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [maven] cstamas commented on a change in pull request #695: [MNG-7432] Dependencies from profile not picked up via -P
Posted by GitBox <gi...@apache.org>.
cstamas commented on a change in pull request #695:
URL: https://github.com/apache/maven/pull/695#discussion_r841079559
##########
File path: maven-core/src/main/java/org/apache/maven/internal/aether/MavenChainedWorkspaceReader.java
##########
@@ -0,0 +1,106 @@
+package org.apache.maven.internal.aether;
+
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+import java.io.File;
+import java.util.Collection;
+import java.util.List;
+
+import org.apache.maven.model.Model;
+import org.apache.maven.repository.internal.MavenWorkspaceReader;
+import org.eclipse.aether.artifact.Artifact;
+import org.eclipse.aether.repository.WorkspaceReader;
+import org.eclipse.aether.repository.WorkspaceRepository;
+import org.eclipse.aether.util.repository.ChainedWorkspaceReader;
+
+/**
+ * A maven workspace reader that delegates to a chain of other readers, effectively aggregating their contents.
+ */
+public final class MavenChainedWorkspaceReader
+ implements MavenWorkspaceReader
+{
+
+ private ChainedWorkspaceReader delegate;
+
+ private WorkspaceReader[] readers;
+
+ /**
+ * Creates a new workspace reader by chaining the specified readers.
+ *
+ * @param readers The readers to chain must not be {@code null}.
+ */
+ private MavenChainedWorkspaceReader( WorkspaceReader... readers )
+ {
+ this.delegate = new ChainedWorkspaceReader( readers );
+ this.readers = readers;
+ }
+
+ @Override
+ public Model findModel( Artifact artifact )
+ {
+ for ( WorkspaceReader workspaceReader : readers )
+ {
+ if ( workspaceReader instanceof MavenWorkspaceReader )
+ {
+ Model model = ( (MavenWorkspaceReader) workspaceReader ).findModel( artifact );
+ if ( model != null )
+ {
+ return model;
+ }
+ }
+ }
+ return null;
+ }
+
+ @Override
+ public WorkspaceRepository getRepository()
+ {
+ return delegate.getRepository();
+ }
+
+ @Override
+ public File findArtifact( Artifact artifact )
+ {
+ return delegate.findArtifact( artifact );
+ }
+
+ @Override
+ public List<String> findVersions( Artifact artifact )
+ {
+ return delegate.findVersions( artifact );
+ }
+
+ /**
+ * chains a collection of {@link WorkspaceReader}s
+ * @param workspaceReaderCollection the collection of readers, might be empty but never <code>null</code>
+ * @return if the collection contains only one item returns the single item, otherwise creates a new
+ * {@link MavenChainedWorkspaceReader} chaining all readers in the order of the given collection.
+ */
+ public static WorkspaceReader of( Collection<WorkspaceReader> workspaceReaderCollection )
+ {
+ WorkspaceReader[] readers = workspaceReaderCollection.toArray( new WorkspaceReader[0] );
+ if ( readers.length == 1 )
Review comment:
~~Still, the check could happen then on collection, not after conversion to array, no?~~ nvm, am fine with it as it is
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: issues-unsubscribe@maven.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [maven] laeubi commented on pull request #695: [MNG-7432] Dependencies from profile not picked up via -P
Posted by GitBox <gi...@apache.org>.
laeubi commented on pull request #695:
URL: https://github.com/apache/maven/pull/695#issuecomment-1073173726
> This fixes the problem for me
but will instantly fail once another workspace reader is registered again ;-)
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: issues-unsubscribe@maven.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [maven] famod commented on pull request #695: Quick Fix for https://github.com/quarkusio/quarkus/pull/24285
Posted by GitBox <gi...@apache.org>.
famod commented on pull request #695:
URL: https://github.com/apache/maven/pull/695#issuecomment-1068495323
I've just created a ticket for this: https://issues.apache.org/jira/browse/MNG-7432
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: issues-unsubscribe@maven.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [maven] laeubi commented on pull request #695: Quick Fix for https://github.com/quarkusio/quarkus/pull/24285
Posted by GitBox <gi...@apache.org>.
laeubi commented on pull request #695:
URL: https://github.com/apache/maven/pull/695#issuecomment-1067751014
FYI @famod @olamy @michael-o
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: issues-unsubscribe@maven.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [maven] laeubi commented on pull request #695: [MNG-7432] Dependencies from profile not picked up via -P
Posted by GitBox <gi...@apache.org>.
laeubi commented on pull request #695:
URL: https://github.com/apache/maven/pull/695#issuecomment-1074208880
> I suppose
>
> https://github.com/apache/maven/blob/af9c75e1ed6b1cc277823e8dcda181a86e2693db/maven-core/src/main/java/org/apache/maven/internal/aether/MavenChainedWorkspaceReader.java#L99-L102
> in this PR effectively restores previous behavior in the normal case, just like [#695 (comment)](https://github.com/apache/maven/pull/695#issuecomment-1073123778)?
No, this is just a shorthand in case there is only one WSR.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: issues-unsubscribe@maven.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [maven] cstamas commented on pull request #695: [MNG-7432] Dependencies from profile not picked up via -P
Posted by GitBox <gi...@apache.org>.
cstamas commented on pull request #695:
URL: https://github.com/apache/maven/pull/695#issuecomment-1086642516
Added some explanations here: https://issues.apache.org/jira/browse/MNG-7432?focusedCommentId=17516300&page=com.atlassian.jira.plugin.system.issuetabpanels%3Acomment-tabpanel#comment-17516300
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: issues-unsubscribe@maven.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [maven] jglick commented on pull request #695: [MNG-7432] Dependencies from profile not picked up via -P
Posted by GitBox <gi...@apache.org>.
jglick commented on pull request #695:
URL: https://github.com/apache/maven/pull/695#issuecomment-1081854700
For reference, the Jenkins build error was at https://github.com/apache/maven/blob/3599d3414f046de2324203b78ddcf9b5e4388aa0/maven-resolver-provider/src/main/java/org/apache/maven/repository/internal/DefaultArtifactDescriptorReader.java#L302
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: issues-unsubscribe@maven.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [maven] famod commented on pull request #695: [MNG-7432] Dependencies from profile not picked up via -P
Posted by GitBox <gi...@apache.org>.
famod commented on pull request #695:
URL: https://github.com/apache/maven/pull/695#issuecomment-1083641682
> > Is there an IT for this? If there would be, I'd check this and add for 3.8.6+.
>
> [The jira](https://issues.apache.org/jira/browse/MNG-7432) has a link [to a reproducer](https://github.com/aloubyansky/playground/tree/maven-3.8.5-profile-activation) maybe this could be integrated an in itest or give a hint how to create one?
ITs are here: https://github.com/apache/maven-integration-testing
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: issues-unsubscribe@maven.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [maven] laeubi commented on pull request #695: [MNG-7432] Dependencies from profile not picked up via -P
Posted by GitBox <gi...@apache.org>.
laeubi commented on pull request #695:
URL: https://github.com/apache/maven/pull/695#issuecomment-1073175696
> I do not really know or care what a workspace reader is. I just want my builds to work again.
You can use maven 3.8.4 in the meantime.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: issues-unsubscribe@maven.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [maven] jglick commented on pull request #695: [MNG-7432] Dependencies from profile not picked up via -P
Posted by GitBox <gi...@apache.org>.
jglick commented on pull request #695:
URL: https://github.com/apache/maven/pull/695#issuecomment-1074003594
I suppose https://github.com/apache/maven/blob/af9c75e1ed6b1cc277823e8dcda181a86e2693db/maven-core/src/main/java/org/apache/maven/internal/aether/MavenChainedWorkspaceReader.java#L99-L102 in this PR effectively restores previous behavior in the normal case, just like https://github.com/apache/maven/pull/695#issuecomment-1073123778?
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: issues-unsubscribe@maven.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [maven] famod edited a comment on pull request #695: [MNG-7432] Dependencies from profile not picked up via -P
Posted by GitBox <gi...@apache.org>.
famod edited a comment on pull request #695:
URL: https://github.com/apache/maven/pull/695#issuecomment-1083641682
@laeubi
> > Is there an IT for this? If there would be, I'd check this and add for 3.8.6+.
>
> [The jira](https://issues.apache.org/jira/browse/MNG-7432) has a link [to a reproducer](https://github.com/aloubyansky/playground/tree/maven-3.8.5-profile-activation) maybe this could be integrated an in itest or give a hint how to create one?
ITs are here: https://github.com/apache/maven-integration-testing
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: issues-unsubscribe@maven.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [maven] cstamas commented on pull request #695: [MNG-7432] Dependencies from profile not picked up via -P
Posted by GitBox <gi...@apache.org>.
cstamas commented on pull request #695:
URL: https://github.com/apache/maven/pull/695#issuecomment-1086661992
Created UT that IMHO should cover the issue https://github.com/apache/maven/pull/706
Please reuse it freely, no need to keep author etc (just lift it from there)
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: issues-unsubscribe@maven.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [maven] michael-o commented on pull request #695: [MNG-7432] Dependencies from profile not picked up via -P
Posted by GitBox <gi...@apache.org>.
michael-o commented on pull request #695:
URL: https://github.com/apache/maven/pull/695#issuecomment-1081813900
Is there an IT for this? If there would be, I'd check this and add for 3.8.6+.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: issues-unsubscribe@maven.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [maven] laeubi commented on pull request #695: [MNG-7432] Dependencies from profile not picked up via -P
Posted by GitBox <gi...@apache.org>.
laeubi commented on pull request #695:
URL: https://github.com/apache/maven/pull/695#issuecomment-1081805771
> Seems like a straightforward fix. If I understand correctly, one or both of
Exactly!
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: issues-unsubscribe@maven.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [maven] laeubi edited a comment on pull request #695: Quick Fix for https://github.com/quarkusio/quarkus/pull/24285
Posted by GitBox <gi...@apache.org>.
laeubi edited a comment on pull request #695:
URL: https://github.com/apache/maven/pull/695#issuecomment-1067752175
~~I have copied the code from `org.eclipse.aether.util.repository.ChainedWorkspaceReader` because it is a final class.~~
I'm using a delegation to the original `org.eclipse.aether.util.repository.ChainedWorkspaceReader`now.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: issues-unsubscribe@maven.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [maven] michael-o commented on pull request #695: [MNG-7432] Dependencies from profile not picked up via -P
Posted by GitBox <gi...@apache.org>.
michael-o commented on pull request #695:
URL: https://github.com/apache/maven/pull/695#issuecomment-1072283040
> @michael-o do you like to review this?
I need to understand the cause first because there seems to be some quirk, no?
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: issues-unsubscribe@maven.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [maven] michael-o commented on pull request #695: [MNG-7432] Dependencies from profile not picked up via -P
Posted by GitBox <gi...@apache.org>.
michael-o commented on pull request #695:
URL: https://github.com/apache/maven/pull/695#issuecomment-1072283040
> @michael-o do you like to review this?
I need to understand the cause first because there seems to be some quirk, no?
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: issues-unsubscribe@maven.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [maven] laeubi commented on pull request #695: [MNG-7432] Dependencies from profile not picked up via -P
Posted by GitBox <gi...@apache.org>.
laeubi commented on pull request #695:
URL: https://github.com/apache/maven/pull/695#issuecomment-1072265226
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: issues-unsubscribe@maven.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [maven] basil commented on pull request #695: [MNG-7432] Dependencies from profile not picked up via -P
Posted by GitBox <gi...@apache.org>.
basil commented on pull request #695:
URL: https://github.com/apache/maven/pull/695#issuecomment-1073122748
@olamy The regression introduced in Maven 3.8.5 in apache/maven@6f141968464b4ad24e5d90f1389065141cda5e3b, which is resolved in this unmerged and unreleased pull request, is causing [all Jenkins core PR builds](https://ci.jenkins.io/job/Core/job/jenkins/job/PR-6385/) to fail.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: issues-unsubscribe@maven.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org