Skip to content
This repository has been archived by the owner on Mar 27, 2024. It is now read-only.

Commit

Permalink
Merge branch 'next' into dataelement-imports
Browse files Browse the repository at this point in the history
  • Loading branch information
dbluhm committed Aug 6, 2020
2 parents c997180 + 0f5a65d commit 61a3b96
Show file tree
Hide file tree
Showing 39 changed files with 917 additions and 66 deletions.
2 changes: 2 additions & 0 deletions org.eclipse.ice.archetypes/.gitignore
@@ -0,0 +1,2 @@
/target/
/bin/
27 changes: 27 additions & 0 deletions org.eclipse.ice.build/.classpath
@@ -0,0 +1,27 @@
<?xml version="1.0" encoding="UTF-8"?>
<classpath>
<classpathentry kind="src" output="target/classes" path="src/main/java">
<attributes>
<attribute name="optional" value="true"/>
<attribute name="maven.pomderived" value="true"/>
</attributes>
</classpathentry>
<classpathentry kind="src" output="target/test-classes" path="src/test/java">
<attributes>
<attribute name="optional" value="true"/>
<attribute name="maven.pomderived" value="true"/>
<attribute name="test" value="true"/>
</attributes>
</classpathentry>
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-1.7">
<attributes>
<attribute name="maven.pomderived" value="true"/>
</attributes>
</classpathentry>
<classpathentry kind="con" path="org.eclipse.m2e.MAVEN2_CLASSPATH_CONTAINER">
<attributes>
<attribute name="maven.pomderived" value="true"/>
</attributes>
</classpathentry>
<classpathentry kind="output" path="target/classes"/>
</classpath>
1 change: 1 addition & 0 deletions org.eclipse.ice.build/.gitignore
@@ -0,0 +1 @@
/target/
23 changes: 23 additions & 0 deletions org.eclipse.ice.build/.project
@@ -0,0 +1,23 @@
<?xml version="1.0" encoding="UTF-8"?>
<projectDescription>
<name>org.eclipse.ice.build</name>
<comment></comment>
<projects>
</projects>
<buildSpec>
<buildCommand>
<name>org.eclipse.jdt.core.javabuilder</name>
<arguments>
</arguments>
</buildCommand>
<buildCommand>
<name>org.eclipse.m2e.core.maven2Builder</name>
<arguments>
</arguments>
</buildCommand>
</buildSpec>
<natures>
<nature>org.eclipse.jdt.core.javanature</nature>
<nature>org.eclipse.m2e.core.maven2Nature</nature>
</natures>
</projectDescription>
31 changes: 31 additions & 0 deletions org.eclipse.ice.build/pom.xml
@@ -0,0 +1,31 @@
<?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/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>

<parent>
<groupId>org.eclipse.ice</groupId>
<artifactId>org.eclipse.ice.parent</artifactId>
<version>2.2.1-SNAPSHOT</version>
<relativePath>../org.eclipse.ice.parent/pom.xml</relativePath>
</parent>
<groupId>org.eclipse.ice</groupId>
<artifactId>org.eclipse.ice.build</artifactId>
<version>1.0-SNAPSHOT</version>
<packaging>pom</packaging>

<name>org.eclipse.ice.build</name>

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

<modules>
<module>../org.eclipse.ice.parent</module>
<module>../org.eclipse.ice.dev</module>
<module>../org.eclipse.ice.archetypes</module>
<module>../org.eclipse.ice.commands</module>

</modules>
</project>
5 changes: 5 additions & 0 deletions org.eclipse.ice.dev/org.eclipse.ice.dev.annotations/pom.xml
Expand Up @@ -102,6 +102,11 @@
<version>3.0.0-SNAPSHOT</version>
<scope>compile</scope>
</dependency>
<dependency>
<groupId>com.cosium.logging</groupId>
<artifactId>annotation-processor-logger</artifactId>
<version>1.0</version>
</dependency>
</dependencies>

<parent>
Expand Down
Expand Up @@ -10,7 +10,6 @@
import java.util.List;
import java.util.Set;

import javax.annotation.processing.AbstractProcessor;
import javax.annotation.processing.Messager;
import javax.annotation.processing.ProcessingEnvironment;
import javax.annotation.processing.Processor;
Expand All @@ -28,6 +27,7 @@
import org.eclipse.ice.dev.annotations.DataElement;
import org.eclipse.ice.dev.annotations.Persisted;

import com.cosium.logging.annotation_processor.AbstractLoggingProcessor;
import com.fasterxml.jackson.databind.ObjectMapper;
import com.google.auto.service.AutoService;

Expand All @@ -46,7 +46,7 @@
})
@SupportedSourceVersion(SourceVersion.RELEASE_11)
@AutoService(Processor.class)
public class DataElementProcessor extends AbstractProcessor {
public class DataElementProcessor extends AbstractLoggingProcessor {
/**
* Return stack trace as string.
* @param e subject exception
Expand All @@ -73,7 +73,7 @@ public void init(final ProcessingEnvironment env) {
}

@Override
public boolean process(final Set<? extends TypeElement> annotations, final RoundEnvironment roundEnv) {
public boolean doProcess(final Set<? extends TypeElement> annotations, final RoundEnvironment roundEnv) {
// Iterate over all elements with DataElement Annotation
for (final Element elem : roundEnv.getElementsAnnotatedWith(DataElement.class)) {
try {
Expand Down
Expand Up @@ -11,62 +11,55 @@

package org.eclipse.ice.dev.annotations.processors;

import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.io.IOException;
import java.io.InputStream;
import java.util.Properties;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

/**
* Properties used to initialize Velocity.
*/
enum VelocityProperties {

// Set up Velocity using the Singleton approach; ClasspathResourceLoader allows
// us to load templates from src/main/resources
LIBRARY_PATH("velocimacro.library.path", "templates/common.vm"),
RESOURCE_LOADER("resource.loader", "class"),
CLASS_RESOURCE_LOADER(
"class.resource.loader.class",
"org.apache.velocity.runtime.resource.loader.ClasspathResourceLoader"
);
class VelocityProperties extends Properties {

/**
* Property key.
* Serial Version ID.
*/
private String key;
private static final long serialVersionUID = 1L;

/**
* Property value.
* Logger.
*/
private String value;

VelocityProperties(String key, String value) {
this.key = key;
this.value = value;
}
private static final Logger logger = LoggerFactory.getLogger(VelocityProperties.class);

/**
* Get key from enum.
* @return key
* Velocity property filename.
*/
String key() {
return this.key;
}
private static final String FILENAME = "velocity.properties";

private static VelocityProperties instance = null;

/**
* Get value from enum.
* @return value
* Construct VelocityProperties, loading from resource file.
*/
String value() {
return this.value;
private VelocityProperties() {
String propertyFile = getClass().getClassLoader().getResource(FILENAME).getPath();
try (InputStream propertyStream = new FileInputStream(propertyFile)) {
super.load(propertyStream);
} catch (FileNotFoundException e) {
logger.error("velocity.properties could not be found");
} catch (IOException e) {
logger.error("velocity.properties could not be read");
}
}

/**
* Generate and return Properties from enum.
* @return Properties
*/
public static Properties get() {
Properties p = new Properties();
for (VelocityProperties vp : VelocityProperties.values()) {
p.setProperty(vp.key(), vp.value());
public static VelocityProperties get() {
if (instance == null) {
instance = new VelocityProperties();
}
return p;
return instance;
}
}
}
@@ -0,0 +1,3 @@
resource.loaders=class
resource.loader.class.class=org.apache.velocity.runtime.resource.loader.ClasspathResourceLoader
velocimacro.library.path=templates/common.vm
Expand Up @@ -13,22 +13,34 @@

import java.lang.reflect.Constructor;
import java.lang.reflect.InvocationTargetException;
import java.util.Locale;

import javax.annotation.processing.Processor;
import javax.tools.Diagnostic;
import javax.tools.JavaFileObject;

import org.eclipse.ice.dev.annotations.processors.DataElementProcessor;

import com.google.testing.compile.Compilation;

import static com.google.testing.compile.Compiler.*;
import static com.google.testing.compile.CompilationSubject.*;

/**
* Helper class for testing DataElement related annotations.
* @author Daniel Bluhm
*/
public class DataElementAnnotationTestHelper {

private boolean showDiagnostics = false;

public DataElementAnnotationTestHelper() {
String show = System.getenv("SHOW_DIAGNOSTICS");
if (show != null && show.equals("true")) {
this.showDiagnostics = true;
}
}

/**
* Retrieve an instance of Lombok's Annotation Processor.
*
Expand All @@ -55,16 +67,32 @@ private Processor getLombokAnnotationProcessor() {
return p;
}

private void printDiagnostics(Compilation compilation) {
for (Diagnostic<? extends JavaFileObject> diag :
compilation.diagnostics()
) {
System.err.println(String.format(
"[%s]: %s",
diag.getKind().toString(),
diag.getMessage(Locale.ENGLISH)
));
}
}

/**
* Compile the sources with needed processors.
* @param sources to compile
* @return Compilation result
*/
public Compilation compile(JavaFileObject... sources) {
return javac()
Compilation compilation = javac()
.withProcessors(
getLombokAnnotationProcessor(),
new DataElementProcessor()
).compile(sources);
if (showDiagnostics) {
printDiagnostics(compilation);
}
return compilation;
}
}

0 comments on commit 61a3b96

Please sign in to comment.