Skip to content
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
6 changes: 6 additions & 0 deletions .devcontainer/devcontainer.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
{
"name": "Java 17 Dev Container",
"image": "mcr.microsoft.com/devcontainers/java:17",
"settings": {},
"extensions": []
}
6 changes: 6 additions & 0 deletions .github/workflows/codeql-analysis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,12 @@ jobs:
- name: Checkout repository
uses: actions/checkout@v2

- name: Set up JDK 17
uses: actions/setup-java@v3
with:
distribution: 'temurin'
java-version: '17'

# Initializes the CodeQL tools for scanning.
- name: Initialize CodeQL
uses: github/codeql-action/init@v1
Expand Down
7 changes: 4 additions & 3 deletions .github/workflows/maven-publish.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,10 +14,11 @@ jobs:

steps:
- uses: actions/checkout@v2
- name: Set up JDK 1.8
uses: actions/setup-java@v1
- name: Set up JDK 17
uses: actions/setup-java@v3
with:
java-version: 1.8
distribution: 'temurin'
java-version: '17'
server-id: github # Value of the distributionManagement/repository/id field of the pom.xml
settings-path: ${{ github.workspace }} # location for the settings.xml file

Expand Down
7 changes: 4 additions & 3 deletions .github/workflows/maven.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,9 +16,10 @@ jobs:

steps:
- uses: actions/checkout@v2
- name: Set up JDK 1.8
uses: actions/setup-java@v1
- name: Set up JDK 17
uses: actions/setup-java@v3
with:
java-version: 1.8
distribution: 'temurin'
java-version: '17'
- name: Build with Maven
run: mvn -B package --file pom.xml
50 changes: 8 additions & 42 deletions dependency-reduced-pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -6,30 +6,9 @@
<version>4.0.0</version>
<build>
<plugins>
<plugin>
<artifactId>maven-install-plugin</artifactId>
<executions>
<execution>
<id>hack-binary</id>
<phase>clean</phase>
<goals>
<goal>install-file</goal>
</goals>
<configuration>
<file>${JAVA_HOME}/lib/tools.jar</file>
<repositoryLayout>default</repositoryLayout>
<groupId>com.sun</groupId>
<artifactId>tools</artifactId>
<version>jdk1.8.0</version>
<packaging>jar</packaging>
<generatePom>true</generatePom>
</configuration>
</execution>
</executions>
</plugin>
<plugin>
<artifactId>maven-shade-plugin</artifactId>
<version>3.0.0</version>
<plugin>
<artifactId>maven-shade-plugin</artifactId>
<version>3.0.0</version>
<executions>
<execution>
<phase>package</phase>
Expand All @@ -44,20 +23,7 @@
</plugin>
</plugins>
</build>
<profiles>
<profile>
<id>windows-profile</id>
<properties>
<toolsjar>${JAVA_HOME}/lib/tools.jar</toolsjar>
</properties>
</profile>
<profile>
<id>mac-profile</id>
<properties>
<toolsjar>${java.home}/../lib/tools.jar</toolsjar>
</properties>
</profile>
</profiles>
<!-- obsolete profiles removed -->
<dependencies>
<dependency>
<groupId>junit</groupId>
Expand All @@ -73,8 +39,8 @@
</dependency>
</dependencies>
<properties>
<maven.compiler.source>1.8</maven.compiler.source>
<maven.compiler.target>1.8</maven.compiler.target>
</properties>
</project>
<maven.compiler.source>17</maven.compiler.source>
<maven.compiler.target>17</maven.compiler.target>
</properties>
</project>

6 changes: 3 additions & 3 deletions nb-configuration.xml
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,6 @@ You can copy and paste the single properties, into the pom.xml file and the IDE
That way multiple projects can share the same settings (useful for formatting rules for example).
Any value defined here will override the pom.xml file value but is only applicable to the current project.
-->
<netbeans.hint.jdkPlatform>JDK_1.8</netbeans.hint.jdkPlatform>
</properties>
</project-shared-configuration>
<netbeans.hint.jdkPlatform>JDK_17</netbeans.hint.jdkPlatform>
</properties>
</project-shared-configuration>
130 changes: 57 additions & 73 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -4,56 +4,41 @@
<artifactId>hellofunction</artifactId>
<version>6.0.1</version>
<properties>
<maven.compiler.source>1.8</maven.compiler.source>
<maven.compiler.target>1.8</maven.compiler.target>
<maven.compiler.source>17</maven.compiler.source>
<maven.compiler.target>17</maven.compiler.target>
<maven.compiler.release>17</maven.compiler.release>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
</properties>

<profiles>
<profile>
<id>windows-profile</id>
<activation>
<activeByDefault>true</activeByDefault>
<file>
<exists>${JAVA_HOME}/lib/tools.jar</exists>
</file>
</activation>
<properties>
<toolsjar>${JAVA_HOME}/lib/tools.jar</toolsjar>
</properties>
</profile>
<profile>
<id>mac-profile</id>
<activation>
<activeByDefault>false</activeByDefault>
<file>
<exists>${java.home}/../lib/tools.jar</exists>
</file>
</activation>
<properties>
<toolsjar>${java.home}/../lib/tools.jar</toolsjar>
</properties>
</profile>
</profiles>
<repositories>
<repository>
<id>cagatay-gurturk</id>
<url>http://maven.cagataygurturk.com/releases</url>
</repository>
<!-- <repository>
<id>repo.eclipse.org</id>
<name>Eclipse Repository - Releases</name>
<url>https://repo.eclipse.org/content/repositories/eclipse-staging/</url>
</repository>-->
</repositories>

<dependencyManagement>
<dependencies>
<dependency>
<groupId>com.amazonaws</groupId>
<artifactId>aws-java-sdk-bom</artifactId>
<version>1.12.789</version>
<type>pom</type>
<scope>import</scope>
</dependency>
<dependency>
<groupId>com.amazonaws</groupId>
<artifactId>aws-java-sdk-bom</artifactId>
<version>1.12.789</version>
<type>pom</type>
<scope>import</scope>
</dependency>
</dependencies>
</dependencyManagement>

<dependencies>
<dependency>
<groupId>com.amazonaws</groupId>
<artifactId>aws-java-sdk-lambda</artifactId>
<version>1.12.789</version>
</dependency>
<dependency>
<groupId>com.amazonaws</groupId>
<artifactId>aws-java-sdk-lambda</artifactId>
<version>1.12.789</version>
</dependency>

<dependency>
<groupId>com.amazonaws</groupId>
Expand Down Expand Up @@ -85,10 +70,9 @@

<dependency>
<groupId>org.eclipse.jdt</groupId>
<artifactId>ecj</artifactId>
<version>3.42.0</version>
<!-- Updated to latest ECJ; in-memory compilation bug fixed in recent releases -->
</dependency>
<artifactId>ecj</artifactId>
<version>3.42.0</version>
</dependency>

<dependency>
<groupId>junit</groupId>
Expand Down Expand Up @@ -119,34 +103,34 @@
</dependencies>
<build>
<plugins>
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>exec-maven-plugin</artifactId>
<version>1.2.1</version>
<configuration>
<mainClass>com.cagataygurturk.lambda.LocalRunner</mainClass>
<arguments>
<argument>handleRequest</argument>
</arguments>
</configuration>
</plugin>

<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-plugin</artifactId>
<version>2.22.2</version>
<configuration>
<systemPropertyVariables>
<run.mycode.debug>true</run.mycode.debug>
</systemPropertyVariables>
</configuration>
</plugin>

<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-shade-plugin</artifactId>
<version>2.3</version>
<configuration>
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>exec-maven-plugin</artifactId>
<version>1.2.1</version>
<configuration>
<mainClass>com.cagataygurturk.lambda.LocalRunner</mainClass>
<arguments>
<argument>handleRequest</argument>
</arguments>
</configuration>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-plugin</artifactId>
<version>2.22.2</version>
<configuration>
<systemPropertyVariables>
<run.mycode.debug>true</run.mycode.debug>
</systemPropertyVariables>
</configuration>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-shade-plugin</artifactId>
<version>2.3</version>
<configuration>
<createDependencyReducedPom>false</createDependencyReducedPom>
</configuration>
<executions>
Expand Down
52 changes: 26 additions & 26 deletions src/main/java/run/myCode/compiler/JavaCodeCompiler.java
Original file line number Diff line number Diff line change
Expand Up @@ -17,11 +17,11 @@
import javax.tools.JavaFileObject;
import javax.tools.StandardJavaFileManager;

import javax.tools.ToolProvider;
import javax.tools.ToolProvider;

public class JavaCodeCompiler {

private static final boolean DEBUG = Boolean.getBoolean("run.mycode.debug");
public class JavaCodeCompiler {
private static final boolean DEBUG = Boolean.getBoolean("run.mycode.debug");

/**
* Compile Java source files into memory
Expand Down Expand Up @@ -56,34 +56,34 @@ public static FromMemoryClassLoader compile(Iterable<? extends JavaFileObject> f

final FromMemoryClassLoader classLoader = new FromMemoryClassLoader(urlcl);
// get system compiler:
// Use the standard Java compiler provided by the JDK. This avoids ECJ
// attempting to resolve in-memory sources on disk which resulted in
// "File ... is missing" errors during tests.
final JavaCompiler compiler = ToolProvider.getSystemJavaCompiler();
// Use the standard Java compiler provided by the JDK. This avoids ECJ
// attempting to resolve in-memory sources on disk which resulted in
// "File ... is missing" errors during tests.
final JavaCompiler compiler = ToolProvider.getSystemJavaCompiler();

// create a diagnostic listener for compilation diagnostic message processing on
// compilation WARNING/ERROR
final CompileDiagnosticListener diag = new CompileDiagnosticListener();
final StandardJavaFileManager stdfileManager = compiler.getStandardFileManager(diag, Locale.ENGLISH, null);

InMemoryJavaFileManager fileManager = new InMemoryJavaFileManager(stdfileManager, classLoader);
for (JavaFileObject file : files) {
fileManager.addSource(file);
if (DEBUG) {
System.out.println("Compiling source " + file.getName());
}
}
InMemoryJavaFileManager fileManager = new InMemoryJavaFileManager(stdfileManager, classLoader);
for (JavaFileObject file : files) {
fileManager.addSource(file);
if (DEBUG) {
System.out.println("Compiling source " + file.getName());
}
}

// specify options for compiler
if (options == null) {
options = new ArrayList<>();
}

// Build the classpath from the current folder and the system classpath
StringBuilder classpathBuilder =
new StringBuilder("." +
System.getProperty("path.separator") +
System.getProperty("java.class.path"));
// Build the classpath from the current folder and the system classpath
StringBuilder classpathBuilder =
new StringBuilder("." +
System.getProperty("path.separator") +
System.getProperty("java.class.path"));

// Add any included jar files from the lib folder to the classpath (wildcard isn't working)
try {
Expand All @@ -108,16 +108,16 @@ public static FromMemoryClassLoader compile(Iterable<? extends JavaFileObject> f
// Set the classpath and java version for the compiler
options.addAll(Arrays.asList("-classpath",
classpath));
options.addAll(Arrays.asList("--release", "8"));
options.addAll(Arrays.asList("-17"));

Writer out = new PrintWriter(System.out);

// Compile the code
JavaCompiler.CompilationTask task = compiler.getTask(out, fileManager, diag, options, null, files);
if (DEBUG) {
System.out.println("Starting compilation with mem URIs");
}
boolean result = task.call();
JavaCompiler.CompilationTask task = compiler.getTask(out, fileManager, diag, options, null, files);
if (DEBUG) {
System.out.println("Starting compilation with mem URIs");
}
boolean result = task.call();

// Return the classloader containing the compiled classes
return classLoader;
Expand Down
Loading