├── .asf.yaml ├── .github ├── ISSUE_TEMPLATE │ ├── BUG.yml │ ├── FEATURE.yml │ └── config.yml ├── dependabot.yml ├── pull_request_template.md ├── release-drafter.yml └── workflows │ ├── maven-verify.yml │ ├── pr-automation.yml │ ├── release-drafter.yml │ └── stale.yml ├── .gitignore ├── Jenkinsfile ├── README.md ├── pom.xml └── src ├── it ├── checkingNameWithTypeReferencesRequired │ ├── consumer │ │ ├── pom.xml │ │ └── src │ │ │ ├── main │ │ │ └── java │ │ │ │ └── consumer │ │ │ │ └── ActualImplementationClass.java │ │ │ └── test │ │ │ └── java │ │ │ └── consumer │ │ │ └── ActualImplementationClassTest.java │ ├── library │ │ ├── pom.xml │ │ └── src │ │ │ └── main │ │ │ └── java │ │ │ └── library │ │ │ └── LibraryObject.java │ ├── pom.xml │ ├── provider │ │ ├── pom.xml │ │ └── src │ │ │ └── main │ │ │ └── java │ │ │ └── provider │ │ │ └── AbstractBaseClass.java │ └── verify.groovy ├── excludeClassFromJar │ ├── pom.xml │ ├── src │ │ └── main │ │ │ └── java │ │ │ └── jarWithXmlTransitiveDependency │ │ │ └── Project.java │ └── verify.groovy ├── excludeClassFromProject │ ├── pom.xml │ ├── setup.groovy │ └── verify.groovy ├── inlinedStaticReference │ ├── pom.xml │ ├── src │ │ └── main │ │ │ └── java │ │ │ └── inlinedStaticReference │ │ │ └── Project.java │ └── verify.groovy ├── jarWithClassInUnnamedPackage │ ├── pom.xml │ ├── project1 │ │ ├── pom.xml │ │ └── src │ │ │ └── main │ │ │ └── java │ │ │ └── coffee.java │ ├── project2 │ │ ├── pom.xml │ │ └── src │ │ │ └── main │ │ │ └── java │ │ │ └── project2 │ │ │ └── Project.java │ └── verify.groovy ├── jarWithCompileDependency │ ├── pom.xml │ ├── project1 │ │ ├── pom.xml │ │ └── src │ │ │ └── main │ │ │ └── java │ │ │ └── jarWithCompileDependency │ │ │ └── project1 │ │ │ └── Project1.java │ ├── project2 │ │ ├── pom.xml │ │ └── src │ │ │ ├── main │ │ │ └── java │ │ │ │ └── jarWithCompileDependency │ │ │ │ └── project2 │ │ │ │ └── Project2.java │ │ │ └── test │ │ │ └── java │ │ │ └── jarWithCompileDependency │ │ │ └── project2 │ │ │ └── Project2Test.java │ └── verify.groovy ├── jarWithCompileScopedTestDependency │ ├── pom.xml │ ├── project1 │ │ ├── pom.xml │ │ └── src │ │ │ └── main │ │ │ └── java │ │ │ └── jarWithTestDependency │ │ │ └── project1 │ │ │ └── Project1.java │ ├── project2 │ │ ├── pom.xml │ │ └── src │ │ │ └── test │ │ │ └── java │ │ │ └── jarWithTestDependency │ │ │ └── project2 │ │ │ └── Project2.java │ └── verify.groovy ├── jarWithNoDependencies │ ├── pom.xml │ ├── src │ │ └── main │ │ │ └── java │ │ │ └── jarWithNoDependencies │ │ │ └── Project.java │ └── verify.groovy ├── jarWithRuntimeScopedTestDependency │ ├── pom.xml │ ├── project1 │ │ ├── pom.xml │ │ └── src │ │ │ └── main │ │ │ └── java │ │ │ └── jarWithTestDependency │ │ │ └── project1 │ │ │ └── Project1.java │ ├── project2 │ │ ├── pom.xml │ │ └── src │ │ │ └── test │ │ │ └── java │ │ │ └── jarWithTestDependency │ │ │ └── project2 │ │ │ └── Project2.java │ └── verify.groovy ├── jarWithTestDependency │ ├── pom.xml │ ├── project1 │ │ ├── pom.xml │ │ └── src │ │ │ └── main │ │ │ └── java │ │ │ └── jarWithTestDependency │ │ │ └── project1 │ │ │ └── Project1.java │ ├── project2 │ │ ├── pom.xml │ │ └── src │ │ │ └── test │ │ │ └── java │ │ │ └── jarWithTestDependency │ │ │ └── project2 │ │ │ └── Project2.java │ └── verify.groovy ├── jarWithXmlTransitiveDependency │ ├── pom.xml │ ├── src │ │ └── main │ │ │ └── java │ │ │ └── jarWithXmlTransitiveDependency │ │ │ └── Project.java │ └── verify.groovy ├── java8methodRefs │ ├── pom.xml │ ├── src │ │ └── main │ │ │ └── java │ │ │ └── inlinedStaticReference │ │ │ └── Project.java │ └── verify.groovy ├── multimoduleProject │ ├── module1 │ │ ├── pom.xml │ │ └── src │ │ │ └── main │ │ │ └── java │ │ │ └── foo │ │ │ └── Main.java │ ├── module2 │ │ ├── pom.xml │ │ └── src │ │ │ └── main │ │ │ └── java │ │ │ └── bar │ │ │ └── Main.java │ ├── pom.xml │ └── verify.groovy ├── pom │ ├── pom.xml │ └── verify.groovy ├── settings.xml ├── setup-mock-plugin │ ├── invoker.properties │ ├── pom.xml │ └── src │ │ └── main │ │ └── java │ │ └── it │ │ └── test │ │ └── MockAnalyzeMojo.java ├── typeUseAnnotationDependency │ ├── annotation │ │ ├── pom.xml │ │ └── src │ │ │ └── main │ │ │ └── java │ │ │ └── typeUseAnnotationDependency │ │ │ └── annotation │ │ │ └── Annotation.java │ ├── pom.xml │ ├── usage │ │ ├── pom.xml │ │ └── src │ │ │ └── main │ │ │ └── java │ │ │ └── typeUseAnnotationDependency │ │ │ └── usage │ │ │ └── Usage.java │ ├── usageLocalVar │ │ ├── pom.xml │ │ └── src │ │ │ └── main │ │ │ └── java │ │ │ └── typeUseAnnotationDependency │ │ │ └── usageLocalVar │ │ │ └── UsageLocalVar.java │ └── verify.groovy ├── unnamedPackageClassReference │ ├── pom.xml │ ├── src │ │ └── main │ │ │ └── java │ │ │ └── unnamedPackageClassReference │ │ │ └── Project.java │ └── verify.groovy └── usedUndeclaredReference │ ├── pom.xml │ ├── src │ └── main │ │ └── java │ │ └── usedUndeclaredReference │ │ └── Project.java │ └── verify.groovy ├── main └── java │ └── org │ └── apache │ └── maven │ └── shared │ └── dependency │ └── analyzer │ ├── ClassAnalyzer.java │ ├── ClassFileVisitor.java │ ├── ClassFileVisitorUtils.java │ ├── ClassesPatterns.java │ ├── CollectorClassFileVisitor.java │ ├── DefaultClassAnalyzer.java │ ├── DefaultProjectDependencyAnalyzer.java │ ├── DependencyAnalyzer.java │ ├── DependencyUsage.java │ ├── ProjectDependencyAnalysis.java │ ├── ProjectDependencyAnalyzer.java │ ├── ProjectDependencyAnalyzerException.java │ └── asm │ ├── ASMDependencyAnalyzer.java │ ├── ConstantPoolParser.java │ ├── DefaultAnnotationVisitor.java │ ├── DefaultClassVisitor.java │ ├── DefaultFieldVisitor.java │ ├── DefaultMethodVisitor.java │ ├── DefaultSignatureVisitor.java │ ├── DependencyClassFileVisitor.java │ ├── ResultCollector.java │ └── VisitClassException.java ├── site ├── apt │ └── index.apt.vm ├── resources │ └── download.cgi ├── site.xml └── xdoc │ └── download.xml.vm └── test ├── java └── org │ └── apache │ └── maven │ └── shared │ └── dependency │ └── analyzer │ ├── ClassFileVisitorUtilsTest.java │ ├── ClassesPatternsTest.java │ ├── CollectorClassFileVisitorTest.java │ ├── DefaultClassAnalyzerTest.java │ ├── ProjectDependencyAnalysisTest.java │ ├── ProjectDependencyAnalyzerExceptionTest.java │ ├── asm │ ├── ASMDependencyAnalyzerTest.java │ ├── DependencyVisitorTest.java │ └── ResultCollectorTest.java │ └── testcases │ ├── ArrayCases.java │ ├── InnerClassCase.java │ ├── MethodHandleCases.java │ ├── analyze │ ├── AnalyzedClass.java │ └── ClassToExclude.java │ └── prepare │ └── Prepare.java └── resources └── org └── apache └── maven └── shared └── dependency └── analyzer ├── commons-bcel-issue362 ├── Bcel362.classx └── Bcel362.java ├── ossfuzz ├── issue51980 │ └── Test.class.clazz ├── issue51989 │ └── Test.class.clazz ├── issue52168 │ └── Test.class.clazz ├── issue53543 │ └── Test.class.clazz ├── issue53544a │ └── Test.class.clazz ├── issue53620 │ └── Test.class.clazz ├── issue53676 │ └── Test.class.clazz ├── issue54119 │ └── Test.class.clazz └── issue54254 │ └── Test.class.clazz └── record-invokedynamic ├── RecordInvokeDynamic.classx └── RecordInvokeDynamic.java /.asf.yaml: -------------------------------------------------------------------------------- 1 | # 2 | # Licensed to the Apache Software Foundation (ASF) under one or more 3 | # contributor license agreements. See the NOTICE file distributed with 4 | # this work for additional information regarding copyright ownership. 5 | # The ASF licenses this file to You under the Apache License, Version 2.0 6 | # (the "License"); you may not use this file except in compliance with 7 | # the License. You may obtain a copy of the License at 8 | # 9 | # http://www.apache.org/licenses/LICENSE-2.0 10 | # 11 | # Unless required by applicable law or agreed to in writing, software 12 | # distributed under the License is distributed on an "AS IS" BASIS, 13 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | # See the License for the specific language governing permissions and 15 | # limitations under the License. 16 | # 17 | # see https://s.apache.org/asfyaml 18 | github: 19 | description: "Apache Maven Dependency Analyzer" 20 | homepage: https://maven.apache.org/shared/maven-dependency-analyzer/ 21 | labels: 22 | - java 23 | - build-management 24 | - maven-shared 25 | - maven 26 | enabled_merge_buttons: 27 | squash: true 28 | merge: false 29 | rebase: true 30 | autolink_jira: 31 | - MSHARED 32 | del_branch_on_merge: true 33 | features: 34 | issues: true 35 | notifications: 36 | commits: commits@maven.apache.org 37 | issues: issues@maven.apache.org 38 | pullrequests: issues@maven.apache.org 39 | jira_options: link label comment 40 | -------------------------------------------------------------------------------- /.github/ISSUE_TEMPLATE/BUG.yml: -------------------------------------------------------------------------------- 1 | # 2 | # Licensed to the Apache Software Foundation (ASF) under one or more 3 | # contributor license agreements. See the NOTICE file distributed with 4 | # this work for additional information regarding copyright ownership. 5 | # The ASF licenses this file to You under the Apache License, Version 2.0 6 | # (the "License"); you may not use this file except in compliance with 7 | # the License. You may obtain a copy of the License at 8 | # 9 | # http://www.apache.org/licenses/LICENSE-2.0 10 | # 11 | # Unless required by applicable law or agreed to in writing, software 12 | # distributed under the License is distributed on an "AS IS" BASIS, 13 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | # See the License for the specific language governing permissions and 15 | # limitations under the License. 16 | # 17 | 18 | # https://docs.github.com/en/communities/using-templates-to-encourage-useful-issues-and-pull-requests/syntax-for-githubs-form-schema 19 | 20 | name: Bug Report 21 | description: File a bug report 22 | labels: ["bug"] 23 | 24 | body: 25 | - type: markdown 26 | attributes: 27 | value: | 28 | Thanks for taking the time to fill out this bug report. 29 | 30 | Simple fixes in single PRs do not require issues. 31 | 32 | **Do you use the latest project version?** 33 | 34 | - type: input 35 | id: version 36 | attributes: 37 | label: Affected version 38 | validations: 39 | required: true 40 | 41 | - type: textarea 42 | id: message 43 | attributes: 44 | label: Bug description 45 | validations: 46 | required: true 47 | 48 | 49 | -------------------------------------------------------------------------------- /.github/ISSUE_TEMPLATE/FEATURE.yml: -------------------------------------------------------------------------------- 1 | # 2 | # Licensed to the Apache Software Foundation (ASF) under one or more 3 | # contributor license agreements. See the NOTICE file distributed with 4 | # this work for additional information regarding copyright ownership. 5 | # The ASF licenses this file to You under the Apache License, Version 2.0 6 | # (the "License"); you may not use this file except in compliance with 7 | # the License. You may obtain a copy of the License at 8 | # 9 | # http://www.apache.org/licenses/LICENSE-2.0 10 | # 11 | # Unless required by applicable law or agreed to in writing, software 12 | # distributed under the License is distributed on an "AS IS" BASIS, 13 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | # See the License for the specific language governing permissions and 15 | # limitations under the License. 16 | # 17 | 18 | # https://docs.github.com/en/communities/using-templates-to-encourage-useful-issues-and-pull-requests/syntax-for-githubs-form-schema 19 | 20 | name: Feature request 21 | description: File a proposal for new feature, improvement 22 | labels: ["enhancement"] 23 | 24 | body: 25 | - type: markdown 26 | attributes: 27 | value: | 28 | Thanks for taking the time to fill out this new feature, improvement proposal. 29 | 30 | - type: textarea 31 | id: message 32 | attributes: 33 | label: New feature, improvement proposal 34 | validations: 35 | required: true 36 | -------------------------------------------------------------------------------- /.github/ISSUE_TEMPLATE/config.yml: -------------------------------------------------------------------------------- 1 | # 2 | # Licensed to the Apache Software Foundation (ASF) under one or more 3 | # contributor license agreements. See the NOTICE file distributed with 4 | # this work for additional information regarding copyright ownership. 5 | # The ASF licenses this file to You under the Apache License, Version 2.0 6 | # (the "License"); you may not use this file except in compliance with 7 | # the License. You may obtain a copy of the License at 8 | # 9 | # http://www.apache.org/licenses/LICENSE-2.0 10 | # 11 | # Unless required by applicable law or agreed to in writing, software 12 | # distributed under the License is distributed on an "AS IS" BASIS, 13 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | # See the License for the specific language governing permissions and 15 | # limitations under the License. 16 | # 17 | 18 | # https://docs.github.com/en/communities/using-templates-to-encourage-useful-issues-and-pull-requests/configuring-issue-templates-for-your-repository#configuring-the-template-chooser 19 | 20 | blank_issues_enabled: false 21 | 22 | contact_links: 23 | 24 | - name: Project Mailing Lists 25 | url: https://maven.apache.org/mailing-lists.html 26 | about: Please ask a question or discuss here 27 | 28 | - name: Old JIRA Issues 29 | url: https://issues.apache.org/jira/issues/?jql=project%20%3D%20MSHARED%20AND%20component%20%3D%20maven-dependency-analyzer 30 | about: Please search old JIRA issues 31 | -------------------------------------------------------------------------------- /.github/dependabot.yml: -------------------------------------------------------------------------------- 1 | # 2 | # Licensed to the Apache Software Foundation (ASF) under one or more 3 | # contributor license agreements. See the NOTICE file distributed with 4 | # this work for additional information regarding copyright ownership. 5 | # The ASF licenses this file to You under the Apache License, Version 2.0 6 | # (the "License"); you may not use this file except in compliance with 7 | # the License. You may obtain a copy of the License at 8 | # 9 | # http://www.apache.org/licenses/LICENSE-2.0 10 | # 11 | # Unless required by applicable law or agreed to in writing, software 12 | # distributed under the License is distributed on an "AS IS" BASIS, 13 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | # See the License for the specific language governing permissions and 15 | # limitations under the License. 16 | # 17 | version: 2 18 | updates: 19 | - package-ecosystem: maven 20 | directory: "/" 21 | schedule: 22 | interval: daily 23 | open-pull-requests-limit: 10 24 | 25 | - package-ecosystem: "github-actions" 26 | directory: "/" 27 | schedule: 28 | interval: "daily" 29 | -------------------------------------------------------------------------------- /.github/pull_request_template.md: -------------------------------------------------------------------------------- 1 | Following this checklist to help us incorporate your 2 | contribution quickly and easily: 3 | 4 | - [ ] Your pull request should address just one issue, without pulling in other changes. 5 | - [ ] Write a pull request description that is detailed enough to understand what the pull request does, how, and why. 6 | - [ ] Each commit in the pull request should have a meaningful subject line and body. 7 | Note that commits might be squashed by a maintainer on merge. 8 | - [ ] Write unit tests that match behavioral changes, where the tests fail if the changes to the runtime are not applied. 9 | This may not always be possible but is a best-practice. 10 | - [ ] Run `mvn verify` to make sure basic checks pass. 11 | A more thorough check will be performed on your pull request automatically. 12 | - [ ] You have run the integration tests successfully (`mvn -Prun-its verify`). 13 | 14 | If your pull request is about ~20 lines of code you don't need to sign an 15 | [Individual Contributor License Agreement](https://www.apache.org/licenses/icla.pdf) if you are unsure 16 | please ask on the developers list. 17 | 18 | To make clear that you license your contribution under 19 | the [Apache License Version 2.0, January 2004](http://www.apache.org/licenses/LICENSE-2.0) 20 | you have to acknowledge this by using the following check-box. 21 | 22 | - [ ] I hereby declare this contribution to be licenced under the [Apache License Version 2.0, January 2004](http://www.apache.org/licenses/LICENSE-2.0) 23 | - [ ] In any other case, please file an [Apache Individual Contributor License Agreement](https://www.apache.org/licenses/icla.pdf). 24 | -------------------------------------------------------------------------------- /.github/release-drafter.yml: -------------------------------------------------------------------------------- 1 | # Licensed to the Apache Software Foundation (ASF) under one 2 | # or more contributor license agreements. See the NOTICE file 3 | # distributed with this work for additional information 4 | # regarding copyright ownership. The ASF licenses this file 5 | # to you under the Apache License, Version 2.0 (the 6 | # "License"); you may not use this file except in compliance 7 | # with the License. You may obtain a copy of the License at 8 | # 9 | # http://www.apache.org/licenses/LICENSE-2.0 10 | # 11 | # Unless required by applicable law or agreed to in writing, 12 | # software distributed under the License is distributed on an 13 | # "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 14 | # KIND, either express or implied. See the License for the 15 | # specific language governing permissions and limitations 16 | # under the License. 17 | 18 | _extends: maven-gh-actions-shared 19 | -------------------------------------------------------------------------------- /.github/workflows/maven-verify.yml: -------------------------------------------------------------------------------- 1 | # Licensed to the Apache Software Foundation (ASF) under one 2 | # or more contributor license agreements. See the NOTICE file 3 | # distributed with this work for additional information 4 | # regarding copyright ownership. The ASF licenses this file 5 | # to you under the Apache License, Version 2.0 (the 6 | # "License"); you may not use this file except in compliance 7 | # with the License. You may obtain a copy of the License at 8 | # 9 | # http://www.apache.org/licenses/LICENSE-2.0 10 | # 11 | # Unless required by applicable law or agreed to in writing, 12 | # software distributed under the License is distributed on an 13 | # "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 14 | # KIND, either express or implied. See the License for the 15 | # specific language governing permissions and limitations 16 | # under the License. 17 | name: Java CI 18 | 19 | on: 20 | push: 21 | pull_request: 22 | 23 | jobs: 24 | build: 25 | name: Verify 26 | uses: apache/maven-gh-actions-shared/.github/workflows/maven-verify.yml@v4 27 | -------------------------------------------------------------------------------- /.github/workflows/pr-automation.yml: -------------------------------------------------------------------------------- 1 | # Licensed to the Apache Software Foundation (ASF) under one 2 | # or more contributor license agreements. See the NOTICE file 3 | # distributed with this work for additional information 4 | # regarding copyright ownership. The ASF licenses this file 5 | # to you under the Apache License, Version 2.0 (the 6 | # "License"); you may not use this file except in compliance 7 | # with the License. You may obtain a copy of the License at 8 | # 9 | # http://www.apache.org/licenses/LICENSE-2.0 10 | # 11 | # Unless required by applicable law or agreed to in writing, 12 | # software distributed under the License is distributed on an 13 | # "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 14 | # KIND, either express or implied. See the License for the 15 | # specific language governing permissions and limitations 16 | # under the License. 17 | 18 | name: PR Automation 19 | on: 20 | pull_request_target: 21 | types: 22 | - closed 23 | 24 | jobs: 25 | pr-automation: 26 | name: PR Automation 27 | uses: apache/maven-gh-actions-shared/.github/workflows/pr-automation.yml@v4 28 | -------------------------------------------------------------------------------- /.github/workflows/release-drafter.yml: -------------------------------------------------------------------------------- 1 | # Licensed to the Apache Software Foundation (ASF) under one 2 | # or more contributor license agreements. See the NOTICE file 3 | # distributed with this work for additional information 4 | # regarding copyright ownership. The ASF licenses this file 5 | # to you under the Apache License, Version 2.0 (the 6 | # "License"); you may not use this file except in compliance 7 | # with the License. You may obtain a copy of the License at 8 | # 9 | # http://www.apache.org/licenses/LICENSE-2.0 10 | # 11 | # Unless required by applicable law or agreed to in writing, 12 | # software distributed under the License is distributed on an 13 | # "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 14 | # KIND, either express or implied. See the License for the 15 | # specific language governing permissions and limitations 16 | # under the License. 17 | 18 | name: Release Drafter 19 | on: 20 | push: 21 | branches: 22 | - master 23 | workflow_dispatch: 24 | 25 | jobs: 26 | update_release_draft: 27 | uses: apache/maven-gh-actions-shared/.github/workflows/release-drafter.yml@v4 28 | -------------------------------------------------------------------------------- /.github/workflows/stale.yml: -------------------------------------------------------------------------------- 1 | # Licensed to the Apache Software Foundation (ASF) under one 2 | # or more contributor license agreements. See the NOTICE file 3 | # distributed with this work for additional information 4 | # regarding copyright ownership. The ASF licenses this file 5 | # to you under the Apache License, Version 2.0 (the 6 | # "License"); you may not use this file except in compliance 7 | # with the License. You may obtain a copy of the License at 8 | # 9 | # http://www.apache.org/licenses/LICENSE-2.0 10 | # 11 | # Unless required by applicable law or agreed to in writing, 12 | # software distributed under the License is distributed on an 13 | # "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 14 | # KIND, either express or implied. See the License for the 15 | # specific language governing permissions and limitations 16 | # under the License. 17 | 18 | name: Stale 19 | 20 | on: 21 | schedule: 22 | - cron: '48 3 * * *' 23 | issue_comment: 24 | types: [ 'created' ] 25 | 26 | jobs: 27 | stale: 28 | uses: 'apache/maven-gh-actions-shared/.github/workflows/stale.yml@v4' 29 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | target/ 2 | .project 3 | .classpath 4 | .settings/ 5 | .svn/ 6 | bin/ 7 | # Intellij 8 | *.ipr 9 | *.iml 10 | .idea 11 | out/ 12 | .DS_Store 13 | /bootstrap 14 | /dependencies.xml 15 | .java-version 16 | .checkstyle 17 | -------------------------------------------------------------------------------- /Jenkinsfile: -------------------------------------------------------------------------------- 1 | /** 2 | * Licensed to the Apache Software Foundation (ASF) under one 3 | * or more contributor license agreements. See the NOTICE file 4 | * distributed with this work for additional information 5 | * regarding copyright ownership. The ASF licenses this file 6 | * to you under the Apache License, Version 2.0 (the 7 | * "License"); you may not use this file except in compliance 8 | * with the License. You may obtain a copy of the License at 9 | * 10 | * http://www.apache.org/licenses/LICENSE-2.0 11 | * 12 | * Unless required by applicable law or agreed to in writing, 13 | * software distributed under the License is distributed on an 14 | * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 15 | * KIND, either express or implied. See the License for the 16 | * specific language governing permissions and limitations 17 | * under the License. 18 | */ 19 | 20 | asfMavenTlpPlgnBuild() 21 | -------------------------------------------------------------------------------- /src/it/checkingNameWithTypeReferencesRequired/consumer/pom.xml: -------------------------------------------------------------------------------- 1 | 19 | 4.0.0 20 | 21 | example 22 | root 23 | 0.0.1-SNAPSHOT 24 | 25 | consumer 26 | 27 | 28 | example 29 | provider 30 | 0.0.1-SNAPSHOT 31 | 32 | 33 | example 34 | library 35 | 0.0.1-SNAPSHOT 36 | 37 | 38 | -------------------------------------------------------------------------------- /src/it/checkingNameWithTypeReferencesRequired/consumer/src/main/java/consumer/ActualImplementationClass.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Licensed to the Apache Software Foundation (ASF) under one 3 | * or more contributor license agreements. See the NOTICE file 4 | * distributed with this work for additional information 5 | * regarding copyright ownership. The ASF licenses this file 6 | * to you under the Apache License, Version 2.0 (the 7 | * "License"); you may not use this file except in compliance 8 | * with the License. You may obtain a copy of the License at 9 | * 10 | * http://www.apache.org/licenses/LICENSE-2.0 11 | * 12 | * Unless required by applicable law or agreed to in writing, 13 | * software distributed under the License is distributed on an 14 | * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 15 | * KIND, either express or implied. See the License for the 16 | * specific language governing permissions and limitations 17 | * under the License. 18 | */package consumer; 19 | 20 | import provider.AbstractBaseClass; 21 | 22 | public class ActualImplementationClass extends AbstractBaseClass 23 | { 24 | private void doSomething() { 25 | this.getObject(); 26 | } 27 | } 28 | -------------------------------------------------------------------------------- /src/it/checkingNameWithTypeReferencesRequired/consumer/src/test/java/consumer/ActualImplementationClassTest.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Licensed to the Apache Software Foundation (ASF) under one 3 | * or more contributor license agreements. See the NOTICE file 4 | * distributed with this work for additional information 5 | * regarding copyright ownership. The ASF licenses this file 6 | * to you under the Apache License, Version 2.0 (the 7 | * "License"); you may not use this file except in compliance 8 | * with the License. You may obtain a copy of the License at 9 | * 10 | * http://www.apache.org/licenses/LICENSE-2.0 11 | * 12 | * Unless required by applicable law or agreed to in writing, 13 | * software distributed under the License is distributed on an 14 | * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 15 | * KIND, either express or implied. See the License for the 16 | * specific language governing permissions and limitations 17 | * under the License. 18 | */package consumer; 19 | 20 | import library.LibraryObject; 21 | 22 | public class ActualImplementationClassTest 23 | { 24 | void someTest() { 25 | new LibraryObject(); 26 | } 27 | } 28 | -------------------------------------------------------------------------------- /src/it/checkingNameWithTypeReferencesRequired/library/pom.xml: -------------------------------------------------------------------------------- 1 | 19 | 4.0.0 20 | 21 | example 22 | root 23 | 0.0.1-SNAPSHOT 24 | 25 | library 26 | -------------------------------------------------------------------------------- /src/it/checkingNameWithTypeReferencesRequired/library/src/main/java/library/LibraryObject.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Licensed to the Apache Software Foundation (ASF) under one 3 | * or more contributor license agreements. See the NOTICE file 4 | * distributed with this work for additional information 5 | * regarding copyright ownership. The ASF licenses this file 6 | * to you under the Apache License, Version 2.0 (the 7 | * "License"); you may not use this file except in compliance 8 | * with the License. You may obtain a copy of the License at 9 | * 10 | * http://www.apache.org/licenses/LICENSE-2.0 11 | * 12 | * Unless required by applicable law or agreed to in writing, 13 | * software distributed under the License is distributed on an 14 | * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 15 | * KIND, either express or implied. See the License for the 16 | * specific language governing permissions and limitations 17 | * under the License. 18 | */package library; 19 | 20 | public class LibraryObject 21 | { 22 | 23 | } 24 | -------------------------------------------------------------------------------- /src/it/checkingNameWithTypeReferencesRequired/pom.xml: -------------------------------------------------------------------------------- 1 | 19 | 20 | 4.0.0 21 | example 22 | root 23 | 0.0.1-SNAPSHOT 24 | pom 25 | 26 | 27 | 1.8 28 | 1.8 29 | 30 | 31 | 32 | consumer 33 | provider 34 | library 35 | 36 | 37 | 38 | 39 | 40 | org.apache.maven.shared.dependency-analyzer.tests 41 | maven-mock-plugin 42 | 1.0 43 | 44 | 45 | 46 | mock-analyze 47 | 48 | 49 | 50 | 51 | 52 | 53 | -------------------------------------------------------------------------------- /src/it/checkingNameWithTypeReferencesRequired/provider/pom.xml: -------------------------------------------------------------------------------- 1 | 19 | 4.0.0 20 | 21 | example 22 | root 23 | 0.0.1-SNAPSHOT 24 | 25 | provider 26 | 27 | 28 | example 29 | library 30 | 0.0.1-SNAPSHOT 31 | 32 | 33 | -------------------------------------------------------------------------------- /src/it/checkingNameWithTypeReferencesRequired/provider/src/main/java/provider/AbstractBaseClass.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Licensed to the Apache Software Foundation (ASF) under one 3 | * or more contributor license agreements. See the NOTICE file 4 | * distributed with this work for additional information 5 | * regarding copyright ownership. The ASF licenses this file 6 | * to you under the Apache License, Version 2.0 (the 7 | * "License"); you may not use this file except in compliance 8 | * with the License. You may obtain a copy of the License at 9 | * 10 | * http://www.apache.org/licenses/LICENSE-2.0 11 | * 12 | * Unless required by applicable law or agreed to in writing, 13 | * software distributed under the License is distributed on an 14 | * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 15 | * KIND, either express or implied. See the License for the 16 | * specific language governing permissions and limitations 17 | * under the License. 18 | */package provider; 19 | 20 | import library.LibraryObject; 21 | 22 | public abstract class AbstractBaseClass 23 | { 24 | protected LibraryObject getObject() { 25 | return new LibraryObject(); 26 | } 27 | } 28 | -------------------------------------------------------------------------------- /src/it/checkingNameWithTypeReferencesRequired/verify.groovy: -------------------------------------------------------------------------------- 1 | /* 2 | * Licensed to the Apache Software Foundation (ASF) under one 3 | * or more contributor license agreements. See the NOTICE file 4 | * distributed with this work for additional information 5 | * regarding copyright ownership. The ASF licenses this file 6 | * to you under the Apache License, Version 2.0 (the 7 | * "License"); you may not use this file except in compliance 8 | * with the License. You may obtain a copy of the License at 9 | * 10 | * http://www.apache.org/licenses/LICENSE-2.0 11 | * 12 | * Unless required by applicable law or agreed to in writing, 13 | * software distributed under the License is distributed on an 14 | * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 15 | * KIND, either express or implied. See the License for the 16 | * specific language governing permissions and limitations 17 | * under the License. 18 | */ 19 | 20 | def analysis = new File( basedir, 'consumer/target/analysis.txt' ).text 21 | 22 | def expected = ''' 23 | UsedDeclaredArtifacts: 24 | example:provider:jar:0.0.1-SNAPSHOT:compile 25 | example:library:jar:0.0.1-SNAPSHOT:compile 26 | 27 | UsedUndeclaredArtifactsWithClasses: 28 | 29 | UnusedDeclaredArtifacts: 30 | 31 | TestArtifactsWithNonTestScope: 32 | ''' 33 | 34 | assert analysis == expected 35 | -------------------------------------------------------------------------------- /src/it/excludeClassFromJar/pom.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 21 | 22 | 27 | 4.0.0 28 | 29 | org.apache.maven.shared.dependency-analyzer.tests 30 | jarWithXercesDependencies 31 | 1.0 32 | jar 33 | 34 | 35 | 36 | dom4j 37 | dom4j 38 | 1.6.1 39 | 40 | 41 | 42 | 43 | 44 | 45 | org.apache.maven.shared.dependency-analyzer.tests 46 | maven-mock-plugin 47 | 1.0 48 | 49 | 50 | 51 | mock-analyze 52 | 53 | 54 | 55 | 56 | 57 | org.xml.sax.* 58 | 59 | 60 | 61 | 62 | 63 | 64 | 65 | -------------------------------------------------------------------------------- /src/it/excludeClassFromJar/src/main/java/jarWithXmlTransitiveDependency/Project.java: -------------------------------------------------------------------------------- 1 | package jarWithXmlTransitiveDependency; 2 | 3 | /* 4 | * Licensed to the Apache Software Foundation (ASF) under one 5 | * or more contributor license agreements. See the NOTICE file 6 | * distributed with this work for additional information 7 | * regarding copyright ownership. The ASF licenses this file 8 | * to you under the Apache License, Version 2.0 (the 9 | * "License"); you may not use this file except in compliance 10 | * with the License. You may obtain a copy of the License at 11 | * 12 | * http://www.apache.org/licenses/LICENSE-2.0 13 | * 14 | * Unless required by applicable law or agreed to in writing, 15 | * software distributed under the License is distributed on an 16 | * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 17 | * KIND, either express or implied. See the License for the 18 | * specific language governing permissions and limitations 19 | * under the License. 20 | */ 21 | 22 | import org.dom4j.Text; 23 | import org.xml.sax.Parser; 24 | 25 | /** 26 | * Dependency on dom4j gives xml-apis transitive dependency, which contains SAX Parser class. But SAX Parser is available in 27 | * JDK: no need to declare a direct dependency. 28 | * 29 | */ 30 | public class Project 31 | { 32 | public Text text; 33 | 34 | public Parser parser; 35 | 36 | // constructors ----------------------------------------------------------- 37 | 38 | public Project() 39 | { 40 | // no op 41 | } 42 | } 43 | -------------------------------------------------------------------------------- /src/it/excludeClassFromJar/verify.groovy: -------------------------------------------------------------------------------- 1 | /* 2 | * Licensed to the Apache Software Foundation (ASF) under one 3 | * or more contributor license agreements. See the NOTICE file 4 | * distributed with this work for additional information 5 | * regarding copyright ownership. The ASF licenses this file 6 | * to you under the Apache License, Version 2.0 (the 7 | * "License"); you may not use this file except in compliance 8 | * with the License. You may obtain a copy of the License at 9 | * 10 | * http://www.apache.org/licenses/LICENSE-2.0 11 | * 12 | * Unless required by applicable law or agreed to in writing, 13 | * software distributed under the License is distributed on an 14 | * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 15 | * KIND, either express or implied. See the License for the 16 | * specific language governing permissions and limitations 17 | * under the License. 18 | */ 19 | 20 | def analysis = new File( basedir, 'target/analysis.txt' ).text 21 | 22 | def expected = ''' 23 | UsedDeclaredArtifacts: 24 | dom4j:dom4j:jar:1.6.1:compile 25 | 26 | UsedUndeclaredArtifactsWithClasses: 27 | 28 | UnusedDeclaredArtifacts: 29 | 30 | TestArtifactsWithNonTestScope: 31 | ''' 32 | 33 | assert analysis == expected 34 | -------------------------------------------------------------------------------- /src/it/excludeClassFromProject/pom.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 21 | 22 | 27 | 4.0.0 28 | 29 | org.apache.maven.shared.dependency-analyzer.tests 30 | jarWithXercesDependencies 31 | 1.0 32 | jar 33 | 34 | 35 | 36 | 37 | org.apache.maven.shared.dependency-analyzer.tests 38 | maven-mock-plugin 39 | 1.0 40 | 41 | 42 | 43 | mock-analyze 44 | 45 | 46 | 47 | 48 | 49 | org.example.BadClass 50 | 51 | 52 | 53 | 54 | 55 | 56 | 57 | -------------------------------------------------------------------------------- /src/it/excludeClassFromProject/setup.groovy: -------------------------------------------------------------------------------- 1 | /* 2 | * Licensed to the Apache Software Foundation (ASF) under one 3 | * or more contributor license agreements. See the NOTICE file 4 | * distributed with this work for additional information 5 | * regarding copyright ownership. The ASF licenses this file 6 | * to you under the Apache License, Version 2.0 (the 7 | * "License"); you may not use this file except in compliance 8 | * with the License. You may obtain a copy of the License at 9 | * 10 | * http://www.apache.org/licenses/LICENSE-2.0 11 | * 12 | * Unless required by applicable law or agreed to in writing, 13 | * software distributed under the License is distributed on an 14 | * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 15 | * KIND, either express or implied. See the License for the 16 | * specific language governing permissions and limitations 17 | * under the License. 18 | */ 19 | def badClass = new File(basedir, 'target/classes/org/example/BadClass.class') 20 | 21 | badClass.getParentFile().mkdirs() 22 | badClass << 'some content' 23 | 24 | assert badClass.isFile() 25 | -------------------------------------------------------------------------------- /src/it/excludeClassFromProject/verify.groovy: -------------------------------------------------------------------------------- 1 | /* 2 | * Licensed to the Apache Software Foundation (ASF) under one 3 | * or more contributor license agreements. See the NOTICE file 4 | * distributed with this work for additional information 5 | * regarding copyright ownership. The ASF licenses this file 6 | * to you under the Apache License, Version 2.0 (the 7 | * "License"); you may not use this file except in compliance 8 | * with the License. You may obtain a copy of the License at 9 | * 10 | * http://www.apache.org/licenses/LICENSE-2.0 11 | * 12 | * Unless required by applicable law or agreed to in writing, 13 | * software distributed under the License is distributed on an 14 | * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 15 | * KIND, either express or implied. See the License for the 16 | * specific language governing permissions and limitations 17 | * under the License. 18 | */ 19 | 20 | def analysis = new File( basedir, 'target/analysis.txt' ).text 21 | 22 | def expected = ''' 23 | UsedDeclaredArtifacts: 24 | 25 | UsedUndeclaredArtifactsWithClasses: 26 | 27 | UnusedDeclaredArtifacts: 28 | 29 | TestArtifactsWithNonTestScope: 30 | ''' 31 | 32 | assert analysis == expected 33 | -------------------------------------------------------------------------------- /src/it/inlinedStaticReference/pom.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 21 | 22 | 27 | 4.0.0 28 | 29 | org.apache.maven.shared.dependency-analyzer.tests 30 | inlinedStaticReference 31 | 1.0 32 | jar 33 | 34 | 35 | 36 | dom4j 37 | dom4j 38 | 1.6.1 39 | 40 | 41 | 42 | 43 | 44 | 45 | org.apache.maven.shared.dependency-analyzer.tests 46 | maven-mock-plugin 47 | 1.0 48 | 49 | 50 | 51 | mock-analyze 52 | 53 | 54 | 55 | 56 | 57 | 58 | 59 | 60 | -------------------------------------------------------------------------------- /src/it/inlinedStaticReference/src/main/java/inlinedStaticReference/Project.java: -------------------------------------------------------------------------------- 1 | package inlinedStaticReference; 2 | 3 | /* 4 | * Licensed to the Apache Software Foundation (ASF) under one 5 | * or more contributor license agreements. See the NOTICE file 6 | * distributed with this work for additional information 7 | * regarding copyright ownership. The ASF licenses this file 8 | * to you under the Apache License, Version 2.0 (the 9 | * "License"); you may not use this file except in compliance 10 | * with the License. You may obtain a copy of the License at 11 | * 12 | * http://www.apache.org/licenses/LICENSE-2.0 13 | * 14 | * Unless required by applicable law or agreed to in writing, 15 | * software distributed under the License is distributed on an 16 | * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 17 | * KIND, either express or implied. See the License for the 18 | * specific language governing permissions and limitations 19 | * under the License. 20 | */ 21 | 22 | import org.dom4j.Node; 23 | import org.dom4j.Text; 24 | 25 | public class Project 26 | { 27 | public static final short myvalue = Node.ELEMENT_NODE; 28 | 29 | public Project() 30 | { 31 | // no op 32 | } 33 | } 34 | -------------------------------------------------------------------------------- /src/it/inlinedStaticReference/verify.groovy: -------------------------------------------------------------------------------- 1 | /* 2 | * Licensed to the Apache Software Foundation (ASF) under one 3 | * or more contributor license agreements. See the NOTICE file 4 | * distributed with this work for additional information 5 | * regarding copyright ownership. The ASF licenses this file 6 | * to you under the Apache License, Version 2.0 (the 7 | * "License"); you may not use this file except in compliance 8 | * with the License. You may obtain a copy of the License at 9 | * 10 | * http://www.apache.org/licenses/LICENSE-2.0 11 | * 12 | * Unless required by applicable law or agreed to in writing, 13 | * software distributed under the License is distributed on an 14 | * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 15 | * KIND, either express or implied. See the License for the 16 | * specific language governing permissions and limitations 17 | * under the License. 18 | */ 19 | 20 | def analysis = new File( basedir, 'target/analysis.txt' ).text 21 | 22 | def expected = ''' 23 | UsedDeclaredArtifacts: 24 | dom4j:dom4j:jar:1.6.1:compile 25 | 26 | UsedUndeclaredArtifactsWithClasses: 27 | 28 | UnusedDeclaredArtifacts: 29 | 30 | TestArtifactsWithNonTestScope: 31 | ''' 32 | 33 | assert analysis == expected 34 | -------------------------------------------------------------------------------- /src/it/jarWithClassInUnnamedPackage/pom.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 21 | 22 | 27 | 4.0.0 28 | org.apache.maven.shared.dependency-analyzer.tests 29 | jarWithClassInUnnamedPackage 30 | pom 31 | 1.0 32 | 33 | 34 | project1 35 | project2 36 | 37 | 38 | -------------------------------------------------------------------------------- /src/it/jarWithClassInUnnamedPackage/project1/pom.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 21 | 22 | 27 | 4.0.0 28 | org.apache.maven.shared.dependency-analyzer.tests 29 | jarWithClassInUnnamedPackage1 30 | jar 31 | 1.0 32 | 33 | -------------------------------------------------------------------------------- /src/it/jarWithClassInUnnamedPackage/project1/src/main/java/coffee.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Licensed to the Apache Software Foundation (ASF) under one 3 | * or more contributor license agreements. See the NOTICE file 4 | * distributed with this work for additional information 5 | * regarding copyright ownership. The ASF licenses this file 6 | * to you under the Apache License, Version 2.0 (the 7 | * "License"); you may not use this file except in compliance 8 | * with the License. You may obtain a copy of the License at 9 | * 10 | * http://www.apache.org/licenses/LICENSE-2.0 11 | * 12 | * Unless required by applicable law or agreed to in writing, 13 | * software distributed under the License is distributed on an 14 | * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 15 | * KIND, either express or implied. See the License for the 16 | * specific language governing permissions and limitations 17 | * under the License. 18 | */ 19 | 20 | public class coffee 21 | { 22 | public coffee() 23 | { 24 | // no-op 25 | } 26 | } 27 | -------------------------------------------------------------------------------- /src/it/jarWithClassInUnnamedPackage/project2/pom.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 21 | 22 | 27 | 4.0.0 28 | org.apache.maven.shared.dependency-analyzer.tests 29 | jarWithClassInUnnamedPackage2 30 | jar 31 | 1.0 32 | 33 | 34 | 35 | org.apache.maven.shared.dependency-analyzer.tests 36 | jarWithClassInUnnamedPackage1 37 | 1.0 38 | 39 | 40 | 41 | 42 | 43 | 44 | org.apache.maven.shared.dependency-analyzer.tests 45 | maven-mock-plugin 46 | 1.0 47 | 48 | 49 | 50 | mock-analyze 51 | 52 | 53 | 54 | 55 | 56 | 57 | 58 | 59 | -------------------------------------------------------------------------------- /src/it/jarWithClassInUnnamedPackage/project2/src/main/java/project2/Project.java: -------------------------------------------------------------------------------- 1 | package project2; 2 | 3 | /* 4 | * Licensed to the Apache Software Foundation (ASF) under one 5 | * or more contributor license agreements. See the NOTICE file 6 | * distributed with this work for additional information 7 | * regarding copyright ownership. The ASF licenses this file 8 | * to you under the Apache License, Version 2.0 (the 9 | * "License"); you may not use this file except in compliance 10 | * with the License. You may obtain a copy of the License at 11 | * 12 | * http://www.apache.org/licenses/LICENSE-2.0 13 | * 14 | * Unless required by applicable law or agreed to in writing, 15 | * software distributed under the License is distributed on an 16 | * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 17 | * KIND, either express or implied. See the License for the 18 | * specific language governing permissions and limitations 19 | * under the License. 20 | */ 21 | 22 | public class Project 23 | { 24 | public Project() 25 | { 26 | String drink = "coffee"; 27 | } 28 | } 29 | -------------------------------------------------------------------------------- /src/it/jarWithClassInUnnamedPackage/verify.groovy: -------------------------------------------------------------------------------- 1 | /* 2 | * Licensed to the Apache Software Foundation (ASF) under one 3 | * or more contributor license agreements. See the NOTICE file 4 | * distributed with this work for additional information 5 | * regarding copyright ownership. The ASF licenses this file 6 | * to you under the Apache License, Version 2.0 (the 7 | * "License"); you may not use this file except in compliance 8 | * with the License. You may obtain a copy of the License at 9 | * 10 | * http://www.apache.org/licenses/LICENSE-2.0 11 | * 12 | * Unless required by applicable law or agreed to in writing, 13 | * software distributed under the License is distributed on an 14 | * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 15 | * KIND, either express or implied. See the License for the 16 | * specific language governing permissions and limitations 17 | * under the License. 18 | */ 19 | 20 | def analysis = new File( basedir, 'project2/target/analysis.txt' ).text 21 | 22 | def expected = ''' 23 | UsedDeclaredArtifacts: 24 | 25 | UsedUndeclaredArtifactsWithClasses: 26 | 27 | UnusedDeclaredArtifacts: 28 | org.apache.maven.shared.dependency-analyzer.tests:jarWithClassInUnnamedPackage1:jar:1.0:compile 29 | 30 | TestArtifactsWithNonTestScope: 31 | ''' 32 | 33 | assert analysis == expected 34 | -------------------------------------------------------------------------------- /src/it/jarWithCompileDependency/pom.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 21 | 22 | 27 | 4.0.0 28 | org.apache.maven.shared.dependency-analyzer.tests 29 | jarWithCompileDependency 30 | pom 31 | 1.0 32 | 33 | 34 | project1 35 | project2 36 | 37 | 38 | 39 | -------------------------------------------------------------------------------- /src/it/jarWithCompileDependency/project1/pom.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 21 | 22 | 27 | 4.0.0 28 | org.apache.maven.shared.dependency-analyzer.tests 29 | jarWithCompileDependency1 30 | jar 31 | 1.0 32 | 33 | 34 | -------------------------------------------------------------------------------- /src/it/jarWithCompileDependency/project1/src/main/java/jarWithCompileDependency/project1/Project1.java: -------------------------------------------------------------------------------- 1 | package jarWithCompileDependency.project1; 2 | 3 | /* 4 | * Licensed to the Apache Software Foundation (ASF) under one 5 | * or more contributor license agreements. See the NOTICE file 6 | * distributed with this work for additional information 7 | * regarding copyright ownership. The ASF licenses this file 8 | * to you under the Apache License, Version 2.0 (the 9 | * "License"); you may not use this file except in compliance 10 | * with the License. You may obtain a copy of the License at 11 | * 12 | * http://www.apache.org/licenses/LICENSE-2.0 13 | * 14 | * Unless required by applicable law or agreed to in writing, 15 | * software distributed under the License is distributed on an 16 | * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 17 | * KIND, either express or implied. See the License for the 18 | * specific language governing permissions and limitations 19 | * under the License. 20 | */ 21 | 22 | /** 23 | * 24 | * 25 | * @author Mark Hobson 26 | */ 27 | public class Project1 28 | { 29 | public Project1() 30 | { 31 | // no-op 32 | } 33 | } 34 | -------------------------------------------------------------------------------- /src/it/jarWithCompileDependency/project2/pom.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 21 | 22 | 27 | 4.0.0 28 | org.apache.maven.shared.dependency-analyzer.tests 29 | jarWithCompileDependency2 30 | jar 31 | 1.0 32 | 33 | 34 | 35 | org.apache.maven.shared.dependency-analyzer.tests 36 | jarWithCompileDependency1 37 | 1.0 38 | 39 | 40 | com.google.guava 41 | guava 42 | 32.0.0-android 43 | 44 | 45 | 46 | 47 | 48 | 49 | org.apache.maven.shared.dependency-analyzer.tests 50 | maven-mock-plugin 51 | 1.0 52 | 53 | 54 | 55 | mock-analyze 56 | 57 | 58 | 59 | 60 | 61 | 62 | 63 | 64 | -------------------------------------------------------------------------------- /src/it/jarWithCompileDependency/project2/src/main/java/jarWithCompileDependency/project2/Project2.java: -------------------------------------------------------------------------------- 1 | package jarWithCompileDependency.project2; 2 | 3 | /* 4 | * Licensed to the Apache Software Foundation (ASF) under one 5 | * or more contributor license agreements. See the NOTICE file 6 | * distributed with this work for additional information 7 | * regarding copyright ownership. The ASF licenses this file 8 | * to you under the Apache License, Version 2.0 (the 9 | * "License"); you may not use this file except in compliance 10 | * with the License. You may obtain a copy of the License at 11 | * 12 | * http://www.apache.org/licenses/LICENSE-2.0 13 | * 14 | * Unless required by applicable law or agreed to in writing, 15 | * software distributed under the License is distributed on an 16 | * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 17 | * KIND, either express or implied. See the License for the 18 | * specific language governing permissions and limitations 19 | * under the License. 20 | */ 21 | 22 | import jarWithCompileDependency.project1.Project1; 23 | import com.google.common.base.Strings; 24 | 25 | /** 26 | * 27 | * 28 | * @author Mark Hobson 29 | */ 30 | public class Project2 31 | { 32 | public Project2() 33 | { 34 | Project1 project = new Project1(); 35 | System.out.println(Strings.emptyToNull("this")); 36 | } 37 | } 38 | -------------------------------------------------------------------------------- /src/it/jarWithCompileDependency/project2/src/test/java/jarWithCompileDependency/project2/Project2Test.java: -------------------------------------------------------------------------------- 1 | package jarWithCompileDependency.project2; 2 | 3 | /* 4 | * Licensed to the Apache Software Foundation (ASF) under one 5 | * or more contributor license agreements. See the NOTICE file 6 | * distributed with this work for additional information 7 | * regarding copyright ownership. The ASF licenses this file 8 | * to you under the Apache License, Version 2.0 (the 9 | * "License"); you may not use this file except in compliance 10 | * with the License. You may obtain a copy of the License at 11 | * 12 | * http://www.apache.org/licenses/LICENSE-2.0 13 | * 14 | * Unless required by applicable law or agreed to in writing, 15 | * software distributed under the License is distributed on an 16 | * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 17 | * KIND, either express or implied. See the License for the 18 | * specific language governing permissions and limitations 19 | * under the License. 20 | */ 21 | 22 | import jarWithCompileDependency.project1.Project1; 23 | import com.google.common.base.Preconditions; 24 | 25 | public class Project2Test 26 | { 27 | public Project2Test() 28 | { 29 | Preconditions.checkNotNull(""); 30 | } 31 | } 32 | -------------------------------------------------------------------------------- /src/it/jarWithCompileDependency/verify.groovy: -------------------------------------------------------------------------------- 1 | /* 2 | * Licensed to the Apache Software Foundation (ASF) under one 3 | * or more contributor license agreements. See the NOTICE file 4 | * distributed with this work for additional information 5 | * regarding copyright ownership. The ASF licenses this file 6 | * to you under the Apache License, Version 2.0 (the 7 | * "License"); you may not use this file except in compliance 8 | * with the License. You may obtain a copy of the License at 9 | * 10 | * http://www.apache.org/licenses/LICENSE-2.0 11 | * 12 | * Unless required by applicable law or agreed to in writing, 13 | * software distributed under the License is distributed on an 14 | * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 15 | * KIND, either express or implied. See the License for the 16 | * specific language governing permissions and limitations 17 | * under the License. 18 | */ 19 | 20 | def analysis = new File( basedir, 'project2/target/analysis.txt' ).text 21 | 22 | def expected = ''' 23 | UsedDeclaredArtifacts: 24 | org.apache.maven.shared.dependency-analyzer.tests:jarWithCompileDependency1:jar:1.0:compile 25 | com.google.guava:guava:jar:32.0.0-android:compile 26 | 27 | UsedUndeclaredArtifactsWithClasses: 28 | 29 | UnusedDeclaredArtifacts: 30 | 31 | TestArtifactsWithNonTestScope: 32 | ''' 33 | 34 | assert analysis == expected 35 | -------------------------------------------------------------------------------- /src/it/jarWithCompileScopedTestDependency/pom.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 21 | 22 | 27 | 4.0.0 28 | org.apache.maven.shared.dependency-analyzer.tests 29 | jarWithCompileScopedTestDependency 30 | pom 31 | 1.0 32 | 33 | 34 | project1 35 | project2 36 | 37 | 38 | 39 | -------------------------------------------------------------------------------- /src/it/jarWithCompileScopedTestDependency/project1/pom.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 21 | 22 | 27 | 4.0.0 28 | org.apache.maven.shared.dependency-analyzer.tests 29 | jarWithCompileScopedTestDependency1 30 | jar 31 | 1.0 32 | 33 | 34 | -------------------------------------------------------------------------------- /src/it/jarWithCompileScopedTestDependency/project1/src/main/java/jarWithTestDependency/project1/Project1.java: -------------------------------------------------------------------------------- 1 | package jarWithTestDependency.project1; 2 | 3 | /* 4 | * Licensed to the Apache Software Foundation (ASF) under one 5 | * or more contributor license agreements. See the NOTICE file 6 | * distributed with this work for additional information 7 | * regarding copyright ownership. The ASF licenses this file 8 | * to you under the Apache License, Version 2.0 (the 9 | * "License"); you may not use this file except in compliance 10 | * with the License. You may obtain a copy of the License at 11 | * 12 | * http://www.apache.org/licenses/LICENSE-2.0 13 | * 14 | * Unless required by applicable law or agreed to in writing, 15 | * software distributed under the License is distributed on an 16 | * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 17 | * KIND, either express or implied. See the License for the 18 | * specific language governing permissions and limitations 19 | * under the License. 20 | */ 21 | 22 | /** 23 | * 24 | * 25 | * @author Mark Hobson 26 | */ 27 | public class Project1 28 | { 29 | public Project1() 30 | { 31 | // no-op 32 | } 33 | } 34 | -------------------------------------------------------------------------------- /src/it/jarWithCompileScopedTestDependency/project2/pom.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 21 | 22 | 27 | 4.0.0 28 | org.apache.maven.shared.dependency-analyzer.tests 29 | jarWithCompileScopedTestDependency2 30 | jar 31 | 1.0 32 | 33 | 34 | 35 | org.apache.maven.shared.dependency-analyzer.tests 36 | jarWithCompileScopedTestDependency1 37 | 1.0 38 | test 39 | 40 | 41 | 42 | junit 43 | junit 44 | 4.13.2 45 | 46 | 47 | 48 | 49 | 50 | 51 | org.apache.maven.shared.dependency-analyzer.tests 52 | maven-mock-plugin 53 | 1.0 54 | 55 | 56 | 57 | mock-analyze 58 | 59 | 60 | 61 | 62 | 63 | 64 | 65 | 66 | -------------------------------------------------------------------------------- /src/it/jarWithCompileScopedTestDependency/project2/src/test/java/jarWithTestDependency/project2/Project2.java: -------------------------------------------------------------------------------- 1 | package jarWithTestDependency.project2; 2 | 3 | /* 4 | * Licensed to the Apache Software Foundation (ASF) under one 5 | * or more contributor license agreements. See the NOTICE file 6 | * distributed with this work for additional information 7 | * regarding copyright ownership. The ASF licenses this file 8 | * to you under the Apache License, Version 2.0 (the 9 | * "License"); you may not use this file except in compliance 10 | * with the License. You may obtain a copy of the License at 11 | * 12 | * http://www.apache.org/licenses/LICENSE-2.0 13 | * 14 | * Unless required by applicable law or agreed to in writing, 15 | * software distributed under the License is distributed on an 16 | * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 17 | * KIND, either express or implied. See the License for the 18 | * specific language governing permissions and limitations 19 | * under the License. 20 | */ 21 | 22 | import jarWithTestDependency.project1.Project1; 23 | 24 | /** 25 | * 26 | * 27 | * @author Mark Hobson 28 | */ 29 | public class Project2 30 | { 31 | // using a constant from JUnit requires junit dependency but is not detected since the constant 32 | // value is copied, then nothing can be detected in bytecode 33 | // Not the case any more, since we sniff it from the constant pool 34 | public final static int STATUS_ERROR = junit.runner.TestRunListener.STATUS_ERROR; 35 | 36 | public Project2() 37 | { 38 | Project1 project = new Project1(); 39 | } 40 | } 41 | -------------------------------------------------------------------------------- /src/it/jarWithCompileScopedTestDependency/verify.groovy: -------------------------------------------------------------------------------- 1 | /* 2 | * Licensed to the Apache Software Foundation (ASF) under one 3 | * or more contributor license agreements. See the NOTICE file 4 | * distributed with this work for additional information 5 | * regarding copyright ownership. The ASF licenses this file 6 | * to you under the Apache License, Version 2.0 (the 7 | * "License"); you may not use this file except in compliance 8 | * with the License. You may obtain a copy of the License at 9 | * 10 | * http://www.apache.org/licenses/LICENSE-2.0 11 | * 12 | * Unless required by applicable law or agreed to in writing, 13 | * software distributed under the License is distributed on an 14 | * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 15 | * KIND, either express or implied. See the License for the 16 | * specific language governing permissions and limitations 17 | * under the License. 18 | */ 19 | 20 | def analysis = new File( basedir, 'project2/target/analysis.txt' ).text 21 | 22 | def expected = ''' 23 | UsedDeclaredArtifacts: 24 | org.apache.maven.shared.dependency-analyzer.tests:jarWithCompileScopedTestDependency1:jar:1.0:test 25 | junit:junit:jar:4.13.2:compile 26 | 27 | UsedUndeclaredArtifactsWithClasses: 28 | 29 | UnusedDeclaredArtifacts: 30 | 31 | TestArtifactsWithNonTestScope: 32 | junit:junit:jar:4.13.2:compile 33 | ''' 34 | 35 | assert analysis == expected 36 | -------------------------------------------------------------------------------- /src/it/jarWithNoDependencies/pom.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 21 | 22 | 27 | 4.0.0 28 | org.apache.maven.shared.dependency-analyzer.tests 29 | jarWithNoDependencies 30 | jar 31 | 1.0 32 | 33 | 34 | 35 | 36 | org.apache.maven.shared.dependency-analyzer.tests 37 | maven-mock-plugin 38 | 1.0 39 | 40 | 41 | 42 | mock-analyze 43 | 44 | 45 | 46 | 47 | 48 | 49 | 50 | 51 | -------------------------------------------------------------------------------- /src/it/jarWithNoDependencies/src/main/java/jarWithNoDependencies/Project.java: -------------------------------------------------------------------------------- 1 | package jarWithNoDependencies; 2 | 3 | /* 4 | * Licensed to the Apache Software Foundation (ASF) under one 5 | * or more contributor license agreements. See the NOTICE file 6 | * distributed with this work for additional information 7 | * regarding copyright ownership. The ASF licenses this file 8 | * to you under the Apache License, Version 2.0 (the 9 | * "License"); you may not use this file except in compliance 10 | * with the License. You may obtain a copy of the License at 11 | * 12 | * http://www.apache.org/licenses/LICENSE-2.0 13 | * 14 | * Unless required by applicable law or agreed to in writing, 15 | * software distributed under the License is distributed on an 16 | * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 17 | * KIND, either express or implied. See the License for the 18 | * specific language governing permissions and limitations 19 | * under the License. 20 | */ 21 | 22 | /** 23 | * 24 | * 25 | * @author Mark Hobson 26 | */ 27 | public class Project 28 | { 29 | public Project() 30 | { 31 | // no-op 32 | } 33 | } 34 | -------------------------------------------------------------------------------- /src/it/jarWithNoDependencies/verify.groovy: -------------------------------------------------------------------------------- 1 | /* 2 | * Licensed to the Apache Software Foundation (ASF) under one 3 | * or more contributor license agreements. See the NOTICE file 4 | * distributed with this work for additional information 5 | * regarding copyright ownership. The ASF licenses this file 6 | * to you under the Apache License, Version 2.0 (the 7 | * "License"); you may not use this file except in compliance 8 | * with the License. You may obtain a copy of the License at 9 | * 10 | * http://www.apache.org/licenses/LICENSE-2.0 11 | * 12 | * Unless required by applicable law or agreed to in writing, 13 | * software distributed under the License is distributed on an 14 | * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 15 | * KIND, either express or implied. See the License for the 16 | * specific language governing permissions and limitations 17 | * under the License. 18 | */ 19 | 20 | def analysis = new File( basedir, 'target/analysis.txt' ).text 21 | 22 | def expected = ''' 23 | UsedDeclaredArtifacts: 24 | 25 | UsedUndeclaredArtifactsWithClasses: 26 | 27 | UnusedDeclaredArtifacts: 28 | 29 | TestArtifactsWithNonTestScope: 30 | ''' 31 | 32 | assert analysis == expected 33 | -------------------------------------------------------------------------------- /src/it/jarWithRuntimeScopedTestDependency/pom.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 21 | 22 | 27 | 4.0.0 28 | org.apache.maven.shared.dependency-analyzer.tests 29 | jarWithRuntimeScopedTestDependency 30 | pom 31 | 1.0 32 | 33 | 34 | project1 35 | project2 36 | 37 | 38 | 39 | -------------------------------------------------------------------------------- /src/it/jarWithRuntimeScopedTestDependency/project1/pom.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 21 | 22 | 27 | 4.0.0 28 | org.apache.maven.shared.dependency-analyzer.tests 29 | jarWithRuntimeScopedTestDependency1 30 | jar 31 | 1.0 32 | 33 | 34 | -------------------------------------------------------------------------------- /src/it/jarWithRuntimeScopedTestDependency/project1/src/main/java/jarWithTestDependency/project1/Project1.java: -------------------------------------------------------------------------------- 1 | package jarWithTestDependency.project1; 2 | 3 | /* 4 | * Licensed to the Apache Software Foundation (ASF) under one 5 | * or more contributor license agreements. See the NOTICE file 6 | * distributed with this work for additional information 7 | * regarding copyright ownership. The ASF licenses this file 8 | * to you under the Apache License, Version 2.0 (the 9 | * "License"); you may not use this file except in compliance 10 | * with the License. You may obtain a copy of the License at 11 | * 12 | * http://www.apache.org/licenses/LICENSE-2.0 13 | * 14 | * Unless required by applicable law or agreed to in writing, 15 | * software distributed under the License is distributed on an 16 | * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 17 | * KIND, either express or implied. See the License for the 18 | * specific language governing permissions and limitations 19 | * under the License. 20 | */ 21 | 22 | /** 23 | * 24 | * 25 | * @author Mark Hobson 26 | */ 27 | public class Project1 28 | { 29 | public Project1() 30 | { 31 | // no-op 32 | } 33 | } 34 | -------------------------------------------------------------------------------- /src/it/jarWithRuntimeScopedTestDependency/project2/pom.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 21 | 22 | 27 | 4.0.0 28 | org.apache.maven.shared.dependency-analyzer.tests 29 | jarWithRuntimeScopedTestDependency2 30 | jar 31 | 1.0 32 | 33 | 34 | 35 | org.apache.maven.shared.dependency-analyzer.tests 36 | jarWithRuntimeScopedTestDependency1 37 | 1.0 38 | test 39 | 40 | 41 | 42 | junit 43 | junit 44 | 4.13.2 45 | runtime 46 | 47 | 48 | 49 | 50 | 51 | 52 | org.apache.maven.shared.dependency-analyzer.tests 53 | maven-mock-plugin 54 | 1.0 55 | 56 | 57 | 58 | mock-analyze 59 | 60 | 61 | 62 | 63 | 64 | 65 | 66 | 67 | -------------------------------------------------------------------------------- /src/it/jarWithRuntimeScopedTestDependency/project2/src/test/java/jarWithTestDependency/project2/Project2.java: -------------------------------------------------------------------------------- 1 | package jarWithTestDependency.project2; 2 | 3 | /* 4 | * Licensed to the Apache Software Foundation (ASF) under one 5 | * or more contributor license agreements. See the NOTICE file 6 | * distributed with this work for additional information 7 | * regarding copyright ownership. The ASF licenses this file 8 | * to you under the Apache License, Version 2.0 (the 9 | * "License"); you may not use this file except in compliance 10 | * with the License. You may obtain a copy of the License at 11 | * 12 | * http://www.apache.org/licenses/LICENSE-2.0 13 | * 14 | * Unless required by applicable law or agreed to in writing, 15 | * software distributed under the License is distributed on an 16 | * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 17 | * KIND, either express or implied. See the License for the 18 | * specific language governing permissions and limitations 19 | * under the License. 20 | */ 21 | 22 | import jarWithTestDependency.project1.Project1; 23 | 24 | /** 25 | * 26 | * @author Mark Hobson 27 | */ 28 | public class Project2 29 | { 30 | // using a constant from JUnit requires junit dependency but is not detected since the constant 31 | // value is copied, then nothing can be detected in bytecode 32 | // Not the case any more, since we sniff it from the constant pool 33 | public final static int STATUS_ERROR = junit.runner.TestRunListener.STATUS_ERROR; 34 | 35 | public Project2() 36 | { 37 | Project1 project = new Project1(); 38 | } 39 | } 40 | -------------------------------------------------------------------------------- /src/it/jarWithRuntimeScopedTestDependency/verify.groovy: -------------------------------------------------------------------------------- 1 | /* 2 | * Licensed to the Apache Software Foundation (ASF) under one 3 | * or more contributor license agreements. See the NOTICE file 4 | * distributed with this work for additional information 5 | * regarding copyright ownership. The ASF licenses this file 6 | * to you under the Apache License, Version 2.0 (the 7 | * "License"); you may not use this file except in compliance 8 | * with the License. You may obtain a copy of the License at 9 | * 10 | * http://www.apache.org/licenses/LICENSE-2.0 11 | * 12 | * Unless required by applicable law or agreed to in writing, 13 | * software distributed under the License is distributed on an 14 | * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 15 | * KIND, either express or implied. See the License for the 16 | * specific language governing permissions and limitations 17 | * under the License. 18 | */ 19 | 20 | def analysis = new File( basedir, 'project2/target/analysis.txt' ).text 21 | 22 | def expected = ''' 23 | UsedDeclaredArtifacts: 24 | org.apache.maven.shared.dependency-analyzer.tests:jarWithRuntimeScopedTestDependency1:jar:1.0:test 25 | junit:junit:jar:4.13.2:runtime 26 | 27 | UsedUndeclaredArtifactsWithClasses: 28 | 29 | UnusedDeclaredArtifacts: 30 | 31 | TestArtifactsWithNonTestScope: 32 | ''' 33 | 34 | assert analysis == expected 35 | -------------------------------------------------------------------------------- /src/it/jarWithTestDependency/pom.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 21 | 22 | 27 | 4.0.0 28 | org.apache.maven.shared.dependency-analyzer.tests 29 | jarWithTestDependency 30 | pom 31 | 1.0 32 | 33 | 34 | project1 35 | project2 36 | 37 | 38 | 39 | -------------------------------------------------------------------------------- /src/it/jarWithTestDependency/project1/pom.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 21 | 22 | 27 | 4.0.0 28 | org.apache.maven.shared.dependency-analyzer.tests 29 | jarWithTestDependency1 30 | jar 31 | 1.0 32 | 33 | 34 | -------------------------------------------------------------------------------- /src/it/jarWithTestDependency/project1/src/main/java/jarWithTestDependency/project1/Project1.java: -------------------------------------------------------------------------------- 1 | package jarWithTestDependency.project1; 2 | 3 | /* 4 | * Licensed to the Apache Software Foundation (ASF) under one 5 | * or more contributor license agreements. See the NOTICE file 6 | * distributed with this work for additional information 7 | * regarding copyright ownership. The ASF licenses this file 8 | * to you under the Apache License, Version 2.0 (the 9 | * "License"); you may not use this file except in compliance 10 | * with the License. You may obtain a copy of the License at 11 | * 12 | * http://www.apache.org/licenses/LICENSE-2.0 13 | * 14 | * Unless required by applicable law or agreed to in writing, 15 | * software distributed under the License is distributed on an 16 | * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 17 | * KIND, either express or implied. See the License for the 18 | * specific language governing permissions and limitations 19 | * under the License. 20 | */ 21 | 22 | /** 23 | * 24 | * @author Mark Hobson 25 | */ 26 | public class Project1 27 | { 28 | public Project1() 29 | { 30 | // no-op 31 | } 32 | } 33 | -------------------------------------------------------------------------------- /src/it/jarWithTestDependency/project2/pom.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 21 | 22 | 27 | 4.0.0 28 | org.apache.maven.shared.dependency-analyzer.tests 29 | jarWithTestDependency2 30 | jar 31 | 1.0 32 | 33 | 34 | 35 | org.apache.maven.shared.dependency-analyzer.tests 36 | jarWithTestDependency1 37 | 1.0 38 | test 39 | 40 | 41 | 42 | junit 43 | junit 44 | 4.13.2 45 | test 46 | 47 | 48 | 49 | 50 | 51 | 52 | org.apache.maven.shared.dependency-analyzer.tests 53 | maven-mock-plugin 54 | 1.0 55 | 56 | 57 | 58 | mock-analyze 59 | 60 | 61 | 62 | 63 | 64 | 65 | 66 | 67 | -------------------------------------------------------------------------------- /src/it/jarWithTestDependency/project2/src/test/java/jarWithTestDependency/project2/Project2.java: -------------------------------------------------------------------------------- 1 | package jarWithTestDependency.project2; 2 | 3 | /* 4 | * Licensed to the Apache Software Foundation (ASF) under one 5 | * or more contributor license agreements. See the NOTICE file 6 | * distributed with this work for additional information 7 | * regarding copyright ownership. The ASF licenses this file 8 | * to you under the Apache License, Version 2.0 (the 9 | * "License"); you may not use this file except in compliance 10 | * with the License. You may obtain a copy of the License at 11 | * 12 | * http://www.apache.org/licenses/LICENSE-2.0 13 | * 14 | * Unless required by applicable law or agreed to in writing, 15 | * software distributed under the License is distributed on an 16 | * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 17 | * KIND, either express or implied. See the License for the 18 | * specific language governing permissions and limitations 19 | * under the License. 20 | */ 21 | 22 | import jarWithTestDependency.project1.Project1; 23 | 24 | /** 25 | * 26 | * @author Mark Hobson 27 | */ 28 | public class Project2 29 | { 30 | // using a constant from JUnit requires junit dependency but is not detected since the constant 31 | // value is copied, then nothing can be detected in bytecode 32 | // Not the case any more, since we sniff it from the constant pool 33 | public final static int STATUS_ERROR = junit.runner.TestRunListener.STATUS_ERROR; 34 | 35 | public Project2() 36 | { 37 | Project1 project = new Project1(); 38 | } 39 | } 40 | -------------------------------------------------------------------------------- /src/it/jarWithTestDependency/verify.groovy: -------------------------------------------------------------------------------- 1 | /* 2 | * Licensed to the Apache Software Foundation (ASF) under one 3 | * or more contributor license agreements. See the NOTICE file 4 | * distributed with this work for additional information 5 | * regarding copyright ownership. The ASF licenses this file 6 | * to you under the Apache License, Version 2.0 (the 7 | * "License"); you may not use this file except in compliance 8 | * with the License. You may obtain a copy of the License at 9 | * 10 | * http://www.apache.org/licenses/LICENSE-2.0 11 | * 12 | * Unless required by applicable law or agreed to in writing, 13 | * software distributed under the License is distributed on an 14 | * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 15 | * KIND, either express or implied. See the License for the 16 | * specific language governing permissions and limitations 17 | * under the License. 18 | */ 19 | 20 | def analysis = new File( basedir, 'project2/target/analysis.txt' ).text 21 | 22 | def expected = ''' 23 | UsedDeclaredArtifacts: 24 | org.apache.maven.shared.dependency-analyzer.tests:jarWithTestDependency1:jar:1.0:test 25 | junit:junit:jar:4.13.2:test 26 | 27 | UsedUndeclaredArtifactsWithClasses: 28 | 29 | UnusedDeclaredArtifacts: 30 | 31 | TestArtifactsWithNonTestScope: 32 | ''' 33 | 34 | assert analysis == expected 35 | -------------------------------------------------------------------------------- /src/it/jarWithXmlTransitiveDependency/pom.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 21 | 22 | 27 | 4.0.0 28 | 29 | org.apache.maven.shared.dependency-analyzer.tests 30 | jarWithXercesDependencies 31 | 1.0 32 | jar 33 | 34 | 35 | 36 | dom4j 37 | dom4j 38 | 1.6.1 39 | 40 | 41 | 42 | 43 | 44 | 45 | org.apache.maven.shared.dependency-analyzer.tests 46 | maven-mock-plugin 47 | 1.0 48 | 49 | 50 | 51 | mock-analyze 52 | 53 | 54 | 55 | 56 | 57 | 58 | 59 | 60 | -------------------------------------------------------------------------------- /src/it/jarWithXmlTransitiveDependency/src/main/java/jarWithXmlTransitiveDependency/Project.java: -------------------------------------------------------------------------------- 1 | package jarWithXmlTransitiveDependency; 2 | 3 | /* 4 | * Licensed to the Apache Software Foundation (ASF) under one 5 | * or more contributor license agreements. See the NOTICE file 6 | * distributed with this work for additional information 7 | * regarding copyright ownership. The ASF licenses this file 8 | * to you under the Apache License, Version 2.0 (the 9 | * "License"); you may not use this file except in compliance 10 | * with the License. You may obtain a copy of the License at 11 | * 12 | * http://www.apache.org/licenses/LICENSE-2.0 13 | * 14 | * Unless required by applicable law or agreed to in writing, 15 | * software distributed under the License is distributed on an 16 | * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 17 | * KIND, either express or implied. See the License for the 18 | * specific language governing permissions and limitations 19 | * under the License. 20 | */ 21 | 22 | import org.dom4j.Text; 23 | import org.xml.sax.Parser; 24 | 25 | /** 26 | * Dependency on dom4j gives xml-apis transitive dependency, which contains SAX Parser class. But SAX Parser is available in 27 | * JDK: no need to declare a direct dependency. 28 | * 29 | */ 30 | public class Project 31 | { 32 | public Text text; 33 | 34 | public Parser parser; 35 | 36 | // constructors ----------------------------------------------------------- 37 | 38 | public Project() 39 | { 40 | // no op 41 | } 42 | } 43 | -------------------------------------------------------------------------------- /src/it/jarWithXmlTransitiveDependency/verify.groovy: -------------------------------------------------------------------------------- 1 | /* 2 | * Licensed to the Apache Software Foundation (ASF) under one 3 | * or more contributor license agreements. See the NOTICE file 4 | * distributed with this work for additional information 5 | * regarding copyright ownership. The ASF licenses this file 6 | * to you under the Apache License, Version 2.0 (the 7 | * "License"); you may not use this file except in compliance 8 | * with the License. You may obtain a copy of the License at 9 | * 10 | * http://www.apache.org/licenses/LICENSE-2.0 11 | * 12 | * Unless required by applicable law or agreed to in writing, 13 | * software distributed under the License is distributed on an 14 | * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 15 | * KIND, either express or implied. See the License for the 16 | * specific language governing permissions and limitations 17 | * under the License. 18 | */ 19 | 20 | def analysis = new File( basedir, 'target/analysis.txt' ).text 21 | 22 | def expected = ''' 23 | UsedDeclaredArtifacts: 24 | dom4j:dom4j:jar:1.6.1:compile 25 | 26 | UsedUndeclaredArtifactsWithClasses: 27 | 28 | UnusedDeclaredArtifacts: 29 | 30 | TestArtifactsWithNonTestScope: 31 | ''' 32 | 33 | assert analysis == expected 34 | -------------------------------------------------------------------------------- /src/it/java8methodRefs/pom.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 21 | 22 | 27 | 4.0.0 28 | 29 | org.apache.maven.shared.dependency-analyzer.tests 30 | java8methodreferences 31 | 1.0 32 | jar 33 | 34 | 35 | 36 | commons-io 37 | commons-io 38 | 2.17.0 39 | 40 | 41 | commons-lang 42 | commons-lang 43 | 2.6 44 | 45 | 46 | 47 | 48 | 49 | 50 | org.apache.maven.shared.dependency-analyzer.tests 51 | maven-mock-plugin 52 | 1.0 53 | 54 | 55 | 56 | mock-analyze 57 | 58 | 59 | 60 | 61 | 62 | 63 | 64 | 65 | -------------------------------------------------------------------------------- /src/it/java8methodRefs/src/main/java/inlinedStaticReference/Project.java: -------------------------------------------------------------------------------- 1 | package inlinedStaticReference; 2 | 3 | /* 4 | * Licensed to the Apache Software Foundation (ASF) under one 5 | * or more contributor license agreements. See the NOTICE file 6 | * distributed with this work for additional information 7 | * regarding copyright ownership. The ASF licenses this file 8 | * to you under the Apache License, Version 2.0 (the 9 | * "License"); you may not use this file except in compliance 10 | * with the License. You may obtain a copy of the License at 11 | * 12 | * http://www.apache.org/licenses/LICENSE-2.0 13 | * 14 | * Unless required by applicable law or agreed to in writing, 15 | * software distributed under the License is distributed on an 16 | * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 17 | * KIND, either express or implied. See the License for the 18 | * specific language governing permissions and limitations 19 | * under the License. 20 | */ 21 | 22 | import java.io.File; 23 | import java.util.function.Function; 24 | 25 | import org.apache.commons.io.FileUtils; 26 | 27 | public class Project 28 | { 29 | public static final long LONG_CONSTANT = 123L; 30 | public static final double DOUBLE_CONSTANT = 123.0; 31 | public static final Function souv = FileUtils::getFile; 32 | 33 | public Project() { 34 | Function fn = org.apache.commons.lang.CharUtils::unicodeEscaped; 35 | } 36 | 37 | } 38 | -------------------------------------------------------------------------------- /src/it/java8methodRefs/verify.groovy: -------------------------------------------------------------------------------- 1 | /* 2 | * Licensed to the Apache Software Foundation (ASF) under one 3 | * or more contributor license agreements. See the NOTICE file 4 | * distributed with this work for additional information 5 | * regarding copyright ownership. The ASF licenses this file 6 | * to you under the Apache License, Version 2.0 (the 7 | * "License"); you may not use this file except in compliance 8 | * with the License. You may obtain a copy of the License at 9 | * 10 | * http://www.apache.org/licenses/LICENSE-2.0 11 | * 12 | * Unless required by applicable law or agreed to in writing, 13 | * software distributed under the License is distributed on an 14 | * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 15 | * KIND, either express or implied. See the License for the 16 | * specific language governing permissions and limitations 17 | * under the License. 18 | */ 19 | 20 | def analysis = new File( basedir, 'target/analysis.txt' ).text 21 | 22 | def expected = ''' 23 | UsedDeclaredArtifacts: 24 | commons-io:commons-io:jar:2.17.0:compile 25 | commons-lang:commons-lang:jar:2.6:compile 26 | 27 | UsedUndeclaredArtifactsWithClasses: 28 | 29 | UnusedDeclaredArtifacts: 30 | 31 | TestArtifactsWithNonTestScope: 32 | ''' 33 | 34 | assert analysis == expected 35 | -------------------------------------------------------------------------------- /src/it/multimoduleProject/module1/pom.xml: -------------------------------------------------------------------------------- 1 | 2 | 20 | 21 | 24 | 4.0.0 25 | 26 | 27 | org.apache.maven.its.dependency 28 | test-parent 29 | 1.0 30 | 31 | 32 | test-module1 33 | 34 | 35 | 36 | org.apache.maven 37 | maven-artifact 38 | @mavenVersion@ 39 | 40 | 41 | org.apache.maven 42 | maven-model 43 | @mavenVersion@ 44 | 45 | 46 | 47 | -------------------------------------------------------------------------------- /src/it/multimoduleProject/module1/src/main/java/foo/Main.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Licensed to the Apache Software Foundation (ASF) under one 3 | * or more contributor license agreements. See the NOTICE file 4 | * distributed with this work for additional information 5 | * regarding copyright ownership. The ASF licenses this file 6 | * to you under the Apache License, Version 2.0 (the 7 | * "License"); you may not use this file except in compliance 8 | * with the License. You may obtain a copy of the License at 9 | * 10 | * http://www.apache.org/licenses/LICENSE-2.0 11 | * 12 | * Unless required by applicable law or agreed to in writing, 13 | * software distributed under the License is distributed on an 14 | * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 15 | * KIND, either express or implied. See the License for the 16 | * specific language governing permissions and limitations 17 | * under the License. 18 | */ 19 | package foo; 20 | 21 | import org.apache.maven.artifact.Artifact; 22 | import org.apache.maven.model.Model; 23 | 24 | public class Main 25 | { 26 | public static final String SCOPE_COMPILE = Artifact.SCOPE_COMPILE; 27 | 28 | public Model model = null; 29 | } 30 | -------------------------------------------------------------------------------- /src/it/multimoduleProject/module2/pom.xml: -------------------------------------------------------------------------------- 1 | 2 | 20 | 21 | 24 | 4.0.0 25 | 26 | 27 | org.apache.maven.its.dependency 28 | test-parent 29 | 1.0 30 | 31 | 32 | test-module2 33 | 34 | 35 | 36 | org.apache.maven.its.dependency 37 | test-module1 38 | ${project.version} 39 | 40 | 41 | 42 | 43 | 44 | 45 | org.apache.maven.shared.dependency-analyzer.tests 46 | maven-mock-plugin 47 | 1.0 48 | 49 | 50 | 51 | mock-analyze 52 | 53 | 54 | 55 | 56 | 57 | 58 | 59 | 60 | -------------------------------------------------------------------------------- /src/it/multimoduleProject/module2/src/main/java/bar/Main.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Licensed to the Apache Software Foundation (ASF) under one 3 | * or more contributor license agreements. See the NOTICE file 4 | * distributed with this work for additional information 5 | * regarding copyright ownership. The ASF licenses this file 6 | * to you under the Apache License, Version 2.0 (the 7 | * "License"); you may not use this file except in compliance 8 | * with the License. You may obtain a copy of the License at 9 | * 10 | * http://www.apache.org/licenses/LICENSE-2.0 11 | * 12 | * Unless required by applicable law or agreed to in writing, 13 | * software distributed under the License is distributed on an 14 | * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 15 | * KIND, either express or implied. See the License for the 16 | * specific language governing permissions and limitations 17 | * under the License. 18 | */ 19 | package bar; 20 | 21 | public class Main 22 | { 23 | public foo.Main dummy = null; 24 | } 25 | -------------------------------------------------------------------------------- /src/it/multimoduleProject/pom.xml: -------------------------------------------------------------------------------- 1 | 2 | 20 | 21 | 24 | 4.0.0 25 | 26 | org.apache.maven.its.dependency 27 | test-parent 28 | 1.0 29 | pom 30 | 31 | Test 32 | 33 | Test dependency:analyze on a multi-module project 34 | 35 | 36 | 37 | module1 38 | module2 39 | 40 | 41 | -------------------------------------------------------------------------------- /src/it/multimoduleProject/verify.groovy: -------------------------------------------------------------------------------- 1 | /* 2 | * Licensed to the Apache Software Foundation (ASF) under one 3 | * or more contributor license agreements. See the NOTICE file 4 | * distributed with this work for additional information 5 | * regarding copyright ownership. The ASF licenses this file 6 | * to you under the Apache License, Version 2.0 (the 7 | * "License"); you may not use this file except in compliance 8 | * with the License. You may obtain a copy of the License at 9 | * 10 | * http://www.apache.org/licenses/LICENSE-2.0 11 | * 12 | * Unless required by applicable law or agreed to in writing, 13 | * software distributed under the License is distributed on an 14 | * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 15 | * KIND, either express or implied. See the License for the 16 | * specific language governing permissions and limitations 17 | * under the License. 18 | */ 19 | 20 | def analysis = new File( basedir, 'module2/target/analysis.txt' ).text 21 | 22 | def expected = ''' 23 | UsedDeclaredArtifacts: 24 | org.apache.maven.its.dependency:test-module1:jar:1.0:compile 25 | 26 | UsedUndeclaredArtifactsWithClasses: 27 | 28 | UnusedDeclaredArtifacts: 29 | 30 | TestArtifactsWithNonTestScope: 31 | ''' 32 | 33 | assert analysis == expected 34 | -------------------------------------------------------------------------------- /src/it/pom/pom.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 21 | 22 | 27 | 4.0.0 28 | org.apache.maven.shared.dependency-analyzer.tests 29 | pom 30 | pom 31 | 1.0 32 | 33 | 34 | 35 | 36 | org.apache.maven.shared.dependency-analyzer.tests 37 | maven-mock-plugin 38 | 1.0 39 | 40 | 41 | 42 | mock-analyze 43 | 44 | 45 | 46 | 47 | 48 | 49 | 50 | -------------------------------------------------------------------------------- /src/it/pom/verify.groovy: -------------------------------------------------------------------------------- 1 | /* 2 | * Licensed to the Apache Software Foundation (ASF) under one 3 | * or more contributor license agreements. See the NOTICE file 4 | * distributed with this work for additional information 5 | * regarding copyright ownership. The ASF licenses this file 6 | * to you under the Apache License, Version 2.0 (the 7 | * "License"); you may not use this file except in compliance 8 | * with the License. You may obtain a copy of the License at 9 | * 10 | * http://www.apache.org/licenses/LICENSE-2.0 11 | * 12 | * Unless required by applicable law or agreed to in writing, 13 | * software distributed under the License is distributed on an 14 | * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 15 | * KIND, either express or implied. See the License for the 16 | * specific language governing permissions and limitations 17 | * under the License. 18 | */ 19 | 20 | def analysis = new File( basedir, 'target/analysis.txt' ).text 21 | 22 | def expected = ''' 23 | UsedDeclaredArtifacts: 24 | 25 | UsedUndeclaredArtifactsWithClasses: 26 | 27 | UnusedDeclaredArtifacts: 28 | 29 | TestArtifactsWithNonTestScope: 30 | ''' 31 | 32 | assert analysis == expected 33 | -------------------------------------------------------------------------------- /src/it/settings.xml: -------------------------------------------------------------------------------- 1 | 2 | 21 | 22 | 23 | 24 | it-repo 25 | 26 | 27 | local.central 28 | @localRepositoryUrl@ 29 | 30 | true 31 | 32 | 33 | true 34 | 35 | 36 | 37 | 38 | 39 | local.central 40 | @localRepositoryUrl@ 41 | 42 | true 43 | 44 | 45 | true 46 | 47 | 48 | 49 | 50 | 51 | 52 | it-repo 53 | 54 | 55 | -------------------------------------------------------------------------------- /src/it/setup-mock-plugin/invoker.properties: -------------------------------------------------------------------------------- 1 | # Licensed to the Apache Software Foundation (ASF) under one 2 | # or more contributor license agreements. See the NOTICE file 3 | # distributed with this work for additional information 4 | # regarding copyright ownership. The ASF licenses this file 5 | # to you under the Apache License, Version 2.0 (the 6 | # "License"); you may not use this file except in compliance 7 | # with the License. You may obtain a copy of the License at 8 | # 9 | # http://www.apache.org/licenses/LICENSE-2.0 10 | # 11 | # Unless required by applicable law or agreed to in writing, 12 | # software distributed under the License is distributed on an 13 | # "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 14 | # KIND, either express or implied. See the License for the 15 | # specific language governing permissions and limitations 16 | # under the License. 17 | 18 | invoker.goals = install 19 | -------------------------------------------------------------------------------- /src/it/setup-mock-plugin/pom.xml: -------------------------------------------------------------------------------- 1 | 2 | 21 | 23 | 4.0.0 24 | 25 | org.apache.maven.shared.dependency-analyzer.tests 26 | maven-mock-plugin 27 | maven-plugin 28 | 1.0 29 | 30 | 31 | 32 | javax.inject 33 | javax.inject 34 | 1 35 | provided 36 | 37 | 38 | org.apache.maven 39 | maven-core 40 | @mavenVersion@ 41 | provided 42 | 43 | 44 | org.apache.maven 45 | maven-plugin-api 46 | @mavenVersion@ 47 | provided 48 | 49 | 50 | org.apache.maven.plugin-tools 51 | maven-plugin-tools-annotations 52 | @version.maven-plugin-tools@ 53 | provided 54 | 55 | 56 | org.apache.maven.shared 57 | maven-dependency-analyzer 58 | @project.version@ 59 | 60 | 61 | 62 | 63 | 64 | 65 | 66 | org.apache.maven.plugins 67 | maven-plugin-plugin 68 | @version.maven-plugin-tools@ 69 | 70 | 71 | 72 | 73 | 74 | 75 | -------------------------------------------------------------------------------- /src/it/typeUseAnnotationDependency/annotation/pom.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 21 | 22 | 27 | 4.0.0 28 | org.apache.maven.shared.dependency-analyzer.tests 29 | typeUseAnnotationDependencyAnnotation 30 | jar 31 | 1.0 32 | 33 | 34 | -------------------------------------------------------------------------------- /src/it/typeUseAnnotationDependency/annotation/src/main/java/typeUseAnnotationDependency/annotation/Annotation.java: -------------------------------------------------------------------------------- 1 | package typeUseAnnotationDependency.annotation; 2 | 3 | import java.lang.annotation.ElementType; 4 | import java.lang.annotation.Retention; 5 | import java.lang.annotation.RetentionPolicy; 6 | import java.lang.annotation.Target; 7 | 8 | /* 9 | * Licensed to the Apache Software Foundation (ASF) under one 10 | * or more contributor license agreements. See the NOTICE file 11 | * distributed with this work for additional information 12 | * regarding copyright ownership. The ASF licenses this file 13 | * to you under the Apache License, Version 2.0 (the 14 | * "License"); you may not use this file except in compliance 15 | * with the License. You may obtain a copy of the License at 16 | * 17 | * http://www.apache.org/licenses/LICENSE-2.0 18 | * 19 | * Unless required by applicable law or agreed to in writing, 20 | * software distributed under the License is distributed on an 21 | * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 22 | * KIND, either express or implied. See the License for the 23 | * specific language governing permissions and limitations 24 | * under the License. 25 | */ 26 | 27 | @Target({ElementType.TYPE_USE, ElementType.TYPE_PARAMETER}) 28 | @Retention(RetentionPolicy.RUNTIME) 29 | public @interface Annotation { 30 | } -------------------------------------------------------------------------------- /src/it/typeUseAnnotationDependency/pom.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 21 | 22 | 27 | 4.0.0 28 | org.apache.maven.shared.dependency-analyzer.tests 29 | typeUseAnnotationDependency 30 | pom 31 | 1.0 32 | 33 | 34 | annotation 35 | usage 36 | usageLocalVar 37 | 38 | 39 | 40 | -------------------------------------------------------------------------------- /src/it/typeUseAnnotationDependency/usage/pom.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 21 | 22 | 27 | 4.0.0 28 | org.apache.maven.shared.dependency-analyzer.tests 29 | typeUseAnnotationDependencyUsage 30 | jar 31 | 1.0 32 | 33 | 34 | 35 | org.apache.maven.shared.dependency-analyzer.tests 36 | typeUseAnnotationDependencyAnnotation 37 | 1.0 38 | 39 | 40 | 41 | 42 | 43 | 44 | org.apache.maven.shared.dependency-analyzer.tests 45 | maven-mock-plugin 46 | 1.0 47 | 48 | 49 | 50 | mock-analyze 51 | 52 | 53 | 54 | 55 | 56 | 57 | 58 | 59 | -------------------------------------------------------------------------------- /src/it/typeUseAnnotationDependency/usage/src/main/java/typeUseAnnotationDependency/usage/Usage.java: -------------------------------------------------------------------------------- 1 | package typeUseAnnotationDependency.usage; 2 | 3 | import typeUseAnnotationDependency.annotation.Annotation; 4 | 5 | /* 6 | * Licensed to the Apache Software Foundation (ASF) under one 7 | * or more contributor license agreements. See the NOTICE file 8 | * distributed with this work for additional information 9 | * regarding copyright ownership. The ASF licenses this file 10 | * to you under the Apache License, Version 2.0 (the 11 | * "License"); you may not use this file except in compliance 12 | * with the License. You may obtain a copy of the License at 13 | * 14 | * http://www.apache.org/licenses/LICENSE-2.0 15 | * 16 | * Unless required by applicable law or agreed to in writing, 17 | * software distributed under the License is distributed on an 18 | * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 19 | * KIND, either express or implied. See the License for the 20 | * specific language governing permissions and limitations 21 | * under the License. 22 | */ 23 | 24 | public interface Usage { 25 | 26 | @Annotation String getValue(); 27 | 28 | } 29 | -------------------------------------------------------------------------------- /src/it/typeUseAnnotationDependency/usageLocalVar/pom.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 21 | 22 | 27 | 4.0.0 28 | org.apache.maven.shared.dependency-analyzer.tests 29 | typeUseAnnotationDependencyUsageLocalVar 30 | jar 31 | 1.0 32 | 33 | 34 | 35 | org.apache.maven.shared.dependency-analyzer.tests 36 | typeUseAnnotationDependencyAnnotation 37 | 1.0 38 | 39 | 40 | 41 | 42 | 43 | 44 | org.apache.maven.shared.dependency-analyzer.tests 45 | maven-mock-plugin 46 | 1.0 47 | 48 | 49 | 50 | mock-analyze 51 | 52 | 53 | 54 | 55 | 56 | 57 | 58 | 59 | -------------------------------------------------------------------------------- /src/it/typeUseAnnotationDependency/usageLocalVar/src/main/java/typeUseAnnotationDependency/usageLocalVar/UsageLocalVar.java: -------------------------------------------------------------------------------- 1 | package typeUseAnnotationDependency.usageLocalVar; 2 | 3 | import typeUseAnnotationDependency.annotation.Annotation; 4 | 5 | /* 6 | * Licensed to the Apache Software Foundation (ASF) under one 7 | * or more contributor license agreements. See the NOTICE file 8 | * distributed with this work for additional information 9 | * regarding copyright ownership. The ASF licenses this file 10 | * to you under the Apache License, Version 2.0 (the 11 | * "License"); you may not use this file except in compliance 12 | * with the License. You may obtain a copy of the License at 13 | * 14 | * http://www.apache.org/licenses/LICENSE-2.0 15 | * 16 | * Unless required by applicable law or agreed to in writing, 17 | * software distributed under the License is distributed on an 18 | * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 19 | * KIND, either express or implied. See the License for the 20 | * specific language governing permissions and limitations 21 | * under the License. 22 | */ 23 | 24 | public class UsageLocalVar { 25 | 26 | public void getValue() { 27 | @Annotation String s = ""; 28 | } 29 | 30 | } 31 | -------------------------------------------------------------------------------- /src/it/typeUseAnnotationDependency/verify.groovy: -------------------------------------------------------------------------------- 1 | /* 2 | * Licensed to the Apache Software Foundation (ASF) under one 3 | * or more contributor license agreements. See the NOTICE file 4 | * distributed with this work for additional information 5 | * regarding copyright ownership. The ASF licenses this file 6 | * to you under the Apache License, Version 2.0 (the 7 | * "License"); you may not use this file except in compliance 8 | * with the License. You may obtain a copy of the License at 9 | * 10 | * http://www.apache.org/licenses/LICENSE-2.0 11 | * 12 | * Unless required by applicable law or agreed to in writing, 13 | * software distributed under the License is distributed on an 14 | * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 15 | * KIND, either express or implied. See the License for the 16 | * specific language governing permissions and limitations 17 | * under the License. 18 | */ 19 | 20 | def analysisUsage = new File( basedir, 'usage/target/analysis.txt' ).text 21 | 22 | def expectedUsage = ''' 23 | UsedDeclaredArtifacts: 24 | org.apache.maven.shared.dependency-analyzer.tests:typeUseAnnotationDependencyAnnotation:jar:1.0:compile 25 | 26 | UsedUndeclaredArtifactsWithClasses: 27 | 28 | UnusedDeclaredArtifacts: 29 | 30 | TestArtifactsWithNonTestScope: 31 | ''' 32 | 33 | assert analysisUsage == expectedUsage 34 | 35 | def analysisUsageLocalVar = new File( basedir, 'usageLocalVar/target/analysis.txt' ).text 36 | 37 | def expectedUsageLocalVar = ''' 38 | UsedDeclaredArtifacts: 39 | org.apache.maven.shared.dependency-analyzer.tests:typeUseAnnotationDependencyAnnotation:jar:1.0:compile 40 | 41 | UsedUndeclaredArtifactsWithClasses: 42 | 43 | UnusedDeclaredArtifacts: 44 | 45 | TestArtifactsWithNonTestScope: 46 | ''' 47 | 48 | assert analysisUsageLocalVar == expectedUsageLocalVar 49 | 50 | 51 | -------------------------------------------------------------------------------- /src/it/unnamedPackageClassReference/pom.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 21 | 22 | 27 | 4.0.0 28 | 29 | org.apache.maven.shared.dependency-analyzer.tests 30 | unnamedPackageClassReference 31 | 1.0 32 | jar 33 | 34 | 35 | 36 | dnsjava 37 | dnsjava 38 | 2.1.8 39 | 40 | 41 | 42 | 43 | 44 | 45 | org.apache.maven.shared.dependency-analyzer.tests 46 | maven-mock-plugin 47 | 1.0 48 | 49 | 50 | 51 | mock-analyze 52 | 53 | 54 | 55 | 56 | 57 | 58 | 59 | 60 | -------------------------------------------------------------------------------- /src/it/unnamedPackageClassReference/src/main/java/unnamedPackageClassReference/Project.java: -------------------------------------------------------------------------------- 1 | package unnamedPackageClassReference; 2 | 3 | /* 4 | * Licensed to the Apache Software Foundation (ASF) under one 5 | * or more contributor license agreements. See the NOTICE file 6 | * distributed with this work for additional information 7 | * regarding copyright ownership. The ASF licenses this file 8 | * to you under the Apache License, Version 2.0 (the 9 | * "License"); you may not use this file except in compliance 10 | * with the License. You may obtain a copy of the License at 11 | * 12 | * http://www.apache.org/licenses/LICENSE-2.0 13 | * 14 | * Unless required by applicable law or agreed to in writing, 15 | * software distributed under the License is distributed on an 16 | * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 17 | * KIND, either express or implied. See the License for the 18 | * specific language governing permissions and limitations 19 | * under the License. 20 | */ 21 | 22 | public class Project 23 | { 24 | // dnsjava 2.1.8 includes a class called "update" 25 | public static final String UPDATE = "update"; 26 | 27 | public Project() 28 | { 29 | // no op 30 | } 31 | } 32 | -------------------------------------------------------------------------------- /src/it/unnamedPackageClassReference/verify.groovy: -------------------------------------------------------------------------------- 1 | /* 2 | * Licensed to the Apache Software Foundation (ASF) under one 3 | * or more contributor license agreements. See the NOTICE file 4 | * distributed with this work for additional information 5 | * regarding copyright ownership. The ASF licenses this file 6 | * to you under the Apache License, Version 2.0 (the 7 | * "License"); you may not use this file except in compliance 8 | * with the License. You may obtain a copy of the License at 9 | * 10 | * http://www.apache.org/licenses/LICENSE-2.0 11 | * 12 | * Unless required by applicable law or agreed to in writing, 13 | * software distributed under the License is distributed on an 14 | * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 15 | * KIND, either express or implied. See the License for the 16 | * specific language governing permissions and limitations 17 | * under the License. 18 | */ 19 | 20 | def analysis = new File( basedir, 'target/analysis.txt' ).text 21 | 22 | def expected = ''' 23 | UsedDeclaredArtifacts: 24 | 25 | UsedUndeclaredArtifactsWithClasses: 26 | 27 | UnusedDeclaredArtifacts: 28 | dnsjava:dnsjava:jar:2.1.8:compile 29 | 30 | TestArtifactsWithNonTestScope: 31 | ''' 32 | 33 | assert analysis == expected 34 | -------------------------------------------------------------------------------- /src/it/usedUndeclaredReference/pom.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 21 | 22 | 27 | 4.0.0 28 | 29 | org.apache.maven.shared.dependency-analyzer.tests 30 | usedUndeclaredReference 31 | 1.0 32 | jar 33 | 34 | 35 | 36 | dom4j 37 | dom4j 38 | 1.6.1 39 | 40 | 41 | 42 | 43 | 44 | 45 | org.apache.maven.shared.dependency-analyzer.tests 46 | maven-mock-plugin 47 | 1.0 48 | 49 | 50 | 51 | mock-analyze 52 | 53 | 54 | 55 | 56 | 57 | 58 | 59 | 60 | -------------------------------------------------------------------------------- /src/it/usedUndeclaredReference/src/main/java/usedUndeclaredReference/Project.java: -------------------------------------------------------------------------------- 1 | package usedUndeclaredReference; 2 | 3 | /* 4 | * Licensed to the Apache Software Foundation (ASF) under one 5 | * or more contributor license agreements. See the NOTICE file 6 | * distributed with this work for additional information 7 | * regarding copyright ownership. The ASF licenses this file 8 | * to you under the Apache License, Version 2.0 (the 9 | * "License"); you may not use this file except in compliance 10 | * with the License. You may obtain a copy of the License at 11 | * 12 | * http://www.apache.org/licenses/LICENSE-2.0 13 | * 14 | * Unless required by applicable law or agreed to in writing, 15 | * software distributed under the License is distributed on an 16 | * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 17 | * KIND, either express or implied. See the License for the 18 | * specific language governing permissions and limitations 19 | * under the License. 20 | */ 21 | 22 | public class Project 23 | { 24 | public static final Class CLASS_REF = org.apache.xmlcommons.Version.class; 25 | } 26 | -------------------------------------------------------------------------------- /src/it/usedUndeclaredReference/verify.groovy: -------------------------------------------------------------------------------- 1 | /* 2 | * Licensed to the Apache Software Foundation (ASF) under one 3 | * or more contributor license agreements. See the NOTICE file 4 | * distributed with this work for additional information 5 | * regarding copyright ownership. The ASF licenses this file 6 | * to you under the Apache License, Version 2.0 (the 7 | * "License"); you may not use this file except in compliance 8 | * with the License. You may obtain a copy of the License at 9 | * 10 | * http://www.apache.org/licenses/LICENSE-2.0 11 | * 12 | * Unless required by applicable law or agreed to in writing, 13 | * software distributed under the License is distributed on an 14 | * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 15 | * KIND, either express or implied. See the License for the 16 | * specific language governing permissions and limitations 17 | * under the License. 18 | */ 19 | 20 | def analysis = new File( basedir, 'target/analysis.txt' ).text 21 | 22 | def expected = ''' 23 | UsedDeclaredArtifacts: 24 | 25 | UsedUndeclaredArtifactsWithClasses: 26 | 27 | UnusedDeclaredArtifacts: 28 | dom4j:dom4j:jar:1.6.1:compile 29 | 30 | TestArtifactsWithNonTestScope: 31 | ''' 32 | 33 | assert analysis == expected 34 | -------------------------------------------------------------------------------- /src/main/java/org/apache/maven/shared/dependency/analyzer/ClassAnalyzer.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Licensed to the Apache Software Foundation (ASF) under one 3 | * or more contributor license agreements. See the NOTICE file 4 | * distributed with this work for additional information 5 | * regarding copyright ownership. The ASF licenses this file 6 | * to you under the Apache License, Version 2.0 (the 7 | * "License"); you may not use this file except in compliance 8 | * with the License. You may obtain a copy of the License at 9 | * 10 | * http://www.apache.org/licenses/LICENSE-2.0 11 | * 12 | * Unless required by applicable law or agreed to in writing, 13 | * software distributed under the License is distributed on an 14 | * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 15 | * KIND, either express or implied. See the License for the 16 | * specific language governing permissions and limitations 17 | * under the License. 18 | */ 19 | package org.apache.maven.shared.dependency.analyzer; 20 | 21 | import java.io.IOException; 22 | import java.net.URL; 23 | import java.util.Set; 24 | 25 | /** 26 | * Gets the set of classes contained in a library given either as a jar file or an exploded directory. 27 | * 28 | * @author Mark Hobson 29 | */ 30 | public interface ClassAnalyzer { 31 | 32 | /** 33 | *

analyze.

34 | * 35 | * @param url the JAR file or directory to analyze 36 | * @return a {@link java.util.Set} object 37 | * @throws java.io.IOException if any 38 | */ 39 | default Set analyze(URL url) throws IOException { 40 | return analyze(url, new ClassesPatterns()); 41 | } 42 | 43 | /** 44 | *

analyze.

45 | * 46 | * @param url the JAR file or directory to analyze 47 | * @return a {@link java.util.Set} object 48 | * @throws java.io.IOException if any 49 | */ 50 | Set analyze(URL url, ClassesPatterns excludedClasses) throws IOException; 51 | } 52 | -------------------------------------------------------------------------------- /src/main/java/org/apache/maven/shared/dependency/analyzer/ClassFileVisitor.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Licensed to the Apache Software Foundation (ASF) under one 3 | * or more contributor license agreements. See the NOTICE file 4 | * distributed with this work for additional information 5 | * regarding copyright ownership. The ASF licenses this file 6 | * to you under the Apache License, Version 2.0 (the 7 | * "License"); you may not use this file except in compliance 8 | * with the License. You may obtain a copy of the License at 9 | * 10 | * http://www.apache.org/licenses/LICENSE-2.0 11 | * 12 | * Unless required by applicable law or agreed to in writing, 13 | * software distributed under the License is distributed on an 14 | * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 15 | * KIND, either express or implied. See the License for the 16 | * specific language governing permissions and limitations 17 | * under the License. 18 | */ 19 | package org.apache.maven.shared.dependency.analyzer; 20 | 21 | import java.io.InputStream; 22 | 23 | /** 24 | *

ClassFileVisitor interface.

25 | * 26 | * @author Mark Hobson 27 | */ 28 | public interface ClassFileVisitor { 29 | /** 30 | *

visitClass.

31 | * 32 | * @param className a {@link java.lang.String} object. 33 | * @param in a {@link java.io.InputStream} object. 34 | */ 35 | void visitClass(String className, InputStream in); 36 | } 37 | -------------------------------------------------------------------------------- /src/main/java/org/apache/maven/shared/dependency/analyzer/ClassesPatterns.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Licensed to the Apache Software Foundation (ASF) under one 3 | * or more contributor license agreements. See the NOTICE file 4 | * distributed with this work for additional information 5 | * regarding copyright ownership. The ASF licenses this file 6 | * to you under the Apache License, Version 2.0 (the 7 | * "License"); you may not use this file except in compliance 8 | * with the License. You may obtain a copy of the License at 9 | * 10 | * http://www.apache.org/licenses/LICENSE-2.0 11 | * 12 | * Unless required by applicable law or agreed to in writing, 13 | * software distributed under the License is distributed on an 14 | * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 15 | * KIND, either express or implied. See the License for the 16 | * specific language governing permissions and limitations 17 | * under the License. 18 | */ 19 | package org.apache.maven.shared.dependency.analyzer; 20 | 21 | import java.util.Collection; 22 | import java.util.Collections; 23 | import java.util.regex.Pattern; 24 | import java.util.stream.Collectors; 25 | 26 | /** 27 | * Patterns for classes 28 | */ 29 | public class ClassesPatterns { 30 | 31 | private final Collection patterns; 32 | 33 | /** 34 | * Default constructor. 35 | * 36 | * @param patterns a patterns to mach 37 | */ 38 | public ClassesPatterns(Collection patterns) { 39 | if (patterns == null) { 40 | this.patterns = Collections.emptyList(); 41 | } else { 42 | this.patterns = patterns.stream().map(Pattern::compile).collect(Collectors.toSet()); 43 | } 44 | } 45 | 46 | public ClassesPatterns() { 47 | this.patterns = Collections.emptySet(); 48 | } 49 | 50 | public boolean isMatch(String className) { 51 | if (patterns.isEmpty()) { 52 | return false; 53 | } 54 | return patterns.stream().anyMatch(pattern -> pattern.matcher(className).matches()); 55 | } 56 | } 57 | -------------------------------------------------------------------------------- /src/main/java/org/apache/maven/shared/dependency/analyzer/CollectorClassFileVisitor.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Licensed to the Apache Software Foundation (ASF) under one 3 | * or more contributor license agreements. See the NOTICE file 4 | * distributed with this work for additional information 5 | * regarding copyright ownership. The ASF licenses this file 6 | * to you under the Apache License, Version 2.0 (the 7 | * "License"); you may not use this file except in compliance 8 | * with the License. You may obtain a copy of the License at 9 | * 10 | * http://www.apache.org/licenses/LICENSE-2.0 11 | * 12 | * Unless required by applicable law or agreed to in writing, 13 | * software distributed under the License is distributed on an 14 | * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 15 | * KIND, either express or implied. See the License for the 16 | * specific language governing permissions and limitations 17 | * under the License. 18 | */ 19 | package org.apache.maven.shared.dependency.analyzer; 20 | 21 | import java.io.InputStream; 22 | import java.util.HashSet; 23 | import java.util.Set; 24 | 25 | /** 26 | * Simply collects the set of visited classes. 27 | * 28 | * @author Mark Hobson 29 | * @see #getClasses() 30 | */ 31 | public class CollectorClassFileVisitor implements ClassFileVisitor { 32 | private final Set classes; 33 | 34 | private final ClassesPatterns excludedClasses; 35 | 36 | /** 37 | *

Constructor for CollectorClassFileVisitor.

38 | */ 39 | public CollectorClassFileVisitor() { 40 | this(new ClassesPatterns()); 41 | } 42 | 43 | public CollectorClassFileVisitor(ClassesPatterns excludedClasses) { 44 | classes = new HashSet<>(); 45 | this.excludedClasses = excludedClasses; 46 | } 47 | 48 | /** {@inheritDoc} */ 49 | @Override 50 | public void visitClass(String className, InputStream in) { 51 | // inner classes have equivalent compilation requirement as container class 52 | if (className.indexOf('$') < 0 && !excludedClasses.isMatch(className)) { 53 | classes.add(className); 54 | } 55 | } 56 | 57 | /** 58 | *

Getter for the field classes.

59 | * 60 | * @return a {@link java.util.Set} object. 61 | */ 62 | public Set getClasses() { 63 | return classes; 64 | } 65 | } 66 | -------------------------------------------------------------------------------- /src/main/java/org/apache/maven/shared/dependency/analyzer/DefaultClassAnalyzer.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Licensed to the Apache Software Foundation (ASF) under one 3 | * or more contributor license agreements. See the NOTICE file 4 | * distributed with this work for additional information 5 | * regarding copyright ownership. The ASF licenses this file 6 | * to you under the Apache License, Version 2.0 (the 7 | * "License"); you may not use this file except in compliance 8 | * with the License. You may obtain a copy of the License at 9 | * 10 | * http://www.apache.org/licenses/LICENSE-2.0 11 | * 12 | * Unless required by applicable law or agreed to in writing, 13 | * software distributed under the License is distributed on an 14 | * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 15 | * KIND, either express or implied. See the License for the 16 | * specific language governing permissions and limitations 17 | * under the License. 18 | */ 19 | package org.apache.maven.shared.dependency.analyzer; 20 | 21 | import javax.inject.Named; 22 | import javax.inject.Singleton; 23 | 24 | import java.io.IOException; 25 | import java.net.URL; 26 | import java.util.Set; 27 | import java.util.zip.ZipException; 28 | 29 | /** 30 | *

DefaultClassAnalyzer class.

31 | * 32 | * @author Mark Hobson 33 | */ 34 | @Named 35 | @Singleton 36 | public class DefaultClassAnalyzer implements ClassAnalyzer { 37 | 38 | @Override 39 | public Set analyze(URL url, ClassesPatterns excludedClasses) throws IOException { 40 | CollectorClassFileVisitor visitor = new CollectorClassFileVisitor(excludedClasses); 41 | 42 | try { 43 | ClassFileVisitorUtils.accept(url, visitor); 44 | } catch (ZipException e) { 45 | // since the current ZipException gives no indication what jar file is corrupted 46 | // we prefer to wrap another ZipException for better error visibility 47 | ZipException ze = new ZipException("Cannot process Jar entry on URL: " + url + " due to " + e.getMessage()); 48 | ze.initCause(e); 49 | throw ze; 50 | } 51 | 52 | return visitor.getClasses(); 53 | } 54 | } 55 | -------------------------------------------------------------------------------- /src/main/java/org/apache/maven/shared/dependency/analyzer/DependencyAnalyzer.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Licensed to the Apache Software Foundation (ASF) under one 3 | * or more contributor license agreements. See the NOTICE file 4 | * distributed with this work for additional information 5 | * regarding copyright ownership. The ASF licenses this file 6 | * to you under the Apache License, Version 2.0 (the 7 | * "License"); you may not use this file except in compliance 8 | * with the License. You may obtain a copy of the License at 9 | * 10 | * http://www.apache.org/licenses/LICENSE-2.0 11 | * 12 | * Unless required by applicable law or agreed to in writing, 13 | * software distributed under the License is distributed on an 14 | * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 15 | * KIND, either express or implied. See the License for the 16 | * specific language governing permissions and limitations 17 | * under the License. 18 | */ 19 | package org.apache.maven.shared.dependency.analyzer; 20 | 21 | import java.io.IOException; 22 | import java.net.URL; 23 | import java.util.Set; 24 | import java.util.stream.Collectors; 25 | 26 | /** 27 | * Gets the set of classes referenced by a library given either as a jar file or an exploded directory. 28 | * 29 | * @author Mark Hobson 30 | */ 31 | public interface DependencyAnalyzer { 32 | 33 | /** 34 | *

analyze.

35 | * 36 | * @param url the JAR file or directory to analyze 37 | * @return the set of class names referenced by the library 38 | * @throws IOException if an error occurs reading a JAR or .class file 39 | */ 40 | default Set analyze(URL url) throws IOException { 41 | return analyze(url, new ClassesPatterns()); 42 | } 43 | 44 | /** 45 | *

analyze.

46 | * 47 | * @param url the JAR file or directory to analyze 48 | * @param excludeClasses a class list to exclude 49 | * @return the set of class names referenced by the library 50 | * @throws IOException if an error occurs reading a JAR or .class file 51 | */ 52 | default Set analyze(URL url, ClassesPatterns excludeClasses) throws IOException { 53 | return analyzeUsages(url, excludeClasses).stream() 54 | .map(DependencyUsage::getDependencyClass) 55 | .collect(Collectors.toSet()); 56 | } 57 | 58 | /** 59 | *

analyzeUsages.

60 | * 61 | * @param url the JAR file or directory to analyze 62 | * @return the set of class names referenced by the library, paired with the 63 | * classes declaring those references. 64 | * @throws IOException if an error occurs reading a JAR or .class file 65 | */ 66 | Set analyzeUsages(URL url, ClassesPatterns excludeClasses) throws IOException; 67 | } 68 | -------------------------------------------------------------------------------- /src/main/java/org/apache/maven/shared/dependency/analyzer/DependencyUsage.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Licensed to the Apache Software Foundation (ASF) under one 3 | * or more contributor license agreements. See the NOTICE file 4 | * distributed with this work for additional information 5 | * regarding copyright ownership. The ASF licenses this file 6 | * to you under the Apache License, Version 2.0 (the 7 | * "License"); you may not use this file except in compliance 8 | * with the License. You may obtain a copy of the License at 9 | * 10 | * http://www.apache.org/licenses/LICENSE-2.0 11 | * 12 | * Unless required by applicable law or agreed to in writing, 13 | * software distributed under the License is distributed on an 14 | * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 15 | * KIND, either express or implied. See the License for the 16 | * specific language governing permissions and limitations 17 | * under the License. 18 | */ 19 | package org.apache.maven.shared.dependency.analyzer; 20 | 21 | /** 22 | * Usage of a dependency class by a project class. 23 | * 24 | * @author Jonathan Haber 25 | */ 26 | public class DependencyUsage { 27 | 28 | private final String dependencyClass; 29 | 30 | private final String usedBy; 31 | 32 | public DependencyUsage(String dependencyClass, String usedBy) { 33 | this.dependencyClass = dependencyClass; 34 | this.usedBy = usedBy; 35 | } 36 | 37 | /** 38 | * @return the dependency class used by the project class 39 | */ 40 | public String getDependencyClass() { 41 | return dependencyClass; 42 | } 43 | 44 | /** 45 | * @return the project class using the dependency class 46 | */ 47 | public String getUsedBy() { 48 | return usedBy; 49 | } 50 | 51 | /* 52 | * @see java.lang.Object#hashCode() 53 | */ 54 | public int hashCode() { 55 | int hashCode = dependencyClass.hashCode(); 56 | hashCode = (hashCode * 37) + usedBy.hashCode(); 57 | 58 | return hashCode; 59 | } 60 | 61 | /* 62 | * @see java.lang.Object#equals(java.lang.Object) 63 | */ 64 | public boolean equals(Object object) { 65 | if (object instanceof DependencyUsage) { 66 | DependencyUsage usage = (DependencyUsage) object; 67 | 68 | return getDependencyClass().equals(usage.getDependencyClass()) 69 | && getUsedBy().equals(usage.getUsedBy()); 70 | } 71 | 72 | return false; 73 | } 74 | 75 | /* 76 | * @see java.lang.Object#toString() 77 | */ 78 | public String toString() { 79 | StringBuilder buffer = new StringBuilder(); 80 | 81 | buffer.append("dependencyClass=").append(getDependencyClass()); 82 | buffer.append(","); 83 | buffer.append("usedBy=").append(getUsedBy()); 84 | 85 | buffer.insert(0, "["); 86 | buffer.insert(0, getClass().getName()); 87 | 88 | buffer.append("]"); 89 | 90 | return buffer.toString(); 91 | } 92 | } 93 | -------------------------------------------------------------------------------- /src/main/java/org/apache/maven/shared/dependency/analyzer/ProjectDependencyAnalyzer.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Licensed to the Apache Software Foundation (ASF) under one 3 | * or more contributor license agreements. See the NOTICE file 4 | * distributed with this work for additional information 5 | * regarding copyright ownership. The ASF licenses this file 6 | * to you under the Apache License, Version 2.0 (the 7 | * "License"); you may not use this file except in compliance 8 | * with the License. You may obtain a copy of the License at 9 | * 10 | * http://www.apache.org/licenses/LICENSE-2.0 11 | * 12 | * Unless required by applicable law or agreed to in writing, 13 | * software distributed under the License is distributed on an 14 | * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 15 | * KIND, either express or implied. See the License for the 16 | * specific language governing permissions and limitations 17 | * under the License. 18 | */ 19 | package org.apache.maven.shared.dependency.analyzer; 20 | 21 | import java.util.Collection; 22 | 23 | import org.apache.maven.project.MavenProject; 24 | 25 | /** 26 | * Analyze a project's declared dependencies and effective classes used to find which artifacts are: 27 | *
    28 | *
  • used and declared,
  • 29 | *
  • used but not declared,
  • 30 | *
  • not used but declared.
  • 31 | *
  • used but declared in too broad a scope
  • 32 | *
33 | * 34 | * @author Mark Hobson 35 | */ 36 | public interface ProjectDependencyAnalyzer { 37 | 38 | /** 39 | *

analyze.

40 | * 41 | * @param project a {@link org.apache.maven.project.MavenProject} object 42 | * @return a {@link org.apache.maven.shared.dependency.analyzer.ProjectDependencyAnalysis} object 43 | * @throws org.apache.maven.shared.dependency.analyzer.ProjectDependencyAnalyzerException if any 44 | */ 45 | default ProjectDependencyAnalysis analyze(MavenProject project) throws ProjectDependencyAnalyzerException { 46 | return analyze(project, null); 47 | } 48 | 49 | /** 50 | *

analyze.

51 | * 52 | * @param project a {@link org.apache.maven.project.MavenProject} object 53 | * @param excludedClasses collection of regular expression of classes name to exclude 54 | * @return a {@link org.apache.maven.shared.dependency.analyzer.ProjectDependencyAnalysis} object 55 | * @throws org.apache.maven.shared.dependency.analyzer.ProjectDependencyAnalyzerException if any 56 | */ 57 | ProjectDependencyAnalysis analyze(MavenProject project, Collection excludedClasses) 58 | throws ProjectDependencyAnalyzerException; 59 | } 60 | -------------------------------------------------------------------------------- /src/main/java/org/apache/maven/shared/dependency/analyzer/ProjectDependencyAnalyzerException.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Licensed to the Apache Software Foundation (ASF) under one 3 | * or more contributor license agreements. See the NOTICE file 4 | * distributed with this work for additional information 5 | * regarding copyright ownership. The ASF licenses this file 6 | * to you under the Apache License, Version 2.0 (the 7 | * "License"); you may not use this file except in compliance 8 | * with the License. You may obtain a copy of the License at 9 | * 10 | * http://www.apache.org/licenses/LICENSE-2.0 11 | * 12 | * Unless required by applicable law or agreed to in writing, 13 | * software distributed under the License is distributed on an 14 | * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 15 | * KIND, either express or implied. See the License for the 16 | * specific language governing permissions and limitations 17 | * under the License. 18 | */ 19 | package org.apache.maven.shared.dependency.analyzer; 20 | 21 | /** 22 | *

ProjectDependencyAnalyzerException class.

23 | * 24 | * @author Mark Hobson 25 | */ 26 | public class ProjectDependencyAnalyzerException extends Exception { 27 | /** 28 | * The serialisation unique ID. 29 | */ 30 | private static final long serialVersionUID = -5954447543668196977L; 31 | 32 | /** 33 | *

Constructor for ProjectDependencyAnalyzerException.

34 | * 35 | * @param message a {@link java.lang.String} object. 36 | */ 37 | public ProjectDependencyAnalyzerException(String message) { 38 | super(message); 39 | } 40 | 41 | /** 42 | *

Constructor for ProjectDependencyAnalyzerException.

43 | * 44 | * @param message a {@link java.lang.String} object. 45 | * @param cause a {@link java.lang.Throwable} object. 46 | */ 47 | public ProjectDependencyAnalyzerException(String message, Throwable cause) { 48 | super(message, cause); 49 | } 50 | } 51 | -------------------------------------------------------------------------------- /src/main/java/org/apache/maven/shared/dependency/analyzer/asm/ASMDependencyAnalyzer.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Licensed to the Apache Software Foundation (ASF) under one 3 | * or more contributor license agreements. See the NOTICE file 4 | * distributed with this work for additional information 5 | * regarding copyright ownership. The ASF licenses this file 6 | * to you under the Apache License, Version 2.0 (the 7 | * "License"); you may not use this file except in compliance 8 | * with the License. You may obtain a copy of the License at 9 | * 10 | * http://www.apache.org/licenses/LICENSE-2.0 11 | * 12 | * Unless required by applicable law or agreed to in writing, 13 | * software distributed under the License is distributed on an 14 | * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 15 | * KIND, either express or implied. See the License for the 16 | * specific language governing permissions and limitations 17 | * under the License. 18 | */ 19 | package org.apache.maven.shared.dependency.analyzer.asm; 20 | 21 | import javax.inject.Named; 22 | import javax.inject.Singleton; 23 | 24 | import java.io.IOException; 25 | import java.net.URL; 26 | import java.util.Set; 27 | 28 | import org.apache.maven.shared.dependency.analyzer.ClassFileVisitorUtils; 29 | import org.apache.maven.shared.dependency.analyzer.ClassesPatterns; 30 | import org.apache.maven.shared.dependency.analyzer.DependencyAnalyzer; 31 | import org.apache.maven.shared.dependency.analyzer.DependencyUsage; 32 | 33 | /** 34 | * ASMDependencyAnalyzer 35 | * 36 | * @author Mark Hobson 37 | */ 38 | @Named 39 | @Singleton 40 | public class ASMDependencyAnalyzer implements DependencyAnalyzer { 41 | 42 | @Override 43 | public Set analyzeUsages(URL url, ClassesPatterns excludeClasses) throws IOException { 44 | DependencyClassFileVisitor visitor = new DependencyClassFileVisitor(excludeClasses); 45 | 46 | ClassFileVisitorUtils.accept(url, visitor); 47 | 48 | return visitor.getDependencyUsages(); 49 | } 50 | } 51 | -------------------------------------------------------------------------------- /src/main/java/org/apache/maven/shared/dependency/analyzer/asm/DefaultAnnotationVisitor.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Licensed to the Apache Software Foundation (ASF) under one 3 | * or more contributor license agreements. See the NOTICE file 4 | * distributed with this work for additional information 5 | * regarding copyright ownership. The ASF licenses this file 6 | * to you under the Apache License, Version 2.0 (the 7 | * "License"); you may not use this file except in compliance 8 | * with the License. You may obtain a copy of the License at 9 | * 10 | * http://www.apache.org/licenses/LICENSE-2.0 11 | * 12 | * Unless required by applicable law or agreed to in writing, 13 | * software distributed under the License is distributed on an 14 | * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 15 | * KIND, either express or implied. See the License for the 16 | * specific language governing permissions and limitations 17 | * under the License. 18 | */ 19 | package org.apache.maven.shared.dependency.analyzer.asm; 20 | 21 | import org.objectweb.asm.AnnotationVisitor; 22 | import org.objectweb.asm.Opcodes; 23 | import org.objectweb.asm.Type; 24 | 25 | /** 26 | * Computes the set of classes referenced by visited code. 27 | * Inspired by org.objectweb.asm.depend.DependencyVisitor in the ASM dependencies example. 28 | * 29 | * @author Mark Hobson 30 | */ 31 | public class DefaultAnnotationVisitor extends AnnotationVisitor { 32 | private final ResultCollector resultCollector; 33 | 34 | private final String usedByClass; 35 | 36 | /** 37 | *

Constructor for DefaultAnnotationVisitor.

38 | * 39 | * @param resultCollector a {@link org.apache.maven.shared.dependency.analyzer.asm.ResultCollector} object. 40 | */ 41 | public DefaultAnnotationVisitor(ResultCollector resultCollector, String usedByClass) { 42 | super(Opcodes.ASM9); 43 | this.resultCollector = resultCollector; 44 | this.usedByClass = usedByClass; 45 | } 46 | 47 | /** {@inheritDoc} */ 48 | @Override 49 | public void visit(final String name, final Object value) { 50 | if (value instanceof Type) { 51 | resultCollector.addType(usedByClass, (Type) value); 52 | } 53 | } 54 | 55 | /** {@inheritDoc} */ 56 | @Override 57 | public void visitEnum(final String name, final String desc, final String value) { 58 | resultCollector.addDesc(usedByClass, desc); 59 | } 60 | 61 | /** {@inheritDoc} */ 62 | @Override 63 | public AnnotationVisitor visitAnnotation(final String name, final String desc) { 64 | resultCollector.addDesc(usedByClass, desc); 65 | 66 | return this; 67 | } 68 | 69 | /** {@inheritDoc} */ 70 | @Override 71 | public AnnotationVisitor visitArray(final String name) { 72 | return this; 73 | } 74 | } 75 | -------------------------------------------------------------------------------- /src/main/java/org/apache/maven/shared/dependency/analyzer/asm/DefaultFieldVisitor.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Licensed to the Apache Software Foundation (ASF) under one 3 | * or more contributor license agreements. See the NOTICE file 4 | * distributed with this work for additional information 5 | * regarding copyright ownership. The ASF licenses this file 6 | * to you under the Apache License, Version 2.0 (the 7 | * "License"); you may not use this file except in compliance 8 | * with the License. You may obtain a copy of the License at 9 | * 10 | * http://www.apache.org/licenses/LICENSE-2.0 11 | * 12 | * Unless required by applicable law or agreed to in writing, 13 | * software distributed under the License is distributed on an 14 | * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 15 | * KIND, either express or implied. See the License for the 16 | * specific language governing permissions and limitations 17 | * under the License. 18 | */ 19 | package org.apache.maven.shared.dependency.analyzer.asm; 20 | 21 | import org.objectweb.asm.AnnotationVisitor; 22 | import org.objectweb.asm.FieldVisitor; 23 | import org.objectweb.asm.Opcodes; 24 | 25 | /** 26 | * Computes the set of classes referenced by visited code. 27 | * Inspired by org.objectweb.asm.depend.DependencyVisitor in the ASM dependencies example. 28 | * 29 | * @author Mark Hobson 30 | */ 31 | public class DefaultFieldVisitor extends FieldVisitor { 32 | private final AnnotationVisitor annotationVisitor; 33 | 34 | private final ResultCollector resultCollector; 35 | 36 | private final String usedByClass; 37 | 38 | /** 39 | *

Constructor for DefaultFieldVisitor.

40 | * 41 | * @param annotationVisitor a {@link org.objectweb.asm.AnnotationVisitor} object. 42 | * @param resultCollector a {@link org.apache.maven.shared.dependency.analyzer.asm.ResultCollector} object. 43 | */ 44 | public DefaultFieldVisitor( 45 | AnnotationVisitor annotationVisitor, ResultCollector resultCollector, String usedByClass) { 46 | super(Opcodes.ASM9); 47 | this.annotationVisitor = annotationVisitor; 48 | this.resultCollector = resultCollector; 49 | this.usedByClass = usedByClass; 50 | } 51 | 52 | /** {@inheritDoc} */ 53 | @Override 54 | public AnnotationVisitor visitAnnotation(final String desc, final boolean visible) { 55 | resultCollector.addDesc(usedByClass, desc); 56 | 57 | return annotationVisitor; 58 | } 59 | } 60 | -------------------------------------------------------------------------------- /src/main/java/org/apache/maven/shared/dependency/analyzer/asm/DefaultSignatureVisitor.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Licensed to the Apache Software Foundation (ASF) under one 3 | * or more contributor license agreements. See the NOTICE file 4 | * distributed with this work for additional information 5 | * regarding copyright ownership. The ASF licenses this file 6 | * to you under the Apache License, Version 2.0 (the 7 | * "License"); you may not use this file except in compliance 8 | * with the License. You may obtain a copy of the License at 9 | * 10 | * http://www.apache.org/licenses/LICENSE-2.0 11 | * 12 | * Unless required by applicable law or agreed to in writing, 13 | * software distributed under the License is distributed on an 14 | * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 15 | * KIND, either express or implied. See the License for the 16 | * specific language governing permissions and limitations 17 | * under the License. 18 | */ 19 | package org.apache.maven.shared.dependency.analyzer.asm; 20 | 21 | import org.objectweb.asm.Opcodes; 22 | import org.objectweb.asm.signature.SignatureVisitor; 23 | 24 | /** 25 | * Computes the set of classes referenced by visited code. 26 | * Inspired by org.objectweb.asm.depend.DependencyVisitor in the ASM dependencies example. 27 | * 28 | * @author Mark Hobson 29 | */ 30 | public class DefaultSignatureVisitor extends SignatureVisitor { 31 | private final ResultCollector resultCollector; 32 | private final String usedByClass; 33 | 34 | /** 35 | *

Constructor for DefaultSignatureVisitor.

36 | * 37 | * @param resultCollector a {@link org.apache.maven.shared.dependency.analyzer.asm.ResultCollector} object. 38 | */ 39 | public DefaultSignatureVisitor(ResultCollector resultCollector, String usedByClass) { 40 | super(Opcodes.ASM9); 41 | this.resultCollector = resultCollector; 42 | this.usedByClass = usedByClass; 43 | } 44 | 45 | /** {@inheritDoc} */ 46 | @Override 47 | public void visitClassType(final String name) { 48 | resultCollector.addName(usedByClass, name); 49 | } 50 | 51 | /** {@inheritDoc} */ 52 | @Override 53 | public void visitInnerClassType(final String name) { 54 | resultCollector.addName(usedByClass, name); 55 | } 56 | } 57 | -------------------------------------------------------------------------------- /src/main/java/org/apache/maven/shared/dependency/analyzer/asm/VisitClassException.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Licensed to the Apache Software Foundation (ASF) under one 3 | * or more contributor license agreements. See the NOTICE file 4 | * distributed with this work for additional information 5 | * regarding copyright ownership. The ASF licenses this file 6 | * to you under the Apache License, Version 2.0 (the 7 | * "License"); you may not use this file except in compliance 8 | * with the License. You may obtain a copy of the License at 9 | * 10 | * http://www.apache.org/licenses/LICENSE-2.0 11 | * 12 | * Unless required by applicable law or agreed to in writing, 13 | * software distributed under the License is distributed on an 14 | * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 15 | * KIND, either express or implied. See the License for the 16 | * specific language governing permissions and limitations 17 | * under the License. 18 | */ 19 | package org.apache.maven.shared.dependency.analyzer.asm; 20 | 21 | /** 22 | * Exception for processing class. 23 | */ 24 | public class VisitClassException extends RuntimeException { 25 | /** 26 | * A constructor 27 | * @param message message 28 | * @param cause cause of exception 29 | */ 30 | public VisitClassException(String message, Throwable cause) { 31 | super(message, cause); 32 | } 33 | } 34 | -------------------------------------------------------------------------------- /src/site/apt/index.apt.vm: -------------------------------------------------------------------------------- 1 | ----- 2 | Introduction 3 | ----- 4 | Hervé Boutemy 5 | ----- 6 | 2013-07-23 7 | ----- 8 | 9 | ~~ Licensed to the Apache Software Foundation (ASF) under one 10 | ~~ or more contributor license agreements. See the NOTICE file 11 | ~~ distributed with this work for additional information 12 | ~~ regarding copyright ownership. The ASF licenses this file 13 | ~~ to you under the Apache License, Version 2.0 (the 14 | ~~ "License"); you may not use this file except in compliance 15 | ~~ with the License. You may obtain a copy of the License at 16 | ~~ 17 | ~~ http://www.apache.org/licenses/LICENSE-2.0 18 | ~~ 19 | ~~ Unless required by applicable law or agreed to in writing, 20 | ~~ software distributed under the License is distributed on an 21 | ~~ "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 22 | ~~ KIND, either express or implied. See the License for the 23 | ~~ specific language governing permissions and limitations 24 | ~~ under the License. 25 | 26 | ~~ NOTE: For help with the syntax of this file, see: 27 | ~~ http://maven.apache.org/doxia/references/apt-format.html 28 | 29 | ${project.name} 30 | 31 | Analyzes the dependencies of a project for undeclared or unused artifacts. 32 | 33 | <>: Because analysis is done on the bytecode rather than the source, 34 | some cases are not detected including constants, annotations with source-only retention, 35 | and links in Javadoc. This can lead to incorrect results when these are the only uses 36 | of a dependency. 37 | 38 | The main component is <<>> 39 | ({{{./apidocs/org/apache/maven/shared/dependency/analyzer/ProjectDependencyAnalyzer.html}javadoc}}), which uses 40 | <<>> 41 | ({{{./apidocs/org/apache/maven/shared/dependency/analyzer/ClassAnalyzer.html}javadoc}}) 42 | and <<>> 43 | ({{{./apidocs/org/apache/maven/shared/dependency/analyzer/DependencyAnalyzer.html}javadoc}}). 44 | -------------------------------------------------------------------------------- /src/site/resources/download.cgi: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | # 3 | # Licensed to the Apache Software Foundation (ASF) under one 4 | # or more contributor license agreements. See the NOTICE file 5 | # distributed with this work for additional information 6 | # regarding copyright ownership. The ASF licenses this file 7 | # to you under the Apache License, Version 2.0 (the 8 | # "License"); you may not use this file except in compliance 9 | # with the License. You may obtain a copy of the License at 10 | # 11 | # http://www.apache.org/licenses/LICENSE-2.0 12 | # 13 | # Unless required by applicable law or agreed to in writing, 14 | # software distributed under the License is distributed on an 15 | # "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 16 | # KIND, either express or implied. See the License for the 17 | # specific language governing permissions and limitations 18 | # under the License. 19 | # 20 | # Just call the standard mirrors.cgi script. It will use download.html 21 | # as the input template. 22 | exec /www/www.apache.org/dyn/mirrors/mirrors.cgi $* -------------------------------------------------------------------------------- /src/site/site.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 21 | 22 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | 33 | 34 | 35 | 36 | 37 | 38 | 39 | -------------------------------------------------------------------------------- /src/site/xdoc/download.xml.vm: -------------------------------------------------------------------------------- 1 | 2 | 3 | 21 | 22 | 23 | 24 | Download ${project.name} Source 25 | 26 | 27 | 28 |
29 | 30 |

${project.name} ${project.version} is distributed in source format.

31 | 32 |

Use a source archive if you intend to build ${project.name} yourself.

33 | 34 |

Otherwise, simply use the ready-made binary artifacts from central repository.

35 | 36 |

${project.name} is distributed under the Apache License, version 2.0.

37 | 38 | 39 | 40 |

This is the current stable version of ${project.name}.

41 | 42 | 43 | 44 | 45 | 46 | 47 | 48 | 49 | 50 | 51 | 52 | 53 | 54 | 55 | 56 | 57 | 58 | 59 |
LinkChecksumSignature
${project.name} ${project.version} (Source zip)${project.artifactId}-${project.version}-source-release.zip${project.artifactId}-${project.version}-source-release.zip.sha512${project.artifactId}-${project.version}-source-release.zip.asc
60 | 61 |

It is essential that you verify the integrity of the downloaded file 62 | using the checksum (.sha512 file) 63 | or using the signature (.asc file) against the public KEYS used by the Apache Maven developers. 64 |

65 | 66 |
67 | 68 | 69 |

It is strongly recommended to use the latest release version of ${project.name} to take advantage of the newest features and bug fixes.

70 |

Older non-recommended releases can be found on our archive site.

71 |
72 |
73 | 74 |
75 | 76 | -------------------------------------------------------------------------------- /src/test/java/org/apache/maven/shared/dependency/analyzer/ClassesPatternsTest.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Licensed to the Apache Software Foundation (ASF) under one 3 | * or more contributor license agreements. See the NOTICE file 4 | * distributed with this work for additional information 5 | * regarding copyright ownership. The ASF licenses this file 6 | * to you under the Apache License, Version 2.0 (the 7 | * "License"); you may not use this file except in compliance 8 | * with the License. You may obtain a copy of the License at 9 | * 10 | * http://www.apache.org/licenses/LICENSE-2.0 11 | * 12 | * Unless required by applicable law or agreed to in writing, 13 | * software distributed under the License is distributed on an 14 | * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 15 | * KIND, either express or implied. See the License for the 16 | * specific language governing permissions and limitations 17 | * under the License. 18 | */ 19 | package org.apache.maven.shared.dependency.analyzer; 20 | 21 | import java.util.Arrays; 22 | 23 | import org.junit.jupiter.api.Test; 24 | 25 | import static org.junit.jupiter.api.Assertions.assertFalse; 26 | import static org.junit.jupiter.api.Assertions.assertTrue; 27 | 28 | class ClassesPatternsTest { 29 | 30 | @Test 31 | void classPatternsTest() { 32 | ClassesPatterns classesPatterns = new ClassesPatterns(Arrays.asList("Test1.*", "io.example.test.Test2")); 33 | 34 | assertTrue(classesPatterns.isMatch("Test1.Test2")); 35 | assertFalse(classesPatterns.isMatch("Test2.Test2")); 36 | assertTrue(classesPatterns.isMatch("io.example.test.Test2")); 37 | } 38 | 39 | @Test 40 | void emptyClassPatternsTest() { 41 | ClassesPatterns classesPatterns = new ClassesPatterns(); 42 | 43 | assertFalse(classesPatterns.isMatch("Test")); 44 | } 45 | 46 | @Test 47 | void nullClassPatternsTest() { 48 | ClassesPatterns classesPatterns = new ClassesPatterns(null); 49 | 50 | assertFalse(classesPatterns.isMatch("Test")); 51 | } 52 | } 53 | -------------------------------------------------------------------------------- /src/test/java/org/apache/maven/shared/dependency/analyzer/CollectorClassFileVisitorTest.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Licensed to the Apache Software Foundation (ASF) under one 3 | * or more contributor license agreements. See the NOTICE file 4 | * distributed with this work for additional information 5 | * regarding copyright ownership. The ASF licenses this file 6 | * to you under the Apache License, Version 2.0 (the 7 | * "License"); you may not use this file except in compliance 8 | * with the License. You may obtain a copy of the License at 9 | * 10 | * http://www.apache.org/licenses/LICENSE-2.0 11 | * 12 | * Unless required by applicable law or agreed to in writing, 13 | * software distributed under the License is distributed on an 14 | * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 15 | * KIND, either express or implied. See the License for the 16 | * specific language governing permissions and limitations 17 | * under the License. 18 | */ 19 | package org.apache.maven.shared.dependency.analyzer; 20 | 21 | import java.util.HashSet; 22 | import java.util.Set; 23 | 24 | import org.junit.jupiter.api.BeforeEach; 25 | import org.junit.jupiter.api.Test; 26 | 27 | import static org.assertj.core.api.Assertions.assertThat; 28 | 29 | /** 30 | * Tests CollectorClassFileVisitor. 31 | * 32 | * @author Mark Hobson 33 | * @see CollectorClassFileVisitor 34 | */ 35 | class CollectorClassFileVisitorTest { 36 | private CollectorClassFileVisitor visitor; 37 | 38 | @BeforeEach 39 | void setUp() { 40 | visitor = new CollectorClassFileVisitor(); 41 | } 42 | 43 | @Test 44 | void testVisitClass() { 45 | visitor.visitClass("a.b.c", null); 46 | visitor.visitClass("x.y.z", null); 47 | 48 | Set expected = new HashSet<>(); 49 | expected.add("a.b.c"); 50 | expected.add("x.y.z"); 51 | 52 | assertThat(visitor.getClasses()).isEqualTo(expected); 53 | } 54 | } 55 | -------------------------------------------------------------------------------- /src/test/java/org/apache/maven/shared/dependency/analyzer/DefaultClassAnalyzerTest.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Licensed to the Apache Software Foundation (ASF) under one 3 | * or more contributor license agreements. See the NOTICE file 4 | * distributed with this work for additional information 5 | * regarding copyright ownership. The ASF licenses this file 6 | * to you under the Apache License, Version 2.0 (the 7 | * "License"); you may not use this file except in compliance 8 | * with the License. You may obtain a copy of the License at 9 | * 10 | * http://www.apache.org/licenses/LICENSE-2.0 11 | * 12 | * Unless required by applicable law or agreed to in writing, 13 | * software distributed under the License is distributed on an 14 | * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 15 | * KIND, either express or implied. See the License for the 16 | * specific language governing permissions and limitations 17 | * under the License. 18 | */ 19 | package org.apache.maven.shared.dependency.analyzer; 20 | 21 | import java.io.ByteArrayOutputStream; 22 | import java.io.FileOutputStream; 23 | import java.io.IOException; 24 | import java.nio.charset.StandardCharsets; 25 | import java.nio.file.Files; 26 | import java.nio.file.Path; 27 | import java.util.HashSet; 28 | import java.util.Set; 29 | import java.util.jar.JarOutputStream; 30 | import java.util.zip.ZipEntry; 31 | import java.util.zip.ZipException; 32 | 33 | import org.junit.jupiter.api.BeforeEach; 34 | import org.junit.jupiter.api.Test; 35 | import org.junit.jupiter.api.io.TempDir; 36 | 37 | import static org.assertj.core.api.Assertions.assertThat; 38 | import static org.assertj.core.api.Assertions.fail; 39 | 40 | /** 41 | * Tests DefaultClassAnalyzer. 42 | * 43 | * @author Mark Hobson 44 | * @see DefaultClassAnalyzer 45 | */ 46 | class DefaultClassAnalyzerTest { 47 | 48 | @TempDir 49 | private Path tempDir; 50 | 51 | private Path file; 52 | 53 | @BeforeEach 54 | void setUp() throws IOException { 55 | file = Files.createTempFile(tempDir, "test", ".jar"); 56 | try (JarOutputStream out = new JarOutputStream(new FileOutputStream(file.toFile()))) { 57 | addZipEntry(out, "a/b/c.class", "class a.b.c"); 58 | addZipEntry(out, "x/y/z.class", "class x.y.z"); 59 | } 60 | } 61 | 62 | @Test 63 | void testAnalyzeWithJar() throws IOException { 64 | Set expectedClasses = new HashSet<>(); 65 | expectedClasses.add("a.b.c"); 66 | expectedClasses.add("x.y.z"); 67 | 68 | DefaultClassAnalyzer analyzer = new DefaultClassAnalyzer(); 69 | Set actualClasses = analyzer.analyze(file.toUri().toURL()); 70 | 71 | assertThat(actualClasses).isEqualTo(expectedClasses); 72 | } 73 | 74 | @Test 75 | void testAnalyzeBadJar() throws IOException { 76 | // to reproduce MDEP-143 77 | // corrupt the jar file by altering its contents 78 | ByteArrayOutputStream baos = new ByteArrayOutputStream(100); 79 | Files.copy(file, baos); 80 | byte[] ba = baos.toByteArray(); 81 | ba[50] = 1; 82 | Files.write(file, ba); 83 | 84 | ClassAnalyzer analyzer = new DefaultClassAnalyzer(); 85 | 86 | try { 87 | analyzer.analyze(file.toUri().toURL()); 88 | fail("Exception expected"); 89 | } catch (ZipException e) { 90 | assertThat(e).hasMessageStartingWith("Cannot process Jar entry on URL:"); 91 | } 92 | } 93 | 94 | private void addZipEntry(JarOutputStream out, String fileName, String content) throws IOException { 95 | out.putNextEntry(new ZipEntry(fileName)); 96 | byte[] bytes = content.getBytes(StandardCharsets.UTF_8); 97 | out.write(bytes, 0, bytes.length); 98 | } 99 | } 100 | -------------------------------------------------------------------------------- /src/test/java/org/apache/maven/shared/dependency/analyzer/ProjectDependencyAnalysisTest.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Licensed to the Apache Software Foundation (ASF) under one 3 | * or more contributor license agreements. See the NOTICE file 4 | * distributed with this work for additional information 5 | * regarding copyright ownership. The ASF licenses this file 6 | * to you under the Apache License, Version 2.0 (the 7 | * "License"); you may not use this file except in compliance 8 | * with the License. You may obtain a copy of the License at 9 | * 10 | * http://www.apache.org/licenses/LICENSE-2.0 11 | * 12 | * Unless required by applicable law or agreed to in writing, 13 | * software distributed under the License is distributed on an 14 | * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 15 | * KIND, either express or implied. See the License for the 16 | * specific language governing permissions and limitations 17 | * under the License. 18 | */ 19 | package org.apache.maven.shared.dependency.analyzer; 20 | 21 | import java.util.Arrays; 22 | import java.util.HashSet; 23 | import java.util.Set; 24 | 25 | import org.apache.maven.artifact.Artifact; 26 | import org.apache.maven.artifact.DefaultArtifact; 27 | import org.apache.maven.artifact.versioning.VersionRange; 28 | import org.junit.jupiter.api.Test; 29 | 30 | import static org.assertj.core.api.Assertions.assertThat; 31 | 32 | /** 33 | * Tests ProjectDependencyAnalysis. 34 | * 35 | * @author Mark Hobson 36 | * @see ProjectDependencyAnalysis 37 | */ 38 | class ProjectDependencyAnalysisTest { 39 | @Test 40 | void testConstructor() { 41 | Set usedDeclaredArtifacts = new HashSet<>(); 42 | Set usedUndeclaredArtifacts = new HashSet<>(); 43 | Set unusedDeclaredArtifacts = new HashSet<>(); 44 | Set testArtifactsWithNonTestScope = new HashSet<>(); 45 | 46 | ProjectDependencyAnalysis analysis = new ProjectDependencyAnalysis( 47 | usedDeclaredArtifacts, usedUndeclaredArtifacts, unusedDeclaredArtifacts, testArtifactsWithNonTestScope); 48 | 49 | assertThat(analysis.getUsedDeclaredArtifacts()).isEqualTo(usedDeclaredArtifacts); 50 | assertThat(analysis.getUsedUndeclaredArtifacts()).isEqualTo(usedUndeclaredArtifacts); 51 | assertThat(analysis.getUnusedDeclaredArtifacts()).isEqualTo(unusedDeclaredArtifacts); 52 | } 53 | 54 | @Test 55 | void ignoreNonCompileShouldFilterOnlyUnusedDeclare() { 56 | Artifact artifactCompile = aTestArtifact("test1", Artifact.SCOPE_COMPILE); 57 | Artifact artifactProvided = aTestArtifact("test2", Artifact.SCOPE_PROVIDED); 58 | Artifact artifactTest = aTestArtifact("test3", Artifact.SCOPE_TEST); 59 | 60 | ProjectDependencyAnalysis analysis = new ProjectDependencyAnalysis( 61 | asSet(artifactCompile, artifactProvided, artifactTest), 62 | asSet(artifactCompile, artifactProvided, artifactTest), 63 | asSet(artifactCompile, artifactProvided, artifactTest), 64 | asSet(artifactCompile, artifactProvided, artifactTest)); 65 | 66 | ProjectDependencyAnalysis compileOnlyAnalysis = analysis.ignoreNonCompile(); 67 | 68 | assertThat(compileOnlyAnalysis.getUsedDeclaredArtifacts()).hasSize(3); 69 | assertThat(compileOnlyAnalysis.getUsedUndeclaredArtifacts()).hasSize(3); 70 | 71 | assertThat(compileOnlyAnalysis.getUnusedDeclaredArtifacts()).hasSize(1).allSatisfy(a -> assertThat(a.getScope()) 72 | .isEqualTo(Artifact.SCOPE_COMPILE)); 73 | 74 | assertThat(compileOnlyAnalysis.getTestArtifactsWithNonTestScope()).hasSize(3); 75 | } 76 | 77 | private Set asSet(T... items) { 78 | return new HashSet<>(Arrays.asList(items)); 79 | } 80 | 81 | private Artifact aTestArtifact(String artifactId, String scope) { 82 | return new DefaultArtifact( 83 | "groupId", artifactId, VersionRange.createFromVersion("1.0"), scope, "jar", "", null); 84 | } 85 | } 86 | -------------------------------------------------------------------------------- /src/test/java/org/apache/maven/shared/dependency/analyzer/ProjectDependencyAnalyzerExceptionTest.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Licensed to the Apache Software Foundation (ASF) under one 3 | * or more contributor license agreements. See the NOTICE file 4 | * distributed with this work for additional information 5 | * regarding copyright ownership. The ASF licenses this file 6 | * to you under the Apache License, Version 2.0 (the 7 | * "License"); you may not use this file except in compliance 8 | * with the License. You may obtain a copy of the License at 9 | * 10 | * http://www.apache.org/licenses/LICENSE-2.0 11 | * 12 | * Unless required by applicable law or agreed to in writing, 13 | * software distributed under the License is distributed on an 14 | * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 15 | * KIND, either express or implied. See the License for the 16 | * specific language governing permissions and limitations 17 | * under the License. 18 | */ 19 | package org.apache.maven.shared.dependency.analyzer; 20 | 21 | import org.junit.jupiter.api.Test; 22 | 23 | import static org.assertj.core.api.Assertions.assertThat; 24 | 25 | /** 26 | * Tests ProjectDependencyAnalyzerException. 27 | * 28 | * @author Mark Hobson 29 | * @see ProjectDependencyAnalyzerException 30 | */ 31 | class ProjectDependencyAnalyzerExceptionTest { 32 | @Test 33 | void testConstructor() { 34 | assertThat(new ProjectDependencyAnalyzerException("a")).hasMessage("a"); 35 | } 36 | 37 | @Test 38 | void testConstructorWithThrowable() { 39 | Throwable throwable = new Exception(); 40 | ProjectDependencyAnalyzerException exception = new ProjectDependencyAnalyzerException("a", throwable); 41 | 42 | assertThat(exception).hasMessage("a").hasCause(throwable); 43 | } 44 | } 45 | -------------------------------------------------------------------------------- /src/test/java/org/apache/maven/shared/dependency/analyzer/asm/ASMDependencyAnalyzerTest.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Licensed to the Apache Software Foundation (ASF) under one 3 | * or more contributor license agreements. See the NOTICE file 4 | * distributed with this work for additional information 5 | * regarding copyright ownership. The ASF licenses this file 6 | * to you under the Apache License, Version 2.0 (the 7 | * "License"); you may not use this file except in compliance 8 | * with the License. You may obtain a copy of the License at 9 | * 10 | * http://www.apache.org/licenses/LICENSE-2.0 11 | * 12 | * Unless required by applicable law or agreed to in writing, 13 | * software distributed under the License is distributed on an 14 | * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 15 | * KIND, either express or implied. See the License for the 16 | * specific language governing permissions and limitations 17 | * under the License. 18 | */ 19 | package org.apache.maven.shared.dependency.analyzer.asm; 20 | 21 | import java.io.IOException; 22 | import java.net.URL; 23 | import java.nio.file.Path; 24 | import java.nio.file.Paths; 25 | import java.util.Collections; 26 | import java.util.Set; 27 | 28 | import org.apache.maven.shared.dependency.analyzer.ClassesPatterns; 29 | import org.apache.maven.shared.dependency.analyzer.DependencyAnalyzer; 30 | import org.junit.jupiter.api.Test; 31 | 32 | import static org.assertj.core.api.Assertions.assertThat; 33 | 34 | class ASMDependencyAnalyzerTest { 35 | private final DependencyAnalyzer analyzer = new ASMDependencyAnalyzer(); 36 | 37 | @Test 38 | void test() throws Exception { 39 | URL jarUrl = this.getClass().getResource("/org/objectweb/asm/ClassReader.class"); 40 | assertThat(jarUrl).isNotNull(); 41 | String fileUrl = 42 | jarUrl.toString().substring("jar:".length(), jarUrl.toString().indexOf("!/")); 43 | 44 | Set result = analyzer.analyze(new URL(fileUrl)); 45 | 46 | assertThat(result).isNotEmpty(); 47 | } 48 | 49 | @Test 50 | void verifyImplicitClassReferenceIncludedInUsedClasses() throws IOException { 51 | Path file = Paths.get("target/test-classes/org/apache/maven/shared/dependency/analyzer/testcases/analyze"); 52 | 53 | Set result = analyzer.analyze(file.toUri().toURL()); 54 | assertThat(result).contains("org.apache.maven.artifact.resolver.ArtifactResolutionRequest"); 55 | assertThat(result).contains("java.util.regex.Pattern"); 56 | } 57 | 58 | @Test 59 | void verifyExcludedClasses() throws IOException { 60 | Path file = Paths.get("target/test-classes/org/apache/maven/shared/dependency/analyzer/testcases/analyze"); 61 | 62 | Set result = 63 | analyzer.analyze(file.toUri().toURL(), new ClassesPatterns(Collections.singleton("ClassToExclude"))); 64 | assertThat(result).contains("org.apache.maven.artifact.resolver.ArtifactResolutionRequest"); 65 | assertThat(result).doesNotContain("java.util.regex.Pattern"); 66 | assertThat(result) 67 | .doesNotContain("org.apache.maven.shared.dependency.analyzer.testcases.analyze.ClassToExclude"); 68 | } 69 | } 70 | -------------------------------------------------------------------------------- /src/test/java/org/apache/maven/shared/dependency/analyzer/testcases/ArrayCases.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Licensed to the Apache Software Foundation (ASF) under one 3 | * or more contributor license agreements. See the NOTICE file 4 | * distributed with this work for additional information 5 | * regarding copyright ownership. The ASF licenses this file 6 | * to you under the Apache License, Version 2.0 (the 7 | * "License"); you may not use this file except in compliance 8 | * with the License. You may obtain a copy of the License at 9 | * 10 | * http://www.apache.org/licenses/LICENSE-2.0 11 | * 12 | * Unless required by applicable law or agreed to in writing, 13 | * software distributed under the License is distributed on an 14 | * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 15 | * KIND, either express or implied. See the License for the 16 | * specific language governing permissions and limitations 17 | * under the License. 18 | */ 19 | package org.apache.maven.shared.dependency.analyzer.testcases; 20 | 21 | import java.lang.annotation.Annotation; 22 | import java.lang.reflect.Constructor; 23 | 24 | import org.apache.maven.shared.dependency.analyzer.asm.DefaultMethodVisitor; 25 | 26 | public class ArrayCases { 27 | /** 28 | * Cause {@link DefaultMethodVisitor#visitMethodInsn(int, String, String, String, boolean)} to be called 29 | * with primitive array 30 | * @param source 31 | * @return 32 | */ 33 | public int[] primitive(int[] source) { 34 | // causes 35 | return source.clone(); 36 | } 37 | 38 | public void arrayOfArrayCollectedAsReference(Class cls) { 39 | Constructor[] constructors = cls.getConstructors(); 40 | for (Constructor constructor : constructors) { 41 | for (Annotation[] parameters : constructor.getParameterAnnotations()) { 42 | for (Annotation annotation : parameters) { 43 | System.out.println("Class: " + cls + ", Annotation: " + annotation); 44 | } 45 | } 46 | } 47 | } 48 | } 49 | -------------------------------------------------------------------------------- /src/test/java/org/apache/maven/shared/dependency/analyzer/testcases/InnerClassCase.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Licensed to the Apache Software Foundation (ASF) under one 3 | * or more contributor license agreements. See the NOTICE file 4 | * distributed with this work for additional information 5 | * regarding copyright ownership. The ASF licenses this file 6 | * to you under the Apache License, Version 2.0 (the 7 | * "License"); you may not use this file except in compliance 8 | * with the License. You may obtain a copy of the License at 9 | * 10 | * http://www.apache.org/licenses/LICENSE-2.0 11 | * 12 | * Unless required by applicable law or agreed to in writing, 13 | * software distributed under the License is distributed on an 14 | * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 15 | * KIND, either express or implied. See the License for the 16 | * specific language governing permissions and limitations 17 | * under the License. 18 | */ 19 | package org.apache.maven.shared.dependency.analyzer.testcases; 20 | 21 | import java.util.function.Consumer; 22 | 23 | public class InnerClassCase { 24 | public Consumer echoThis() { 25 | return (s) -> System.out.println(s); 26 | } 27 | } 28 | -------------------------------------------------------------------------------- /src/test/java/org/apache/maven/shared/dependency/analyzer/testcases/MethodHandleCases.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Licensed to the Apache Software Foundation (ASF) under one 3 | * or more contributor license agreements. See the NOTICE file 4 | * distributed with this work for additional information 5 | * regarding copyright ownership. The ASF licenses this file 6 | * to you under the Apache License, Version 2.0 (the 7 | * "License"); you may not use this file except in compliance 8 | * with the License. You may obtain a copy of the License at 9 | * 10 | * http://www.apache.org/licenses/LICENSE-2.0 11 | * 12 | * Unless required by applicable law or agreed to in writing, 13 | * software distributed under the License is distributed on an 14 | * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 15 | * KIND, either express or implied. See the License for the 16 | * specific language governing permissions and limitations 17 | * under the License. 18 | */ 19 | package org.apache.maven.shared.dependency.analyzer.testcases; 20 | 21 | import java.util.function.Consumer; 22 | 23 | public class MethodHandleCases { 24 | public void sayHello() { 25 | sayHello(this::callSite); 26 | } 27 | 28 | void sayHello(Consumer consumer) { 29 | consumer.accept("hello"); 30 | } 31 | 32 | private void callSite(String output) { 33 | System.out.println(output); 34 | } 35 | } 36 | -------------------------------------------------------------------------------- /src/test/java/org/apache/maven/shared/dependency/analyzer/testcases/analyze/AnalyzedClass.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Licensed to the Apache Software Foundation (ASF) under one 3 | * or more contributor license agreements. See the NOTICE file 4 | * distributed with this work for additional information 5 | * regarding copyright ownership. The ASF licenses this file 6 | * to you under the Apache License, Version 2.0 (the 7 | * "License"); you may not use this file except in compliance 8 | * with the License. You may obtain a copy of the License at 9 | * 10 | * http://www.apache.org/licenses/LICENSE-2.0 11 | * 12 | * Unless required by applicable law or agreed to in writing, 13 | * software distributed under the License is distributed on an 14 | * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 15 | * KIND, either express or implied. See the License for the 16 | * specific language governing permissions and limitations 17 | * under the License. 18 | */ 19 | package org.apache.maven.shared.dependency.analyzer.testcases.analyze; 20 | 21 | import org.apache.maven.shared.dependency.analyzer.testcases.prepare.Prepare; 22 | 23 | /** 24 | * Class to be analyzed in unit test. 25 | *

26 | * The handler method in {@link Prepare} takes an implicit Consumer<ArtifactResolutionRequest> argument. Analyze 27 | * this class to verify the implicit reference. 28 | */ 29 | public class AnalyzedClass { 30 | 31 | public void useFirst() { 32 | new Prepare().handler(this::doNothing); 33 | } 34 | 35 | private void doNothing(final Object object) {} 36 | } 37 | -------------------------------------------------------------------------------- /src/test/java/org/apache/maven/shared/dependency/analyzer/testcases/analyze/ClassToExclude.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Licensed to the Apache Software Foundation (ASF) under one 3 | * or more contributor license agreements. See the NOTICE file 4 | * distributed with this work for additional information 5 | * regarding copyright ownership. The ASF licenses this file 6 | * to you under the Apache License, Version 2.0 (the 7 | * "License"); you may not use this file except in compliance 8 | * with the License. You may obtain a copy of the License at 9 | * 10 | * http://www.apache.org/licenses/LICENSE-2.0 11 | * 12 | * Unless required by applicable law or agreed to in writing, 13 | * software distributed under the License is distributed on an 14 | * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 15 | * KIND, either express or implied. See the License for the 16 | * specific language governing permissions and limitations 17 | * under the License. 18 | */ 19 | package org.apache.maven.shared.dependency.analyzer.testcases.analyze; 20 | 21 | import java.util.regex.Pattern; 22 | 23 | /** 24 | * Class to be skipped during analyzed in unit test. 25 | */ 26 | public class ClassToExclude { 27 | private void doNothing(final Pattern pattern) {} 28 | } 29 | -------------------------------------------------------------------------------- /src/test/java/org/apache/maven/shared/dependency/analyzer/testcases/prepare/Prepare.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Licensed to the Apache Software Foundation (ASF) under one 3 | * or more contributor license agreements. See the NOTICE file 4 | * distributed with this work for additional information 5 | * regarding copyright ownership. The ASF licenses this file 6 | * to you under the Apache License, Version 2.0 (the 7 | * "License"); you may not use this file except in compliance 8 | * with the License. You may obtain a copy of the License at 9 | * 10 | * http://www.apache.org/licenses/LICENSE-2.0 11 | * 12 | * Unless required by applicable law or agreed to in writing, 13 | * software distributed under the License is distributed on an 14 | * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 15 | * KIND, either express or implied. See the License for the 16 | * specific language governing permissions and limitations 17 | * under the License. 18 | */ 19 | package org.apache.maven.shared.dependency.analyzer.testcases.prepare; 20 | 21 | import java.util.function.Consumer; 22 | 23 | import org.apache.maven.artifact.resolver.ArtifactResolutionRequest; 24 | import org.apache.maven.artifact.resolver.ResolutionErrorHandler; 25 | 26 | /** 27 | * Class to be used for verifying that analyzer picks up usage of classes with no import. 28 | */ 29 | public class Prepare { 30 | 31 | @SuppressWarnings("checkstyle:UnusedLocalVariable") 32 | public void handler(Consumer consumer) { 33 | ResolutionErrorHandler resolutionErrorHandler = (request, result) -> { 34 | consumer.accept(request); 35 | }; 36 | } 37 | } 38 | -------------------------------------------------------------------------------- /src/test/resources/org/apache/maven/shared/dependency/analyzer/commons-bcel-issue362/Bcel362.classx: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/apache/maven-dependency-analyzer/71c0554ec346c175e7d5f2874a7b0de4bf504041/src/test/resources/org/apache/maven/shared/dependency/analyzer/commons-bcel-issue362/Bcel362.classx -------------------------------------------------------------------------------- /src/test/resources/org/apache/maven/shared/dependency/analyzer/commons-bcel-issue362/Bcel362.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Licensed to the Apache Software Foundation (ASF) under one or more 3 | * contributor license agreements. See the NOTICE file distributed with 4 | * this work for additional information regarding copyright ownership. 5 | * The ASF licenses this file to You under the Apache License, Version 2.0 6 | * (the "License"); you may not use this file except in compliance with 7 | * the License. You may obtain a copy of the License at 8 | * 9 | * http://www.apache.org/licenses/LICENSE-2.0 10 | * 11 | * Unless required by applicable law or agreed to in writing, software 12 | * distributed under the License is distributed on an "AS IS" BASIS, 13 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | * See the License for the specific language governing permissions and 15 | * limitations under the License. 16 | */ 17 | 18 | package issue362; 19 | 20 | /** 21 | * Compile to Java 11 byte code, then instrument with JaCoCo in order to add 22 | * condy (constant dynamic) instructions 23 | */ 24 | public class Bcel362 { 25 | public static void main(String[] args) { 26 | System.out.println("Hello world!"); 27 | } 28 | } 29 | -------------------------------------------------------------------------------- /src/test/resources/org/apache/maven/shared/dependency/analyzer/ossfuzz/issue51980/Test.class.clazz: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/apache/maven-dependency-analyzer/71c0554ec346c175e7d5f2874a7b0de4bf504041/src/test/resources/org/apache/maven/shared/dependency/analyzer/ossfuzz/issue51980/Test.class.clazz -------------------------------------------------------------------------------- /src/test/resources/org/apache/maven/shared/dependency/analyzer/ossfuzz/issue51989/Test.class.clazz: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/apache/maven-dependency-analyzer/71c0554ec346c175e7d5f2874a7b0de4bf504041/src/test/resources/org/apache/maven/shared/dependency/analyzer/ossfuzz/issue51989/Test.class.clazz -------------------------------------------------------------------------------- /src/test/resources/org/apache/maven/shared/dependency/analyzer/ossfuzz/issue52168/Test.class.clazz: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/apache/maven-dependency-analyzer/71c0554ec346c175e7d5f2874a7b0de4bf504041/src/test/resources/org/apache/maven/shared/dependency/analyzer/ossfuzz/issue52168/Test.class.clazz -------------------------------------------------------------------------------- /src/test/resources/org/apache/maven/shared/dependency/analyzer/ossfuzz/issue53543/Test.class.clazz: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/apache/maven-dependency-analyzer/71c0554ec346c175e7d5f2874a7b0de4bf504041/src/test/resources/org/apache/maven/shared/dependency/analyzer/ossfuzz/issue53543/Test.class.clazz -------------------------------------------------------------------------------- /src/test/resources/org/apache/maven/shared/dependency/analyzer/ossfuzz/issue53544a/Test.class.clazz: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/apache/maven-dependency-analyzer/71c0554ec346c175e7d5f2874a7b0de4bf504041/src/test/resources/org/apache/maven/shared/dependency/analyzer/ossfuzz/issue53544a/Test.class.clazz -------------------------------------------------------------------------------- /src/test/resources/org/apache/maven/shared/dependency/analyzer/ossfuzz/issue53620/Test.class.clazz: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/apache/maven-dependency-analyzer/71c0554ec346c175e7d5f2874a7b0de4bf504041/src/test/resources/org/apache/maven/shared/dependency/analyzer/ossfuzz/issue53620/Test.class.clazz -------------------------------------------------------------------------------- /src/test/resources/org/apache/maven/shared/dependency/analyzer/ossfuzz/issue53676/Test.class.clazz: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/apache/maven-dependency-analyzer/71c0554ec346c175e7d5f2874a7b0de4bf504041/src/test/resources/org/apache/maven/shared/dependency/analyzer/ossfuzz/issue53676/Test.class.clazz -------------------------------------------------------------------------------- /src/test/resources/org/apache/maven/shared/dependency/analyzer/ossfuzz/issue54119/Test.class.clazz: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/apache/maven-dependency-analyzer/71c0554ec346c175e7d5f2874a7b0de4bf504041/src/test/resources/org/apache/maven/shared/dependency/analyzer/ossfuzz/issue54119/Test.class.clazz -------------------------------------------------------------------------------- /src/test/resources/org/apache/maven/shared/dependency/analyzer/ossfuzz/issue54254/Test.class.clazz: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/apache/maven-dependency-analyzer/71c0554ec346c175e7d5f2874a7b0de4bf504041/src/test/resources/org/apache/maven/shared/dependency/analyzer/ossfuzz/issue54254/Test.class.clazz -------------------------------------------------------------------------------- /src/test/resources/org/apache/maven/shared/dependency/analyzer/record-invokedynamic/RecordInvokeDynamic.classx: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/apache/maven-dependency-analyzer/71c0554ec346c175e7d5f2874a7b0de4bf504041/src/test/resources/org/apache/maven/shared/dependency/analyzer/record-invokedynamic/RecordInvokeDynamic.classx -------------------------------------------------------------------------------- /src/test/resources/org/apache/maven/shared/dependency/analyzer/record-invokedynamic/RecordInvokeDynamic.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Licensed to the Apache Software Foundation (ASF) under one or more 3 | * contributor license agreements. See the NOTICE file distributed with 4 | * this work for additional information regarding copyright ownership. 5 | * The ASF licenses this file to You under the Apache License, Version 2.0 6 | * (the "License"); you may not use this file except in compliance with 7 | * the License. You may obtain a copy of the License at 8 | * 9 | * http://www.apache.org/licenses/LICENSE-2.0 10 | * 11 | * Unless required by applicable law or agreed to in writing, software 12 | * distributed under the License is distributed on an "AS IS" BASIS, 13 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | * See the License for the specific language governing permissions and 15 | * limitations under the License. 16 | */ 17 | 18 | package recordinvokedynamic; 19 | 20 | // javac --release 17 RecordInvokeDynamic.java 21 | public record RecordInvokeDynamic(String a) { 22 | } 23 | --------------------------------------------------------------------------------