Skip to content

Commit

Permalink
[MNG-8254] Reproducer
Browse files Browse the repository at this point in the history
  • Loading branch information
jonasrutishauser committed Sep 9, 2024
1 parent 1e803a6 commit b3d11fc
Show file tree
Hide file tree
Showing 8 changed files with 215 additions and 0 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
/*
* 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.
*/
package org.apache.maven.it;

import java.io.File;

import org.apache.maven.shared.verifier.Verifier;
import org.apache.maven.shared.verifier.util.ResourceExtractor;
import org.junit.jupiter.api.Test;

/**
* This is a test set for <a href="https://issues.apache.org/jira/browse/MNG-8220">MNG-8220</a>.
*/
public class MavenITmng8254ExtensionWithDITest extends AbstractMavenIntegrationTestCase {
public MavenITmng8254ExtensionWithDITest() {
super("[4.0.0-beta-4,)");
}

/**
* Verify that the central url can be overridden by a user property.
*
* @throws Exception in case of failure
*/
@Test
public void testitModel() throws Exception {
File testDir = ResourceExtractor.simpleExtractResources(getClass(), "/mng-8254-extension-with-di");

Verifier verifier = newVerifier(new File(testDir, "extension").getAbsolutePath());
verifier.addCliArgument("install");
verifier.execute();
verifier.verifyErrorFreeLog();

verifier = newVerifier(new File(testDir, "test").getAbsolutePath());
verifier.addCliArgument("-X");
verifier.addCliArgument("validate");
verifier.execute();
verifier.verifyTextInLog("[MNG-8254] DumbModelBuilder Called from extension");
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -120,6 +120,7 @@ public TestSuiteOrdering() {
* the tests are to finishing. Newer tests are also more likely to fail, so this is
* a fail fast technique as well.
*/
suite.addTestSuite(MavenITmng8254ExtensionWithDITest.class);
suite.addTestSuite(MavenITmng8220ExtensionWithDITest.class);
suite.addTestSuite(MavenITmng8181CentralRepoTest.class);
suite.addTestSuite(MavenITmng8123BuildCacheTest.class);
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
<?xml version="1.0" encoding="UTF-8"?>
<!--
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.
-->
<project xmlns="http://maven.apache.org/POM/4.1.0">
<groupId>org.apache.maven.its.mng8254</groupId>
<artifactId>extension</artifactId>
<version>1.0-SNAPSHOT</version>
<packaging>jar</packaging>

<dependencies>
<dependency>
<groupId>org.apache.maven</groupId>
<artifactId>maven-api-di</artifactId>
<version>4.0.0-beta-4</version>
</dependency>
<dependency>
<groupId>org.apache.maven</groupId>
<artifactId>maven-api-impl</artifactId>
<version>4.0.0-beta-4</version>
</dependency>
</dependencies>
</project>
Original file line number Diff line number Diff line change
@@ -0,0 +1,67 @@
/*
* 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.
*/
package org.apache.maven.its.mng8254.extension;

import java.util.List;

import org.apache.maven.api.di.Inject;
import org.apache.maven.api.di.Named;
import org.apache.maven.api.di.Priority;
import org.apache.maven.api.di.Singleton;
import org.apache.maven.api.model.Model;
import org.apache.maven.api.services.ModelBuilder;
import org.apache.maven.api.services.ModelBuilderException;
import org.apache.maven.api.services.ModelBuilderRequest;
import org.apache.maven.api.services.ModelBuilderResult;
import org.apache.maven.api.services.ModelTransformerContextBuilder;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

@Singleton
@Named
@Priority(42)
final class DumbModelBuilder implements ModelBuilder {

private final Logger logger = LoggerFactory.getLogger(getClass());
private final ModelBuilder delegate;

@Inject
public DumbModelBuilder(List<ModelBuilder> delegate) {
this.delegate = delegate.stream()
.filter(modelBuilder -> !(modelBuilder instanceof DumbModelBuilder))
.findFirst()
.get();
}

@Override
public ModelBuilderResult build(ModelBuilderRequest request) throws ModelBuilderException {
logger.warn("[MNG-8254] DumbModelBuilder Called from extension");
return delegate.build(request);
}

@Override
public ModelTransformerContextBuilder newTransformerContextBuilder() {
return delegate.newTransformerContextBuilder();
}

@Override
public Model buildRawModel(ModelBuilderRequest request) {
return delegate.buildRawModel(request);
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
org.apache.maven.its.mng8254.extension.DumbModelBuilder
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
<extensions>
<extension>
<groupId>org.apache.maven.its.mng8254</groupId>
<artifactId>extension</artifactId>
<version>1.0-SNAPSHOT</version>
</extension>
</extensions>
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
<?xml version="1.0" encoding="UTF-8"?>
<!--
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.
-->
<project xmlns="http://maven.apache.org/POM/4.1.0">
<groupId>org.apache.maven.its.mng8254</groupId>
<artifactId>test</artifactId>
<version>1.0-SNAPSHOT</version>
<packaging>jar</packaging>
</project>
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
/*
* 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.
*/
package org.apache.maven.its.mng8220.test;

public class Dumb {}

0 comments on commit b3d11fc

Please sign in to comment.