Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support custom config files #212

Merged
merged 25 commits into from
Sep 6, 2023
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
25 commits
Select commit Hold shift + click to select a range
b7ff73c
change config file logic (#194)
dshimo Aug 8, 2023
e025c59
Fix determination of Liberty Workspace for non-default server.xml (#201)
cherylking Aug 23, 2023
6acab22
xmlreader on config portion
dshimo Aug 23, 2023
a7b4a60
Initial changes to watch and process liberty-plugin-config.xml
evie-lau Aug 23, 2023
f59e641
Process and store custom config files
evie-lau Aug 23, 2023
3df2de1
init test, refactor to use LCFM
dshimo Aug 24, 2023
ad35bf3
Initial tests. Small refactor
evie-lau Aug 25, 2023
1c303fe
Fix uri string mismatch. Update key completion to use file-checking m…
evie-lau Aug 28, 2023
146a267
Update comments and todos
evie-lau Aug 29, 2023
41c4c30
Add check for config file path, moved from client-side filewatch filt…
evie-lau Sep 1, 2023
93ff57a
Fix paths for windows
evie-lau Sep 1, 2023
6807f9c
init custom config files list
dshimo Sep 1, 2023
6c55625
Normalize paths. Test still fails on Windows because test file has un…
evie-lau Sep 1, 2023
763c653
Run custom config file test in Unix only
evie-lau Sep 1, 2023
5d4de2b
Modify tests to account for Windows
evie-lau Sep 1, 2023
8bfd08e
Cleanup comments and add copyright
evie-lau Sep 1, 2023
529c6ea
Update filenames to use URI formatted string
evie-lau Sep 5, 2023
a7ae07b
PR comments and cleanup
dshimo Sep 5, 2023
0ac0973
oops
dshimo Sep 5, 2023
07d6414
Minor fixes
evie-lau Sep 5, 2023
5e8b0aa
Fix Windows pathing
evie-lau Sep 5, 2023
95cc901
Fix parse on file change.
evie-lau Sep 5, 2023
1043bbe
Make sure build/test actions are separate. Suppress progress tracking…
evie-lau Sep 6, 2023
c8f4a3a
Add comments, use constants
evie-lau Sep 6, 2023
74620ab
Modify initCustomConfigTest to use a separate test resource folder
evie-lau Sep 6, 2023
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
Original file line number Diff line number Diff line change
Expand Up @@ -31,8 +31,8 @@

public class LibertyConfigFileManager {
public static final String LIBERTY_PLUGIN_CONFIG_XML = "liberty-plugin-config.xml";
public static final String CUSTOM_SERVER_ENV_XML_TAG = "serverEnvFile";
public static final String CUSTOM_BOOTSTRAP_PREOPERTIES_XML_TAG = "bootstrapPropertiesFile";
public static final String CUSTOM_SERVER_ENV_XML_TAG = "serverEnv";
public static final String CUSTOM_BOOTSTRAP_PROPERTIES_XML_TAG = "bootstrapPropertiesFile";

private static Set<String> customServerEnvFiles = new HashSet<String>();
private static Set<String> customBootstrapFiles = new HashSet<String>();
Expand Down Expand Up @@ -70,14 +70,14 @@ public static void processLibertyPluginConfigXml(String uri) {
}
Map<String, String> customConfigFiles = XmlReader.readTagsFromXml(uri,
cherylking marked this conversation as resolved.
Show resolved Hide resolved
CUSTOM_SERVER_ENV_XML_TAG,
CUSTOM_BOOTSTRAP_PREOPERTIES_XML_TAG);
CUSTOM_BOOTSTRAP_PROPERTIES_XML_TAG);
// TODO: handle deletions. maybe use map with <uri, path> ? and clear all that
// match uri
if (customConfigFiles.containsKey(CUSTOM_SERVER_ENV_XML_TAG)) {
customServerEnvFiles.add(customConfigFiles.get(CUSTOM_SERVER_ENV_XML_TAG));
}
if (customConfigFiles.containsKey(CUSTOM_BOOTSTRAP_PREOPERTIES_XML_TAG)) {
customBootstrapFiles.add(customConfigFiles.get(CUSTOM_BOOTSTRAP_PREOPERTIES_XML_TAG));
if (customConfigFiles.containsKey(CUSTOM_BOOTSTRAP_PROPERTIES_XML_TAG)) {
customBootstrapFiles.add(customConfigFiles.get(CUSTOM_BOOTSTRAP_PROPERTIES_XML_TAG));
}
}

Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*******************************************************************************
* Copyright (c) 2020, 2022 IBM Corporation and others.
* Copyright (c) 2020, 2023 IBM Corporation and others.
*
* This program and the accompanying materials are made available under the
* terms of the Eclipse Public License v. 2.0 which is available at
Expand Down Expand Up @@ -29,7 +29,7 @@
import io.openliberty.tools.langserver.common.ParentProcessWatcher.ProcessLanguageServer;

public class LibertyLanguageServer extends AbstractLanguageServer implements ProcessLanguageServer, LanguageClientAware {

protected String test;
dshimo marked this conversation as resolved.
Show resolved Hide resolved
public static final String LANGUAGE_ID = "LANGUAGE_ID_LIBERTY";
private static final Logger LOGGER = Logger.getLogger(LibertyLanguageServer.class.getName());

Expand Down Expand Up @@ -124,8 +124,4 @@ public LanguageClient getLanguageClient() {
public void setLanguageClient(LanguageClient languageClient) {
this.languageClient = languageClient;
}

private void initLibertyConfigFileManager() {

}
}
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*******************************************************************************
* Copyright (c) 2020, 2022 IBM Corporation and others.
* Copyright (c) 2020, 2023 IBM Corporation and others.
*
* This program and the accompanying materials are made available under the
* terms of the Eclipse Public License v. 2.0 which is available at
Expand All @@ -26,7 +26,6 @@ public class LibertyWorkspaceService implements WorkspaceService {

public LibertyWorkspaceService(LibertyLanguageServer libertyls) {
this.libertyLanguageServer = libertyls;
// TODO: init scanning liberty-plugin-config.xml files
}

@Override
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*******************************************************************************
* Copyright (c) 2022 IBM Corporation and others.
* Copyright (c) 2022, 2023 IBM Corporation and others.
*
* This program and the accompanying materials are made available under the
* terms of the Eclipse Public License v. 2.0 which is available at
Expand Down Expand Up @@ -31,7 +31,6 @@

import io.openliberty.tools.langserver.LibertyConfigFileManager;
dshimo marked this conversation as resolved.
Show resolved Hide resolved
import io.openliberty.tools.langserver.ls.LibertyTextDocument;
import io.openliberty.tools.langserver.utils.ParserFileHelperUtil;
import io.openliberty.tools.langserver.utils.PropertiesValidationResult;
import io.openliberty.tools.langserver.utils.ServerPropertyValues;

Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*******************************************************************************
* Copyright (c) 2022 IBM Corporation and others.
* Copyright (c) 2022, 2023 IBM Corporation and others.
*
* This program and the accompanying materials are made available under the
* terms of the Eclipse Public License v. 2.0 which is available at
Expand Down Expand Up @@ -29,4 +29,4 @@ public String getLine(String text, int line) {
}
return null;
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -74,8 +74,8 @@ public static Map<String, String> getElementValues(File file, Set<String> elemen
} catch (FileNotFoundException e) {
LOGGER.severe("Unable to access file "+ file.getName());
} catch (XMLStreamException e) {
LOGGER.severe("Error received trying to read XML file: " + file.getName());
e.printStackTrace();
LOGGER.severe("Error received trying to read XML file: " + file.getName() +
"\n\tError" + e.getMessage());
} finally {
if (reader != null) {
try {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,27 +23,27 @@ public class XmlReaderTest {
public void readLibertyPluginConfigXml() throws IOException {
File lpcXml = new File(resourcesDir, "xml/unix/liberty-plugin-config.xml");
Map<String, String> tagValues = XmlReader.readTagsFromXml(lpcXml.toURI().getPath(),
LibertyConfigFileManager.CUSTOM_BOOTSTRAP_PREOPERTIES_XML_TAG,
LibertyConfigFileManager.CUSTOM_BOOTSTRAP_PROPERTIES_XML_TAG,
LibertyConfigFileManager.CUSTOM_SERVER_ENV_XML_TAG);

assertNotNull(tagValues);
assertEquals("Did not find custom config files", 2, tagValues.size());

Set<String> elementNames = new HashSet<String> ();
elementNames.add("configFile");
elementNames.add("bootstrapPropertiesFile");
elementNames.add("serverEnvFile");
elementNames.add(LibertyConfigFileManager.CUSTOM_BOOTSTRAP_PROPERTIES_XML_TAG);
elementNames.add(LibertyConfigFileManager.CUSTOM_SERVER_ENV_XML_TAG);

Map<String, String> values = XmlReader.getElementValues(lpcXml, elementNames);
assertTrue("Did not find expected number of elements in liberty-plugin-config.xml file. Expected 3, found "+values.size(), values.size() == 3);

assertTrue("Expected configFile element not found", values.containsKey("configFile"));
assertTrue("Expected configFile value not found. Value found: "+values.get("configFile"), values.get("configFile").equals("/user/sample-project/src/main/liberty/config/server.xml"));

assertTrue("Expected bootstrapPropertiesFile element not found", values.containsKey("bootstrapPropertiesFile"));
assertTrue("Expected bootstrapPropertiesFile value not found. Value found: "+values.get("bootstrapPropertiesFile"), values.get("bootstrapPropertiesFile").equals("/user/sample-project/src/main/liberty/config/custombootstrapprops.properties"));
assertTrue("Expected bootstrapPropertiesFile element not found", values.containsKey(LibertyConfigFileManager.CUSTOM_BOOTSTRAP_PROPERTIES_XML_TAG));
assertTrue("Expected bootstrapPropertiesFile value not found. Value found: "+values.get(LibertyConfigFileManager.CUSTOM_BOOTSTRAP_PROPERTIES_XML_TAG), values.get("bootstrapPropertiesFile").equals("/user/sample-project/src/main/liberty/config/custombootstrapprops.properties"));

assertTrue("Expected serverEnvFile element not found", values.containsKey("serverEnvFile"));
assertTrue("Expected serverEnvFile value not found. Value found: "+values.get("serverEnvFile"), values.get("serverEnvFile").equals("/user/sample-project/src/main/liberty/config/customserverenv.env"));
assertTrue("Expected serverEnvFile element not found", values.containsKey(LibertyConfigFileManager.CUSTOM_SERVER_ENV_XML_TAG));
assertTrue("Expected serverEnvFile value not found. Value found: "+values.get(LibertyConfigFileManager.CUSTOM_SERVER_ENV_XML_TAG), values.get(LibertyConfigFileManager.CUSTOM_SERVER_ENV_XML_TAG).equals("/user/sample-project/src/main/liberty/config/customserverenv.env"));
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
<configDirectory>/user/sample-project/src/main/liberty/config</configDirectory>
<configFile>/user/sample-project/src/main/liberty/config/server.xml</configFile>
<bootstrapPropertiesFile>/user/sample-project/src/main/liberty/config/custombootstrapprops.properties</bootstrapPropertiesFile>
<serverEnvFile>/user/sample-project/src/main/liberty/config/customserverenv.env</serverEnvFile>
<serverEnv>/user/sample-project/src/main/liberty/config/customserverenv.env</serverEnvFile>
<appsDirectory>apps</appsDirectory>
<looseApplication>true</looseApplication>
<stripVersion>false</stripVersion>
Expand All @@ -31,4 +31,4 @@
<projectCompileDependency>org.opentest4j:opentest4j:1.2.0</projectCompileDependency>
<projectCompileDependency>org.junit.platform:junit-platform-commons:1.8.2</projectCompileDependency>
<projectCompileDependency>org.apiguardian:apiguardian-api:1.1.2</projectCompileDependency>
</liberty-plugin-config>
</liberty-plugin-config>
Loading