Skip to content

Commit

Permalink
Merge pull request #371 from simonjhy/IDE-5118
Browse files Browse the repository at this point in the history
IDE-5118 set proxy for embed blade
  • Loading branch information
simonjhy authored Oct 9, 2023
2 parents 8f66047 + e897312 commit c33334d
Show file tree
Hide file tree
Showing 7 changed files with 75 additions and 20 deletions.
15 changes: 1 addition & 14 deletions .github/workflows/verify.yml
Original file line number Diff line number Diff line change
Expand Up @@ -55,17 +55,4 @@ jobs:
- name: Run tests
shell: bash
run: |
./run-tests.sh
- name: Upload tests
uses: actions/upload-artifact@v1
if: ${{ failure() }}
with:
name: surefire-reports.tar.gz
path: surefire-reports.tar.gz
- name: Run reporter
uses: check-run-reporter/[email protected]
if: ${{ always() }}
with:
label: "Maven surefire test reports"
report: "**/TEST-*.xml"
token: "000f9d8e-4211-4cb7-9438-cb165d0db32a"
./run-tests.sh
4 changes: 2 additions & 2 deletions build/parent/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -27,8 +27,8 @@
<name>Liferay IDE Parent</name>

<properties>
<blade-latest-download-url>https://repository.liferay.com/nexus/content/repositories/liferay-public-snapshots/com/liferay/blade/com.liferay.blade.cli/4.1.2-SNAPSHOT/com.liferay.blade.cli-4.1.2-20230425.080220-14.jar</blade-latest-download-url>
<blade-latest-md5>209251e2e308ea119def0941e1d78b1c</blade-latest-md5>
<blade-latest-download-url>https://repository-cdn.liferay.com/nexus/content/repositories/liferay-public-snapshots/com/liferay/blade/com.liferay.blade.cli/5.0.1-SNAPSHOT/com.liferay.blade.cli-5.0.1-20230927.053520-3.jar</blade-latest-download-url>
<blade-latest-md5>73f74298226c1b1e818969fd064101d2</blade-latest-md5>
<blade-392-download-url>https://repository.liferay.com/nexus/content/repositories/public/com/liferay/blade/com.liferay.blade.cli/3.9.2/com.liferay.blade.cli-3.9.2.jar</blade-392-download-url>
<blade-392-md5>08aedcb6bacc3166060d0032f9489dd1</blade-392-md5>
<upgrade-plan-content-zip-url>https://us-east-1.linodeobjects.com/devtools-s3.liferay.com/liferay-ide-files/docs/code-upgrade-docs-20210312.zip</upgrade-plan-content-zip-url>
Expand Down
2 changes: 1 addition & 1 deletion tools/plugins/com.liferay.ide.gradle.core/.classpath
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,6 @@
<classpathentry kind="con" path="org.eclipse.pde.core.requiredPlugins"/>
<classpathentry kind="src" path="src/"/>
<classpathentry exported="true" kind="lib" path="lib/gradle-tooling.jar"/>
<classpathentry exported="true" kind="lib" path="lib/groovy-2.4.3.jar"/>
<classpathentry exported="true" kind="lib" path="lib/groovy-4.0.7.jar"/>
<classpathentry kind="output" path="target/classes"/>
</classpath>
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ Require-Bundle: biz.aQute.bndlib;bundle-version="[5,6)",
org.apache.commons.lang,
org.eclipse.core.commands,
org.eclipse.core.expressions,
org.eclipse.core.net,
org.eclipse.core.resources,
org.eclipse.core.runtime,
org.eclipse.emf.ecore,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,15 +15,19 @@
package com.liferay.ide.project.core.modules;

import com.liferay.ide.core.IWorkspaceProject;
import com.liferay.ide.core.LiferayCore;
import com.liferay.ide.core.StringBufferOutputStream;
import com.liferay.ide.core.util.FileUtil;
import com.liferay.ide.core.util.StringUtil;
import com.liferay.ide.core.workspace.LiferayWorkspaceUtil;
import com.liferay.ide.project.core.ProjectCore;

import java.io.File;
import java.io.IOException;
import java.io.PrintStream;

import java.net.URL;

import java.util.ArrayList;
import java.util.List;
import java.util.Objects;
Expand All @@ -32,7 +36,10 @@
import org.apache.tools.ant.DefaultLogger;
import org.apache.tools.ant.Project;
import org.apache.tools.ant.taskdefs.Java;
import org.apache.tools.ant.types.Environment;

import org.eclipse.core.net.proxy.IProxyData;
import org.eclipse.core.net.proxy.IProxyService;
import org.eclipse.core.runtime.FileLocator;
import org.eclipse.core.runtime.IPath;
import org.eclipse.core.runtime.Path;
Expand Down Expand Up @@ -174,6 +181,65 @@ private static String[] _execute(IPath bladeCLIPath, String args) throws BladeCL
javaTask.setJar(bladeCLIPath.toFile());
javaTask.setArgs(args);

try {
IProxyService proxyService = LiferayCore.getProxyService();

URL downloadProductInfoUrl = new URL(_PRODUCT_INFO_URL);

IProxyData[] proxyDatas = proxyService.select(downloadProductInfoUrl.toURI());

for (IProxyData proxyData : proxyDatas) {
if (Objects.isNull(proxyData)) {
continue;
}

if (Objects.isNull(proxyData.getHost())) {
continue;
}

String proxyType = StringUtil.toLowerCase(proxyData.getType());

Environment.Variable proxyHostVariable = new Environment.Variable();

proxyHostVariable.setKey(proxyType + ".proxyHost");
proxyHostVariable.setValue(proxyData.getHost());

javaTask.addSysproperty(proxyHostVariable);

Environment.Variable proxyPortVariable = new Environment.Variable();

proxyPortVariable.setKey(proxyType + ".proxyPort");
proxyPortVariable.setValue(String.valueOf(proxyData.getPort()));

javaTask.addSysproperty(proxyPortVariable);

if (!proxyData.isRequiresAuthentication()) {
continue;
}

if (Objects.isNull(proxyData.getUserId()) || Objects.isNull(proxyData.getPassword())) {
continue;
}

Environment.Variable proxyUserVariable = new Environment.Variable();

proxyUserVariable.setKey(proxyType + ".proxyUser");
proxyUserVariable.setValue(proxyData.getUserId());

javaTask.addSysproperty(proxyUserVariable);

Environment.Variable proxyPasswordVariable = new Environment.Variable();

proxyPasswordVariable.setKey(proxyType + ".proxyPassword");
proxyPasswordVariable.setValue(proxyData.getPassword());

javaTask.addSysproperty(proxyPasswordVariable);
}
}
catch (Exception exception) {
throw new BladeCLIException(exception.getMessage());
}

DefaultLogger logger = new DefaultLogger();

project.addBuildListener(logger);
Expand Down Expand Up @@ -233,6 +299,8 @@ private static IPath _getBladeJarFromBundle(String jarName) throws IOException {
return new Path(bladeJarBundleFile.getCanonicalPath());
}

private static final String _PRODUCT_INFO_URL = "https://releases.liferay.com/tools/workspace/.product_info.json";

private static String _bladeJarName = null;

}
Original file line number Diff line number Diff line change
Expand Up @@ -49,9 +49,9 @@ public void testBundleFileIsValid() throws Exception

Domain domain = Domain.domain( bladeFile );

assertTrue( domain.getBundleVersion().startsWith( "4" ) );
assertTrue( domain.getBundleVersion().startsWith( "5" ) );

assertFalse( domain.getBundleVersion().startsWith( "3" ) );
assertFalse( domain.getBundleVersion().startsWith( "4" ) );
}

@Test
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,6 @@
import com.liferay.ide.core.tests.TestUtil;
import com.liferay.ide.core.util.CoreUtil;
import com.liferay.ide.core.util.FileUtil;
import com.liferay.ide.core.workspace.LiferayWorkspaceUtil;
import com.liferay.ide.project.core.modules.NewLiferayComponentOp;
import com.liferay.ide.project.core.modules.NewLiferayComponentOpMethods;
import com.liferay.ide.project.core.modules.NewLiferayModuleProjectOp;
Expand Down

0 comments on commit c33334d

Please sign in to comment.