Skip to content

Upgrade Guice to 6 - Add support to run test with jakarta @Inject annotations #51

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

Merged
merged 2 commits into from
May 27, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 5 additions & 2 deletions .github/workflows/maven.yml
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ jobs:
strategy:
matrix:
os: [ubuntu-latest,windows-latest, macOS-latest]
java: [8, 11, 17]
java: [8, 11, 17, 20]
jdk: [temurin]
fail-fast: false

Expand All @@ -43,4 +43,7 @@ jobs:
cache: 'maven'

- name: Build with Maven
run: mvn install javadoc:javadoc -e -B -V -Pno-tests-if-not-on-osx
run: mvn install javadoc:javadoc -e -B -V

- name: Build with Maven and target Java level - ${{ matrix.java }}
run: mvn clean install javadoc:javadoc -e -DjavaVersion=${{ matrix.java }}
5 changes: 4 additions & 1 deletion pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,9 @@
</distributionManagement>

<properties>
<!-- remove with parent upgrade -->
<maven.compiler.source>${javaVersion}</maven.compiler.source>
<maven.compiler.target>${javaVersion}</maven.compiler.target>
<project.build.outputTimestamp>2021-09-21T23:45:11Z</project.build.outputTimestamp>
</properties>

Expand All @@ -43,7 +46,7 @@
<dependency>
<groupId>com.google.inject</groupId>
<artifactId>guice</artifactId>
<version>5.1.0</version>
<version>6.0.0</version>
</dependency>
<dependency>
<groupId>org.junit.jupiter</groupId>
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
package org.codehaus.plexus.testing;

/*
* 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 jakarta.inject.Inject;
import org.junit.jupiter.api.Test;

import static org.junit.jupiter.api.Assertions.assertNotNull;

@PlexusTest
class PlexusTestJakartaTest {

@Inject
private TestJakartaComponent testJakartaComponent;

@Test
void dependencyShouldBeInjected() {
assertNotNull(testJakartaComponent);
assertNotNull(testJakartaComponent.getTestJakartaComponent2());
assertNotNull(testJakartaComponent.getTestJavaxComponent2());
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -26,14 +26,14 @@
import static org.junit.jupiter.api.Assertions.assertNotNull;

@PlexusTest
class PlexusTestTest {
class PlexusTestJavaxTest {

@Inject
private TestComponent testComponent;
private TestJavaxComponent testJavaxComponent;

@Test
void dependencyShouldBeInjected() {
assertNotNull(testComponent);
assertNotNull(testComponent.getTestComponent2());
assertNotNull(testJavaxComponent);
assertNotNull(testJavaxComponent.getTestComponent2());
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
package org.codehaus.plexus.testing;

/*
* 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 jakarta.inject.Inject;
import jakarta.inject.Named;

@Named
public class TestJakartaComponent {
@Inject
private TestJavaxComponent2 testJavaxComponent2;

@Inject
private TestJakartaComponent2 testJakartaComponent2;

public TestJavaxComponent2 getTestJavaxComponent2() {
return testJavaxComponent2;
}

public TestJakartaComponent2 getTestJakartaComponent2() {
return testJakartaComponent2;
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
package org.codehaus.plexus.testing;

/*
* 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 javax.inject.Named;

@Named
public class TestJakartaComponent2 {}
Original file line number Diff line number Diff line change
Expand Up @@ -23,11 +23,11 @@
import javax.inject.Named;

@Named
public class TestComponent {
public class TestJavaxComponent {
@Inject
private TestComponent2 testComponent2;
private TestJavaxComponent2 testJavaxComponent2;

public TestComponent2 getTestComponent2() {
return testComponent2;
public TestJavaxComponent2 getTestComponent2() {
return testJavaxComponent2;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -22,4 +22,4 @@
import javax.inject.Named;

@Named
public class TestComponent2 {}
public class TestJavaxComponent2 {}