com-lihaoyi / mill

Your shiny new Java/Scala build tool!
https://mill-build.com/
MIT License
1.99k stars 303 forks source link

Feature Request: Support for Publishing POM Artifacts #3206

Closed tecklead closed 2 weeks ago

tecklead commented 3 weeks ago

Description:

In Maven, the packaging attribute allows for publishing pom artifacts. This is particularly useful for creating parent POMs that can be used as dependencies in other projects. Here is an example of how this works in Maven: Example POM Configuration:

<groupId>com.example</groupId>
<artifactId>abc-starter</artifactId>
<version>1.1-SNAPSHOT</version>
<packaging>pom</packaging>

With the above configuration, the com.example.abc-starter artifact can be referenced as a parent in another POM: Example Usage in a Consumer POM:

<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0"
         xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
         xsi:schemaLocation="http://maven.apache.org/xsd/maven-4.0.0.xsd">
    <modelVersion>4.0.0</modelVersion>

    <parent>
        <groupId>com.example</groupId>
        <artifactId>abc-starter</artifactId>
        <version>1.1-SNAPSHOT</version>
    </parent>

</project>

Request:

It would be highly beneficial if Mill could provide similar support for publishing pom artifacts. This would allow for the creation of parent POMs that can be used as dependencies in consumer POMs using the same syntax as shown above.

Benefits:

Thank you for considering this feature request!

lefou commented 3 weeks ago

I see two task to implement this:

@tecklead Can you clarify whether in Maven pom-packaging modules compilation is possible at all? Is it optional or even disallowed? Can pom-packaging modules have tests?

tecklead commented 3 weeks ago

@lefou In our case, we don't have any code/tests in pom-packaging modules. referred springboot-starter-web and looks like they also don't have any code.

IMHO, In Maven, when you define a module with pom packaging, it serves as a container for other modules but does not produce a deployable artifact like a JAR or WAR. This is typically used for parent projects that aggregate several sub-modules.

POM Packaging Module:
    A module with <packaging>pom</packaging> does not produce a JAR or WAR.
    It is primarily used to manage and build multiple sub-modules as a single unit.
    This type of module often contains configuration that is inherited by sub-modules, such as dependency management, plugin configurations, and build settings.

Dependency Resolution:
    When a module with pom packaging is used as a dependency, Maven will download the POM file of that module.
    The downloaded POM file may contain dependency management, plugins, and other settings that will be applied to the consuming project.

Spring Boot Starters:
    Spring Boot starters, such as spring-boot-starter-web, typically depend on multiple libraries needed for a particular use case (like web development).
    These starters usually use jar packaging, but they pull in other dependencies that provide the actual implementation.

Testing in POM Modules:
    It is common not to have code or tests directly in a POM packaging module.
    Tests are generally placed in sub-modules that produce deployable artifacts.

References :-

https://maven.apache.org/pom.html#aggregation-or-multi-module https://www.baeldung.com/maven-packaging-types