Here's ChatGPT's answer... :-)

To create a common `reportSet` that is applied to all child projects
but not activated in the parent POM itself, you can use a few Maven
techniques, such as creating a profile or leveraging inheritance in a
way that allows the children to inherit the `reportSet` but prevents
the parent project from running the reports.

Here’s a general approach you can take to solve this:

### 1. Use a Reporting Plugin in a Profile
You can define the `reportSet` inside a profile in the parent POM and
activate the profile only for the child projects. This way, the
reporting configuration will be inherited by the children, but the
parent won't execute the reports unless the profile is explicitly
activated for the parent.

#### Steps:
- Define a profile for reporting in the parent POM.
- The profile should include your `reportSet`.
- Use conditions (such as activation by default for child modules
only) to ensure that the reports are only active in child projects.

#### Example:

```xml
<project>
  <!-- Parent POM -->
  <groupId>com.example</groupId>
  <artifactId>parent-project</artifactId>
  <version>1.0-SNAPSHOT</version>
  <packaging>pom</packaging>

  <profiles>
    <profile>
      <id>child-reporting</id>
      <activation>
        <!-- This ensures the profile is activated for child projects -->
        <property>
          <name>!skip-reports</name>
        </property>
      </activation>

      <build>
        <plugins>
          <!-- Reporting plugin configuration -->
          <plugin>
            <groupId>org.apache.maven.plugins</groupId>
            <artifactId>maven-site-plugin</artifactId>
            <version>3.9.1</version>
            <reportSets>
              <reportSet>
                <id>my-reports</id>
                <reports>
                  <report>report1</report>
                  <report>report2</report>
                  <!-- Define reports you want in child modules -->
                </reports>
              </reportSet>
            </reportSets>
          </plugin>
        </plugins>
      </build>
    </profile>
  </profiles>

  <!-- You can add <modules> here for child projects -->
</project>
```

### 2. Activate the Profile in Child Projects
In each child module, you can ensure that the profile is activated by
default. If you want the parent to never run the reports, you can
activate the profile in child projects only.

In each child POM, add the following:

```xml
<project>
  <parent>
    <groupId>com.example</groupId>
    <artifactId>parent-project</artifactId>
    <version>1.0-SNAPSHOT</version>
  </parent>

  <properties>
    <!-- Ensure reports are not skipped in child -->
    <skip-reports>false</skip-reports>
  </properties>

  <!-- No need to add reporting here, it will be inherited from the parent -->
</project>
```

### 3. Optional: Skipping Reports in the Parent
If you want to ensure that reports are always skipped in the parent
but activated in the children, you can define a property in the parent
that disables the profile:

```xml
<project>
  <properties>
    <skip-reports>true</skip-reports>
  </properties>
</project>
```

### Summary of the Approach:
- **Parent POM**: Define a reporting profile that includes the `reportSet`.
- **Profile Activation**: Control profile activation via a property
(`skip-reports`) that is defined in the parent but can be overridden
in the children.
- **Child Modules**: In child projects, override the property to
enable reporting by setting `skip-reports` to `false`.

This way, your child modules inherit and apply the `reportSet`, but
the parent POM does not run reports unless you explicitly activate the
profile.

Le ven. 6 sept. 2024 à 11:10, Konrad Windszus <k...@apache.org> a écrit :
>
> Hi,
> Unlike plugin (with plugin management and its configuration) the reportSet 
> (https://maven.apache.org/ref/3.9.9/maven-model/maven.html#class_reportSet) 
> cannot be configured on a POM level which itself should not have the 
> configured reports.
> Once a reportSuite is configured it is active both on the current project and 
> inheriting ones. What I want to achieve is a common report set for all 
> children without being active on the parent itself.
> Any idea?
>
> Thanks in advance,
> Konrad
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: dev-unsubscr...@maven.apache.org
> For additional commands, e-mail: dev-h...@maven.apache.org
>


-- 
------------------------
Guillaume Nodet

---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscr...@maven.apache.org
For additional commands, e-mail: dev-h...@maven.apache.org

Reply via email to