Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[BUG] Mapstruct processor dependency is deleted #76

Closed
afillatre opened this issue Apr 11, 2021 · 3 comments · Fixed by #82
Closed

[BUG] Mapstruct processor dependency is deleted #76

afillatre opened this issue Apr 11, 2021 · 3 comments · Fixed by #82
Assignees
Labels
bug Something isn't working

Comments

@afillatre
Copy link
Contributor

afillatre commented Apr 11, 2021

Describe the bug
After depclean completes, and given mapstruct processor is used, the mapstruct-processor direct dependency is not longer present on the debloated pom.xml

To Reproduce
Steps to reproduce the behavior:

  1. Configure the maven-processor-plugin to use the mapstruct annotation
      <plugin>
        <groupId>org.bsc.maven</groupId>
        <artifactId>maven-processor-plugin</artifactId>
        <executions>
          <execution>
            <id>process</id>
            <goals>
              <goal>process</goal>
            </goals>
            <phase>generate-sources</phase>
            <configuration>
              <processors>
                <processor>org.mapstruct.ap.MappingProcessor</processor>
              </processors>
            </configuration>
          </execution>
        </executions>
      </plugin>
  1. Add required mapstruct dependencies
    <dependency>
      <groupId>org.mapstruct</groupId>
      <artifactId>mapstruct</artifactId>
    </dependency>
    <dependency>
      <groupId>org.mapstruct</groupId>
      <artifactId>mapstruct-processor</artifactId>
      <scope>provided</scope>
    </dependency>
  1. Run depclean with debloated-pom generation

Expected behavior
mapstruct-processor dependency is conserved

Additional context
Mapstruct generates code during the generated-sources phase, but do not keep mapstruct-processor imports in the generated classes. This may be why it is eventually removed from the debloated-pom.

One could manually list this dependency into the ignoreDependencies configuration, but it may be better to consider annotation processor classes to be rightful provided dependencies

@afillatre afillatre added the bug Something isn't working label Apr 11, 2021
@afillatre afillatre changed the title [BUG] Mapstruct processor is deleted [BUG] Mapstruct processor dependency is deleted Apr 11, 2021
@cesarsotovalero
Copy link
Collaborator

cesarsotovalero commented Apr 11, 2021

Hi @afillatre, thanks for reporting this issue.

Can you please give more details about your proposal?

... but it may be better to consider annotation processor classes to be rightful provided dependencies

@cesarsotovalero cesarsotovalero self-assigned this Apr 11, 2021
@afillatre
Copy link
Contributor Author

Yes. Given this plugin configuration

      <plugin>
        <groupId>org.bsc.maven</groupId>
        <artifactId>maven-processor-plugin</artifactId>
        <executions>
          <execution>
            <id>process</id>
            <goals>
              <goal>process</goal>
            </goals>
            <phase>generate-sources</phase>
            <configuration>
              <processors>
                <processor>org.mapstruct.ap.MappingProcessor</processor>
              </processors>
            </configuration>
          </execution>
        </executions>
      </plugin>

Depclean could consider org.mapstruct.ap.MappingProcessor to be rightfully part of the project, and add it to the Dependency Usage Analysis, because it is declared in the pom as a processor

@cesarsotovalero
Copy link
Collaborator

cesarsotovalero commented Apr 11, 2021

Hi@afillatre, I understand your proposal.

It is definitely not difficult to implement some rules that analyze the xml pom to consider this and other similar usage cases. Thus, excluding some false positives (such as in the case of processors).

I'll implement the pom rule parser ASAP.

In case you feel comfortable with the task, the debloated-pom is generated here: https://github.com/castor-software/depclean/blob/master/depclean-maven-plugin/src/main/java/se/kth/depclean/DepCleanMojo.java#L586-L658.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants