Skip to content
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
8 changes: 4 additions & 4 deletions src/it/modular-sources/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -51,20 +51,20 @@
<sources>
<source>
<module>org.foo</module>
<directory>src/java/org.foo/main</directory>
<directory>src/org.foo/main/java</directory>
</source>
<source>
<module>org.foo</module>
<directory>src/java/org.foo/test</directory>
<directory>src/org.foo/test/java</directory>
<scope>test</scope>
</source>
<source>
<module>org.bar</module>
<directory>src/java/org.bar/main</directory>
<directory>src/org.bar/main/java</directory>
</source>
<source>
<module>org.bar</module>
<directory>src/java/org.bar/test</directory>
<directory>src/org.bar/test/java</directory>
<scope>test</scope>
</source>
</sources>
Expand Down
19 changes: 19 additions & 0 deletions src/it/module-info-patch/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/module-info-patch/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>module-info-patch</artifactId>
<version>1.0-SNAPSHOT</version>
<packaging>jar</packaging>
<name>Modular project with module-info-patch files</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/org.foo/main/java</directory>
</source>
<source>
<module>org.foo</module>
<directory>src/org.foo/test/java</directory>
<scope>test</scope>
</source>
<source>
<module>org.bar</module>
<directory>src/org.bar/main/java</directory>
</source>
<source>
<module>org.bar</module>
<directory>src/org.bar/test/java</directory>
<scope>test</scope>
</source>
</sources>
</build>
</project>
25 changes: 25 additions & 0 deletions src/it/module-info-patch/src/org.bar/main/java/bar/App.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
/*
* 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) {
System.out.println("Bar");
}
}
21 changes: 21 additions & 0 deletions src/it/module-info-patch/src/org.bar/main/java/module-info.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
/*
* 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.
*/
module org.bar {
requires org.foo;
}
35 changes: 35 additions & 0 deletions src/it/module-info-patch/src/org.bar/test/java/bar/AppTest.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
/*
* 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;

import org.junit.jupiter.api.Test;

/**
* Verifies that the compiler has access to JUnit and the main code.
*/
public class AppTest {
@Test
public void testMain() {
App.main(null);

// The following requires that the `foo` package from the `org.foo` module is exported
// to this `org.bar` module, which is declared in the `module-info-patch.maven` file.
foo.App.main(null);
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
/*
* 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.
*/

patch-module org.bar {
add-modules TEST-MODULE-PATH;
add-reads org.junit.jupiter.api;
}
25 changes: 25 additions & 0 deletions src/it/module-info-patch/src/org.foo/main/java/foo/App.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
/*
* 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 foo;

public class App {
public static void main(String[] args) {
System.out.println("Foo");
}
}
21 changes: 21 additions & 0 deletions src/it/module-info-patch/src/org.foo/main/java/module-info.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
/*
* 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.
*/
module org.foo {
// Do not export `foo` as we want to test `--add-opens` options.
}
31 changes: 31 additions & 0 deletions src/it/module-info-patch/src/org.foo/test/java/foo/AppTest.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
/*
* 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 foo;

import org.junit.jupiter.api.Test;

/**
* 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
@@ -0,0 +1,29 @@
/*
* 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.
*/

patch-module org.foo {
add-modules TEST-MODULE-PATH;

// Similar to `requires` in module-info.
// Accept also TEST-MODULE-PATH (Maven-specific).
add-reads org.junit.jupiter.api;

// Similar to `exports` in module-info.
add-exports foo to org.bar;
}
28 changes: 28 additions & 0 deletions src/it/module-info-patch/verify.groovy
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
/*
* 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.
*/

import java.util.jar.JarFile

assert new File( basedir, "target/classes/org.foo/module-info.class").exists()
assert new File( basedir, "target/classes/org.foo/foo/App.class").exists()
assert new File( basedir, "target/test-classes/org.foo/foo/AppTest.class").exists()

assert new File( basedir, "target/classes/org.bar/module-info.class").exists()
assert new File( basedir, "target/classes/org.bar/bar/App.class").exists()
assert new File( basedir, "target/test-classes/org.bar/bar/AppTest.class").exists()
Original file line number Diff line number Diff line change
Expand Up @@ -1311,6 +1311,7 @@ public Options parseParameters(final OptionChecker compiler) {
* @throws IOException if an input file cannot be read
* @throws MojoException if the compilation failed
*/
@SuppressWarnings("UseSpecificCatch")
private void compile(final JavaCompiler compiler, final Options configuration) throws IOException {
final ToolExecutor executor = createExecutor(null);
if (!executor.applyIncrementalBuild(this, configuration)) {
Expand Down Expand Up @@ -1536,6 +1537,7 @@ final DependencyResolverResult resolveDependencies(boolean hasModuleDeclaration)
* {@code processor}, {@code classpath-processor} or {@code modular-processor}.
*/
@Deprecated(since = "4.0.0")
@SuppressWarnings("UseSpecificCatch")
final void resolveProcessorPathEntries(Map<PathType, List<Path>> addTo) throws MojoException {
List<DependencyCoordinate> dependencies = annotationProcessorPaths;
if (dependencies != null && !dependencies.isEmpty()) {
Expand Down
Loading
Loading