Skip to content
This repository was archived by the owner on Nov 28, 2022. It is now read-only.

Commit 68311d8

Browse files
authored
OpenAPI: Make use of Open Liberty Library (#130)
* OpenAPI: Make use of Open Liberty Library * Update version number and feature
1 parent 90c02f7 commit 68311d8

6 files changed

Lines changed: 41 additions & 6 deletions

File tree

dev/org.eclipse.codewind.openapi.feature/feature.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414
<feature
1515
id="org.eclipse.codewind.openapi.feature"
1616
label="%featureName"
17-
version="0.8.0.qualifier"
17+
version="0.9.0.qualifier"
1818
provider-name="%providerName">
1919

2020
<description>

dev/org.eclipse.codewind.openapi.ui/META-INF/MANIFEST.MF

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ Manifest-Version: 1.0
22
Bundle-ManifestVersion: 2
33
Bundle-Name: Codewind OpenAPI Tools UI
44
Bundle-SymbolicName: org.eclipse.codewind.openapi.ui;singleton:=true
5-
Bundle-Version: 1.0.400.qualifier
5+
Bundle-Version: 1.0.500.qualifier
66
Bundle-Localization: plugin
77
Bundle-Activator: org.eclipse.codewind.openapi.ui.Activator
88
Bundle-Vendor: IBM

dev/org.eclipse.codewind.openapi.ui/src/org/eclipse/codewind/openapi/ui/commands/AbstractOpenApiGeneratorCommand.java

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*******************************************************************************
2-
* Copyright (c) 2019 IBM Corporation and others.
2+
* Copyright (c) 2019, 2020 IBM Corporation and others.
33
* All rights reserved. This program and the accompanying materials
44
* are made available under the terms of the Eclipse Public License 2.0
55
* which accompanies this distribution, and is available at
@@ -51,6 +51,7 @@ public abstract class AbstractOpenApiGeneratorCommand extends WorkspaceModifyOpe
5151
protected String language = null;
5252
protected String generatorType = null;
5353
protected boolean pomFileExists = false;
54+
protected String codewindProjectTypeId = null;
5455

5556
public AbstractOpenApiGeneratorCommand() {
5657
// empty
@@ -80,6 +81,10 @@ public void setGeneratorType(String generatorType) {
8081
this.generatorType = generatorType;
8182
}
8283

84+
public void setCodewindProjectTypeId(String codewindProjectTypeId) {
85+
this.codewindProjectTypeId = codewindProjectTypeId;
86+
}
87+
8388
public void setOutputFolderString(String outputFolderString) {
8489
this.outputFolderString = outputFolderString;
8590
}

dev/org.eclipse.codewind.openapi.ui/src/org/eclipse/codewind/openapi/ui/commands/GenerateServerCommand.java

Lines changed: 25 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*******************************************************************************
2-
* Copyright (c) 2019 IBM Corporation and others.
2+
* Copyright (c) 2019, 2020 IBM Corporation and others.
33
* All rights reserved. This program and the accompanying materials
44
* are made available under the terms of the Eclipse Public License 2.0
55
* which accompanies this distribution, and is available at
@@ -18,6 +18,7 @@
1818

1919
import org.eclipse.codewind.openapi.core.commands.CommandRunner;
2020
import org.eclipse.codewind.openapi.ui.Activator;
21+
import org.eclipse.core.resources.IResource;
2122
import org.eclipse.core.runtime.FileLocator;
2223
import org.eclipse.core.runtime.IStatus;
2324
import org.eclipse.core.runtime.jobs.ISchedulingRule;
@@ -44,6 +45,29 @@ protected void populateArgsList(List<String> mainArgsList) {
4445
mainArgsList.add("generate"); //$NON-NLS-1$
4546
mainArgsList.add("-g"); //$NON-NLS-1$
4647
mainArgsList.add(generatorType);
48+
49+
boolean isLiberty = false;
50+
boolean isAppsodyLiberty = false;
51+
52+
IResource serverProjectFile = project.findMember("/src/main/liberty/config/server.xml"); //$NON-NLS-1$
53+
if (serverProjectFile != null) {
54+
isLiberty = serverProjectFile.exists();
55+
56+
IResource appsodyProjectFile = project.findMember(".appsody-config.yaml"); //$NON-NLS-1$
57+
58+
if (appsodyProjectFile != null) {
59+
isAppsodyLiberty = isLiberty && appsodyProjectFile.exists();
60+
}
61+
}
62+
63+
if (generatorType.equals("jaxrs-spec") && (codewindProjectTypeId != null && codewindProjectTypeId.toLowerCase().indexOf("liberty") >= 0) //$NON-NLS-1$ //$NON-NLS-2$
64+
|| (codewindProjectTypeId != null && codewindProjectTypeId.toLowerCase().indexOf("docker") >= 0 && isLiberty) //$NON-NLS-1$
65+
|| (codewindProjectTypeId != null && codewindProjectTypeId.toLowerCase().indexOf("appsodyextension") >= 0 && isAppsodyLiberty)) { //$NON-NLS-1$
66+
mainArgsList.add("--library"); //$NON-NLS-1$
67+
mainArgsList.add("openliberty"); //$NON-NLS-1$
68+
mainArgsList.add("--enable-post-process-file"); //$NON-NLS-1$
69+
}
70+
4771
mainArgsList.add("-i"); //$NON-NLS-1$
4872
if (this.openApiFile != null) {
4973
mainArgsList.add(argSurround + openApiFile.getLocation().toOSString() + argSurround);

dev/org.eclipse.codewind.openapi.ui/src/org/eclipse/codewind/openapi/ui/wizard/AbstractGenerateWizard.java

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*******************************************************************************
2-
* Copyright (c) 2019 IBM Corporation and others.
2+
* Copyright (c) 2019, 2020 IBM Corporation and others.
33
* All rights reserved. This program and the accompanying materials
44
* are made available under the terms of the Eclipse Public License 2.0
55
* which accompanies this distribution, and is available at
@@ -90,6 +90,8 @@ public boolean performFinish() {
9090
}
9191

9292
PROJECT_TYPE projectType = page.getProjectType();
93+
94+
cmd.setCodewindProjectTypeId(page.getCodewindProjectTypeId());
9395

9496
// Need a wrapper outside the context of the wizard page, since the wizard will be disposed of.
9597
// Pass in the needed parameters gathered by the wizard

dev/org.eclipse.codewind.openapi.ui/src/org/eclipse/codewind/openapi/ui/wizard/AbstractGenerateWizardPage.java

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*******************************************************************************
2-
* Copyright (c) 2019 IBM Corporation and others.
2+
* Copyright (c) 2019, 2020 IBM Corporation and others.
33
* All rights reserved. This program and the accompanying materials
44
* are made available under the terms of the Eclipse Public License 2.0
55
* which accompanies this distribution, and is available at
@@ -126,6 +126,10 @@ public String getPomFileBackupName() {
126126
return tempOrigFileName;
127127
}
128128

129+
public String getCodewindProjectTypeId() {
130+
return codewindProjectTypeId;
131+
}
132+
129133
@Override
130134
public void createControl(Composite parent) {
131135
Composite container = new Composite(parent, SWT.NULL);

0 commit comments

Comments
 (0)