davsclaus commented on code in PR #26330: URL: https://github.com/apache/camel/pull/26330#discussion_r4002318829
########## .github/workflows/dep-check.yml: ########## @@ -0,0 +1,75 @@ +# +# 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. +# + +name: 'Dependency Analysis' + +on: + pull_request: + branches: + - main + paths-ignore: + - .claude-plugin/** + - .idea/** + - .github/** + - .oss-ai-helper-rules/** + - AGENTS.md + - README.md + - SECURITY.md + - Jenkinsfile + - Jenkinsfile.* + - NOTICE.txt + +concurrency: + group: ${{ github.workflow }}-${{ github.event.pull_request.number || github.ref }} + cancel-in-progress: true + +permissions: + contents: read + +jobs: + dep-check: + if: github.repository == 'apache/camel' + name: Dependency Analysis (non-blocking) + runs-on: ubuntu-latest + continue-on-error: true + steps: + - name: Checkout + uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1 + with: + ref: ${{ github.event.pull_request.head.sha }} + fetch-depth: 0 + + - name: Set up JDK 21 + uses: actions/setup-java@c5195efecf7bdfc987ee8bae7a71cb8b11521c00 # v4.7.1 + with: + distribution: 'temurin' Review Comment: All 12 other `setup-java` usages in `.github/workflows` pin v6.0.0; Dependabot will otherwise open a bump PR right away. ```suggestion uses: actions/setup-java@dd06d9cba3e5552c54d9f8ea23572deb30010f7c # v6.0.0 ``` ########## .github/workflows/dep-check.yml: ########## @@ -0,0 +1,75 @@ +# +# 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. +# + +name: 'Dependency Analysis' + +on: + pull_request: + branches: + - main + paths-ignore: + - .claude-plugin/** + - .idea/** + - .github/** + - .oss-ai-helper-rules/** + - AGENTS.md + - README.md + - SECURITY.md + - Jenkinsfile + - Jenkinsfile.* + - NOTICE.txt + +concurrency: + group: ${{ github.workflow }}-${{ github.event.pull_request.number || github.ref }} + cancel-in-progress: true + +permissions: + contents: read + +jobs: + dep-check: + if: github.repository == 'apache/camel' + name: Dependency Analysis (non-blocking) + runs-on: ubuntu-latest + continue-on-error: true + steps: + - name: Checkout + uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1 + with: + ref: ${{ github.event.pull_request.head.sha }} + fetch-depth: 0 + + - name: Set up JDK 21 + uses: actions/setup-java@c5195efecf7bdfc987ee8bae7a71cb8b11521c00 # v4.7.1 + with: + distribution: 'temurin' + java-version: '21' + cache: 'maven' + + - name: Run dependency analysis + run: | + mvn verify -Pdep-check -DskipTests -Dlicense.skip -Dquickly \ + --no-transfer-progress --batch-mode -q \ + 2>&1 | tee dep-check-output.txt || true Review Comment: Two things here: - `-q` sets Maven's log level to ERROR, so the `[WARNING] Used undeclared dependencies found:` lines from `analyze-only` never reach `dep-check-output.txt`. Verified on `core/camel-util`: 0 findings with `-q`, the expected junit findings without it. - `|| true` hides genuine `BUILD FAILURE`s (which is how the `legal.xml` failure went unnoticed). Dependency warnings are already non-blocking via `failOnWarning=false`, and `continue-on-error: true` keeps the job from blocking the PR — so let the step itself go red when Maven fails. ```suggestion mvn verify -Pdep-check -DskipTests -Dlicense.skip -Dquickly \ --no-transfer-progress --batch-mode \ 2>&1 | tee dep-check-output.txt ``` ########## pom.xml: ########## @@ -992,6 +994,43 @@ </pluginRepository> </pluginRepositories> </profile> + <profile> + <!-- + Opt-in dependency analysis profile. + Usage: mvn verify -Pdep-check [-DfailOnWarning=true] + Runs maven-dependency-plugin:analyze on every module and reports + used-undeclared / unused-declared dependencies. Non-blocking by + default (failOnWarning=false); set -DfailOnWarning=true to enforce. + --> + <id>dep-check</id> + <build> + <plugins> + <plugin> + <groupId>org.apache.maven.plugins</groupId> + <artifactId>maven-dependency-plugin</artifactId> + <executions> + <execution> + <id>dep-analyze</id> + <goals> + <goal>analyze-only</goal> + </goals> + <phase>verify</phase> + <configuration> + <failOnWarning>${failOnWarning}</failOnWarning> + <outputXML>true</outputXML> + <ignoredUnusedDeclaredDependencies> + <!-- Logging implementations are runtime deps intentionally declared at compile scope --> + <ignoredUnusedDeclaredDependency>org.apache.logging.log4j:log4j-slf4j2-impl</ignoredUnusedDeclaredDependency> + <ignoredUnusedDeclaredDependency>org.apache.logging.log4j:log4j-core</ignoredUnusedDeclaredDependency> + </ignoredUnusedDeclaredDependencies> Review Comment: Suggest also ignoring the JUnit aggregator/api pair, otherwise nearly every module in the reactor gets flagged twice (`parent/pom.xml` declares `junit-jupiter`, code compiles against `junit-jupiter-api`): ```suggestion <ignoredUnusedDeclaredDependencies> <!-- Logging implementations are runtime deps intentionally declared at compile scope --> <ignoredUnusedDeclaredDependency>org.apache.logging.log4j:log4j-slf4j2-impl</ignoredUnusedDeclaredDependency> <ignoredUnusedDeclaredDependency>org.apache.logging.log4j:log4j-core</ignoredUnusedDeclaredDependency> <!-- JUnit aggregator is declared in parent; code compiles against junit-jupiter-api --> <ignoredUnusedDeclaredDependency>org.junit.jupiter:junit-jupiter</ignoredUnusedDeclaredDependency> </ignoredUnusedDeclaredDependencies> <ignoredUsedUndeclaredDependencies> <ignoredUsedUndeclaredDependency>org.junit.jupiter:junit-jupiter-api</ignoredUsedUndeclaredDependency> </ignoredUsedUndeclaredDependencies> ``` -- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. To unsubscribe, e-mail: [email protected] For queries about this service, please contact Infrastructure at: [email protected]
