Skip to content

Commit

Permalink
[MNG-8259] Improve Sisu / DI bridge (#363)
Browse files Browse the repository at this point in the history
  • Loading branch information
gnodet authored Sep 18, 2024
1 parent 10e5a98 commit 4d1ee34
Show file tree
Hide file tree
Showing 16 changed files with 347 additions and 9 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ public MavenITmng8220ExtensionWithDITest() {
public void testitModel() throws Exception {
File testDir = ResourceExtractor.simpleExtractResources(getClass(), "/mng-8220-extension-with-di");

Verifier verifier = newVerifier(new File(testDir, "extension").getAbsolutePath());
Verifier verifier = newVerifier(new File(testDir, "extensions").getAbsolutePath());
verifier.addCliArgument("install");
verifier.execute();
verifier.verifyErrorFreeLog();
Expand All @@ -50,6 +50,9 @@ public void testitModel() throws Exception {
verifier.addCliArgument("validate");
verifier.execute();
verifier.verifyErrorFreeLog();
verifier.verifyTextInLog("[MNG-8220] DumbModelParser Called from extension");
verifier.verifyTextInLog("[MNG-8220] DumbModelParser1 Called from extension");
verifier.verifyTextInLog("[MNG-8220] DumbModelParser2 Called from extension");
verifier.verifyTextInLog("[MNG-8220] DumbModelParser3 Called from extension");
verifier.verifyTextInLog("[MNG-8220] DumbModelParser4 Called from extension");
}
}

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ under the License.
-->
<project xmlns="http://maven.apache.org/POM/4.1.0">
<groupId>org.apache.maven.its.mng8220</groupId>
<artifactId>extension</artifactId>
<artifactId>extension1</artifactId>
<version>1.0-SNAPSHOT</version>
<packaging>jar</packaging>

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
* specific language governing permissions and limitations
* under the License.
*/
package org.apache.maven.its.mng8220.extension;
package org.apache.maven.its.mng8220.extension1;

import java.nio.file.Path;
import java.util.Map;
Expand All @@ -34,16 +34,16 @@

@Singleton
@Named
final class DumbModelParser implements ModelParser {
final class DumbModelParser1 implements ModelParser {

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

@Inject
public DumbModelParser() {}
public DumbModelParser1() {}

@Override
public Optional<Source> locate(Path dir) {
logger.warn("[MNG-8220] DumbModelParser Called from extension");
logger.warn("[MNG-8220] DumbModelParser1 Called from extension");
return Optional.empty();
}

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
org.apache.maven.its.mng8220.extension1.DumbModelParser1
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.mng8220</groupId>
<artifactId>extension2</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-3</version>
</dependency>
<dependency>
<groupId>org.apache.maven</groupId>
<artifactId>maven-api-impl</artifactId>
<version>4.0.0-beta-3</version>
</dependency>
</dependencies>
</project>
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
/*
* 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.extension2;

import java.nio.file.Path;
import java.util.Map;
import java.util.Optional;

import org.apache.maven.api.di.Inject;
import org.apache.maven.api.di.Named;
import org.apache.maven.api.model.Model;
import org.apache.maven.api.services.Source;
import org.apache.maven.api.spi.ModelParser;
import org.apache.maven.api.spi.ModelParserException;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

@Named("dumb")
final class DumbModelParser2 implements ModelParser {

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

@Inject
public DumbModelParser2() {}

@Override
public Optional<Source> locate(Path dir) {
logger.warn("[MNG-8220] DumbModelParser2 Called from extension");
return Optional.empty();
}

@Override
public Model parse(Source source, Map<String, ?> options) throws ModelParserException {
return null;
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
org.apache.maven.its.mng8220.extension2.DumbModelParser2
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
<?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.mng8220</groupId>
<artifactId>extension3</artifactId>
<version>1.0-SNAPSHOT</version>
<packaging>jar</packaging>

<dependencies>
<dependency>
<groupId>org.apache.maven</groupId>
<artifactId>maven-api-spi</artifactId>
<version>4.0.0-beta-3</version>
</dependency>
<dependency>
<groupId>org.slf4j</groupId>
<artifactId>slf4j-api</artifactId>
<version>2.0.16</version>
</dependency>
<dependency>
<groupId>javax.inject</groupId>
<artifactId>javax.inject</artifactId>
<version>1</version>
</dependency>
</dependencies>
</project>
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
/*
* 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.extension3;

import javax.inject.Inject;
import javax.inject.Named;

import java.nio.file.Path;
import java.util.Map;
import java.util.Optional;

import org.apache.maven.api.model.Model;
import org.apache.maven.api.services.Source;
import org.apache.maven.api.spi.ModelParser;
import org.apache.maven.api.spi.ModelParserException;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

@Named("dumb")
final class DumbModelParser3 implements ModelParser {

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

@Inject
public DumbModelParser3() {}

@Override
public Optional<Source> locate(Path dir) {
logger.warn("[MNG-8220] DumbModelParser3 Called from extension");
return Optional.empty();
}

@Override
public Model parse(Source source, Map<String, ?> options) throws ModelParserException {
return null;
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
org.apache.maven.its.mng8220.extension3.DumbModelParser3
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
<?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.mng8220</groupId>
<artifactId>extension4</artifactId>
<version>1.0-SNAPSHOT</version>
<packaging>jar</packaging>

<dependencies>
<dependency>
<groupId>org.apache.maven</groupId>
<artifactId>maven-api-spi</artifactId>
<version>4.0.0-beta-3</version>
</dependency>
<dependency>
<groupId>org.slf4j</groupId>
<artifactId>slf4j-api</artifactId>
<version>2.0.16</version>
</dependency>
<dependency>
<groupId>javax.inject</groupId>
<artifactId>javax.inject</artifactId>
<version>1</version>
</dependency>
</dependencies>
</project>
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.its.mng8220.extension4;

import javax.inject.Inject;
import javax.inject.Named;
import javax.inject.Singleton;

import java.nio.file.Path;
import java.util.Map;
import java.util.Optional;

import org.apache.maven.api.model.Model;
import org.apache.maven.api.services.Source;
import org.apache.maven.api.spi.ModelParser;
import org.apache.maven.api.spi.ModelParserException;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

@Named
@Singleton
final class DumbModelParser4 implements ModelParser {

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

@Inject
public DumbModelParser4() {}

@Override
public Optional<Source> locate(Path dir) {
logger.warn("[MNG-8220] DumbModelParser4 Called from extension");
return Optional.empty();
}

@Override
public Model parse(Source source, Map<String, ?> options) throws ModelParserException {
return null;
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
org.apache.maven.its.mng8220.extension4.DumbModelParser4
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
<?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.mng8220</groupId>
<artifactId>parent</artifactId>
<version>1.0-SNAPSHOT</version>
<packaging>pom</packaging>

<modules>
<module>extension1</module>
<module>extension2</module>
<module>extension3</module>
<module>extension4</module>
</modules>

</project>
Loading

0 comments on commit 4d1ee34

Please sign in to comment.