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

Feature Request: Support for Publishing POM Artifacts #3206

Closed
teeckoo opened this issue Jun 14, 2024 · 2 comments · Fixed by #3222
Closed

Feature Request: Support for Publishing POM Artifacts #3206

teeckoo opened this issue Jun 14, 2024 · 2 comments · Fixed by #3222
Milestone

Comments

@teeckoo
Copy link

teeckoo commented Jun 14, 2024

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:

  • Facilitates better project structure and dependency management.
  • Aligns with common practices in Maven, making it easier for users transitioning from Maven to Mill.
  • Enhances Mill's flexibility and usability for complex project setups.

Thank you for considering this feature request!

@lefou
Copy link
Member

lefou commented Jun 14, 2024

I see two task to implement this:

  • Support pom-packaging type in PublishModule
  • (optional?) Create a stipped down version of JavaModule, which has dependency management but no compilation setup (This is needed to handle pom-packaging modules locally when resolving modules transitively. It may also become handy as a leaner baseline for concrete run modules, which need to resolve their deps but don't want to compile anything.)

@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?

@teeckoo
Copy link
Author

teeckoo commented Jun 14, 2024

@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

lefou added a commit that referenced this issue Jun 20, 2024
Added new `PublishModuleTests` test suite and moved all publish test there.

Fix #3206
@lefou lefou closed this as completed in 4f6742d Jun 21, 2024
@lefou lefou added this to the 0.11.8 milestone Jun 21, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants