Skip to content
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

[MDEP-922] dependency:analyze-exclusions - should report issue only in current project #378

Merged
merged 1 commit into from
Apr 21, 2024
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
37 changes: 37 additions & 0 deletions src/it/mrm/repository/a-with-dep.pom
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
<?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.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 https://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>

<groupId>org.apache.maven.its.dependency</groupId>
<artifactId>a-with-dep</artifactId>
<version>1.0.0</version>

<dependencies>
<dependency>
<groupId>org.apache.maven.its.dependency</groupId>
<artifactId>b-with-dep</artifactId>
<version>1.0.0</version>
</dependency>
</dependencies>
</project>
38 changes: 38 additions & 0 deletions src/it/mrm/repository/b-with-dep.pom
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.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 https://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>

<groupId>org.apache.maven.its.dependency</groupId>
<artifactId>b-with-dep</artifactId>
<version>1.0.0</version>

<dependencies>
<dependency>
<groupId>org.apache.maven.its.dependency</groupId>
<artifactId>c-without-dep</artifactId>
<version>1.0.0</version>
</dependency>
</dependencies>

</project>
30 changes: 30 additions & 0 deletions src/it/mrm/repository/c-without-dep.pom
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
<?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.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 https://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>

<groupId>org.apache.maven.its.dependency</groupId>
<artifactId>c-without-dep</artifactId>
<version>1.0.0</version>

</project>
Original file line number Diff line number Diff line change
Expand Up @@ -33,8 +33,23 @@

<dependencies>
<dependency>
<groupId>org.apache.maven</groupId>
<artifactId>maven-core</artifactId>
<groupId>org.apache.maven.its.dependency</groupId>
<artifactId>a-with-dep</artifactId>
<version>1.0.0</version>
<exclusions>
<exclusion>
<groupId>org.apache.maven.its.dependency</groupId>
<artifactId>invalid-exclusion2</artifactId>
</exclusion>
<exclusion>
<groupId>org.apache.maven.its.dependency</groupId>
<artifactId>c-without-dep</artifactId>
</exclusion>
<exclusion>
<groupId>org.apache.maven.its.dependency</groupId>
<artifactId>invalid-exclusion3</artifactId>
</exclusion>
</exclusions>
</dependency>
</dependencies>
</project>
Original file line number Diff line number Diff line change
Expand Up @@ -38,8 +38,8 @@
<version>${project.version}</version>
<exclusions>
<exclusion>
<groupId>org.apache.maven</groupId>
<artifactId>maven-core</artifactId>
<groupId>org.apache.maven.its.dependency</groupId>
<artifactId>a-with-dep</artifactId>
</exclusion>
</exclusions>
</dependency>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -45,13 +45,13 @@
<dependencyManagement>
<dependencies>
<dependency>
<groupId>org.apache.maven</groupId>
<artifactId>maven-core</artifactId>
<version>3.9.6</version>
<groupId>org.apache.maven.its.dependency</groupId>
<artifactId>a-with-dep</artifactId>
<version>1.0.0</version>
<exclusions>
<exclusion>
<groupId>javax.servlet</groupId>
<artifactId>javax.servlet-api</artifactId>
<groupId>org.apache.maven.its.dependency</groupId>
<artifactId>invalid-exclusion1</artifactId>
</exclusion>
</exclusions>
</dependency>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
import java.lang.reflect.Array

/*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
Expand All @@ -17,14 +19,34 @@
* under the License.
*/

File file = new File( basedir, "build.log" );

static void checkMessagedInLogs(logLines, messages) {
def index = logLines.indexOf(messages[0])
assert index > 0: "no messages: '" + messages[0] + "' in log"

def logMessages = logLines[index..index + messages.size() - 1]

assert logMessages == messages

}

def file = new File(basedir, "build.log");
assert file.exists();

String buildLog = file.getText( "UTF-8" );
assert buildLog.contains( '[WARNING] test-module1 defines following unnecessary excludes');
assert buildLog.contains( '[WARNING] org.apache.maven:maven-core:');
assert buildLog.contains( '[WARNING] - javax.servlet:javax.servlet-api');
def logLines = buildLog = file.readLines()

checkMessagedInLogs(logLines, [
'[WARNING] Test defines following unnecessary excludes',
'[WARNING] org.apache.maven.its.dependency:a-with-dep:1.0.0',
'[WARNING] - org.apache.maven.its.dependency:invalid-exclusion1 @ line: 52'
])

checkMessagedInLogs(logLines, [
'[WARNING] test-module1 defines following unnecessary excludes',
'[WARNING] org.apache.maven.its.dependency:a-with-dep:1.0.0',
'[WARNING] - org.apache.maven.its.dependency:invalid-exclusion2 @ line: 40',
'[WARNING] - org.apache.maven.its.dependency:invalid-exclusion3 @ line: 48'

assert !buildLog.contains( '[WARNING] test-module2 defines following unnecessary excludes');
])

return true;
assert logLines.count('[INFO] No problems with dependencies exclusions') == 1
70 changes: 38 additions & 32 deletions src/it/projects/analyze-invalid-exclude/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -36,53 +36,59 @@
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
</properties>

<dependencyManagement>
<dependencies>
<dependency>
<groupId>org.apache.maven.its.dependency</groupId>
<artifactId>a-with-dep</artifactId>
<version>1.0.0</version>
<exclusions>
<exclusion>
<groupId>org.apache.maven.its.dependency</groupId>
<artifactId>invalid-exclusion1</artifactId>
</exclusion>
</exclusions>
</dependency>
</dependencies>
</dependencyManagement>

<dependencies>
<dependency>
<groupId>org.apache.maven</groupId>
<artifactId>maven-core</artifactId>
<groupId>org.apache.maven.its.dependency</groupId>
<artifactId>b-with-dep</artifactId>
<version>1.0.0</version>
<exclusions>
<exclusion>
<groupId>org.apache.maven.its.dependency</groupId>
<artifactId>c-without-dep</artifactId>
</exclusion>
<exclusion>
<groupId>org.apache.maven.its.dependency</groupId>
<artifactId>invalid-exclusion3</artifactId>
</exclusion>
</exclusions>
</dependency>
<dependency>
<groupId>org.apache.maven</groupId>
<artifactId>maven-artifact</artifactId>
<version>3.9.6</version>
<groupId>org.apache.maven.its.dependency</groupId>
<artifactId>a-with-dep</artifactId>
<exclusions>
<exclusion>
<groupId>javax.annotation</groupId>
<artifactId>javax.annotation-api</artifactId>
<groupId>org.apache.maven.its.dependency</groupId>
<artifactId>invalid-exclusion2</artifactId>
</exclusion>
<exclusion>
<groupId>javax.activation</groupId>
<artifactId>javax.activation-api</artifactId>
<groupId>org.apache.maven.its.dependency</groupId>
<artifactId>c-without-dep</artifactId>
</exclusion>
</exclusions>
</dependency>
<dependency>
<groupId>org.apache.maven</groupId>
<artifactId>maven-model</artifactId>
<version>3.9.6</version>
<groupId>org.apache.maven.its.dependency</groupId>
<artifactId>c-without-dep</artifactId>
<version>1.0.0</version>
</dependency>
</dependencies>

<dependencyManagement>
<dependencies>
<dependency>
<groupId>org.apache.maven</groupId>
<artifactId>maven-core</artifactId>
<version>3.9.6</version>
<exclusions>
<exclusion>
<groupId>javax.servlet</groupId>
<artifactId>javax.servlet-api</artifactId>
</exclusion>
<exclusion>
<groupId>org.codehaus.plexus</groupId>
<artifactId>*</artifactId>
</exclusion>
</exclusions>
</dependency>
</dependencies>
</dependencyManagement>

<build>
<pluginManagement>
<plugins>
Expand Down
26 changes: 17 additions & 9 deletions src/it/projects/analyze-invalid-exclude/verify.groovy
Original file line number Diff line number Diff line change
Expand Up @@ -17,15 +17,23 @@
* under the License.
*/

File file = new File( basedir, "build.log" );
def file = new File(basedir, "build.log");
assert file.exists();

String buildLog = file.getText( "UTF-8" );
assert buildLog.contains( '[WARNING] test-module defines following unnecessary excludes');
assert buildLog.contains( '[WARNING] org.apache.maven:maven-artifact:');
assert buildLog.contains( '[WARNING] - javax.annotation:javax.annotation-api');
assert buildLog.contains( '[WARNING] - javax.activation:javax.activation-api');
assert buildLog.contains( '[WARNING] org.apache.maven:maven-core:');
assert buildLog.contains( '[WARNING] - javax.servlet:javax.servlet-api');
def logLines = buildLog = file.readLines()

def index = logLines.indexOf('[WARNING] test-module defines following unnecessary excludes')
assert index > 0: "no messages in log"

def messages = logLines[index..index + 5];

assert messages == [
'[WARNING] test-module defines following unnecessary excludes',
'[WARNING] org.apache.maven.its.dependency:a-with-dep:1.0.0',
'[WARNING] - org.apache.maven.its.dependency:invalid-exclusion1 @ line: 46',
'[WARNING] - org.apache.maven.its.dependency:invalid-exclusion2 @ line: 75',
'[WARNING] org.apache.maven.its.dependency:b-with-dep:1.0.0',
'[WARNING] - org.apache.maven.its.dependency:invalid-exclusion3 @ line: 65'
]


return true;
Loading