Skip to content

Commit

Permalink
[MCOMPILER-538] Add test case
Browse files Browse the repository at this point in the history
  • Loading branch information
mensinda committed Nov 4, 2024
1 parent fdebd58 commit 642f6c3
Show file tree
Hide file tree
Showing 11 changed files with 419 additions and 0 deletions.
29 changes: 29 additions & 0 deletions src/it/MCOMPILER-538/code/MyAnnotatedClass.bad.java
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.
*/
package bar;

import foo.MyAnnotation;

@MyAnnotation
public class MyAnnotatedClass {
MyGeneratedClass generatedClass = new MyGeneratedClass(false);

// foo

}
29 changes: 29 additions & 0 deletions src/it/MCOMPILER-538/code/MyAnnotatedClass.good.java
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.
*/
package bar;

import foo.MyAnnotation;

@MyAnnotation
public class MyAnnotatedClass {
MyGeneratedClass generatedClass = new MyGeneratedClass();

// foo

}
93 changes: 93 additions & 0 deletions src/it/MCOMPILER-538/code/pom.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,93 @@
<?xml version="1.0"?>
<!--
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 xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 https://maven.apache.org/xsd/maven-4.0.0.xsd" xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<modelVersion>4.0.0</modelVersion>
<parent>
<groupId>foo</groupId>
<artifactId>bar</artifactId>
<version>${revision}</version>
</parent>
<version>${revision}</version>
<packaging>jar</packaging>
<artifactId>code</artifactId>

<dependencies>
<dependency>
<groupId>foo</groupId>
<artifactId>processor</artifactId>
<version>${revision}</version>
<scope>provided</scope>
</dependency>
</dependencies>

<build>
<plugins>
<plugin>
<groupId>com.kohlschutter.mavenplugins</groupId>
<artifactId>copy-rename-maven-plugin</artifactId>
<version>2.0.0</version>
<executions>
<execution>
<id>set-source</id>
<phase>generate-sources</phase>
<goals>
<goal>copy</goal>
</goals>
<configuration>
<fileSets>
<fileSet>
<sourceFile>${basedir}/MyAnnotatedClass.${it.type}.java</sourceFile>
<destinationFile>${basedir}/src/main/java/bar/MyAnnotatedClass.java</destinationFile>
</fileSet>
</fileSets>
</configuration>
</execution>
</executions>
</plugin>

<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-clean-plugin</artifactId>
<version>@version.maven-clean-plugin@</version>
<executions>
<execution>
<id>clean-source-file</id>
<phase>validate</phase>
<goals>
<goal>clean</goal>
</goals>
<configuration>
<excludeDefaultDirectories>true</excludeDefaultDirectories>
<filesets>
<fileset>
<directory>src/main/java</directory>
<excludes>
<exclude>package-info.java</exclude>
</excludes>
</fileset>
</filesets>
</configuration>
</execution>
</executions>
</plugin>
</plugins>
</build>
</project>
1 change: 1 addition & 0 deletions src/it/MCOMPILER-538/code/src/main/java/bar/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
MyAnnotatedClass.java
20 changes: 20 additions & 0 deletions src/it/MCOMPILER-538/code/src/main/java/bar/package-info.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
/*
* 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;
23 changes: 23 additions & 0 deletions src/it/MCOMPILER-538/invoker.properties
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.

# NOTE: The first time, we run up to "integration-test" phase which includes the AntRun execution which saves the
# timestamp of the first JAR for comparison with the timestamp of the JAR from the final "package" invocation.
# Note:
invoker.goals.1 = clean
invoker.goals.2 = compile -Dit.type=bad -Dmaven.compiler.failOnError=false
invoker.goals.3 = compile -Dit.type=good
65 changes: 65 additions & 0 deletions src/it/MCOMPILER-538/pom.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,65 @@
<?xml version="1.0"?>
<!--
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 xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 https://maven.apache.org/xsd/maven-4.0.0.xsd" xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<modelVersion>4.0.0</modelVersion>
<groupId>foo</groupId>
<artifactId>bar</artifactId>
<version>${revision}</version>
<packaging>pom</packaging>

<properties>
<revision>1.0-SNAPSHOT</revision>

<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
</properties>

<modules>
<module>processor</module>
<module>code</module>
</modules>

<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>@project.version@</version>
<configuration>
<encoding>UTF-8</encoding>
<source>17</source>
<target>17</target>
<showWarnings>true</showWarnings>
<showDeprecation>true</showDeprecation>
<fork>true</fork> <!-- Change this to false and the Diagnostic.Kind.NOTE messages show up -->
<useIncrementalCompilation>false</useIncrementalCompilation>
<compilerArgs combine.children="append">
<arg>-Xlint:all,-processing</arg>
<arg>-Xdoclint:all,-missing,-accessibility</arg>
<arg>-Xmaxerrs</arg>
<arg>2147483647</arg>
<arg>-Xmaxwarns</arg>
<arg>2147483647</arg>
</compilerArgs>
</configuration>
</plugin>
</plugins>
</build>
</project>
44 changes: 44 additions & 0 deletions src/it/MCOMPILER-538/processor/pom.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
<?xml version="1.0"?>
<!--
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 xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 https://maven.apache.org/xsd/maven-4.0.0.xsd" xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<modelVersion>4.0.0</modelVersion>
<parent>
<groupId>foo</groupId>
<artifactId>bar</artifactId>
<version>${revision}</version>
</parent>
<version>${revision}</version>
<artifactId>processor</artifactId>
<packaging>jar</packaging>

<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.11.0</version>
<configuration>
<proc>none</proc>
</configuration>
</plugin>
</plugins>
</build>
</project>
28 changes: 28 additions & 0 deletions src/it/MCOMPILER-538/processor/src/main/java/foo/MyAnnotation.java
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.
*/
package foo;

import java.lang.annotation.ElementType;
import java.lang.annotation.Retention;
import java.lang.annotation.RetentionPolicy;
import java.lang.annotation.Target;

@Retention(RetentionPolicy.SOURCE)
@Target(ElementType.TYPE)
public @interface MyAnnotation {}
Loading

0 comments on commit 642f6c3

Please sign in to comment.