You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@maven.apache.org by ol...@apache.org on 2022/02/07 06:11:35 UTC
[maven-compiler-plugin] branch master updated: [MCOMPILER-225] javac.sh/javac.bat added to archive (#91)
This is an automated email from the ASF dual-hosted git repository.
olamy pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/maven-compiler-plugin.git
The following commit(s) were added to refs/heads/master by this push:
new b57e3bc [MCOMPILER-225] javac.sh/javac.bat added to archive (#91)
b57e3bc is described below
commit b57e3bc1489f714f32ffe6f4491fc6c97843f9b5
Author: Olivier Lamy <ol...@apache.org>
AuthorDate: Mon Feb 7 16:11:32 2022 +1000
[MCOMPILER-225] javac.sh/javac.bat added to archive (#91)
* [MCOMPILER-225] javac.sh/javac.bat added to archive
Signed-off-by: Olivier Lamy <ol...@apache.org>
---
pom.xml | 15 +++++-
src/it/default-fork-windows/invoker.properties | 18 +++++++
src/it/default-fork-windows/pom.xml | 60 ++++++++++++++++++++++
.../src/main/java/MyClass.java | 23 +++++++++
.../default-fork-windows/src/test/java/MyTest.java | 26 ++++++++++
src/it/default-fork-windows/verify.groovy | 32 ++++++++++++
src/it/default-fork/invoker.properties | 18 +++++++
src/it/default-fork/pom.xml | 60 ++++++++++++++++++++++
src/it/default-fork/src/main/java/MyClass.java | 23 +++++++++
src/it/default-fork/src/test/java/MyTest.java | 26 ++++++++++
src/it/default-fork/verify.groovy | 33 ++++++++++++
.../plugin/compiler/AbstractCompilerMojo.java | 4 ++
.../apache/maven/plugin/compiler/CompilerMojo.java | 16 ++++++
.../maven/plugin/compiler/TestCompilerMojo.java | 14 +++++
14 files changed, 367 insertions(+), 1 deletion(-)
diff --git a/pom.xml b/pom.xml
index a2dde74..cb32c94 100644
--- a/pom.xml
+++ b/pom.xml
@@ -68,7 +68,7 @@ under the License.
! The following property is used in the integration tests MCOMPILER-157
-->
<mavenPluginPluginVersion>3.5</mavenPluginPluginVersion>
- <plexusCompilerVersion>2.9.0</plexusCompilerVersion>
+ <plexusCompilerVersion>2.9.1-SNAPSHOT</plexusCompilerVersion>
<groovyVersion>2.4.21</groovyVersion>
<groovyEclipseCompilerVersion>3.7.0</groovyEclipseCompilerVersion>
<groovy-eclipse-batch>2.5.14-02</groovy-eclipse-batch>
@@ -86,6 +86,19 @@ under the License.
</contributor>
</contributors>
+ <repositories>
+ <repository>
+ <id>plexus.snapshots</id>
+ <url>https://oss.sonatype.org/content/repositories/plexus-snapshots</url>
+ <releases>
+ <enabled>false</enabled>
+ </releases>
+ <snapshots>
+ <enabled>true</enabled>
+ </snapshots>
+ </repository>
+ </repositories>
+
<dependencyManagement>
<dependencies>
<dependency>
diff --git a/src/it/default-fork-windows/invoker.properties b/src/it/default-fork-windows/invoker.properties
new file mode 100644
index 0000000..b75cc35
--- /dev/null
+++ b/src/it/default-fork-windows/invoker.properties
@@ -0,0 +1,18 @@
+# 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.os.family = windows
diff --git a/src/it/default-fork-windows/pom.xml b/src/it/default-fork-windows/pom.xml
new file mode 100644
index 0000000..ed149bf
--- /dev/null
+++ b/src/it/default-fork-windows/pom.xml
@@ -0,0 +1,60 @@
+<?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.0.0"
+ xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
+ <modelVersion>4.0.0</modelVersion>
+
+ <groupId>org.apache.maven.plugins.compiler.it</groupId>
+ <artifactId>default-fork</artifactId>
+ <version>1.0-SNAPSHOT</version>
+
+ <name>Test for default configuration</name>
+
+ <properties>
+ <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
+ </properties>
+
+ <dependencies>
+ <dependency>
+ <groupId>junit</groupId>
+ <artifactId>junit</artifactId>
+ <version>3.8.2</version>
+ </dependency>
+ </dependencies>
+
+ <build>
+ <plugins>
+ <plugin>
+ <groupId>org.apache.maven.plugins</groupId>
+ <artifactId>maven-compiler-plugin</artifactId>
+ <version>@pom.version@</version>
+ <configuration>
+ <fork>true</fork>
+ <compilerArgs>
+ <compilerArg>-Xlint:-path</compilerArg>
+ </compilerArgs>
+ </configuration>
+ </plugin>
+ </plugins>
+ </build>
+
+</project>
diff --git a/src/it/default-fork-windows/src/main/java/MyClass.java b/src/it/default-fork-windows/src/main/java/MyClass.java
new file mode 100644
index 0000000..4945381
--- /dev/null
+++ b/src/it/default-fork-windows/src/main/java/MyClass.java
@@ -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.
+ */
+
+public class MyClass
+{
+
+}
diff --git a/src/it/default-fork-windows/src/test/java/MyTest.java b/src/it/default-fork-windows/src/test/java/MyTest.java
new file mode 100644
index 0000000..46ba41d
--- /dev/null
+++ b/src/it/default-fork-windows/src/test/java/MyTest.java
@@ -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.
+ */
+
+import junit.framework.TestCase;
+
+public class MyTest
+ extends TestCase
+{
+
+}
diff --git a/src/it/default-fork-windows/verify.groovy b/src/it/default-fork-windows/verify.groovy
new file mode 100644
index 0000000..6b1651d
--- /dev/null
+++ b/src/it/default-fork-windows/verify.groovy
@@ -0,0 +1,32 @@
+/*
+ * 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.
+ */
+
+assert new File( basedir, 'target/classes/MyClass.class').exists()
+
+assert new File( basedir, 'target/test-classes/MyTest.class').exists()
+
+assert !new File( basedir, 'target/classes/javac.sh').exists()
+assert !new File( basedir, 'target/classes/javac.bat').exists()
+
+assert !new File( basedir, 'target/javac.sh').exists()
+assert !new File( basedir, 'target/javac-test.sh').exists()
+assert new File( basedir, 'target/javac.bat').exists()
+assert new File( basedir, 'target/javac-test.bat').exists()
+
+
diff --git a/src/it/default-fork/invoker.properties b/src/it/default-fork/invoker.properties
new file mode 100644
index 0000000..5890964
--- /dev/null
+++ b/src/it/default-fork/invoker.properties
@@ -0,0 +1,18 @@
+# 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.os.family = !windows
diff --git a/src/it/default-fork/pom.xml b/src/it/default-fork/pom.xml
new file mode 100644
index 0000000..ed149bf
--- /dev/null
+++ b/src/it/default-fork/pom.xml
@@ -0,0 +1,60 @@
+<?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.0.0"
+ xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
+ <modelVersion>4.0.0</modelVersion>
+
+ <groupId>org.apache.maven.plugins.compiler.it</groupId>
+ <artifactId>default-fork</artifactId>
+ <version>1.0-SNAPSHOT</version>
+
+ <name>Test for default configuration</name>
+
+ <properties>
+ <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
+ </properties>
+
+ <dependencies>
+ <dependency>
+ <groupId>junit</groupId>
+ <artifactId>junit</artifactId>
+ <version>3.8.2</version>
+ </dependency>
+ </dependencies>
+
+ <build>
+ <plugins>
+ <plugin>
+ <groupId>org.apache.maven.plugins</groupId>
+ <artifactId>maven-compiler-plugin</artifactId>
+ <version>@pom.version@</version>
+ <configuration>
+ <fork>true</fork>
+ <compilerArgs>
+ <compilerArg>-Xlint:-path</compilerArg>
+ </compilerArgs>
+ </configuration>
+ </plugin>
+ </plugins>
+ </build>
+
+</project>
diff --git a/src/it/default-fork/src/main/java/MyClass.java b/src/it/default-fork/src/main/java/MyClass.java
new file mode 100644
index 0000000..4945381
--- /dev/null
+++ b/src/it/default-fork/src/main/java/MyClass.java
@@ -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.
+ */
+
+public class MyClass
+{
+
+}
diff --git a/src/it/default-fork/src/test/java/MyTest.java b/src/it/default-fork/src/test/java/MyTest.java
new file mode 100644
index 0000000..46ba41d
--- /dev/null
+++ b/src/it/default-fork/src/test/java/MyTest.java
@@ -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.
+ */
+
+import junit.framework.TestCase;
+
+public class MyTest
+ extends TestCase
+{
+
+}
diff --git a/src/it/default-fork/verify.groovy b/src/it/default-fork/verify.groovy
new file mode 100644
index 0000000..ba3bd7a
--- /dev/null
+++ b/src/it/default-fork/verify.groovy
@@ -0,0 +1,33 @@
+/*
+ * 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.
+ */
+
+assert new File( basedir, 'target/classes/MyClass.class').exists()
+
+assert new File( basedir, 'target/test-classes/MyTest.class').exists()
+
+assert !new File( basedir, 'target/classes/javac.sh').exists()
+assert !new File( basedir, 'target/classes/javac.bat').exists()
+
+assert !new File( basedir, 'target/javac.bat').exists()
+assert !new File( basedir, 'target/javac-test.bat').exists()
+
+assert new File( basedir, 'target/javac.sh').exists()
+assert new File( basedir, 'target/javac-test.sh').exists()
+
+
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 7988a22..a027e55 100644
--- a/src/main/java/org/apache/maven/plugin/compiler/AbstractCompilerMojo.java
+++ b/src/main/java/org/apache/maven/plugin/compiler/AbstractCompilerMojo.java
@@ -590,6 +590,8 @@ public abstract class AbstractCompilerMojo
protected abstract File getGeneratedSourcesDirectory();
+ protected abstract String getDebugFileName();
+
protected final MavenProject getProject()
{
return project;
@@ -674,6 +676,8 @@ public abstract class AbstractCompilerMojo
compilerConfiguration.setDebug( debug );
+ compilerConfiguration.setDebugFileName( getDebugFileName() );
+
if ( debug && StringUtils.isNotEmpty( debuglevel ) )
{
String[] split = StringUtils.split( debuglevel, "," );
diff --git a/src/main/java/org/apache/maven/plugin/compiler/CompilerMojo.java b/src/main/java/org/apache/maven/plugin/compiler/CompilerMojo.java
index 182ec43..8c5eee2 100644
--- a/src/main/java/org/apache/maven/plugin/compiler/CompilerMojo.java
+++ b/src/main/java/org/apache/maven/plugin/compiler/CompilerMojo.java
@@ -129,6 +129,13 @@ public class CompilerMojo
@Parameter
private boolean multiReleaseOutput;
+ /**
+ * when forking and debug activated the commandline used will be dumped in this file
+ * @since 3.10.0
+ */
+ @Parameter( defaultValue = "javac" )
+ private String debugFileName;
+
final LocationManager locationManager = new LocationManager();
private List<String> classpathElements;
@@ -425,6 +432,12 @@ public class CompilerMojo
return generatedSourcesDirectory;
}
+ @Override
+ protected String getDebugFileName()
+ {
+ return debugFileName;
+ }
+
private void writeBoxedWarning( String message )
{
String line = StringUtils.repeat( "*", message.length() + 4 );
@@ -432,4 +445,7 @@ public class CompilerMojo
getLog().warn( "* " + MessageUtils.buffer().strong( message ) + " *" );
getLog().warn( line );
}
+
+
+
}
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 b1c0b7c..c352cf9 100644
--- a/src/main/java/org/apache/maven/plugin/compiler/TestCompilerMojo.java
+++ b/src/main/java/org/apache/maven/plugin/compiler/TestCompilerMojo.java
@@ -156,6 +156,14 @@ public class TestCompilerMojo
@Parameter( defaultValue = "${project.testClasspathElements}", readonly = true )
private List<String> testPath;
+
+ /**
+ * when forking and debug activated the commandline used will be dumped in this file
+ * @since 3.10.0
+ */
+ @Parameter( defaultValue = "javac-test" )
+ private String debugFileName;
+
final LocationManager locationManager = new LocationManager();
private Map<String, JavaModuleDescriptor> pathElements;
@@ -478,6 +486,12 @@ public class TestCompilerMojo
}
@Override
+ protected String getDebugFileName()
+ {
+ return debugFileName;
+ }
+
+ @Override
protected boolean isTestCompile()
{
return true;