Skip to content

Commit 5290a6f

Browse files
committed
Create seperate module for compile-time test utilities
1 parent 73723eb commit 5290a6f

8 files changed

Lines changed: 108 additions & 3 deletions

File tree

Lines changed: 75 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,75 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<!--
3+
4+
Copyright (C) 2010-2015 eBusiness Information, Excilys Group
5+
6+
Licensed under the Apache License, Version 2.0 (the "License"); you may not
7+
use this file except in compliance with the License. You may obtain a copy of
8+
the License at
9+
10+
http://www.apache.org/licenses/LICENSE-2.0
11+
12+
Unless required by applicable law or agreed To in writing, software
13+
distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
14+
WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
15+
License for the specific language governing permissions and limitations under
16+
the License.
17+
18+
-->
19+
<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">
20+
<modelVersion>4.0.0</modelVersion>
21+
22+
<parent>
23+
<groupId>org.androidannotations</groupId>
24+
<artifactId>androidannotations-core</artifactId>
25+
<version>4.0-SNAPSHOT</version>
26+
</parent>
27+
28+
<artifactId>androidannotations-testutils</artifactId>
29+
<name>AndroidAnnotations Common Test Utilities</name>
30+
<description>Common test utilities for testing processors</description>
31+
32+
<properties>
33+
<main.basedir>${project.parent.parent.basedir}</main.basedir>
34+
</properties>
35+
36+
<dependencies>
37+
<dependency>
38+
<groupId>junit</groupId>
39+
<artifactId>junit</artifactId>
40+
<scope>compile</scope>
41+
</dependency>
42+
</dependencies>
43+
44+
<build>
45+
<plugins>
46+
<plugin>
47+
<artifactId>maven-javadoc-plugin</artifactId>
48+
<executions>
49+
<execution>
50+
<id>attach-javadocs</id>
51+
<goals>
52+
<goal>jar</goal>
53+
</goals>
54+
</execution>
55+
</executions>
56+
</plugin>
57+
<plugin>
58+
<artifactId>maven-source-plugin</artifactId>
59+
<executions>
60+
<execution>
61+
<id>attach-sources</id>
62+
<goals>
63+
<goal>jar</goal>
64+
</goals>
65+
</execution>
66+
</executions>
67+
</plugin>
68+
<plugin>
69+
<groupId>org.apache.maven.plugins</groupId>
70+
<artifactId>maven-resources-plugin</artifactId>
71+
</plugin>
72+
</plugins>
73+
</build>
74+
75+
</project>

AndroidAnnotations/androidannotations-core/androidannotations/src/main/java/org/androidannotations/testutils/AAProcessorTestHelper.java renamed to AndroidAnnotations/androidannotations-core/androidannotations-testutils/src/main/java/org/androidannotations/testutils/AAProcessorTestHelper.java

Lines changed: 18 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -15,9 +15,8 @@
1515
*/
1616
package org.androidannotations.testutils;
1717

18-
import static org.androidannotations.helper.ModelConstants.classSuffix;
19-
2018
import java.io.File;
19+
import java.lang.reflect.Method;
2120

2221
public class AAProcessorTestHelper extends ProcessorTestHelper {
2322

@@ -31,12 +30,28 @@ public void addManifestProcessorParameter(Class<?> classOfPackagingContainingMan
3130
}
3231

3332
public File toGeneratedFile(Class<?> compiledClass) {
34-
File output = new File(OUTPUT_DIRECTORY, toPath(compiledClass.getPackage()) + "/" + compiledClass.getSimpleName() + classSuffix() + SOURCE_FILE_SUFFIX);
33+
File output = new File(OUTPUT_DIRECTORY, toPath(compiledClass.getPackage()) + "/" + compiledClass.getSimpleName() + getAndroidAnnotationsClassSuffix() + SOURCE_FILE_SUFFIX);
3534
return output;
3635
}
3736

3837
public String toPath(Class<?> classOfPackagingContainingFile, String filename) {
3938
return classOfPackagingContainingFile.getResource(filename).getPath();
4039
}
4140

41+
/**
42+
* This module cannot depend on androidannotations module, because that would introduce a cycle in the dependency graph.
43+
* That is why we cannot directly reference the <code>classSuffix</code> method.
44+
* We still have to use this method, so we call it reflectively.
45+
*
46+
* @return the result of <code>org.androidannotations.helper.ModelConstants.classSuffix()</code>
47+
*/
48+
private static String getAndroidAnnotationsClassSuffix() {
49+
try {
50+
Class<?> modelConstantsClazz = Class.forName("org.androidannotations.helper.ModelConstants");
51+
Method classSuffixMethod = modelConstantsClazz.getMethod("classSuffix");
52+
return (String) classSuffixMethod.invoke(null);
53+
} catch (ReflectiveOperationException e) {
54+
return "_";
55+
}
56+
}
4257
}

AndroidAnnotations/androidannotations-core/androidannotations/src/main/java/org/androidannotations/testutils/ClassFinder.java renamed to AndroidAnnotations/androidannotations-core/androidannotations-testutils/src/main/java/org/androidannotations/testutils/ClassFinder.java

File renamed without changes.

AndroidAnnotations/androidannotations-core/androidannotations/src/main/java/org/androidannotations/testutils/ProcessorTestHelper.java renamed to AndroidAnnotations/androidannotations-core/androidannotations-testutils/src/main/java/org/androidannotations/testutils/ProcessorTestHelper.java

File renamed without changes.

‎AndroidAnnotations/androidannotations-core/androidannotations/pom.xml‎

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,10 @@
4646
<groupId>junit</groupId>
4747
<artifactId>junit</artifactId>
4848
</dependency>
49+
<dependency>
50+
<groupId>org.androidannotations</groupId>
51+
<artifactId>androidannotations-testutils</artifactId>
52+
</dependency>
4953
<dependency>
5054
<groupId>com.google.android</groupId>
5155
<artifactId>android</artifactId>

‎AndroidAnnotations/androidannotations-core/pom.xml‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,7 @@
3838
<module>androidannotations</module>
3939
<module>androidannotations-api</module>
4040
<module>androidannotations-test</module>
41+
<module>androidannotations-testutils</module>
4142
</modules>
4243

4344
</project>

‎AndroidAnnotations/androidannotations-rest-spring/rest-spring/pom.xml‎

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -61,6 +61,10 @@
6161
<groupId>junit</groupId>
6262
<artifactId>junit</artifactId>
6363
</dependency>
64+
<dependency>
65+
<groupId>org.androidannotations</groupId>
66+
<artifactId>androidannotations-testutils</artifactId>
67+
</dependency>
6468
</dependencies>
6569

6670
<build>

‎AndroidAnnotations/pom.xml‎

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -157,6 +157,12 @@
157157
<version>${project.version}</version>
158158
<scope>compile</scope>
159159
</dependency>
160+
<dependency>
161+
<groupId>org.androidannotations</groupId>
162+
<artifactId>androidannotations-testutils</artifactId>
163+
<version>${project.version}</version>
164+
<scope>test</scope>
165+
</dependency>
160166
<dependency>
161167
<groupId>com.sun.codemodel</groupId>
162168
<artifactId>codemodel</artifactId>

0 commit comments

Comments
 (0)