-
Notifications
You must be signed in to change notification settings - Fork 51
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Update libertyDev task and docs for Podman (#843)
* Update libertyDev task and docs for Podman * Use action to install Podman * Disable DevContainerTest * Update libertyDev properties and docs
- Loading branch information
Showing
15 changed files
with
481 additions
and
91 deletions.
There are no files selected for viewing
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
Large diffs are not rendered by default.
Oops, something went wrong.
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
147 changes: 93 additions & 54 deletions
147
src/main/groovy/io/openliberty/tools/gradle/tasks/DevTask.groovy
Large diffs are not rendered by default.
Oops, something went wrong.
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
63 changes: 63 additions & 0 deletions
63
src/test/groovy/io/openliberty/tools/gradle/DevContainerTest.groovy
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,63 @@ | ||
/* | ||
* (C) Copyright IBM Corporation 2023. | ||
* | ||
* 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 io.openliberty.tools.gradle; | ||
|
||
import static org.junit.Assert.*; | ||
|
||
import java.io.BufferedWriter; | ||
import org.apache.commons.io.FileUtils; | ||
import java.io.File; | ||
import org.junit.Before; | ||
import org.junit.BeforeClass; | ||
import org.junit.AfterClass; | ||
import org.junit.Test; | ||
import java.nio.charset.Charset; | ||
import java.nio.charset.StandardCharsets; | ||
import java.nio.file.Files; | ||
import java.nio.file.Path; | ||
|
||
class DevContainerTest extends BaseDevTest { | ||
|
||
static final String projectName = "dev-container"; | ||
static File resourceDir = new File("build/resources/test/dev-test/" + projectName); | ||
static File testBuildDir = new File(integTestDir, "/test-dev-container") | ||
|
||
@BeforeClass | ||
public static void setup() throws IOException, InterruptedException, FileNotFoundException { | ||
createDir(testBuildDir) | ||
createTestProject(testBuildDir, resourceDir, "build.gradle", true) | ||
|
||
File buildFile = new File(resourceDir, buildFilename) | ||
copyBuildFiles(buildFile, testBuildDir, false) | ||
|
||
runDevMode("--container", testBuildDir) | ||
} | ||
|
||
@Test | ||
public void devmodeContainerTest() throws Exception { | ||
assertTrue("The container build did not complete.", verifyLogMessage(20000, "Completed building container image.", logFile)); | ||
assertTrue("The application start message is missing.", verifyLogMessage(20000, "CWWKZ0001I: Application rest started", logFile)); | ||
} | ||
|
||
@AfterClass | ||
public static void cleanUpAfterClass() throws Exception { | ||
String stdout = getContents(logFile, "Dev mode std output"); | ||
System.out.println(stdout); | ||
String stderr = getContents(errFile, "Dev mode std error"); | ||
System.out.println(stderr); | ||
cleanUpAfterClassCheckLogFile(true); | ||
} | ||
} |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
# Start with OL runtime. | ||
# tag::from[] | ||
FROM icr.io/appcafe/open-liberty:full-java11-openj9-ubi | ||
# end::from[] | ||
|
||
ARG VERSION=1.0 | ||
ARG REVISION=SNAPSHOT | ||
# tag::label[] | ||
|
||
LABEL \ | ||
org.opencontainers.image.authors="Your Name" \ | ||
org.opencontainers.image.vendor="IBM" \ | ||
org.opencontainers.image.url="local" \ | ||
org.opencontainers.image.source="https://github.com/OpenLiberty/guide-docker" \ | ||
org.opencontainers.image.version="$VERSION" \ | ||
org.opencontainers.image.revision="$REVISION" \ | ||
vendor="Open Liberty" \ | ||
name="system" \ | ||
version="$VERSION-$REVISION" \ | ||
summary="The system microservice from the Docker Guide" \ | ||
# tag::description[] | ||
description="This image contains the system microservice running with the Open Liberty runtime." | ||
# end::description[] | ||
# end::label[] | ||
|
||
|
||
USER root | ||
|
||
COPY --chown=1001:0 src/main/liberty/config/server.xml /config/ | ||
|
||
COPY --chown=1001:0 build/libs/*.war /config/apps/ | ||
|
||
USER 1001 |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
apply plugin: "liberty" | ||
apply plugin: "war" | ||
|
||
sourceCompatibility = 1.8 | ||
targetCompatibility = 1.8 | ||
tasks.withType(JavaCompile) { | ||
options.encoding = "UTF-8" | ||
} | ||
|
||
buildscript { | ||
repositories { | ||
mavenCentral() | ||
mavenLocal() | ||
maven { | ||
url 'https://oss.sonatype.org/content/repositories/snapshots/' | ||
} | ||
} | ||
dependencies { | ||
classpath "io.openliberty.tools:liberty-gradle-plugin:$lgpVersion" | ||
} | ||
} | ||
|
||
repositories { | ||
mavenCentral() | ||
} | ||
|
||
dependencies { | ||
providedCompile 'jakarta.platform:jakarta.jakartaee-api:9.1.0' | ||
providedCompile 'org.eclipse.microprofile:microprofile:5.0' | ||
|
||
testImplementation 'org.junit.jupiter:junit-jupiter:5.8.2' | ||
testImplementation 'org.jboss.resteasy:resteasy-client:6.0.0.Final' | ||
testImplementation 'org.jboss.resteasy:resteasy-json-binding-provider:6.0.0.Final' | ||
testImplementation 'org.glassfish:jakarta.json:2.0.1' | ||
testImplementation 'javax.xml.bind:jaxb-api:2.3.1' | ||
} | ||
|
||
war { | ||
archiveBaseName = 'rest' | ||
} | ||
|
||
test { | ||
systemProperty 'liberty.test.port', '9080' | ||
} |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
//Empty |
43 changes: 43 additions & 0 deletions
43
...s/dev-test/dev-container/src/main/java/io/openliberty/guides/rest/PropertiesResource.java
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
// tag::copyright[] | ||
/******************************************************************************* | ||
* Copyright (c) 2017, 2022 IBM Corporation and others. | ||
* All rights reserved. This program and the accompanying materials | ||
* are made available under the terms of the Eclipse Public License v1.0 | ||
* which accompanies this distribution, and is available at | ||
* http://www.eclipse.org/legal/epl-v10.html | ||
* | ||
* Contributors: | ||
* IBM Corporation - Initial implementation | ||
*******************************************************************************/ | ||
// end::copyright[] | ||
package io.openliberty.guides.rest; | ||
|
||
import jakarta.ws.rs.Path; | ||
import jakarta.ws.rs.core.MediaType; | ||
import jakarta.ws.rs.GET; | ||
import jakarta.ws.rs.Produces; | ||
|
||
import jakarta.json.JsonObject; | ||
import jakarta.json.JsonObjectBuilder; | ||
import jakarta.json.Json; | ||
|
||
// tag::Path[] | ||
@Path("properties") | ||
// end::Path[] | ||
public class PropertiesResource { | ||
|
||
@GET | ||
@Produces(MediaType.APPLICATION_JSON) | ||
public JsonObject getProperties() { | ||
|
||
JsonObjectBuilder builder = Json.createObjectBuilder(); | ||
|
||
System.getProperties() | ||
.entrySet() | ||
.stream() | ||
.forEach(entry -> builder.add((String) entry.getKey(), | ||
(String) entry.getValue())); | ||
|
||
return builder.build(); | ||
} | ||
} |
21 changes: 21 additions & 0 deletions
21
...es/dev-test/dev-container/src/main/java/io/openliberty/guides/rest/SystemApplication.java
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
// tag::copyright[] | ||
/******************************************************************************* | ||
* Copyright (c) 2017, 2022 IBM Corporation and others. | ||
* All rights reserved. This program and the accompanying materials | ||
* are made available under the terms of the Eclipse Public License v1.0 | ||
* which accompanies this distribution, and is available at | ||
* http://www.eclipse.org/legal/epl-v10.html | ||
* | ||
* Contributors: | ||
* IBM Corporation - Initial implementation | ||
*******************************************************************************/ | ||
// end::copyright[] | ||
package io.openliberty.guides.rest; | ||
|
||
import jakarta.ws.rs.core.Application; | ||
import jakarta.ws.rs.ApplicationPath; | ||
|
||
@ApplicationPath("system") | ||
public class SystemApplication extends Application { | ||
|
||
} |
16 changes: 16 additions & 0 deletions
16
src/test/resources/dev-test/dev-container/src/main/liberty/config/server.xml
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
<server description="Sample Liberty server"> | ||
|
||
<featureManager> | ||
<feature>restfulWS-3.0</feature> | ||
<feature>jsonb-2.0</feature> | ||
<feature>jsonp-2.0</feature> | ||
</featureManager> | ||
|
||
<variable name="default.http.port" defaultValue="9080"/> | ||
<variable name="default.https.port" defaultValue="9443"/> | ||
|
||
<httpEndpoint httpPort="${default.http.port}" httpsPort="${default.https.port}" | ||
id="defaultHttpEndpoint" host="*" /> | ||
|
||
<webApplication location="rest.war" contextRoot="/"/> | ||
</server> |
10 changes: 10 additions & 0 deletions
10
src/test/resources/dev-test/dev-container/src/main/webapp/WEB-INF/web.xml
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
<?xml version="1.0" encoding="UTF-8"?> | ||
<web-app xmlns="http://xmlns.jcp.org/xml/ns/javaee" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" | ||
xsi:schemaLocation="http://xmlns.jcp.org/xml/ns/javaee http://xmlns.jcp.org/xml/ns/javaee/web-app_3_1.xsd" | ||
version="3.1"> | ||
<display-name>Liberty Project</display-name> | ||
|
||
<welcome-file-list> | ||
<welcome-file>index.html</welcome-file> | ||
</welcome-file-list> | ||
</web-app> |
41 changes: 41 additions & 0 deletions
41
src/test/resources/dev-test/dev-container/src/main/webapp/index.html
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
<!-- | ||
Copyright (c) 2016, 2022 IBM Corp. | ||
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. | ||
--> | ||
<html> | ||
<body> | ||
<h1>Welcome to your Open Liberty application</h1> | ||
<p>Open Liberty is a lightweight open framework for building fast and efficient cloud-native Java microservices. Find out more at <a href="http://openliberty.io/" target="_blank" rel="noopener noreferrer">openliberty.io</a>.</p> | ||
<div> | ||
<h2>Eclipse MicroProfile</h2> | ||
<p> | ||
The <a href="https://microprofile.io/" target="_blank" rel="noopener noreferrer">Eclipse MicroProfile project</a> is an open community with the aim of optimizing enterprise Java for a microservices architecture. | ||
MicroProfile evolves with guidance from the community. | ||
</p> | ||
<p> | ||
If you want to share your thoughts, you can post straight to the | ||
<a href="https://groups.google.com/forum/#!forum/microprofile" target="_blank" rel="noopener noreferrer">MicroProfile Google group</a>. | ||
</p> | ||
<p> | ||
For more information about the features used in this application, see the Open Liberty documentation: | ||
<ul> | ||
<li><a href="https://openliberty.io/docs/ref/feature/#microProfile-5.0.html" target="_blank" rel="noopener noreferrer">MicroProfile 5.0</a></li> | ||
<li><a href="https://openliberty.io/docs/ref/feature/#restfulWS-3.0.html" target="_blank" rel="noopener noreferrer">Java RESTful Services 3.0</a></li> | ||
<li><a href="https://openliberty.io/docs/ref/feature/#jsonp-2.0.html" target="_blank" rel="noopener noreferrer">JavaScript Object Notation Processing 2.0</a></li> | ||
<li><a href="https://openliberty.io/docs/ref/feature/#jsonb-2.0.html" target="_blank" rel="noopener noreferrer">JavaScript Object Notation Binding 2.0</a></li> | ||
</ul> | ||
</p> | ||
</div> | ||
</body> | ||
</html> |
Oops, something went wrong.