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

IDE-5121 support quarter release #403

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
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 @@ -14,6 +14,8 @@

package com.liferay.ide.core.util;

import com.liferay.ide.core.workspace.WorkspaceConstants;

import java.util.regex.Matcher;
import java.util.regex.Pattern;

Expand All @@ -27,6 +29,13 @@ public static String simplifyTargetPlatformVersion(String targetPlatformVersion)
return null;
}

Matcher dxpQuarterReleaseTargetplatformVersionMatcher =
WorkspaceConstants.dxpQuarterReleaseTargetplatformVersionPattern.matcher(targetPlatformVersion);

if (dxpQuarterReleaseTargetplatformVersionMatcher.matches()) {
return "7.4";
}

String[] segments = targetPlatformVersion.split("\\.");

StringBuilder sb = new StringBuilder();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -235,6 +235,14 @@ public static String getLiferayWorkspaceProjectVersion() {

if (CoreUtil.isNotNullOrEmpty(simplifiedTargetPlatformVersion)) {
try {
Matcher dxpQuarterlyVersionMatcher =
WorkspaceConstants.dxpQuarterReleaseTargetplatformVersionPattern.matcher(
liferayWorkspaceProject.getTargetPlatformVersion());

if (dxpQuarterlyVersionMatcher.matches()) {
return "7.4";
}

Version liferayVersion = new Version(simplifiedTargetPlatformVersion);

return new String(liferayVersion.getMajor() + "." + liferayVersion.getMinor());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,8 @@

package com.liferay.ide.core.workspace;

import java.util.regex.Pattern;

/**
* @author Terry Jia
*/
Expand Down Expand Up @@ -80,4 +82,7 @@ public class WorkspaceConstants {

public static final String WORKSPACE_PRODUCT_PROPERTY = "liferay.workspace.product";

public static final Pattern dxpQuarterReleaseTargetplatformVersionPattern = Pattern.compile(
"(\\d{4})\\.q([1234])\\.(\\d+)(-(\\d+))?");

}
Original file line number Diff line number Diff line change
Expand Up @@ -184,7 +184,7 @@ private static String[] _execute(IPath bladeCLIPath, String args) throws BladeCL
try {
IProxyService proxyService = LiferayCore.getProxyService();

URL downloadProductInfoUrl = new URL(_PRODUCT_INFO_URL);
URL downloadProductInfoUrl = new URL(_productInfoUrl);

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

Expand Down Expand Up @@ -299,8 +299,7 @@ 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;
private static String _productInfoUrl = "https://releases.liferay.com/tools/workspace/.product_info.json";

}
Original file line number Diff line number Diff line change
Expand Up @@ -39,10 +39,9 @@ protected String compute() {
}

try {
String simplifiedVersion = VersionUtil.simplifyTargetPlatformVersion(
liferayWorkspaceProject.getTargetPlatformVersion());
if (Version.isVersion(
VersionUtil.simplifyTargetPlatformVersion(liferayWorkspaceProject.getTargetPlatformVersion()))) {

if (Version.isVersion(simplifiedVersion)) {
return Boolean.toString(true);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@
import com.liferay.ide.core.util.StringUtil;
import com.liferay.ide.core.util.VersionUtil;
import com.liferay.ide.core.workspace.LiferayWorkspaceUtil;
import com.liferay.ide.core.workspace.WorkspaceConstants;
import com.liferay.ide.project.core.NewLiferayProjectProvider;
import com.liferay.ide.project.core.ProjectCore;

Expand All @@ -40,6 +41,7 @@
import java.util.HashMap;
import java.util.Map;
import java.util.Objects;
import java.util.regex.Matcher;
import java.util.zip.ZipEntry;
import java.util.zip.ZipFile;

Expand Down Expand Up @@ -76,15 +78,24 @@ protected Status compute() {
return retval;
}

NewLiferayModuleProjectOp op = context(NewLiferayModuleProjectOp.class);

String targetPlatformVersionString = VersionUtil.simplifyTargetPlatformVersion(
Matcher dxpQuarterlyVersionMatcher = WorkspaceConstants.dxpQuarterReleaseTargetplatformVersionPattern.matcher(
liferayWorkspaceProject.getTargetPlatformVersion());

if (dxpQuarterlyVersionMatcher.matches()) {
return retval;
}

NewLiferayModuleProjectOp op = context(NewLiferayModuleProjectOp.class);

String liferayVersion = get(op.getLiferayVersion());

if (CoreUtil.isNotNullOrEmpty(targetPlatformVersionString)) {
Version targetPlatformVersion = Version.parseVersion(targetPlatformVersionString);
String targetPlatformVersionString = liferayWorkspaceProject.getTargetPlatformVersion();

String simplifyTargetPlatformVersionString = VersionUtil.simplifyTargetPlatformVersion(
targetPlatformVersionString);

if (CoreUtil.isNotNullOrEmpty(simplifyTargetPlatformVersionString)) {
Version targetPlatformVersion = Version.parseVersion(simplifyTargetPlatformVersionString);

liferayVersion = new String(targetPlatformVersion.getMajor() + "." + targetPlatformVersion.getMinor());
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,7 @@
import com.liferay.ide.project.core.model.NewLiferayPluginProjectOp;
import com.liferay.ide.project.core.model.PluginType;
import com.liferay.ide.project.core.modules.BladeCLI;
import com.liferay.ide.project.core.modules.BladeCLIException;
import com.liferay.ide.project.core.modules.BndProperties;
import com.liferay.ide.project.core.modules.BndPropertiesValue;
import com.liferay.ide.sdk.core.ISDKConstants;
Expand All @@ -67,6 +68,7 @@
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collection;
import java.util.Enumeration;
import java.util.HashMap;
import java.util.HashSet;
import java.util.Iterator;
Expand All @@ -78,6 +80,8 @@
import java.util.Set;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
import java.util.zip.ZipEntry;
import java.util.zip.ZipFile;

import org.apache.commons.lang.WordUtils;

Expand Down Expand Up @@ -144,8 +148,6 @@
@SuppressWarnings("restriction")
public class ProjectUtil {

public static final String METADATA_FOLDER = ".metadata";

public static void collectProjectsFromDirectory(List<IProject> result, File location) {
File[] children = location.listFiles();

Expand Down Expand Up @@ -240,7 +242,7 @@ else if (file.isFile() && dotProject.equals(file.getName())) {
// no project description found, so recurse into sub-directories

for (File file : contents) {
if (file.isDirectory() && !METADATA_FOLDER.equals(file.getName())) {
if (file.isDirectory() && !_METADATA_FOLDER.equals(file.getName())) {
try {
String canonicalPath = file.getCanonicalPath();

Expand Down Expand Up @@ -1060,16 +1062,57 @@ public static IFile getPortletXmlFile(IProject project) {
}

public static Map<String, ProductInfo> getProductInfos() {
try (JsonReader jsonReader = new JsonReader(Files.newBufferedReader(_workspaceCacheFile.toPath()))) {
Gson gson = new Gson();
Gson gson = new Gson();

TypeToken<Map<String, ProductInfo>> typeToken = new TypeToken<Map<String, ProductInfo>>() {
};
TypeToken<Map<String, ProductInfo>> typeToken = new TypeToken<Map<String, ProductInfo>>() {
};

if (Objects.nonNull(workspaceProductInfo)) {
_workspaceCacheFile = new File(workspaceProductInfo);
}
else {
_workspaceCacheFile = new File(System.getProperty("user.home"), _DEFAULT_WORKSPACE_CACHE_FILE);
}

try (JsonReader jsonReader = new JsonReader(Files.newBufferedReader(_workspaceCacheFile.toPath()))) {
return gson.fromJson(jsonReader, typeToken.getType());
}
catch (Exception ce) {
ProjectCore.logError("Cannot Find Product Info", ce);
catch (Exception exception) {
try {
IPath bladeCLIPath = BladeCLI.getBladeCLIPath();

if (Objects.isNull(bladeCLIPath)) {
return null;
}

if (FileUtil.notExists(bladeCLIPath.toFile())) {
return null;
}

try (ZipFile zipFile = new ZipFile(bladeCLIPath.toFile())) {
Enumeration<? extends ZipEntry> entries = zipFile.entries();

while (entries.hasMoreElements()) {
ZipEntry entry = entries.nextElement();

String entryName = entry.getName();

if (entryName.equals(".product_info.json")) {
try (InputStream resourceAsStream = zipFile.getInputStream(entry);
JsonReader jsonReader = new JsonReader(new InputStreamReader(resourceAsStream))) {

return gson.fromJson(jsonReader, typeToken.getType());
}
}
}
}
catch (Exception exception2) {
ProjectCore.logError("Cannot Find Product Info", exception2);
}
}
catch (BladeCLIException bladeException) {
ProjectCore.logError("Cannot Find blade jar", bladeException);
}
}

return null;
Expand Down Expand Up @@ -2032,14 +2075,16 @@ private static boolean _isLiferayRuntimePluginClassPath(IClasspathEntry entry) {

private static final String _DEFAULT_WORKSPACE_CACHE_FILE = ".liferay/workspace/.product_info.json";

private static final String _METADATA_FOLDER = ".metadata";

private static final SapphireContentAccessor _getter = new SapphireContentAccessor() {
};
private static final Pattern _themeBuilderPlugin = Pattern.compile(
".*apply.*plugin.*:.*[\'\"]com\\.liferay\\.portal\\.tools\\.theme\\.builder[\'\"].*",
Pattern.MULTILINE | Pattern.DOTALL);
private static final Pattern _warPlugin = Pattern.compile(".*apply.*war.*", Pattern.MULTILINE | Pattern.DOTALL);
private static final File _workspaceCacheFile = new File(
System.getProperty("user.home"), _DEFAULT_WORKSPACE_CACHE_FILE);
private static File _workspaceCacheFile;
private static String workspaceProductInfo = System.getProperty("liferay.workspace.product.info");

private static class Msgs extends NLS {

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@
import java.util.Collections;
import java.util.List;
import java.util.Objects;
import java.util.regex.Matcher;
import java.util.stream.Collectors;
import java.util.stream.Stream;

Expand Down Expand Up @@ -113,19 +114,30 @@ private List<String> _getAllDependenciesArtifactIds() {
return Collections.emptyList();
}

String productKey = gradleWorkspaceProject.getProperty(WorkspaceConstants.WORKSPACE_PRODUCT_PROPERTY, null);
String targetPlatformVersionProperty = gradleWorkspaceProject.getProperty(
WorkspaceConstants.TARGET_PLATFORM_VERSION_PROPERTY, null);

List<String> allArtifactIds = new ArrayList<>();

String[] versionParts = simplifiedVersion.split("\\.");
Matcher dxpQuarterReleaseTargetplatformVersionMatcher =
WorkspaceConstants.dxpQuarterReleaseTargetplatformVersionPattern.matcher(targetPlatformVersionProperty);

if (productKey.startsWith("dxp")) {
simplifiedVersion = versionParts[0] + "." + versionParts[1] + "." + versionParts[2] + ".x";
if (dxpQuarterReleaseTargetplatformVersionMatcher.matches()) {
simplifiedVersion = "7.4.13.x";
}
else if (productKey.startsWith("portal")) {
simplifiedVersion = versionParts[0] + "." + versionParts[1] + ".x";
else {
String productKey = gradleWorkspaceProject.getProperty(WorkspaceConstants.WORKSPACE_PRODUCT_PROPERTY, null);

String[] versionParts = simplifiedVersion.split("\\.");

if (productKey.startsWith("dxp")) {
simplifiedVersion = versionParts[0] + "." + versionParts[1] + "." + versionParts[2] + ".x";
}
else if (productKey.startsWith("portal")) {
simplifiedVersion = versionParts[0] + "." + versionParts[1] + ".x";
}
}

List<String> allArtifactIds = new ArrayList<>();

Class<?> clazz = SwitchToUseReleaseAPIDependencyCommand.class;

try (InputStream inputStream = clazz.getResourceAsStream("/release-api/" + simplifiedVersion + "-versions.txt");
Expand Down
Loading