Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings
This repository was archived by the owner on Feb 26, 2023. It is now read-only.
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 14 additions & 0 deletions 14 AndroidAnnotations/androidannotations-api/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,10 @@
<target>1.6</target>
</configuration>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-resources-plugin</artifactId>
</plugin>
<plugin>
<artifactId>maven-javadoc-plugin</artifactId>
<executions>
Expand All @@ -66,6 +70,16 @@
</executions>
</plugin>
</plugins>

<resources>
<resource>
<directory>src/main/resources</directory>
<filtering>true</filtering>
<includes>
<include>**/*.properties</include>
</includes>
</resource>
</resources>
</build>

</project>
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ eclipse.preferences.version=1
encoding//src/main/java=UTF-8
encoding//src/main/java/rebel.xml=UTF-8
encoding//src/main/resources=UTF-8
encoding//src/main/resources/androidannotations-version.properties=utf-8
encoding//src/main/resources/androidannotations.properties=utf-8
encoding//src/main/resources/rebel.xml=UTF-8
encoding//src/test/java=UTF-8
encoding//src/test/resources=UTF-8
Expand Down
4 changes: 0 additions & 4 deletions 4 AndroidAnnotations/androidannotations/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -80,10 +80,6 @@
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-resources-plugin</artifactId>
<version>2.5</version>
<configuration>
<encoding>${project.build.sourceEncoding}</encoding>
</configuration>
</plugin>
</plugins>

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,10 +21,12 @@
import static org.androidannotations.helper.ModelConstants.TRACE_OPTION;
import static org.androidannotations.rclass.ProjectRClassFinder.RESOURCE_PACKAGE_NAME_OPTION;

import java.io.FileNotFoundException;
import java.io.IOException;
import java.net.URL;
import java.util.Collections;
import java.util.HashSet;
import java.util.Iterator;
import java.util.Map;
import java.util.Properties;
import java.util.Set;
Expand Down Expand Up @@ -124,6 +126,7 @@
import org.androidannotations.annotations.sharedpreferences.Pref;
import org.androidannotations.annotations.sharedpreferences.SharedPref;
import org.androidannotations.exception.ProcessingException;
import org.androidannotations.exception.VersionMismatchException;
import org.androidannotations.generation.CodeModelGenerator;
import org.androidannotations.helper.AndroidManifest;
import org.androidannotations.helper.AndroidManifestFinder;
Expand Down Expand Up @@ -285,6 +288,7 @@
public class AndroidAnnotationProcessor extends AbstractProcessor {

private final Properties properties = new Properties();
private final Properties propertiesApi = new Properties();
private final TimeStats timeStats = new TimeStats();
private final ErrorHelper errorHelper = new ErrorHelper();

Expand All @@ -296,18 +300,36 @@ public synchronized void init(ProcessingEnvironment processingEnv) {

Messager messager = processingEnv.getMessager();

loadPropertyFile();
try {
loadPropertyFile();
loadApiPropertyFile();
} catch (Exception e) {
messager.printMessage(Diagnostic.Kind.ERROR, "AndroidAnnotations processing failed: " + e.getMessage());
throw new RuntimeException("AndroidAnnotations processing failed", e);
}

timeStats.setMessager(messager);

messager.printMessage(Diagnostic.Kind.NOTE, "Starting AndroidAnnotations annotation processing");

}

private void checkApiAndCoreVersions() throws VersionMismatchException {
String apiVersion = getAAApiVersion();
String coreVersion = getAAProcessorVersion();

if (!apiVersion.equals(coreVersion)) {
throw new VersionMismatchException("AndroidAnnotation version for API (" + apiVersion + ") and core (" + coreVersion + " doesn't match. Please check your classpath)");
}
}

@Override
public boolean process(Set<? extends TypeElement> annotations, RoundEnvironment roundEnv) {
timeStats.clear();
timeStats.start("Whole Processing");

try {
checkApiAndCoreVersions();
processThrowing(annotations, roundEnv);
} catch (ProcessingException e) {
handleException(annotations, roundEnv, e);
Expand All @@ -319,23 +341,34 @@ public boolean process(Set<? extends TypeElement> annotations, RoundEnvironment
return true;
}

private void loadPropertyFile() {
String filename = "androidannotations-version.properties";
private void loadPropertyFile() throws FileNotFoundException {
String filename = "androidannotations.properties";
try {
URL url = getClass().getClassLoader().getResource(filename);
properties.load(url.openStream());
} catch (Exception e) {
e.printStackTrace();
throw new FileNotFoundException(filename + " couldn't be parsed.");
}
}

Messager messager = processingEnv.getMessager();
messager.printMessage(Diagnostic.Kind.NOTE, "AndroidAnnotations processing failed because " + filename + " couldn't be parsed : " + e.getLocalizedMessage());
private void loadApiPropertyFile() throws FileNotFoundException {
String filename = "androidannotations-api.properties";
try {
URL url = getClass().getClassLoader().getResource(filename);
propertiesApi.load(url.openStream());
} catch (Exception e) {
throw new FileNotFoundException(filename + " couldn't be parsed. Please check your classpath and verify that AA-API's version is at least 3.0");
}
}

private String getAAProcessorVersion() {
return properties.getProperty("version", "3.0+");
}

private String getAAApiVersion() {
return propertiesApi.getProperty("version", null);
}

private void processThrowing(Set<? extends TypeElement> annotations, RoundEnvironment roundEnv) throws ProcessingException, Exception {
if (nothingToDo(annotations, roundEnv)) {
return;
Expand Down Expand Up @@ -619,8 +652,16 @@ private void handleException(Set<? extends TypeElement> annotations, RoundEnviro
* eclipse.
*/

Element element = roundEnv.getElementsAnnotatedWith(annotations.iterator().next()).iterator().next();
messager.printMessage(Diagnostic.Kind.ERROR, errorMessage, element);
Iterator<? extends TypeElement> iterator = annotations.iterator();
if (iterator.hasNext()) {
Element element = roundEnv.getElementsAnnotatedWith(iterator.next()).iterator().next();
messager.printMessage(Diagnostic.Kind.ERROR, errorMessage, element);
} else {
// Sometime this is a total mess and javac could not even find one
// element on which we could print the error. So we should just
// throw an exception and let it go.
throw new RuntimeException("An error occured and couldn't be printed on an element: " + errorMessage);
}
}

@Override
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
/**
* Copyright (C) 2010-2013 eBusiness Information, Excilys Group
*
* Licensed 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 org.androidannotations.exception;

public class VersionMismatchException extends Exception {

private static final long serialVersionUID = 1457334941140141471L;

public VersionMismatchException() {
super();
}

public VersionMismatchException(String message, Throwable cause) {
super(message, cause);
}

public VersionMismatchException(String message) {
super(message);
}

public VersionMismatchException(Throwable cause) {
super(cause);
}

}
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
#
# Copyright (C) 2010-2013 eBusiness Information, Excilys Group
#
# Licensed 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.
#

version=${project.version}
11 changes: 9 additions & 2 deletions 11 AndroidAnnotations/pom.xml
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
<?xml version="1.0" encoding="UTF-8"?>
<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">
<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>

<parent>
Expand Down Expand Up @@ -196,6 +195,14 @@
<artifactId>maven-compiler-plugin</artifactId>
<version>2.3.2</version>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-resources-plugin</artifactId>
<version>2.5</version>
<configuration>
<encoding>${project.build.sourceEncoding}</encoding>
</configuration>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-jar-plugin</artifactId>
Expand Down
Morty Proxy This is a proxified and sanitized view of the page, visit original site.