Skip to content

Commit

Permalink
Get rid of maven-dependency-tree use Resolver - fix #257
Browse files Browse the repository at this point in the history
  • Loading branch information
slawekjaranowski committed Mar 10, 2024
1 parent ddfdae9 commit 61d2173
Show file tree
Hide file tree
Showing 20 changed files with 308 additions and 225 deletions.
7 changes: 1 addition & 6 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@
<scm>
<connection>scm:git:https://github.com/mojohaus/extra-enforcer-rules.git</connection>
<developerConnection>scm:git:ssh://git@github.com/mojohaus/extra-enforcer-rules.git</developerConnection>
<tag>1.7.0</tag>
<tag>HEAD</tag>
<url>https://github.com/mojohaus/extra-enforcer-rules/tree/master</url>
</scm>

Expand Down Expand Up @@ -84,11 +84,6 @@
</dependency>

<!-- Maven shared -->
<dependency>
<groupId>org.apache.maven.shared</groupId>
<artifactId>maven-dependency-tree</artifactId>
<version>3.2.1</version>
</dependency>
<dependency>
<groupId>org.apache.maven.shared</groupId>
<artifactId>maven-common-artifact-filters</artifactId>
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
invoker.goals = enforcer:enforce
47 changes: 47 additions & 0 deletions src/it/enforce-bytecode-version-direct-deps/pom.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>test</groupId>
<artifactId>enforce-bytecode-version-direct-deps</artifactId>
<version>1.0-SNAPSHOT</version>
<description>Check only direct dependencies</description>

<build>
<plugins>
<plugin>
<artifactId>maven-enforcer-plugin</artifactId>
<version>@enforcerPluginVersion@</version>
<dependencies>
<dependency>
<groupId>@project.groupId@</groupId>
<artifactId>@project.artifactId@</artifactId>
<version>@project.version@</version>
</dependency>
</dependencies>
<configuration>
<rules>
<enforceBytecodeVersion>
<maxJdkVersion>1.5</maxJdkVersion>
<searchTransitive>false</searchTransitive>
</enforceBytecodeVersion>
</rules>
</configuration>
</plugin>
</plugins>
</build>

<dependencies>
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>4.13.2</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.slf4j</groupId>
<artifactId>slf4j-simple</artifactId>
<version>1.7.2</version>
</dependency>
</dependencies>
</project>
12 changes: 12 additions & 0 deletions src/it/enforce-bytecode-version-direct-deps/verify.groovy
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
File file = new File(basedir, "build.log");
assert file.exists();

String text = file.getText("utf-8");

// only direct dependency
assert text.contains('[DEBUG] Analyzing artifact junit:junit:jar')
assert text.contains('[DEBUG] Analyzing artifact org.slf4j:slf4j-simple:jar')

// no transitive dependencies
assert !text.contains('[DEBUG] Analyzing artifact org.hamcrest:hamcrest-core:jar')
assert !text.contains('[DEBUG] Analyzing artifact org.slf4j:slf4j-api:jar')
Original file line number Diff line number Diff line change
@@ -1,2 +1 @@
invoker.goals = enforcer:enforce install
invoker.buildResult = success
invoker.goals = enforcer:enforce
Original file line number Diff line number Diff line change
Expand Up @@ -30,11 +30,6 @@
</enforceBytecodeVersion>
</rules>
</configuration>
<executions>
<execution>
<phase>compile</phase>
</execution>
</executions>
</plugin>
</plugins>
</build>
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
/*
* 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.
*/
File log = new File(basedir, 'build.log')
assert log.exists()

assert log.getText().contains('[DEBUG] Skipping junit:junit:jar:4.13.2 (test) due to scope')
assert log.getText().contains('[DEBUG] Skipping javax.transaction:jta:jar:1.1 (compile?) due to skip optional')
4 changes: 2 additions & 2 deletions src/it/mojo-1799/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -10,12 +10,12 @@
<dependency>
<groupId>commons-logging</groupId>
<artifactId>commons-logging</artifactId>
<version>1.1.1</version>
<version>1.3.0</version>
</dependency>
<dependency>
<groupId>org.slf4j</groupId>
<artifactId>jcl-over-slf4j</artifactId>
<version>1.6.1</version>
<version>1.7.2</version>
<scope>test</scope>
</dependency>
</dependencies>
Expand Down
2 changes: 1 addition & 1 deletion src/it/mojo-1799/verify.groovy
Original file line number Diff line number Diff line change
Expand Up @@ -18,4 +18,4 @@
*/
File log = new File(basedir, 'build.log')
assert log.exists()
assert log.getText().contains('[DEBUG] Skipping org.slf4j:jcl-over-slf4j:jar:1.6.1:test due to scope')
assert log.getText().contains('DEBUG] Skipping org.slf4j:jcl-over-slf4j:jar:1.7.2 (test) due to scope')
Loading

0 comments on commit 61d2173

Please sign in to comment.