Skip to content

Commit

Permalink
[MENFORCER-497] Require Maven 3.6.3+
Browse files Browse the repository at this point in the history
  • Loading branch information
slachiewicz authored and slawekjaranowski committed May 26, 2024
1 parent 5c7d0bc commit 81dcc28
Show file tree
Hide file tree
Showing 14 changed files with 30 additions and 146 deletions.
8 changes: 4 additions & 4 deletions enforcer-rules/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -71,12 +71,12 @@
<scope>provided</scope>
</dependency>
<dependency>
<groupId>org.eclipse.aether</groupId>
<artifactId>aether-api</artifactId>
<groupId>org.apache.maven.resolver</groupId>
<artifactId>maven-resolver-api</artifactId>
</dependency>
<dependency>
<groupId>org.eclipse.aether</groupId>
<artifactId>aether-util</artifactId>
<groupId>org.apache.maven.resolver</groupId>
<artifactId>maven-resolver-util</artifactId>
</dependency>
<dependency>
<groupId>org.eclipse.sisu</groupId>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@
# KIND, either express or implied. See the License for the
# specific language governing permissions and limitations
# under the License.
invoker.maven.version = 3.3.1+
invoker.goals.1 = validate
invoker.goals.2 = verify
invoker.buildResult.2 = failure

This file was deleted.

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -15,5 +15,4 @@
# specific language governing permissions and limitations
# under the License.

invoker.maven.version = 3.5.0+
invoker.buildResult=failure
invoker.buildResult=failure

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -14,5 +14,4 @@
# KIND, either express or implied. See the License for the
# specific language governing permissions and limitations
# under the License.
invoker.maven.version = 3.5.0+
invoker.goals = install -Drevision=0.10.0-SNAPSHOT
invoker.goals = install -Drevision=0.10.0-SNAPSHOT

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -15,5 +15,4 @@
# specific language governing permissions and limitations
# under the License.

invoker.maven.version = 3.5.0+
invoker.buildResult = failure

This file was deleted.

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
import java.util.Arrays;
import java.util.Collections;
import java.util.List;
import java.util.Properties;

import org.apache.maven.enforcer.rule.api.EnforcerLevel;
import org.apache.maven.enforcer.rule.api.EnforcerRule;
Expand All @@ -33,21 +34,21 @@
import org.apache.maven.plugins.enforcer.internal.EnforcerRuleDesc;
import org.apache.maven.plugins.enforcer.internal.EnforcerRuleManager;
import org.assertj.core.api.Assertions;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test;
import org.junit.jupiter.api.extension.ExtendWith;
import org.mockito.InjectMocks;
import org.mockito.Mock;
import org.mockito.Mockito;
import org.mockito.junit.jupiter.MockitoExtension;
import org.mockito.junit.jupiter.MockitoSettings;
import org.mockito.quality.Strictness;

import static org.assertj.core.api.Assertions.assertThatCode;
import static org.assertj.core.api.Assertions.assertThatThrownBy;
import static org.junit.jupiter.api.Assertions.assertFalse;
import static org.junit.jupiter.api.Assertions.assertTrue;
import static org.junit.jupiter.api.Assertions.fail;
import static org.mockito.ArgumentMatchers.any;
import static org.mockito.Mockito.lenient;
import static org.mockito.Mockito.verify;
import static org.mockito.Mockito.when;

Expand All @@ -57,7 +58,6 @@
* @author <a href="mailto:brianf@apache.org">Brian Fox</a>
*/
@ExtendWith(MockitoExtension.class)
@MockitoSettings(strictness = Strictness.LENIENT)
class TestEnforceMojo {

@Mock
Expand All @@ -69,6 +69,12 @@ class TestEnforceMojo {
@InjectMocks
private EnforceMojo mojo;

@BeforeEach
void setup() {
lenient().when(session.getSystemProperties()).thenReturn(new Properties());
lenient().when(session.getUserProperties()).thenReturn(new Properties());
}

@Test
void emptyRuleListShouldThrowException() {
mojo.setFail(false);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
import javax.inject.Provider;

import java.util.List;
import java.util.Properties;

import org.apache.maven.enforcer.rule.api.EnforcerLevel;
import org.apache.maven.enforcer.rule.api.EnforcerRuleBase;
Expand Down Expand Up @@ -94,7 +95,10 @@ void setupMocks(Boolean hasComponent) {

when(mojoDescriptor.getPluginDescriptor()).thenReturn(mock(PluginDescriptor.class));

when(sessionProvider.get()).thenReturn(mock(MavenSession.class));
MavenSession mavenSession = mock(MavenSession.class);
when(mavenSession.getSystemProperties()).thenReturn(new Properties());
when(mavenSession.getUserProperties()).thenReturn(new Properties());
when(sessionProvider.get()).thenReturn(mavenSession);

when(plexusContainer.hasComponent(any(Class.class), anyString())).thenReturn(hasComponent);
}
Expand Down
27 changes: 10 additions & 17 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -77,13 +77,13 @@
</distributionManagement>

<properties>
<mavenVersion>3.2.5</mavenVersion>
<mavenVersion>3.6.3</mavenVersion>
<maven.site.path>enforcer-archives/enforcer-LATEST</maven.site.path>
<javaVersion>8</javaVersion>
<mockito.version>4.11.0</mockito.version>
<project.build.outputTimestamp>2024-05-26T08:52:43Z</project.build.outputTimestamp>
<!-- the same as Maven 3.2.5 -->
<aether.version>1.0.0.v20140518</aether.version>
<project.build.outputTimestamp>2023-09-07T17:27:52Z</project.build.outputTimestamp>
<!-- the same as Maven 3.6.3 -->
<resolver.version>1.4.1</resolver.version>

<!-- plugins used in IT, not defined in parent -->
<version.maven-pmd-plugin>3.21.0</version.maven-pmd-plugin>
Expand Down Expand Up @@ -149,15 +149,15 @@
<scope>provided</scope>
</dependency>
<dependency>
<groupId>org.eclipse.aether</groupId>
<artifactId>aether-api</artifactId>
<version>${aether.version}</version>
<groupId>org.apache.maven.resolver</groupId>
<artifactId>maven-resolver-api</artifactId>
<version>${resolver.version}</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>org.eclipse.aether</groupId>
<artifactId>aether-util</artifactId>
<version>${aether.version}</version>
<groupId>org.apache.maven.resolver</groupId>
<artifactId>maven-resolver-util</artifactId>
<version>${resolver.version}</version>
</dependency>
<dependency>
<groupId>org.eclipse.sisu</groupId>
Expand Down Expand Up @@ -202,13 +202,6 @@
</dependency>

<!-- test dependencies -->
<dependency>
<groupId>org.junit</groupId>
<artifactId>junit-bom</artifactId>
<version>5.10.2</version>
<type>pom</type>
<scope>import</scope>
</dependency>
<dependency>
<groupId>org.mockito</groupId>
<artifactId>mockito-core</artifactId>
Expand Down

0 comments on commit 81dcc28

Please sign in to comment.