Skip to content

Refactoring and support of <release> and <module> elements #320

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

Merged
merged 14 commits into from
May 4, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .github/workflows/maven-verify.yml
Original file line number Diff line number Diff line change
Expand Up @@ -28,4 +28,4 @@ jobs:
with:
jdk-distribution-matrix: '[ "temurin", "zulu", "microsoft", "adopt-openj9" ]'
maven4-build: true
maven4-version: '4.0.0-rc-2' # the same as used in project
maven4-version: '4.0.0-rc-3' # the same as used in project
20 changes: 13 additions & 7 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -21,9 +21,9 @@ Contributing to [Apache Maven Compiler Plugin](https://maven.apache.org/plugins/
[![Maven Central](https://img.shields.io/maven-central/v/org.apache.maven.plugins/maven-compiler-plugin.svg?label=Maven%20Central&versionPrefix=3.)](https://search.maven.org/artifact/org.apache.maven.plugins/maven-compiler-plugin)
[![Maven Central](https://img.shields.io/maven-central/v/org.apache.maven.plugins/maven-compiler-plugin.svg?label=Maven%20Central)](https://search.maven.org/artifact/org.apache.maven.plugins/maven-compiler-plugin)
[![Reproducible Builds](https://img.shields.io/endpoint?url=https://raw.githubusercontent.com/jvm-repo-rebuild/reproducible-central/master/content/org/apache/maven/plugins/maven-compiler-plugin/badge.json)](https://github.com/jvm-repo-rebuild/reproducible-central/blob/master/content/org/apache/maven/plugins/maven-compiler-plugin/README.md)
<!--
<!--
[![Jenkins Status](https://img.shields.io/jenkins/s/https/ci-maven.apache.org/job/Maven/job/maven-box/job/maven-compiler-plugin/job/master.svg?)][build]
[![Jenkins tests](https://img.shields.io/jenkins/t/https/ci-maven.apache.org/job/Maven/job/maven-box/job/maven-compiler-plugin/job/master.svg?)][test-results]
[![Jenkins tests](https://img.shields.io/jenkins/t/https/ci-maven.apache.org/job/Maven/job/maven-box/job/maven-compiler-plugin/job/master.svg?)][test-results]
-->


Expand All @@ -37,28 +37,34 @@ Getting Started
---------------

+ Make sure you have a [GitHub account](https://github.com/signup/free).
+ If you're planning to implement a new feature, it makes sense to discuss your changes
on the [dev list][ml-list] first.
This way you can make sure you're not wasting your time on something that isn't
+ If you're planning to implement a new feature, it makes sense to discuss your changes
on the [dev list][ml-list] first.
This way you can make sure you're not wasting your time on something that isn't
considered to be in Apache Maven's scope.
+ Submit a ticket for your issue, assuming one does not already exist.
+ Clearly describe the issue, including steps to reproduce when it is a bug.
+ Make sure you fill in the earliest version that you know has the issue.
+ Fork the repository on GitHub.

Build requirements
--------------

Building requires Maven 4. Executing the tests on Windows requires the developer mode.
This is enabled with _Settings_ > _Update & Security_ > _For Developers_.

Making and Submitting Changes
--------------

We accept Pull Requests via GitHub. The [developer mailing list][ml-list] is the
main channel of communication for contributors.
main channel of communication for contributors.
There are some guidelines which will make applying PRs easier for us:
+ Create a topic branch from where you want to base your work (this is usually the master branch).
Push your changes to a topic branch in your fork of the repository.
+ Make commits of logical units.
+ Respect the original code style: by using the same [codestyle][code-style],
patches should only highlight the actual difference, not being disturbed by any formatting issues:
+ Only use spaces for indentation.
+ Create minimal diffs - disable on save actions like reformat source code or organize imports.
+ Create minimal diffs - disable on save actions like reformat source code or organize imports.
If you feel the source code should be reformatted, create a separate PR for this change.
+ Check for unnecessary whitespace with `git diff --check` before committing.
+ Make sure you have added the necessary tests (JUnit/IT) for your changes.
Expand Down
4 changes: 2 additions & 2 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -82,12 +82,12 @@ under the License.

<properties>
<javaVersion>17</javaVersion>
<mavenVersion>4.0.0-rc-2</mavenVersion>
<mavenVersion>4.0.0-rc-3</mavenVersion>

<asmVersion>9.7.1</asmVersion>
<guiceVersion>6.0.0</guiceVersion>
<mockitoVersion>5.17.0</mockitoVersion>
<mavenPluginTestingHarnessVersion>4.0.0-beta-3</mavenPluginTestingHarnessVersion>
<mavenPluginTestingHarnessVersion>4.0.0-beta-4</mavenPluginTestingHarnessVersion>
<plexusCompilerVersion>2.15.0</plexusCompilerVersion>
<sisuPlexusVersion>0.9.0.M2</sisuPlexusVersion>
<version.maven-plugin-tools-3.x>3.13.1</version.maven-plugin-tools-3.x>
Expand Down
2 changes: 1 addition & 1 deletion src/it/MCOMPILER-192/verify.groovy
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ assert logFile.exists()
def content = logFile.getText('UTF-8')

def causedByExpected = content.contains ( 'Caused by: org.apache.maven.plugin.compiler.CompilationFailureException:' )
def twoFilesBeingCompiled = content.contains ( 'Compiling 2 source files' )
def twoFilesBeingCompiled = content.contains ( 'Compiling all files' )
def checkResult = content.contains ( 'BUILD FAILURE' )
def compilationFailure1 = content.contains( '[ERROR] Failed to execute goal org.apache.maven.plugins:maven-compiler-plugin:')
def compilationFailure2 = content.contains( ':compile (default-compile) on project blah: Cannot compile')
Expand Down
13 changes: 11 additions & 2 deletions src/it/MCOMPILER-346/verify.groovy
Original file line number Diff line number Diff line change
Expand Up @@ -21,5 +21,14 @@ def logFile = new File( basedir, 'build.log' )
assert logFile.exists()
content = logFile.text

assert content.contains( 'package org.jenkinsci.test.acceptance.controller does not exist' )
assert content.contains( 'package org.jenkinsci.test.acceptance.log does not exist' )
/*
* The messages expected by this test were:
*
* - package org.jenkinsci.test.acceptance.controller does not exist
* - package org.jenkinsci.test.acceptance.log does not exist
*
* But we cannot test the full messages as shown above because they may be localized.
* Test only the package name on the assumption that they will be present in all locales.
*/
assert content.contains( 'org.jenkinsci.test.acceptance.controller' )
assert content.contains( 'org.jenkinsci.test.acceptance.log' )
2 changes: 1 addition & 1 deletion src/it/MCOMPILER-366/verify.groovy
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,6 @@

buildLog = new File( basedir, 'build.log' ).text;

assert buildLog.contains("[WARNING] Filename-based automodules detected on the module-path:")
assert buildLog.contains("[WARNING] Filename-based automodules detected on the module path:")
assert buildLog.contains(" - plexus-utils-3.0.24.jar")
assert buildLog.contains(" - plexus-resources-1.1.0.jar")
2 changes: 1 addition & 1 deletion src/it/automodules-application/verify.groovy
Original file line number Diff line number Diff line change
Expand Up @@ -19,5 +19,5 @@

buildLog = new File( basedir, 'build.log' ).text;

assert buildLog.contains("[WARNING] Filename-based automodules detected on the module-path:")
assert buildLog.contains("[WARNING] Filename-based automodules detected on the module path:")
assert buildLog.contains(" - plexus-utils-3.0.24.jar")
2 changes: 1 addition & 1 deletion src/it/automodules-library/verify.groovy
Original file line number Diff line number Diff line change
Expand Up @@ -19,5 +19,5 @@

buildLog = new File( basedir, 'build.log' ).text;

assert buildLog.contains("[WARNING] Filename-based automodules detected on the module-path:")
assert buildLog.contains("[WARNING] Filename-based automodules detected on the module path:")
assert buildLog.contains(" - plexus-utils-3.0.24.jar")
2 changes: 1 addition & 1 deletion src/it/automodules-manifest/verify.groovy
Original file line number Diff line number Diff line change
Expand Up @@ -19,4 +19,4 @@

buildLog = new File( basedir, 'build.log' ).text;

assert !buildLog.contains("Filename-based automodules detected on the module-path")
assert !buildLog.contains("Filename-based automodules detected on the module path")
2 changes: 1 addition & 1 deletion src/it/automodules-transitive-module/verify.groovy
Original file line number Diff line number Diff line change
Expand Up @@ -19,5 +19,5 @@

buildLog = new File( basedir, 'build.log' ).text;

assert buildLog.contains("[WARNING] Filename-based automodules detected on the module-path:")
assert buildLog.contains("[WARNING] Filename-based automodules detected on the module path:")
assert buildLog.contains(" - plexus-utils-3.0.24.jar")
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
* under the License.
*/

module foo {
module foo.bar {
requires org.apache.commons.lang3;

exports foo;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,6 @@ void constructor() {
@Test
void moduleNameIsFoo() {
Assertions.assertTrue(Foo.class.getModule().isNamed(), "Foo resides in a named module");
Assertions.assertEquals("foo", Foo.class.getModule().getName());
Assertions.assertEquals("foo.bar", Foo.class.getModule().getName());
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,8 @@
* under the License.
*/

open module bar {
requires foo;
open module bar.biz {
requires foo.bar;
requires java.scripting;
requires org.junit.jupiter.api;
}
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,6 @@
* under the License.
*/

module foo {
module foo.bar {
requires org.apache.commons.lang3;
}
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,6 @@ void constructor() {
@Test
void moduleNameIsFoo() {
Assertions.assertTrue(Foo.class.getModule().isNamed(), "Foo resides in a named module");
Assertions.assertEquals("foo", Foo.class.getModule().getName());
Assertions.assertEquals("foo.bar", Foo.class.getModule().getName());
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
* under the License.
*/

open module foo {
open module foo.bar {
// main
requires org.apache.commons.lang3;

Expand Down
7 changes: 6 additions & 1 deletion src/it/mcompiler-120/verify.groovy
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,12 @@ def logFile = new File( basedir, 'build.log' )
assert logFile.exists()
content = logFile.text

/*
* The message expected by this test was "unchecked call to add(E) as a member of the raw type List".
* But we cannot test that message because it is locale-dependent. Check only a few keywords instead.
*/
assert content.contains( 'add(E)' )
assert content.contains( 'List' ) // May be `List` or `java.util.List`.
assert content.contains( 'COMPILATION ERROR:' )
assert content.contains( 'CompilationFailureException' ) // In debug level logs.
assert !content.contains( 'invalid flag' )
assert content.contains( 'unchecked call to add(E) as a member of the raw type ' ) // List or java.util.List
10 changes: 9 additions & 1 deletion src/it/mcompiler-179/verify.groovy
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,14 @@ def logFile = new File( basedir, 'build.log' )
assert logFile.exists()
content = logFile.text

assert content.contains( '[WARNING] unchecked call' )
/*
* The message expected by this test was "[WARNING] unchecked call" (the full message
* is actually "unchecked call to add(E) as a member of the raw type java.util.List").
* But we cannot test that message because it is locale-dependent.
* Check only a few keywords instead.
*/
assert content.contains( '[WARNING]' )
assert content.contains( 'add(E)' )
assert content.contains( 'List' ) // May be `List` or `java.util.List`.
assert content.contains( 'COMPILATION ERROR:' )
assert content.contains( 'CompilationFailureException' ) // In debug level logs.
3 changes: 3 additions & 0 deletions src/it/mcompiler-21_methodname-change/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,9 @@ under the License.
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>@project.version@</version>
<configuration>
<incrementalCompilation>sources,rebuild-on-change</incrementalCompilation>
</configuration>
</plugin>
</plugins>
</pluginManagement>
Expand Down
19 changes: 19 additions & 0 deletions src/it/modular-sources/invoker.properties
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
# Licensed to the Apache Software Foundation (ASF) under one
# or more contributor license agreements. See the NOTICE file
# distributed with this work for additional information
# regarding copyright ownership. The ASF licenses this file
# to you under the Apache License, Version 2.0 (the
# "License"); you may not use this file except in compliance
# with the License. You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing,
# software distributed under the License is distributed on an
# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
# KIND, either express or implied. See the License for the
# specific language governing permissions and limitations
# under the License.

invoker.goals = clean compile test-compile
invoker.buildResult = success
72 changes: 72 additions & 0 deletions src/it/modular-sources/pom.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,72 @@
<?xml version="1.0" encoding="UTF-8"?>
<!--
~ Licensed to the Apache Software Foundation (ASF) under one
~ or more contributor license agreements. See the NOTICE file
~ distributed with this work for additional information
~ regarding copyright ownership. The ASF licenses this file
~ to you under the Apache License, Version 2.0 (the
~ "License"); you may not use this file except in compliance
~ with the License. You may obtain a copy of the License at
~
~ http://www.apache.org/licenses/LICENSE-2.0
~
~ Unless required by applicable law or agreed to in writing,
~ software distributed under the License is distributed on an
~ "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
~ KIND, either express or implied. See the License for the
~ specific language governing permissions and limitations
~ under the License.
-->
<project xmlns="http://maven.apache.org/POM/4.1.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.1.0 http://maven.apache.org/xsd/maven-4.1.0.xsd">
<modelVersion>4.1.0</modelVersion>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>modular-sources</artifactId>
<version>1.0-SNAPSHOT</version>
<packaging>jar</packaging>
<name>Modular project in Maven 4</name>

<dependencies>
<dependency>
<groupId>org.junit.jupiter</groupId>
<artifactId>junit-jupiter-api</artifactId>
<version>5.8.2</version>
<scope>test</scope>
</dependency>
</dependencies>

<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>@project.version@</version>
<configuration>
<!-- TODO: remove source and target after we identified where Maven inherits those values. -->
<source />
<target />
</configuration>
</plugin>
</plugins>

<sources>
<source>
<module>org.foo</module>
<directory>src/java/org.foo/main</directory>
</source>
<source>
<module>org.foo</module>
<directory>src/java/org.foo/test</directory>
<scope>test</scope>
</source>
<source>
<module>org.bar</module>
<directory>src/java/org.bar/main</directory>
</source>
<source>
<module>org.bar</module>
<directory>src/java/org.bar/test</directory>
<scope>test</scope>
</source>
</sources>
</build>
</project>
26 changes: 26 additions & 0 deletions src/it/modular-sources/src/java/org.bar/main/bar/App.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
/*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. The ASF licenses this file
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
*/
package bar;

public class App {
public static void main(String[] args) {
foo.App.main(args);
System.out.println("Bar");
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@
* specific language governing permissions and limitations
* under the License.
*/
module example.mrjar {
exports base;
exports mr;
module org.bar {
requires org.foo;
}
Original file line number Diff line number Diff line change
Expand Up @@ -16,17 +16,16 @@
* specific language governing permissions and limitations
* under the License.
*/
package mr;
package bar;

import base.Base;
import org.junit.jupiter.api.Test;

public class A implements I {
public static String getString() {
return Base.get() + " -> 8";
}

@Override
public Class<?> introducedClass() {
return java.time.LocalDateTime.class;
/**
* Verifies that the compiler has access to JUnit and the main code.
*/
public class AppTest {
@Test
public void testMain() {
App.main(null);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -16,11 +16,10 @@
* specific language governing permissions and limitations
* under the License.
*/
package base;
package foo;

public class Base {

public static String get() {
return "BASE";
public class App {
public static void main(String[] args) {
System.out.println("Foo");
}
}
Loading
Loading