Last active
April 5, 2019 11:40
-
-
Save njoyce/e5dbd90a4931704e42881b83a79e959e to your computer and use it in GitHub Desktop.
Code samples for Building minimal Docker Containers for Java Applications on blog.realkinetic.com
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
plugins { | |
id "java" | |
} | |
repositories { | |
mavenCentral() | |
} | |
dependencies { | |
compile "joda-time:joda-time:2.10.1" | |
testCompile "junit:junit:4.12" | |
} | |
compileJava { | |
sourceCompatibility = 1.7 | |
targetCompatibility = 1.7 | |
} | |
jar { | |
baseName = "hello-world" | |
manifest { | |
attributes( | |
"Main-Class": "hello.HelloWorld" | |
) | |
} | |
from { | |
configurations.compile.collect { it.isDirectory() ? it : zipTree(it) } | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<project> | |
<modelVersion>4.0.0</modelVersion> | |
<groupId>com.realkinetic</groupId> | |
<artifactId>hello-world</artifactId> | |
<version>1.0.0</version> | |
<name>Hello World</name> | |
<packaging>jar</packaging> | |
<properties> | |
<maven.compiler.source>1.7</maven.compiler.source> | |
<maven.compiler.target>1.7</maven.compiler.target> | |
</properties> | |
<repositories> | |
<repository> | |
<id>central</id> | |
<name>Maven Repository Switchboard</name> | |
<layout>default</layout> | |
<url>http://repo1.maven.org/maven2</url> | |
<snapshots> | |
<enabled>false</enabled> | |
</snapshots> | |
</repository> | |
</repositories> | |
<pluginRepositories> | |
<pluginRepository> | |
<id>central</id> | |
<name>Maven Plugin Repository</name> | |
<url>http://repo1.maven.org/maven2</url> | |
<layout>default</layout> | |
<snapshots> | |
<enabled>false</enabled> | |
</snapshots> | |
<releases> | |
<updatePolicy>never</updatePolicy> | |
</releases> | |
</pluginRepository> | |
</pluginRepositories> | |
<dependencies> | |
<dependency> | |
<groupId>joda-time</groupId> | |
<artifactId>joda-time</artifactId> | |
<version>2.10.1</version> | |
</dependency> | |
<dependency> | |
<groupId>junit</groupId> | |
<artifactId>junit</artifactId> | |
<version>4.12</version> | |
<scope>test</scope> | |
</dependency> | |
</dependencies> | |
<build> | |
<plugins> | |
<plugin> | |
<groupId>org.apache.maven.plugins</groupId> | |
<artifactId>maven-shade-plugin</artifactId> | |
<executions> | |
<execution> | |
<goals> | |
<goal>shade</goal> | |
</goals> | |
<configuration> | |
<shadedArtifactAttached>true</shadedArtifactAttached> | |
<transformers> | |
<transformer implementation="org.apache.maven.plugins.shade.resource.ManifestResourceTransformer"> | |
<mainClass>hello.HelloWorld</mainClass> | |
</transformer> | |
</transformers> | |
</configuration> | |
</execution> | |
</executions> | |
</plugin> | |
</plugins> | |
</build> | |
</project> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package hello; | |
import org.joda.time.LocalTime; | |
public class HelloWorld { | |
public static void main(String[] args) { | |
LocalTime currentTime = new LocalTime(); | |
System.out.println("The current local time is: " + currentTime); | |
System.out.println("Hello World"); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment