Skip to content

Commit

Permalink
add java-8
Browse files Browse the repository at this point in the history
  • Loading branch information
samruddhikhandale committed Aug 26, 2022
1 parent a47b35c commit e16537d
Show file tree
Hide file tree
Showing 20 changed files with 584 additions and 10 deletions.
13 changes: 11 additions & 2 deletions .github/workflows/smoke-java.yaml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
name: Smoke test "java" build
name: Smoke test "java" and "java-8" build

on:
workflow_dispatch:
Expand All @@ -8,6 +8,7 @@ on:
pull_request:
paths:
- src/java/**
- src/java-8/**
- .github/workflows/smoke-java.yaml
- .github/actions/**
- build/**
Expand All @@ -21,10 +22,18 @@ jobs:
id: checkout
uses: actions/checkout@v3

- name: Smoke test
- name: Smoke test java
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
id: smoke_test_java
uses: ./.github/actions/smoke-test
with:
image: java

- name: Smoke test java-8
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
id: smoke_test_java_8
uses: ./.github/actions/smoke-test
with:
image: java-8
42 changes: 42 additions & 0 deletions src/java-8/.devcontainer.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
{
"name": "Java 8",
"build": {
"dockerfile": "Dockerfile"
},
"features": {
"ghcr.io/devcontainers/features/java:1": {
"version": "8"
},
"ghcr.io/devcontainers/features/node:1": "none"
},

// Configure tool-specific properties.
"customizations": {
// Configure properties specific to VS Code.
"vscode": {
// Set *default* container specific settings.json values on container create.
"settings": {
"java.import.gradle.java.home": "/usr/local/sdkman/candidates/java/current",
"java.configuration.runtimes": [
{
"default": true,
"name": "JavaSE-1.8",
"path": "/usr/local/sdkman/candidates/java/current"
}
]
},
// Add the IDs of extensions you want installed when the container is created.
"extensions": [
"vscjava.vscode-java-pack"
]
}
},
// Use 'forwardPorts' to make a list of ports inside the container available locally.
// "forwardPorts": [],

// Use 'postCreateCommand' to run commands after the container is created.
// "postCreateCommand": "java -version",

// Comment out to connect as root instead. More info: https://aka.ms/vscode-remote/containers/non-root.
"remoteUser": "vscode"
}
5 changes: 5 additions & 0 deletions src/java-8/.npmignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
README.md
test-project
history
manifest.json
.npmignore
7 changes: 7 additions & 0 deletions src/java-8/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
# [Choice] Debian OS version (use bullseye on local arm64/Apple Silicon): buster, bullseye
ARG VARIANT="bullseye"
FROM mcr.microsoft.com/devcontainers/base:${VARIANT}

# [Optional] Uncomment this section to install additional OS packages.
# RUN apt-get update && export DEBIAN_FRONTEND=noninteractive \
# && apt-get -y install --no-install-recommends <your-package-list-here>
76 changes: 76 additions & 0 deletions src/java-8/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,76 @@
# Java 8

## Summary

*Develop Java applications. Includes the JDK 8 and Java extensions.*

| Metadata | Value |
|----------|-------|
| *Categories* | Core, Languages |
| *Image type* | Dockerfile |
| *Published images* | mcr.microsoft.com/devcontainers/java:8 |
| *Available image variants* | 8 / 8-buster, 8-bullseye ([full list](https://mcr.microsoft.com/v2/devcontainers/java/tags/list)) |
| *Published image architecture(s)* | x86-64, arm64/aarch64 for `bullseye` variant |
| *Container host OS support* | Linux, macOS, Windows |
| *Container OS* | Debian |
| *Languages, platforms* | Java |

See **[history](history)** for information on the contents of published images.

## Using this image

> **Note:** A version of this [image for **newer JDKs**](../java) is also available!
You can directly reference pre-built versions of `Dockerfile` by using the `image` property in `.devcontainer.json` or updating the `FROM` statement in your own `Dockerfile` to one of the following. An example `Dockerfile` is included in this repository.

- `mcr.microsoft.com/devcontainers/java:8` (or `8-bullseye`, `8-buster` to pin to an OS version)

You can decide how often you want updates by referencing a [semantic version](https://semver.org/) of each image. For example:

- `mcr.microsoft.com/devcontainers/java:1-8` (or `1-8-bullseye`, `1-8-buster` to pin to an OS version)
- `mcr.microsoft.com/devcontainers/java:1.0-8` (or `1.0-8-bullseye`, `1.0-8-buster` to pin to an OS version)
- `mcr.microsoft.com/devcontainers/java:1.0.0-8` (or `1.0.0-8-bullseye`, `1.0.0-8-buster` to pin to an OS version)

However, we only do security patching on the latest [non-breaking, in support](https://github.com/microsoft/vscode-dev-containers/issues/532) versions of images (e.g. `1-8`). You may want to run `apt-get update && apt-get upgrade` in your Dockerfile if you lock to a more specific version to at least pick up OS security updates.

See [history](history) for information on the contents of each version and [here for a complete list of available tags](https://mcr.microsoft.com/v2/devcontainers/java/tags/list).

Alternatively, you can use the contents of `Dockerfile` to fully customize your container's contents or to build it for a container host architecture not supported by the image.

### Installing Maven or Gradle

You can use the [Java Feature](https://github.com/devcontainers/features/tree/main/src/java) to install `maven` and `gradle` in `.devcontainer.json`:

```json
{
"features": {
"ghcr.io/devcontainers/features/java:1": {
"version": "none",
"installGradle": "true",
"installMaven": "true"
}
}
}
```

### Installing Node.js

Given JavaScript front-end web client code written for use in conjunction with a Java back-end often requires the use of Node.js-based utilities to build, this container also includes `nvm` so that you can easily install Node.js.

Also, you can use a [Node Feature](https://github.com/devcontainers/features/tree/main/src/node) to install any version of Node by adding the following to `.devcontainer.json`:

```json
{
"features": {
"ghcr.io/devcontainers/features/node:1": {
"version": "latest"
}
}
}
```

## License

Copyright (c) Microsoft Corporation. All rights reserved.

Licensed under the MIT License. See [LICENSE](https://github.com/devcontainers/images/blob/main/LICENSE).
61 changes: 61 additions & 0 deletions src/java-8/manifest.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,61 @@
{
"version": "1.0.0",
"variants": [
"bullseye",
"buster"
],
"build": {
"latest": false,
"rootDistro": "debian",
"architectures": {
"bullseye": [
"linux/amd64",
"linux/arm64"
],
"buster": [
"linux/amd64"
]
},
"tags": [
"java:${VERSION}-8-${VARIANT}"
],
"variantTags": {
"buster": [
"java:${VERSION}-8",
"java:${VERSION}-8-jdk-buster"
],
"bullseye": [
"java:${VERSION}-8-jdk-bullseye"
]
}
},
"dependencies": {
"image": "buildpack-deps:${BASE_IMAGE_VERSION_CODENAME}-curl",
"imageLink": "https://hub.docker.com/_/buildpack-deps",
"apt": [
{
"cgIgnore": false,
"name": "yarn"
}
],
"git": {
"Oh My Zsh!": "/home/vscode/.oh-my-zsh",
"nvm": "/usr/local/share/nvm"
},
"other": {
"SDKMAN!": null,
"Eclipse Temurin": {
"markdownIgnore": true,
"versionCommand": "/usr/local/sdkman/candidates/java/current/bin/java -version 2>&1 | grep -ozP '^openjdk\\sversion\\s\\\"\\K[^\\\"]+' | tr '\\0' '\\n'",
"downloadUrl": "https://adoptium.net/"
}
},
"languages": {
"Java": {
"cgIgnore": true,
"versionCommand": "/usr/local/sdkman/candidates/java/current/bin/java -version 2>&1 | grep -ozP '^openjdk\\sversion\\s\\\"\\K[^\\\"]+' | tr '\\0' '\\n' && /usr/local/openjdk-*/bin/java --version | grep -ozP 'openjdk\\s+\\K[0-9]+\\.[0-9]+\\.[0-9]+' | tr '\\0' '\\n'",
"path": "/usr/local/sdkman/candidates/java/current<br />/usr/local"
}
}
}
}
44 changes: 44 additions & 0 deletions src/java-8/test-project/.classpath
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
<?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.8">
<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="src" path="target/generated-sources/annotations">
<attributes>
<attribute name="optional" value="true"/>
<attribute name="maven.pomderived" value="true"/>
<attribute name="ignore_optional_problems" value="true"/>
<attribute name="m2e-apt" value="true"/>
</attributes>
</classpathentry>
<classpathentry kind="src" output="target/test-classes" path="target/generated-test-sources/test-annotations">
<attributes>
<attribute name="optional" value="true"/>
<attribute name="maven.pomderived" value="true"/>
<attribute name="ignore_optional_problems" value="true"/>
<attribute name="m2e-apt" value="true"/>
<attribute name="test" value="true"/>
</attributes>
</classpathentry>
<classpathentry kind="output" path="target/classes"/>
</classpath>
1 change: 1 addition & 0 deletions src/java-8/test-project/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
target
23 changes: 23 additions & 0 deletions src/java-8/test-project/.project
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
<?xml version="1.0" encoding="UTF-8"?>
<projectDescription>
<name>my-app</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>
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
eclipse.preferences.version=1
org.eclipse.jdt.apt.aptEnabled=false
9 changes: 9 additions & 0 deletions src/java-8/test-project/.settings/org.eclipse.jdt.core.prefs
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
eclipse.preferences.version=1
org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.8
org.eclipse.jdt.core.compiler.compliance=1.8
org.eclipse.jdt.core.compiler.problem.enablePreviewFeatures=disabled
org.eclipse.jdt.core.compiler.problem.forbiddenReference=warning
org.eclipse.jdt.core.compiler.problem.reportPreviewFeatures=ignore
org.eclipse.jdt.core.compiler.processAnnotations=disabled
org.eclipse.jdt.core.compiler.release=disabled
org.eclipse.jdt.core.compiler.source=1.8
4 changes: 4 additions & 0 deletions src/java-8/test-project/.settings/org.eclipse.m2e.core.prefs
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
activeProfiles=
eclipse.preferences.version=1
resolveWorkspaceProjects=true
version=1
56 changes: 56 additions & 0 deletions src/java-8/test-project/pom.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
<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>
<groupId>com.mycompany.app</groupId>
<artifactId>my-app</artifactId>
<packaging>jar</packaging>
<version>1.0-SNAPSHOT</version>
<name>my-app</name>
<url>http://maven.apache.org</url>

<properties>
<maven.compiler.source>8</maven.compiler.source>
<maven.compiler.target>8</maven.compiler.target>
</properties>

<dependencies>
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>4.13.1</version>
<scope>test</scope>
</dependency>
</dependencies>

<build>
<pluginManagement>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-plugin</artifactId>
<version>3.0.0-M3</version>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.8.0</version>
<configuration>
<source>8</source>
<target>8</target>
</configuration>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-jar-plugin</artifactId>
<configuration>
<archive>
<manifest>
<mainClass>com.mycompany.app.App</mainClass>
</manifest>
</archive>
</configuration>
</plugin>
</plugins>
</pluginManagement>
</build>
</project>
17 changes: 17 additions & 0 deletions src/java-8/test-project/src/main/java/com/mycompany/app/App.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
/*-------------------------------------------------------------------------------------------------------------
* Copyright (c) Microsoft Corporation. All rights reserved.
* Licensed under the MIT License. See https://go.microsoft.com/fwlink/?linkid=2090316 for license information.
*-------------------------------------------------------------------------------------------------------------*/

package com.mycompany.app;

import static javax.xml.XMLConstants.XML_NS_PREFIX;

public class App
{
public static void main( String[] args )
{
System.out.println( "Hello Remote World!" );
System.out.println("The XML namespace prefix is: " + XML_NS_PREFIX);
}
}
Loading

0 comments on commit e16537d

Please sign in to comment.