From 68c84b4a1c2e663cacdeb41b895b59bd49f77548 Mon Sep 17 00:00:00 2001 From: loizbak Date: Tue, 17 Dec 2019 13:46:11 +0100 Subject: [PATCH 01/10] [MCOMPILER-372] - integration test --- .../invoker.properties | 21 ++++++ .../MCOMPILER-372_modularized_testjar/pom.xml | 54 +++++++++++++++ .../prj1/pom.xml | 69 +++++++++++++++++++ .../prj1/src/main/java/module-info.java | 24 +++++++ .../prj1/src/main/java/prj1/Dummy.java | 25 +++++++ .../prj1/src/test/java/prj1/Prj1Test.java | 30 ++++++++ .../prj2/pom.xml | 65 +++++++++++++++++ .../prj2/src/main/java/module-info.java | 24 +++++++ .../prj2/src/main/java/prj2/Dummy.java | 25 +++++++ .../prj2/src/test/java/prj2/Prj2Test.java | 36 ++++++++++ 10 files changed, 373 insertions(+) create mode 100644 src/it/MCOMPILER-372_modularized_testjar/invoker.properties create mode 100644 src/it/MCOMPILER-372_modularized_testjar/pom.xml create mode 100644 src/it/MCOMPILER-372_modularized_testjar/prj1/pom.xml create mode 100644 src/it/MCOMPILER-372_modularized_testjar/prj1/src/main/java/module-info.java create mode 100644 src/it/MCOMPILER-372_modularized_testjar/prj1/src/main/java/prj1/Dummy.java create mode 100644 src/it/MCOMPILER-372_modularized_testjar/prj1/src/test/java/prj1/Prj1Test.java create mode 100644 src/it/MCOMPILER-372_modularized_testjar/prj2/pom.xml create mode 100644 src/it/MCOMPILER-372_modularized_testjar/prj2/src/main/java/module-info.java create mode 100644 src/it/MCOMPILER-372_modularized_testjar/prj2/src/main/java/prj2/Dummy.java create mode 100644 src/it/MCOMPILER-372_modularized_testjar/prj2/src/test/java/prj2/Prj2Test.java diff --git a/src/it/MCOMPILER-372_modularized_testjar/invoker.properties b/src/it/MCOMPILER-372_modularized_testjar/invoker.properties new file mode 100644 index 000000000..668d5c4ca --- /dev/null +++ b/src/it/MCOMPILER-372_modularized_testjar/invoker.properties @@ -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. + +## For remote debug +#invoker.mavenOpts = -Xdebug -Xrunjdwp:transport=dt_socket,server=y,suspend=y,address=8000 + +invoker.goals = clean test diff --git a/src/it/MCOMPILER-372_modularized_testjar/pom.xml b/src/it/MCOMPILER-372_modularized_testjar/pom.xml new file mode 100644 index 000000000..5afac3b86 --- /dev/null +++ b/src/it/MCOMPILER-372_modularized_testjar/pom.xml @@ -0,0 +1,54 @@ + + + + + 4.0.0 + + org.apache.maven.plugins.compiler.it.372 + mcompiler-372 + 1.0-SNAPSHOT + pom + + + UTF-8 + + + + prj1 + prj2 + + + + + + org.apache.maven.plugins + maven-compiler-plugin + @project.version@ + + 11 + 11 + + + + + diff --git a/src/it/MCOMPILER-372_modularized_testjar/prj1/pom.xml b/src/it/MCOMPILER-372_modularized_testjar/prj1/pom.xml new file mode 100644 index 000000000..ed9f70c52 --- /dev/null +++ b/src/it/MCOMPILER-372_modularized_testjar/prj1/pom.xml @@ -0,0 +1,69 @@ + + + + + 4.0.0 + + + org.apache.maven.plugins.compiler.it.372 + mcompiler-372 + 1.0-SNAPSHOT + + + prj1-372 + + + + + + + + org.apache.maven.plugins + maven-jar-plugin + 3.2.0 + + + + test-jar + + + + + + + + + + + + + junit + junit + 3.8.2 + test + + + + + + diff --git a/src/it/MCOMPILER-372_modularized_testjar/prj1/src/main/java/module-info.java b/src/it/MCOMPILER-372_modularized_testjar/prj1/src/main/java/module-info.java new file mode 100644 index 000000000..f44230a67 --- /dev/null +++ b/src/it/MCOMPILER-372_modularized_testjar/prj1/src/main/java/module-info.java @@ -0,0 +1,24 @@ +/* + * 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 prj1_372 { + + exports prj1; + +} \ No newline at end of file diff --git a/src/it/MCOMPILER-372_modularized_testjar/prj1/src/main/java/prj1/Dummy.java b/src/it/MCOMPILER-372_modularized_testjar/prj1/src/main/java/prj1/Dummy.java new file mode 100644 index 000000000..fe753214a --- /dev/null +++ b/src/it/MCOMPILER-372_modularized_testjar/prj1/src/main/java/prj1/Dummy.java @@ -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 prj1; + +public class Dummy +{ + +} diff --git a/src/it/MCOMPILER-372_modularized_testjar/prj1/src/test/java/prj1/Prj1Test.java b/src/it/MCOMPILER-372_modularized_testjar/prj1/src/test/java/prj1/Prj1Test.java new file mode 100644 index 000000000..820a2ed93 --- /dev/null +++ b/src/it/MCOMPILER-372_modularized_testjar/prj1/src/test/java/prj1/Prj1Test.java @@ -0,0 +1,30 @@ +/* + * 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 prj1; + +import junit.framework.TestCase; + +public class Prj1Test extends TestCase +{ + public void test() { + + } + +} diff --git a/src/it/MCOMPILER-372_modularized_testjar/prj2/pom.xml b/src/it/MCOMPILER-372_modularized_testjar/prj2/pom.xml new file mode 100644 index 000000000..12272d37a --- /dev/null +++ b/src/it/MCOMPILER-372_modularized_testjar/prj2/pom.xml @@ -0,0 +1,65 @@ + + + + + 4.0.0 + + + org.apache.maven.plugins.compiler.it.372 + mcompiler-372 + 1.0-SNAPSHOT + + + prj2-372 + + + + + org.apache.maven.plugins.compiler.it.372 + prj1-372 + 1.0-SNAPSHOT + + + + + org.apache.maven.plugins.compiler.it.372 + prj1-372 + 1.0-SNAPSHOT + tests + test + + + + junit + junit + 3.8.2 + test + + + + + diff --git a/src/it/MCOMPILER-372_modularized_testjar/prj2/src/main/java/module-info.java b/src/it/MCOMPILER-372_modularized_testjar/prj2/src/main/java/module-info.java new file mode 100644 index 000000000..915a38171 --- /dev/null +++ b/src/it/MCOMPILER-372_modularized_testjar/prj2/src/main/java/module-info.java @@ -0,0 +1,24 @@ +/* + * 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 prj2_372 { + + requires prj1_372; + +} \ No newline at end of file diff --git a/src/it/MCOMPILER-372_modularized_testjar/prj2/src/main/java/prj2/Dummy.java b/src/it/MCOMPILER-372_modularized_testjar/prj2/src/main/java/prj2/Dummy.java new file mode 100644 index 000000000..d666a2bf1 --- /dev/null +++ b/src/it/MCOMPILER-372_modularized_testjar/prj2/src/main/java/prj2/Dummy.java @@ -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 prj2; + +public class Dummy +{ + +} diff --git a/src/it/MCOMPILER-372_modularized_testjar/prj2/src/test/java/prj2/Prj2Test.java b/src/it/MCOMPILER-372_modularized_testjar/prj2/src/test/java/prj2/Prj2Test.java new file mode 100644 index 000000000..91504d550 --- /dev/null +++ b/src/it/MCOMPILER-372_modularized_testjar/prj2/src/test/java/prj2/Prj2Test.java @@ -0,0 +1,36 @@ +/* + * 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 prj2; + +import prj1.Prj1Test; + +public class Prj2Test extends Prj1Test +{ + + public Prj2Test() { + super(); + } + + @Override + public void test() { + + } + +} From a6379abb474cd92b784ff8829a022f7835c703db Mon Sep 17 00:00:00 2001 From: loizbak Date: Tue, 17 Dec 2019 13:46:11 +0100 Subject: [PATCH 02/10] [MCOMPILER-372] - add dependent modules test path as --patchModule compiler argument --- .../invoker.properties | 21 +++ .../MCOMPILER-372_modularized_testjar/pom.xml | 54 ++++++++ .../prj1/pom.xml | 69 ++++++++++ .../prj1/src/main/java/module-info.java | 24 ++++ .../prj1/src/main/java/prj1/Dummy.java | 25 ++++ .../prj1/src/test/java/prj1/Prj1Test.java | 30 +++++ .../prj2/pom.xml | 65 ++++++++++ .../prj2/src/main/java/module-info.java | 24 ++++ .../prj2/src/main/java/prj2/Dummy.java | 25 ++++ .../prj2/src/test/java/prj2/Prj2Test.java | 36 ++++++ .../plugin/compiler/TestCompilerMojo.java | 121 ++++++++++++++++-- 11 files changed, 485 insertions(+), 9 deletions(-) create mode 100644 src/it/MCOMPILER-372_modularized_testjar/invoker.properties create mode 100644 src/it/MCOMPILER-372_modularized_testjar/pom.xml create mode 100644 src/it/MCOMPILER-372_modularized_testjar/prj1/pom.xml create mode 100644 src/it/MCOMPILER-372_modularized_testjar/prj1/src/main/java/module-info.java create mode 100644 src/it/MCOMPILER-372_modularized_testjar/prj1/src/main/java/prj1/Dummy.java create mode 100644 src/it/MCOMPILER-372_modularized_testjar/prj1/src/test/java/prj1/Prj1Test.java create mode 100644 src/it/MCOMPILER-372_modularized_testjar/prj2/pom.xml create mode 100644 src/it/MCOMPILER-372_modularized_testjar/prj2/src/main/java/module-info.java create mode 100644 src/it/MCOMPILER-372_modularized_testjar/prj2/src/main/java/prj2/Dummy.java create mode 100644 src/it/MCOMPILER-372_modularized_testjar/prj2/src/test/java/prj2/Prj2Test.java diff --git a/src/it/MCOMPILER-372_modularized_testjar/invoker.properties b/src/it/MCOMPILER-372_modularized_testjar/invoker.properties new file mode 100644 index 000000000..668d5c4ca --- /dev/null +++ b/src/it/MCOMPILER-372_modularized_testjar/invoker.properties @@ -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. + +## For remote debug +#invoker.mavenOpts = -Xdebug -Xrunjdwp:transport=dt_socket,server=y,suspend=y,address=8000 + +invoker.goals = clean test diff --git a/src/it/MCOMPILER-372_modularized_testjar/pom.xml b/src/it/MCOMPILER-372_modularized_testjar/pom.xml new file mode 100644 index 000000000..5afac3b86 --- /dev/null +++ b/src/it/MCOMPILER-372_modularized_testjar/pom.xml @@ -0,0 +1,54 @@ + + + + + 4.0.0 + + org.apache.maven.plugins.compiler.it.372 + mcompiler-372 + 1.0-SNAPSHOT + pom + + + UTF-8 + + + + prj1 + prj2 + + + + + + org.apache.maven.plugins + maven-compiler-plugin + @project.version@ + + 11 + 11 + + + + + diff --git a/src/it/MCOMPILER-372_modularized_testjar/prj1/pom.xml b/src/it/MCOMPILER-372_modularized_testjar/prj1/pom.xml new file mode 100644 index 000000000..ed9f70c52 --- /dev/null +++ b/src/it/MCOMPILER-372_modularized_testjar/prj1/pom.xml @@ -0,0 +1,69 @@ + + + + + 4.0.0 + + + org.apache.maven.plugins.compiler.it.372 + mcompiler-372 + 1.0-SNAPSHOT + + + prj1-372 + + + + + + + + org.apache.maven.plugins + maven-jar-plugin + 3.2.0 + + + + test-jar + + + + + + + + + + + + + junit + junit + 3.8.2 + test + + + + + + diff --git a/src/it/MCOMPILER-372_modularized_testjar/prj1/src/main/java/module-info.java b/src/it/MCOMPILER-372_modularized_testjar/prj1/src/main/java/module-info.java new file mode 100644 index 000000000..f44230a67 --- /dev/null +++ b/src/it/MCOMPILER-372_modularized_testjar/prj1/src/main/java/module-info.java @@ -0,0 +1,24 @@ +/* + * 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 prj1_372 { + + exports prj1; + +} \ No newline at end of file diff --git a/src/it/MCOMPILER-372_modularized_testjar/prj1/src/main/java/prj1/Dummy.java b/src/it/MCOMPILER-372_modularized_testjar/prj1/src/main/java/prj1/Dummy.java new file mode 100644 index 000000000..fe753214a --- /dev/null +++ b/src/it/MCOMPILER-372_modularized_testjar/prj1/src/main/java/prj1/Dummy.java @@ -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 prj1; + +public class Dummy +{ + +} diff --git a/src/it/MCOMPILER-372_modularized_testjar/prj1/src/test/java/prj1/Prj1Test.java b/src/it/MCOMPILER-372_modularized_testjar/prj1/src/test/java/prj1/Prj1Test.java new file mode 100644 index 000000000..820a2ed93 --- /dev/null +++ b/src/it/MCOMPILER-372_modularized_testjar/prj1/src/test/java/prj1/Prj1Test.java @@ -0,0 +1,30 @@ +/* + * 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 prj1; + +import junit.framework.TestCase; + +public class Prj1Test extends TestCase +{ + public void test() { + + } + +} diff --git a/src/it/MCOMPILER-372_modularized_testjar/prj2/pom.xml b/src/it/MCOMPILER-372_modularized_testjar/prj2/pom.xml new file mode 100644 index 000000000..12272d37a --- /dev/null +++ b/src/it/MCOMPILER-372_modularized_testjar/prj2/pom.xml @@ -0,0 +1,65 @@ + + + + + 4.0.0 + + + org.apache.maven.plugins.compiler.it.372 + mcompiler-372 + 1.0-SNAPSHOT + + + prj2-372 + + + + + org.apache.maven.plugins.compiler.it.372 + prj1-372 + 1.0-SNAPSHOT + + + + + org.apache.maven.plugins.compiler.it.372 + prj1-372 + 1.0-SNAPSHOT + tests + test + + + + junit + junit + 3.8.2 + test + + + + + diff --git a/src/it/MCOMPILER-372_modularized_testjar/prj2/src/main/java/module-info.java b/src/it/MCOMPILER-372_modularized_testjar/prj2/src/main/java/module-info.java new file mode 100644 index 000000000..915a38171 --- /dev/null +++ b/src/it/MCOMPILER-372_modularized_testjar/prj2/src/main/java/module-info.java @@ -0,0 +1,24 @@ +/* + * 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 prj2_372 { + + requires prj1_372; + +} \ No newline at end of file diff --git a/src/it/MCOMPILER-372_modularized_testjar/prj2/src/main/java/prj2/Dummy.java b/src/it/MCOMPILER-372_modularized_testjar/prj2/src/main/java/prj2/Dummy.java new file mode 100644 index 000000000..d666a2bf1 --- /dev/null +++ b/src/it/MCOMPILER-372_modularized_testjar/prj2/src/main/java/prj2/Dummy.java @@ -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 prj2; + +public class Dummy +{ + +} diff --git a/src/it/MCOMPILER-372_modularized_testjar/prj2/src/test/java/prj2/Prj2Test.java b/src/it/MCOMPILER-372_modularized_testjar/prj2/src/test/java/prj2/Prj2Test.java new file mode 100644 index 000000000..91504d550 --- /dev/null +++ b/src/it/MCOMPILER-372_modularized_testjar/prj2/src/test/java/prj2/Prj2Test.java @@ -0,0 +1,36 @@ +/* + * 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 prj2; + +import prj1.Prj1Test; + +public class Prj2Test extends Prj1Test +{ + + public Prj2Test() { + super(); + } + + @Override + public void test() { + + } + +} diff --git a/src/main/java/org/apache/maven/plugin/compiler/TestCompilerMojo.java b/src/main/java/org/apache/maven/plugin/compiler/TestCompilerMojo.java index 7b3cabab4..b6a2eeaa6 100644 --- a/src/main/java/org/apache/maven/plugin/compiler/TestCompilerMojo.java +++ b/src/main/java/org/apache/maven/plugin/compiler/TestCompilerMojo.java @@ -380,28 +380,131 @@ else if ( Double.valueOf( getTarget() ) < Double.valueOf( MODULE_INFO_TARGET ) ) { compilerArgs = new ArrayList<>(); } - compilerArgs.add( "--patch-module" ); + + // Patch module to add + LinkedHashMap> patchModules = new LinkedHashMap<>(); + + List mainModulePaths = new ArrayList<>(); + // Add main output dir + mainModulePaths.add( mainOutputDirectory.getAbsolutePath() ); + // Add source roots + mainModulePaths.addAll( compileSourceRoots ); + patchModules.put( mainModuleDescriptor.name(), mainModulePaths ); - StringBuilder patchModuleValue = new StringBuilder( mainModuleDescriptor.name() ) - .append( '=' ) - .append( mainOutputDirectory ) - .append( PS ); - for ( String root : compileSourceRoots ) + // Main module detected, modularized test dependencies must augment patch modules + patchModulesForTestDependencies( + mainModuleDescriptor.name(), mainOutputDirectory.getAbsolutePath(), + patchModules + ); + + for ( Entry> patchModuleEntry: patchModules.entrySet() ) { - patchModuleValue.append( root ).append( PS ); + compilerArgs.add( "--patch-module" ); + StringBuilder patchModuleValue = new StringBuilder( patchModuleEntry.getKey() ) + .append( '=' ); + + for ( String path : patchModuleEntry.getValue() ) + { + patchModuleValue.append( path ).append( PS ); + } + + compilerArgs.add( patchModuleValue.toString() ); } - compilerArgs.add( patchModuleValue.toString() ); - compilerArgs.add( "--add-reads" ); compilerArgs.add( mainModuleDescriptor.name() + "=ALL-UNNAMED" ); + } else { modulepathElements = Collections.emptyList(); classpathElements = testPath; } + + } + } + + /** + * Compiling with test classpath is not sufficient because some dependencies
+ * may be modularized and their test class path addition would be ignored.

+ * Example from MCOMPILER-372_modularized_test:
+ * prj2 test classes depend on prj1 classes and test classes
+ * As prj1.jar is added as a module, pjr1-tests.jar classes are ignored if we add jar class path
+ * We have to add pjr1-tests.jar as --patch-module

+ * @param mainModuleName + * param mainModuleTarget + * @param patchModules map of module names -> list of paths to add to --patch-module option + * + */ + protected void patchModulesForTestDependencies( + String mainModuleName, String mainModuleTarget, + LinkedHashMap> patchModules + ) + { + + ResolvePathsResult result; + + try + { + // Get compile path information to identify modularized compile path elements + ResolvePathsRequest request = + ResolvePathsRequest.ofStrings( compilePath ); + + request.setIncludeAllProviders( true ); + + Toolchain toolchain = getToolchain(); + if ( toolchain instanceof DefaultJavaToolChain ) + { + request.setJdkHome( ( (DefaultJavaToolChain) toolchain ).getJavaHome() ); + } + + result = locationManager.resolvePaths( request ); + } + catch ( IOException e ) + { + throw new RuntimeException( e ); + } + + // Get modularized dependencies resolved before + for ( Entry pathElt : result.getPathElements().entrySet() ) + { + + String path = pathElt.getKey(); + JavaModuleDescriptor javaModuleDescriptor = pathElt.getValue(); + + if ( + // Is it a modularized compile elements? + ( path != null ) && ( javaModuleDescriptor != null ) + && + // Is it different from main module name + !mainModuleName.equals( javaModuleDescriptor.name() ) + ) + { + + // Add compile classpath + // Yes, add it as patch module + List listPath = patchModules.get( javaModuleDescriptor.name() ); + // Make sure it is initialized + if ( listPath == null ) + { + listPath = new ArrayList<>(); + patchModules.put( javaModuleDescriptor.name(), listPath ); + } + + // Add test compile path but not main module target + listPath.addAll( testPath ); + // Remove main target path + listPath.remove( mainModuleTarget ); + + } + } + + if ( pathElements == null ) + { + pathElements = new LinkedHashMap<>( result.getPathElements().size() ); + pathElements.putAll( result.getPathElements() ); } + } protected SourceInclusionScanner getSourceInclusionScanner( int staleMillis ) From c9bc4dfe0603063dd5fed8af055425de4ad8a642 Mon Sep 17 00:00:00 2001 From: loizbak Date: Thu, 19 Dec 2019 08:37:02 +0100 Subject: [PATCH 03/10] [MCOMPILER-372] added Prj0 to test compilation with JAXB XSD to java generation --- .../MCOMPILER-372_modularized_testjar/pom.xml | 1 + .../prj0/pom.xml | 119 +++++++++++++++++ .../prj0/src/main/java/module-info.java | 29 ++++ .../prj0/src/main/java/prj0/Dummy.java | 25 ++++ .../prj0/src/main/resources/prj0/Prj0Conf.xsd | 58 ++++++++ .../prj0/src/test/java/prj0/Prj0Test.java | 30 +++++ .../plugin/compiler/TestCompilerMojo.java | 125 +++++++++++++----- 7 files changed, 351 insertions(+), 36 deletions(-) create mode 100644 src/it/MCOMPILER-372_modularized_testjar/prj0/pom.xml create mode 100644 src/it/MCOMPILER-372_modularized_testjar/prj0/src/main/java/module-info.java create mode 100644 src/it/MCOMPILER-372_modularized_testjar/prj0/src/main/java/prj0/Dummy.java create mode 100644 src/it/MCOMPILER-372_modularized_testjar/prj0/src/main/resources/prj0/Prj0Conf.xsd create mode 100644 src/it/MCOMPILER-372_modularized_testjar/prj0/src/test/java/prj0/Prj0Test.java diff --git a/src/it/MCOMPILER-372_modularized_testjar/pom.xml b/src/it/MCOMPILER-372_modularized_testjar/pom.xml index 5afac3b86..1a2511ad4 100644 --- a/src/it/MCOMPILER-372_modularized_testjar/pom.xml +++ b/src/it/MCOMPILER-372_modularized_testjar/pom.xml @@ -34,6 +34,7 @@ + prj0 prj1 prj2 diff --git a/src/it/MCOMPILER-372_modularized_testjar/prj0/pom.xml b/src/it/MCOMPILER-372_modularized_testjar/prj0/pom.xml new file mode 100644 index 000000000..267b1f094 --- /dev/null +++ b/src/it/MCOMPILER-372_modularized_testjar/prj0/pom.xml @@ -0,0 +1,119 @@ + + + + + 4.0.0 + + This project tests a JAXB XSD to java test compilation + + + org.apache.maven.plugins.compiler.it.372 + mcompiler-372 + 1.0-SNAPSHOT + + + prj0-372 + + + + + + + + org.apache.maven.plugins + maven-jar-plugin + 3.2.0 + + + + test-jar + + + + + + + + org.codehaus.mojo + jaxb2-maven-plugin + 2.5.0 + + + + + config + + xjc + + + + + src/main/resources/prj0/Prj0Conf.xsd + + prj0.conf + ${project.build.directory}/generated-sources/xjcConf + + + + + + + + + + + + + + + javax.xml.bind + jaxb-api + 2.3.1 + + + com.sun.xml.bind + jaxb-core + 2.3.0.1 + + + com.sun.xml.bind + jaxb-impl + 2.3.1 + + + + javax.activation + activation + 1.1.1 + + + junit + junit + 3.8.2 + test + + + + + + diff --git a/src/it/MCOMPILER-372_modularized_testjar/prj0/src/main/java/module-info.java b/src/it/MCOMPILER-372_modularized_testjar/prj0/src/main/java/module-info.java new file mode 100644 index 000000000..200db0e10 --- /dev/null +++ b/src/it/MCOMPILER-372_modularized_testjar/prj0/src/main/java/module-info.java @@ -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. + */ + +module prj0_372 { + + exports prj0; + + // For JAXB compilation + requires transitive java.xml; + requires transitive java.xml.bind; + requires transitive java.activation; + +} \ No newline at end of file diff --git a/src/it/MCOMPILER-372_modularized_testjar/prj0/src/main/java/prj0/Dummy.java b/src/it/MCOMPILER-372_modularized_testjar/prj0/src/main/java/prj0/Dummy.java new file mode 100644 index 000000000..8882f6bd6 --- /dev/null +++ b/src/it/MCOMPILER-372_modularized_testjar/prj0/src/main/java/prj0/Dummy.java @@ -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 prj0; + +public class Dummy +{ + +} diff --git a/src/it/MCOMPILER-372_modularized_testjar/prj0/src/main/resources/prj0/Prj0Conf.xsd b/src/it/MCOMPILER-372_modularized_testjar/prj0/src/main/resources/prj0/Prj0Conf.xsd new file mode 100644 index 000000000..b46e2eae9 --- /dev/null +++ b/src/it/MCOMPILER-372_modularized_testjar/prj0/src/main/resources/prj0/Prj0Conf.xsd @@ -0,0 +1,58 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/src/it/MCOMPILER-372_modularized_testjar/prj0/src/test/java/prj0/Prj0Test.java b/src/it/MCOMPILER-372_modularized_testjar/prj0/src/test/java/prj0/Prj0Test.java new file mode 100644 index 000000000..f5d30dde1 --- /dev/null +++ b/src/it/MCOMPILER-372_modularized_testjar/prj0/src/test/java/prj0/Prj0Test.java @@ -0,0 +1,30 @@ +/* + * 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 prj0; + +import junit.framework.TestCase; + +public class Prj0Test extends TestCase +{ + public void test() { + + } + +} diff --git a/src/main/java/org/apache/maven/plugin/compiler/TestCompilerMojo.java b/src/main/java/org/apache/maven/plugin/compiler/TestCompilerMojo.java index b6a2eeaa6..5b06fd061 100644 --- a/src/main/java/org/apache/maven/plugin/compiler/TestCompilerMojo.java +++ b/src/main/java/org/apache/maven/plugin/compiler/TestCompilerMojo.java @@ -33,11 +33,13 @@ import java.util.Map.Entry; import java.util.Set; +import org.apache.maven.artifact.Artifact; import org.apache.maven.plugin.MojoExecutionException; import org.apache.maven.plugins.annotations.LifecyclePhase; import org.apache.maven.plugins.annotations.Mojo; import org.apache.maven.plugins.annotations.Parameter; import org.apache.maven.plugins.annotations.ResolutionScope; +import org.apache.maven.project.MavenProject; import org.apache.maven.toolchain.Toolchain; import org.apache.maven.toolchain.java.DefaultJavaToolChain; import org.codehaus.plexus.compiler.util.scan.SimpleSourceInclusionScanner; @@ -45,6 +47,7 @@ import org.codehaus.plexus.compiler.util.scan.StaleSourceScanner; import org.codehaus.plexus.languages.java.jpms.JavaModuleDescriptor; import org.codehaus.plexus.languages.java.jpms.LocationManager; +import org.codehaus.plexus.languages.java.jpms.ModuleNameSource; import org.codehaus.plexus.languages.java.jpms.ResolvePathsRequest; import org.codehaus.plexus.languages.java.jpms.ResolvePathsResult; @@ -159,6 +162,13 @@ public class TestCompilerMojo @Parameter( defaultValue = "${project.testClasspathElements}", readonly = true ) private List testPath; + /** + * @see org.apache.maven.plugin.compiler.CompilerMojo.multiReleaseOutput + */ + @Parameter + private boolean multiReleaseOutput; + + final LocationManager locationManager = new LocationManager(); private Map pathElements; @@ -442,20 +452,23 @@ protected void patchModulesForTestDependencies( ) { - ResolvePathsResult result; + File mainModuleDescriptorClassFile = new File( mainModuleTarget, "module-info.class" ); + + ResolvePathsResult result; try { // Get compile path information to identify modularized compile path elements - ResolvePathsRequest request = - ResolvePathsRequest.ofStrings( compilePath ); - - request.setIncludeAllProviders( true ); + Collection dependencyArtifacts = getCompileClasspathElements( getProject() ); + ResolvePathsRequest request = + ResolvePathsRequest.ofFiles( dependencyArtifacts ) + .setMainModuleDescriptor( mainModuleDescriptorClassFile ); + Toolchain toolchain = getToolchain(); if ( toolchain instanceof DefaultJavaToolChain ) { - request.setJdkHome( ( (DefaultJavaToolChain) toolchain ).getJavaHome() ); + request.setJdkHome( new File( ( (DefaultJavaToolChain) toolchain ).getJavaHome() ) ); } result = locationManager.resolvePaths( request ); @@ -466,45 +479,55 @@ protected void patchModulesForTestDependencies( } // Get modularized dependencies resolved before - for ( Entry pathElt : result.getPathElements().entrySet() ) + for ( Entry pathElt : result.getModulepathElements().entrySet() ) { - String path = pathElt.getKey(); - JavaModuleDescriptor javaModuleDescriptor = pathElt.getValue(); + File path = pathElt.getKey(); + ModuleNameSource moduleNameSource = pathElt.getValue(); - if ( - // Is it a modularized compile elements? - ( path != null ) && ( javaModuleDescriptor != null ) - && - // Is it different from main module name - !mainModuleName.equals( javaModuleDescriptor.name() ) - ) + // Retain only modules with an explicit module-info descriptor + if ( ModuleNameSource.MODULEDESCRIPTOR.equals( moduleNameSource ) ) { + // Get module name + JavaModuleDescriptor moduleDesc = result.getPathElements().get( path ); + String moduleName = ( moduleDesc != null ) ? moduleDesc.name() : null; + + if ( + // Is it a modularized compile elements? + ( path != null ) && ( moduleName != null ) + && + // Is it different from main module name + !mainModuleName.equals( moduleName ) + ) + { + + // Add compile classpath + // Yes, add it as patch module + List listPath = patchModules.get( moduleName ); + // Make sure it is initialized + if ( listPath == null ) + { + listPath = new ArrayList<>(); + patchModules.put( moduleName, listPath ); + } + + // Add test compile path but not main module target + listPath.addAll( testPath ); + // Remove main target path + listPath.remove( mainModuleTarget ); + + } + } - // Add compile classpath - // Yes, add it as patch module - List listPath = patchModules.get( javaModuleDescriptor.name() ); - // Make sure it is initialized - if ( listPath == null ) + if ( pathElements == null ) + { + pathElements = new LinkedHashMap<>( result.getPathElements().size() ); + for ( Entry entry : result.getPathElements().entrySet() ) { - listPath = new ArrayList<>(); - patchModules.put( javaModuleDescriptor.name(), listPath ); + pathElements.put( entry.getKey().getAbsolutePath(), entry.getValue() ); } - - // Add test compile path but not main module target - listPath.addAll( testPath ); - // Remove main target path - listPath.remove( mainModuleTarget ); - } } - - if ( pathElements == null ) - { - pathElements = new LinkedHashMap<>( result.getPathElements().size() ); - pathElements.putAll( result.getPathElements() ); - } - } protected SourceInclusionScanner getSourceInclusionScanner( int staleMillis ) @@ -588,4 +611,34 @@ protected boolean isTestCompile() return true; } + private List getCompileClasspathElements( MavenProject project ) + { + // 3 is outputFolder + 2 preserved for multirelease + List list = new ArrayList<>( project.getArtifacts().size() + 3 ); + + if ( multiReleaseOutput ) + { + File versionsFolder = new File( project.getBuild().getOutputDirectory(), "META-INF/versions" ); + + // in reverse order + for ( int version = Integer.parseInt( getRelease() ) - 1; version >= 9 ; version-- ) + { + File versionSubFolder = new File( versionsFolder, String.valueOf( version ) ); + if ( versionSubFolder.exists() ) + { + list.add( versionSubFolder ); + } + } + } + + list.add( new File( project.getBuild().getOutputDirectory() ) ); + + for ( Artifact a : project.getArtifacts() ) + { + list.add( a.getFile() ); + } + return list; + } + + } From 3fd2a26635a7388103511aac3b13e97dbad7752b Mon Sep 17 00:00:00 2001 From: loizbak Date: Fri, 3 Jan 2020 17:54:02 +0100 Subject: [PATCH 04/10] [MCOMPILER-372] added log4j dependency to Prj0 to test test-compile with module --- .../prj0/pom.xml | 33 +++++++++++++------ .../prj0/src/main/java/module-info.java | 3 ++ .../prj0/src/main/java/prj0/Dummy.java | 5 +++ .../prj0/src/test/java/prj0/Prj0Test.java | 5 +++ 4 files changed, 36 insertions(+), 10 deletions(-) diff --git a/src/it/MCOMPILER-372_modularized_testjar/prj0/pom.xml b/src/it/MCOMPILER-372_modularized_testjar/prj0/pom.xml index 267b1f094..f0eb0dbc0 100644 --- a/src/it/MCOMPILER-372_modularized_testjar/prj0/pom.xml +++ b/src/it/MCOMPILER-372_modularized_testjar/prj0/pom.xml @@ -84,28 +84,42 @@ - - + + + org.apache.logging.log4j + log4j-api + 2.12.1 + + + + org.apache.logging.log4j + log4j-core + 2.12.1 + + + + javax.xml.bind jaxb-api 2.3.1 - - + + com.sun.xml.bind jaxb-core 2.3.0.1 - - + + com.sun.xml.bind jaxb-impl 2.3.1 - + - + javax.activation activation 1.1.1 - + + junit junit @@ -115,5 +129,4 @@ - diff --git a/src/it/MCOMPILER-372_modularized_testjar/prj0/src/main/java/module-info.java b/src/it/MCOMPILER-372_modularized_testjar/prj0/src/main/java/module-info.java index 200db0e10..2c1aba25b 100644 --- a/src/it/MCOMPILER-372_modularized_testjar/prj0/src/main/java/module-info.java +++ b/src/it/MCOMPILER-372_modularized_testjar/prj0/src/main/java/module-info.java @@ -21,6 +21,9 @@ exports prj0; + // For log4j + requires transitive org.apache.logging.log4j; + // For JAXB compilation requires transitive java.xml; requires transitive java.xml.bind; diff --git a/src/it/MCOMPILER-372_modularized_testjar/prj0/src/main/java/prj0/Dummy.java b/src/it/MCOMPILER-372_modularized_testjar/prj0/src/main/java/prj0/Dummy.java index 8882f6bd6..a1311b391 100644 --- a/src/it/MCOMPILER-372_modularized_testjar/prj0/src/main/java/prj0/Dummy.java +++ b/src/it/MCOMPILER-372_modularized_testjar/prj0/src/main/java/prj0/Dummy.java @@ -19,7 +19,12 @@ package prj0; +import org.apache.logging.log4j.LogManager; +import org.apache.logging.log4j.Logger; + public class Dummy { + public static final Logger LOGGER = LogManager.getLogger( Dummy.class ); + } diff --git a/src/it/MCOMPILER-372_modularized_testjar/prj0/src/test/java/prj0/Prj0Test.java b/src/it/MCOMPILER-372_modularized_testjar/prj0/src/test/java/prj0/Prj0Test.java index f5d30dde1..84fa40711 100644 --- a/src/it/MCOMPILER-372_modularized_testjar/prj0/src/test/java/prj0/Prj0Test.java +++ b/src/it/MCOMPILER-372_modularized_testjar/prj0/src/test/java/prj0/Prj0Test.java @@ -19,10 +19,15 @@ package prj0; +import org.apache.logging.log4j.LogManager; +import org.apache.logging.log4j.Logger; import junit.framework.TestCase; public class Prj0Test extends TestCase { + + public static final Logger LOGGER = LogManager.getLogger( Prj0Test.class ); + public void test() { } From ac47aa6e27fa977ced17bfa513b099b45ab05f24 Mon Sep 17 00:00:00 2001 From: loizbak Date: Fri, 3 Jan 2020 17:54:02 +0100 Subject: [PATCH 05/10] [MCOMPILER-372] added log4j dependency to Prj0 to test test-compile with module --- .../prj0/pom.xml | 33 +++++++++++++------ .../prj0/src/main/java/module-info.java | 3 ++ .../prj0/src/main/java/prj0/Dummy.java | 5 +++ .../prj0/src/test/java/prj0/Prj0Test.java | 5 +++ .../prj1/pom.xml | 14 ++++++++ .../prj1/src/test/java/prj1/Prj1Test.java | 5 +++ .../prj2/src/test/java/prj2/Prj2Test.java | 5 +++ 7 files changed, 60 insertions(+), 10 deletions(-) diff --git a/src/it/MCOMPILER-372_modularized_testjar/prj0/pom.xml b/src/it/MCOMPILER-372_modularized_testjar/prj0/pom.xml index 267b1f094..f0eb0dbc0 100644 --- a/src/it/MCOMPILER-372_modularized_testjar/prj0/pom.xml +++ b/src/it/MCOMPILER-372_modularized_testjar/prj0/pom.xml @@ -84,28 +84,42 @@ - - + + + org.apache.logging.log4j + log4j-api + 2.12.1 + + + + org.apache.logging.log4j + log4j-core + 2.12.1 + + + + javax.xml.bind jaxb-api 2.3.1 - - + + com.sun.xml.bind jaxb-core 2.3.0.1 - - + + com.sun.xml.bind jaxb-impl 2.3.1 - + - + javax.activation activation 1.1.1 - + + junit junit @@ -115,5 +129,4 @@ - diff --git a/src/it/MCOMPILER-372_modularized_testjar/prj0/src/main/java/module-info.java b/src/it/MCOMPILER-372_modularized_testjar/prj0/src/main/java/module-info.java index 200db0e10..2c1aba25b 100644 --- a/src/it/MCOMPILER-372_modularized_testjar/prj0/src/main/java/module-info.java +++ b/src/it/MCOMPILER-372_modularized_testjar/prj0/src/main/java/module-info.java @@ -21,6 +21,9 @@ exports prj0; + // For log4j + requires transitive org.apache.logging.log4j; + // For JAXB compilation requires transitive java.xml; requires transitive java.xml.bind; diff --git a/src/it/MCOMPILER-372_modularized_testjar/prj0/src/main/java/prj0/Dummy.java b/src/it/MCOMPILER-372_modularized_testjar/prj0/src/main/java/prj0/Dummy.java index 8882f6bd6..a1311b391 100644 --- a/src/it/MCOMPILER-372_modularized_testjar/prj0/src/main/java/prj0/Dummy.java +++ b/src/it/MCOMPILER-372_modularized_testjar/prj0/src/main/java/prj0/Dummy.java @@ -19,7 +19,12 @@ package prj0; +import org.apache.logging.log4j.LogManager; +import org.apache.logging.log4j.Logger; + public class Dummy { + public static final Logger LOGGER = LogManager.getLogger( Dummy.class ); + } diff --git a/src/it/MCOMPILER-372_modularized_testjar/prj0/src/test/java/prj0/Prj0Test.java b/src/it/MCOMPILER-372_modularized_testjar/prj0/src/test/java/prj0/Prj0Test.java index f5d30dde1..84fa40711 100644 --- a/src/it/MCOMPILER-372_modularized_testjar/prj0/src/test/java/prj0/Prj0Test.java +++ b/src/it/MCOMPILER-372_modularized_testjar/prj0/src/test/java/prj0/Prj0Test.java @@ -19,10 +19,15 @@ package prj0; +import org.apache.logging.log4j.LogManager; +import org.apache.logging.log4j.Logger; import junit.framework.TestCase; public class Prj0Test extends TestCase { + + public static final Logger LOGGER = LogManager.getLogger( Prj0Test.class ); + public void test() { } diff --git a/src/it/MCOMPILER-372_modularized_testjar/prj1/pom.xml b/src/it/MCOMPILER-372_modularized_testjar/prj1/pom.xml index ed9f70c52..174380acd 100644 --- a/src/it/MCOMPILER-372_modularized_testjar/prj1/pom.xml +++ b/src/it/MCOMPILER-372_modularized_testjar/prj1/pom.xml @@ -56,6 +56,20 @@ + + + org.apache.logging.log4j + log4j-api + 2.12.1 + + + + org.apache.logging.log4j + log4j-core + 2.12.1 + + + junit junit diff --git a/src/it/MCOMPILER-372_modularized_testjar/prj1/src/test/java/prj1/Prj1Test.java b/src/it/MCOMPILER-372_modularized_testjar/prj1/src/test/java/prj1/Prj1Test.java index 820a2ed93..47178c966 100644 --- a/src/it/MCOMPILER-372_modularized_testjar/prj1/src/test/java/prj1/Prj1Test.java +++ b/src/it/MCOMPILER-372_modularized_testjar/prj1/src/test/java/prj1/Prj1Test.java @@ -19,10 +19,15 @@ package prj1; +import org.apache.logging.log4j.LogManager; +import org.apache.logging.log4j.Logger; import junit.framework.TestCase; public class Prj1Test extends TestCase { + + public static final Logger LOGGER = LogManager.getLogger( Prj1Test.class ); + public void test() { } diff --git a/src/it/MCOMPILER-372_modularized_testjar/prj2/src/test/java/prj2/Prj2Test.java b/src/it/MCOMPILER-372_modularized_testjar/prj2/src/test/java/prj2/Prj2Test.java index 91504d550..c04349265 100644 --- a/src/it/MCOMPILER-372_modularized_testjar/prj2/src/test/java/prj2/Prj2Test.java +++ b/src/it/MCOMPILER-372_modularized_testjar/prj2/src/test/java/prj2/Prj2Test.java @@ -19,11 +19,16 @@ package prj2; +import org.apache.logging.log4j.LogManager; +import org.apache.logging.log4j.Logger; + import prj1.Prj1Test; public class Prj2Test extends Prj1Test { + public static final Logger LOGGER = LogManager.getLogger( Prj2Test.class ); + public Prj2Test() { super(); } From ad4bb3c37c72d309ec4c6d8a2bd6c71c168b5814 Mon Sep 17 00:00:00 2001 From: loizbak Date: Fri, 3 Jan 2020 17:59:04 +0100 Subject: [PATCH 06/10] [MCOMPILER-372] Prj3 to test 2 levels of module usage --- .../MCOMPILER-372_modularized_testjar/pom.xml | 1 + .../prj3/pom.xml | 74 +++++++++++++++++++ .../prj3/src/main/java/module-info.java | 25 +++++++ .../prj3/src/main/java/prj3/Dummy.java | 25 +++++++ .../prj3/src/test/java/prj3/Prj3Test.java | 47 ++++++++++++ 5 files changed, 172 insertions(+) create mode 100644 src/it/MCOMPILER-372_modularized_testjar/prj3/pom.xml create mode 100644 src/it/MCOMPILER-372_modularized_testjar/prj3/src/main/java/module-info.java create mode 100644 src/it/MCOMPILER-372_modularized_testjar/prj3/src/main/java/prj3/Dummy.java create mode 100644 src/it/MCOMPILER-372_modularized_testjar/prj3/src/test/java/prj3/Prj3Test.java diff --git a/src/it/MCOMPILER-372_modularized_testjar/pom.xml b/src/it/MCOMPILER-372_modularized_testjar/pom.xml index 1a2511ad4..25536df43 100644 --- a/src/it/MCOMPILER-372_modularized_testjar/pom.xml +++ b/src/it/MCOMPILER-372_modularized_testjar/pom.xml @@ -37,6 +37,7 @@ prj0 prj1 prj2 + prj3 diff --git a/src/it/MCOMPILER-372_modularized_testjar/prj3/pom.xml b/src/it/MCOMPILER-372_modularized_testjar/prj3/pom.xml new file mode 100644 index 000000000..52514c2fa --- /dev/null +++ b/src/it/MCOMPILER-372_modularized_testjar/prj3/pom.xml @@ -0,0 +1,74 @@ + + + + + 4.0.0 + + + org.apache.maven.plugins.compiler.it.372 + mcompiler-372 + 1.0-SNAPSHOT + + + prj3-372 + + + + + org.apache.maven.plugins.compiler.it.372 + prj2-372 + 1.0-SNAPSHOT + + + + + org.apache.maven.plugins.compiler.it.372 + prj2-372 + 1.0-SNAPSHOT + tests + test + + + + org.apache.maven.plugins.compiler.it.372 + prj1-372 + 1.0-SNAPSHOT + tests + test + + + + junit + junit + 3.8.2 + test + + + + + diff --git a/src/it/MCOMPILER-372_modularized_testjar/prj3/src/main/java/module-info.java b/src/it/MCOMPILER-372_modularized_testjar/prj3/src/main/java/module-info.java new file mode 100644 index 000000000..0da57e20f --- /dev/null +++ b/src/it/MCOMPILER-372_modularized_testjar/prj3/src/main/java/module-info.java @@ -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. + */ + +module prj3_372 { + + requires prj1_372; + requires prj2_372; + +} \ No newline at end of file diff --git a/src/it/MCOMPILER-372_modularized_testjar/prj3/src/main/java/prj3/Dummy.java b/src/it/MCOMPILER-372_modularized_testjar/prj3/src/main/java/prj3/Dummy.java new file mode 100644 index 000000000..bc61e5902 --- /dev/null +++ b/src/it/MCOMPILER-372_modularized_testjar/prj3/src/main/java/prj3/Dummy.java @@ -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 prj3; + +public class Dummy +{ + +} diff --git a/src/it/MCOMPILER-372_modularized_testjar/prj3/src/test/java/prj3/Prj3Test.java b/src/it/MCOMPILER-372_modularized_testjar/prj3/src/test/java/prj3/Prj3Test.java new file mode 100644 index 000000000..0dac72f9d --- /dev/null +++ b/src/it/MCOMPILER-372_modularized_testjar/prj3/src/test/java/prj3/Prj3Test.java @@ -0,0 +1,47 @@ +/* + * 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 prj3; + +import org.apache.logging.log4j.LogManager; +import org.apache.logging.log4j.Logger; + +import prj1.Prj1Test; +import prj2.Prj2Test; + +/** + * We want to test that import of 2 levels of modularized test projects is OK + */ +public class Prj3Test extends Prj2Test +{ + + public static final Logger LOGGER = LogManager.getLogger( Prj3Test.class ); + + private Prj1Test prj1Test = new Prj1Test(); + + public Prj3Test() { + super(); + } + + @Override + public void test() { + + } + +} From b086f21641c456ca9f5b6f2b9c69c98624549487 Mon Sep 17 00:00:00 2001 From: loizbak Date: Fri, 3 Jan 2020 19:29:16 +0100 Subject: [PATCH 07/10] [MCOMPILER-372] for each module, --patch-module add tests artifacts (when existing) For each module : --add-reads =ALL-UNNAMED given access to classes from unnamed modules (for example JUnit classes) --- .../plugin/compiler/TestCompilerMojo.java | 188 +++++++++++++----- 1 file changed, 141 insertions(+), 47 deletions(-) diff --git a/src/main/java/org/apache/maven/plugin/compiler/TestCompilerMojo.java b/src/main/java/org/apache/maven/plugin/compiler/TestCompilerMojo.java index 5b06fd061..ee60085ab 100644 --- a/src/main/java/org/apache/maven/plugin/compiler/TestCompilerMojo.java +++ b/src/main/java/org/apache/maven/plugin/compiler/TestCompilerMojo.java @@ -33,6 +33,7 @@ import java.util.Map.Entry; import java.util.Set; +import org.apache.commons.io.FilenameUtils; import org.apache.maven.artifact.Artifact; import org.apache.maven.plugin.MojoExecutionException; import org.apache.maven.plugins.annotations.LifecyclePhase; @@ -162,13 +163,6 @@ public class TestCompilerMojo @Parameter( defaultValue = "${project.testClasspathElements}", readonly = true ) private List testPath; - /** - * @see org.apache.maven.plugin.compiler.CompilerMojo.multiReleaseOutput - */ - @Parameter - private boolean multiReleaseOutput; - - final LocationManager locationManager = new LocationManager(); private Map pathElements; @@ -478,6 +472,58 @@ protected void patchModulesForTestDependencies( throw new RuntimeException( e ); } + // Prepare a path list containing test paths for modularized paths + // This path list will augment modules to be able to compile + List listModuleTestPaths = new ArrayList<>( testPath.size() ); + + // Browse modules + for ( Entry pathElt : result.getModulepathElements().entrySet() ) + { + + File modulePathElt = pathElt.getKey(); + + // Get module name + JavaModuleDescriptor moduleDesc = result.getPathElements().get( modulePathElt ); + String moduleName = ( moduleDesc != null ) ? moduleDesc.name() : null; + + if ( + // Is it a modularized compile elements? + ( modulePathElt != null ) && ( moduleName != null ) + && + // Is it different from main module name + !mainModuleName.equals( moduleName ) + ) + { + + // Get test path element + File moduleTestPathElt = getModuleTestPathElt( modulePathElt ); + + if ( moduleTestPathElt != null ) + { + listModuleTestPaths.add( moduleTestPathElt.getAbsolutePath() ); + } + + } + + } + + // Remove main target path + listModuleTestPaths.remove( mainModuleTarget ); + listModuleTestPaths.remove( outputDirectory.getAbsolutePath() ); + + // Freeze list + listModuleTestPaths = Collections.unmodifiableList( listModuleTestPaths ); + + if ( getLog().isDebugEnabled() ) + { + getLog().debug( "patchModule test paths:" ); + for ( String moduleTestPath : listModuleTestPaths ) + { + getLog().debug( " " + moduleTestPath ); + } + + } + // Get modularized dependencies resolved before for ( Entry pathElt : result.getModulepathElements().entrySet() ) { @@ -485,23 +531,31 @@ protected void patchModulesForTestDependencies( File path = pathElt.getKey(); ModuleNameSource moduleNameSource = pathElt.getValue(); - // Retain only modules with an explicit module-info descriptor - if ( ModuleNameSource.MODULEDESCRIPTOR.equals( moduleNameSource ) ) + // Get module name + JavaModuleDescriptor moduleDesc = result.getPathElements().get( path ); + String moduleName = ( moduleDesc != null ) ? moduleDesc.name() : null; + + if ( + // Is it a modularized compile elements? + ( path != null ) && ( moduleName != null ) + && + // Not an auto-module + !moduleDesc.isAutomatic() + && + // Is it different from main module name + !mainModuleName.equals( moduleName ) + ) { - // Get module name - JavaModuleDescriptor moduleDesc = result.getPathElements().get( path ); - String moduleName = ( moduleDesc != null ) ? moduleDesc.name() : null; + + // Add --add-reads =ALL-UNNAMED + compilerArgs.add( "--add-reads" ); + StringBuilder sbAddReads = new StringBuilder(); + sbAddReads.append( moduleName ).append( "=ALL-UNNAMED" ); + compilerArgs.add( sbAddReads.toString() ); - if ( - // Is it a modularized compile elements? - ( path != null ) && ( moduleName != null ) - && - // Is it different from main module name - !mainModuleName.equals( moduleName ) - ) + // Add compile classpath if needed + if ( !listModuleTestPaths.isEmpty() ) { - - // Add compile classpath // Yes, add it as patch module List listPath = patchModules.get( moduleName ); // Make sure it is initialized @@ -509,27 +563,82 @@ protected void patchModulesForTestDependencies( { listPath = new ArrayList<>(); patchModules.put( moduleName, listPath ); - } + } // Add test compile path but not main module target - listPath.addAll( testPath ); - // Remove main target path - listPath.remove( mainModuleTarget ); - + listPath.addAll( listModuleTestPaths ); } + } - if ( pathElements == null ) + } + + if ( pathElements == null ) + { + pathElements = new LinkedHashMap<>( result.getPathElements().size() ); + for ( Entry entry : result.getPathElements().entrySet() ) { - pathElements = new LinkedHashMap<>( result.getPathElements().size() ); - for ( Entry entry : result.getPathElements().entrySet() ) - { - pathElements.put( entry.getKey().getAbsolutePath(), entry.getValue() ); - } + pathElements.put( entry.getKey().getAbsolutePath(), entry.getValue() ); } } } + /** + * Get module test path element from module path element + * @param modulePathElt + * @return + */ + private File getModuleTestPathElt( File modulePathElt ) + { + + File result = null; + + // Get parent, base name and extension + File parentFile = modulePathElt.getParentFile(); + // Get base name + String baseName = FilenameUtils.getBaseName( modulePathElt.getName() ); + + // For test directory + if ( modulePathElt.isDirectory() ) + { + + // Already a test path? + if ( baseName.startsWith( "test-" ) ) + { + // Sorry, no test path for test path + return null; + } + + // Build new name + String testName = "test-" + modulePathElt.getName(); + result = new File( parentFile, testName ); + + } + else + { + + // Already a test path? + if ( modulePathElt.isFile() && ( baseName.endsWith( "-tests" ) ) ) + { + // Sorry, no test path for test path + return null; + } + + // Build new name + String testName = baseName + "-tests." + FilenameUtils.getExtension( modulePathElt.getName() ); + result = new File( parentFile, testName ); + + } + + // Last check : result (directory or file) exists? + if ( ( result != null ) && !result.exists() ) + { + result = null; + } + + return result; + } + protected SourceInclusionScanner getSourceInclusionScanner( int staleMillis ) { SourceInclusionScanner scanner; @@ -616,21 +725,6 @@ private List getCompileClasspathElements( MavenProject project ) // 3 is outputFolder + 2 preserved for multirelease List list = new ArrayList<>( project.getArtifacts().size() + 3 ); - if ( multiReleaseOutput ) - { - File versionsFolder = new File( project.getBuild().getOutputDirectory(), "META-INF/versions" ); - - // in reverse order - for ( int version = Integer.parseInt( getRelease() ) - 1; version >= 9 ; version-- ) - { - File versionSubFolder = new File( versionsFolder, String.valueOf( version ) ); - if ( versionSubFolder.exists() ) - { - list.add( versionSubFolder ); - } - } - } - list.add( new File( project.getBuild().getOutputDirectory() ) ); for ( Artifact a : project.getArtifacts() ) From 5430acf902fad37d80d3f8e65f16c737a49ea5e6 Mon Sep 17 00:00:00 2001 From: loizbak Date: Tue, 7 Jan 2020 10:52:52 +0100 Subject: [PATCH 08/10] [MCOMPILER-372] First use reactor projects to get test path element from path element, if it does not succeed, guess test path element from path element --- .../plugin/compiler/AbstractCompilerMojo.java | 12 ++++++ .../plugin/compiler/TestCompilerMojo.java | 43 ++++++++++++++++++- 2 files changed, 54 insertions(+), 1 deletion(-) diff --git a/src/main/java/org/apache/maven/plugin/compiler/AbstractCompilerMojo.java b/src/main/java/org/apache/maven/plugin/compiler/AbstractCompilerMojo.java index 703b9aabc..a0977d091 100644 --- a/src/main/java/org/apache/maven/plugin/compiler/AbstractCompilerMojo.java +++ b/src/main/java/org/apache/maven/plugin/compiler/AbstractCompilerMojo.java @@ -434,6 +434,12 @@ public abstract class AbstractCompilerMojo @Parameter( defaultValue = "${project}", readonly = true, required = true ) private MavenProject project; + /** + * Reactor projects list + */ + @Parameter( defaultValue = "${reactorProjects}", readonly = true, required = true ) + private List reactorProjects; + /** * Strategy to re use javacc class created: *

    @@ -1755,4 +1761,10 @@ public void setRelease( String release ) this.release = release; targetOrReleaseSet = true; } + + public List getReactorProjects() + { + return reactorProjects; + } + } diff --git a/src/main/java/org/apache/maven/plugin/compiler/TestCompilerMojo.java b/src/main/java/org/apache/maven/plugin/compiler/TestCompilerMojo.java index ee60085ab..963f256c4 100644 --- a/src/main/java/org/apache/maven/plugin/compiler/TestCompilerMojo.java +++ b/src/main/java/org/apache/maven/plugin/compiler/TestCompilerMojo.java @@ -591,8 +591,16 @@ protected void patchModulesForTestDependencies( private File getModuleTestPathElt( File modulePathElt ) { - File result = null; + // Get test path from reactor projects + File result = getModuleTestPathEltFromReactorProjects( modulePathElt ); + + // Success? + if ( result != null ) + { + return result; + } + // Not found in reactor project, try to guess test path from module path // Get parent, base name and extension File parentFile = modulePathElt.getParentFile(); // Get base name @@ -636,6 +644,39 @@ private File getModuleTestPathElt( File modulePathElt ) result = null; } + return result; + + } + + protected File getModuleTestPathEltFromReactorProjects( File modulePathElt ) + { + File result = null; + + // Get reactor projects + List reactorProjects = getReactorProjects(); + + // Find project matching module path + for ( MavenProject reactorProject : reactorProjects ) + { + // Get build folder + File reactorProjectBuildFolder = new File( reactorProject.getBuild().getOutputDirectory() ); + + // Same as module path element? + if ( modulePathElt.equals( reactorProjectBuildFolder ) ) + { + // Yes, get test build folder + result = new File( reactorProject.getBuild().getTestOutputDirectory() ); + // Loop is finished + break; + } + } + + // Last check : result (directory or file) exists? + if ( ( result != null ) && !result.exists() ) + { + result = null; + } + return result; } From da56e60c63cb20e945b3b43a6bb84f2b41ce5283 Mon Sep 17 00:00:00 2001 From: loizbak Date: Wed, 8 Jan 2020 09:06:01 +0100 Subject: [PATCH 09/10] [MCOMPILER-372] - Fixed command lines compilation issues for Prj3 Prj2 was not uploading test jar to local repo. Prj2 was not opening prj2 package. --- .../prj2/pom.xml | 22 +++++++++++++++++++ .../prj2/src/main/java/module-info.java | 2 ++ 2 files changed, 24 insertions(+) diff --git a/src/it/MCOMPILER-372_modularized_testjar/prj2/pom.xml b/src/it/MCOMPILER-372_modularized_testjar/prj2/pom.xml index 12272d37a..121beb38f 100644 --- a/src/it/MCOMPILER-372_modularized_testjar/prj2/pom.xml +++ b/src/it/MCOMPILER-372_modularized_testjar/prj2/pom.xml @@ -32,6 +32,28 @@ prj2-372 + + + + + + + org.apache.maven.plugins + maven-jar-plugin + 3.2.0 + + + + test-jar + + + + + + + + + diff --git a/src/it/MCOMPILER-372_modularized_testjar/prj2/src/main/java/module-info.java b/src/it/MCOMPILER-372_modularized_testjar/prj2/src/main/java/module-info.java index 915a38171..f338c8caa 100644 --- a/src/it/MCOMPILER-372_modularized_testjar/prj2/src/main/java/module-info.java +++ b/src/it/MCOMPILER-372_modularized_testjar/prj2/src/main/java/module-info.java @@ -21,4 +21,6 @@ requires prj1_372; + exports prj2; + } \ No newline at end of file From f0dfa601999860e65154f2155995f65db7a635ba Mon Sep 17 00:00:00 2001 From: loizbak Date: Thu, 9 Jan 2020 20:38:31 +0100 Subject: [PATCH 10/10] [MCOMPILER-372] Reactor is used to get test artifact No guessing by artifact name. --- .../plugin/compiler/TestCompilerMojo.java | 58 +------------------ 1 file changed, 3 insertions(+), 55 deletions(-) diff --git a/src/main/java/org/apache/maven/plugin/compiler/TestCompilerMojo.java b/src/main/java/org/apache/maven/plugin/compiler/TestCompilerMojo.java index 963f256c4..0447c2f2d 100644 --- a/src/main/java/org/apache/maven/plugin/compiler/TestCompilerMojo.java +++ b/src/main/java/org/apache/maven/plugin/compiler/TestCompilerMojo.java @@ -33,7 +33,6 @@ import java.util.Map.Entry; import java.util.Set; -import org.apache.commons.io.FilenameUtils; import org.apache.maven.artifact.Artifact; import org.apache.maven.plugin.MojoExecutionException; import org.apache.maven.plugins.annotations.LifecyclePhase; @@ -529,7 +528,6 @@ protected void patchModulesForTestDependencies( { File path = pathElt.getKey(); - ModuleNameSource moduleNameSource = pathElt.getValue(); // Get module name JavaModuleDescriptor moduleDesc = result.getPathElements().get( path ); @@ -588,64 +586,13 @@ protected void patchModulesForTestDependencies( * @param modulePathElt * @return */ - private File getModuleTestPathElt( File modulePathElt ) + protected File getModuleTestPathElt( File modulePathElt ) { // Get test path from reactor projects File result = getModuleTestPathEltFromReactorProjects( modulePathElt ); - - // Success? - if ( result != null ) - { - return result; - } - - // Not found in reactor project, try to guess test path from module path - // Get parent, base name and extension - File parentFile = modulePathElt.getParentFile(); - // Get base name - String baseName = FilenameUtils.getBaseName( modulePathElt.getName() ); - - // For test directory - if ( modulePathElt.isDirectory() ) - { - - // Already a test path? - if ( baseName.startsWith( "test-" ) ) - { - // Sorry, no test path for test path - return null; - } - - // Build new name - String testName = "test-" + modulePathElt.getName(); - result = new File( parentFile, testName ); - - } - else - { - - // Already a test path? - if ( modulePathElt.isFile() && ( baseName.endsWith( "-tests" ) ) ) - { - // Sorry, no test path for test path - return null; - } - - // Build new name - String testName = baseName + "-tests." + FilenameUtils.getExtension( modulePathElt.getName() ); - result = new File( parentFile, testName ); - - } - - // Last check : result (directory or file) exists? - if ( ( result != null ) && !result.exists() ) - { - result = null; - } - return result; - + } protected File getModuleTestPathEltFromReactorProjects( File modulePathElt ) @@ -669,6 +616,7 @@ protected File getModuleTestPathEltFromReactorProjects( File modulePathElt ) // Loop is finished break; } + } // Last check : result (directory or file) exists?