Skip to content

Commit

Permalink
Merge pull request #320 from drewbrokke/BLADE-743-TASK-v1-quarterly-i…
Browse files Browse the repository at this point in the history
…nit-rebase

BLADE-743 Support initializing the quarterly releases
  • Loading branch information
drewbrokke authored Apr 5, 2024
2 parents b0cde64 + f4911ea commit 379463c
Show file tree
Hide file tree
Showing 90 changed files with 797 additions and 3,488 deletions.
14 changes: 0 additions & 14 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -228,11 +228,6 @@ subprojects {
"name: \"com.liferay.blade.extensions.maven.profile\", version: \"$version\""
}

buildGradle.text = buildGradle.text.replaceAll(/name: "com.liferay.project.templates.client.extension", version: "(.*)-SNAPSHOT"/) {
all, version ->
"name: \"com.liferay.project.templates.client.extension\", version: \"$version\""
}

buildGradle.text = buildGradle.text.replaceAll(/name: "com.liferay.project.templates.js.theme", version: "(.*)-SNAPSHOT"/) {
all, version ->
"name: \"com.liferay.project.templates.js.theme\", version: \"$version\""
Expand Down Expand Up @@ -267,15 +262,6 @@ subprojects {
"name: \"com.liferay.blade.extensions.maven.profile\", version: \"${newVersion}-SNAPSHOT\""
}

buildGradle.text = buildGradle.text.replaceAll(/name: "com.liferay.project.templates.client.extension", version: "(.*)"/) {
all, version ->
Version currentVersion = new Version(version)

Version newVersion = new Version(currentVersion.major, currentVersion.minor, currentVersion.micro + 1)

"name: \"com.liferay.project.templates.client.extension\", version: \"${newVersion}-SNAPSHOT\""
}

buildGradle.text = buildGradle.text.replaceAll(/name: "com.liferay.project.templates.js.theme", version: "(.*)"/) {
all, version ->
Version currentVersion = new Version(version)
Expand Down
62 changes: 3 additions & 59 deletions cli/blade-jar-smoke-tests.gradle
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
import org.apache.tools.ant.taskdefs.condition.Os

task smokeTests
task testBladeCreateCommandClientExtension(type: JavaExec)
task testBladeCreateCommandClientExtensionInCurrentDir(type: JavaExec)
task testBladeCreateCommandFormField(type: JavaExec)
task testBladeCreateCommandJsTheme(type: JavaExec)
task testBladeCreateCommandListTemplates(type: JavaExec)
Expand Down Expand Up @@ -42,60 +40,6 @@ ByteArrayOutputStream standardStream = new ByteArrayOutputStream()
File initDir = new File(buildDir, "initTest")
File clientExtensionDir = new File(initDir, "client-extension")

testBladeCreateCommandClientExtension {
dependsOn testBladeInitCommand

doFirst {
clientExtensionDir.mkdirs()
}

onlyIf {
!Os.isFamily(Os.FAMILY_WINDOWS)
}

args = [jar.archivePath, "create", "-t", "client-extension", "--extension-name", "test123", "--extension-type", "customElement", "-d", clientExtensionDir.path, "customelementtest"]
errorOutput = errorStream
standardOutput = standardStream
workingDir = initDir

doLast {
String error = errorStream.toString().toLowerCase()
File projectDir = new File(clientExtensionDir, "customelementtest")
boolean projectDirExists = projectDir.exists()

errorStream.reset()
standardStream.reset()

assert projectDirExists
assert !error.contains("error")
}
}

testBladeCreateCommandClientExtensionInCurrentDir {
dependsOn testBladeInitCommand

onlyIf {
!Os.isFamily(Os.FAMILY_WINDOWS)
}

args = [jar.archivePath, "create", "-t", "client-extension", "--extension-name", "test123", "--extension-type", "customElement", "customelementtest1"]
errorOutput = errorStream
standardOutput = standardStream
workingDir = initDir

doLast {
String error = errorStream.toString().toLowerCase()
File projectDir = new File(initDir, "customelementtest1")
boolean projectDirExists = projectDir.exists()

errorStream.reset()
standardStream.reset()

assert projectDirExists
assert !error.contains("error")
}
}

testBladeCreateCommandFormField {
dependsOn testBladeInitCommand

Expand Down Expand Up @@ -284,7 +228,7 @@ testBladeInitCommand {
initDir.mkdirs()
}

args = [jar.archivePath, "init", "-v", "dxp-7.2-ga1"]
args = [jar.archivePath, "init", "-v", "dxp-7.2.8"]
errorOutput = errorStream
standardOutput = standardStream
workingDir = initDir
Expand Down Expand Up @@ -361,7 +305,7 @@ testBladeInitCommandList {
standardStream.reset()

assert !error.contains("error")
assert !output.contains("dxp-7.2-sp1")
assert !output.contains("dxp-2023.q4.6")
}
}

Expand All @@ -383,7 +327,7 @@ testBladeInitCommandListAll {
standardStream.reset()

assert !error.contains("error")
assert output.contains("dxp-7.2-sp1")
assert output.contains("dxp-2023.q4.6")
}
}

Expand Down
4 changes: 3 additions & 1 deletion cli/bnd.bnd
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,8 @@ Private-Package:\
\
aQute.service.reporter;-split-package:=merge-first,\
\
com.fasterxml.jackson.*,\
\
com.liferay.blade.gradle.tooling,\
\
groovy.json,\
Expand Down Expand Up @@ -321,8 +323,8 @@ Private-Package:\
@com.liferay.gogo.shell.client-1.0.0.jar,\
@com.liferay.project.templates-*.jar,\
@jansi-*.jar,\
${project.buildDir}/releases.json,\
${project.buildDir}/tooling.zip,\
${project.buildDir}/wrapper.zip,\
${project.buildDir}/.product_info.json,\
mvnw.cmd
-sources: false
15 changes: 8 additions & 7 deletions cli/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ buildscript {
}

apply plugin: "biz.aQute.bnd.builder"
apply plugin: "idea"
apply plugin: "java-library"
apply plugin: "maven-publish"

Expand All @@ -31,7 +32,7 @@ tasks.register('copyMavenProfileJar', Copy)
tasks.register('createToolingZip', Zip)
tasks.register('createWrapperZip', Zip)
tasks.register('downloadPortal', Download)
tasks.register('downloadProductInfo', Download)
tasks.register('downloadReleasesJson', Download)
tasks.register('unzipManifest', Copy)
tasks.register('unzipPortal', Copy)

Expand Down Expand Up @@ -76,8 +77,9 @@ createWrapperZip {

dependencies {
api group: "biz.aQute.bnd", name: "biz.aQute.bndlib", version: "5.3.0"
api group: "com.fasterxml.jackson.core", name: "jackson-databind", version: "2.16.1"
api group: "com.liferay", name: "com.liferay.gogo.shell.client", version: "1.0.0"
api group: "com.liferay", name: "com.liferay.project.templates", version: "5.0.269"
api group: "com.liferay", name: "com.liferay.project.templates", version: "5.0.289"
api group: "commons-io", name: "commons-io", version: "2.7"
api group: "commons-lang", name: "commons-lang", version: "2.6"
api group: "org.apache.ant", name: "ant", version: "1.10.11"
Expand Down Expand Up @@ -112,7 +114,6 @@ dependencies {
api name: "org.objectweb.asm.util-6.0.0"

bladeExtensions group: "com.liferay.blade", name: "com.liferay.blade.extensions.maven.profile", version: "1.0.39-SNAPSHOT"
bladeExtensions group: "com.liferay.blade", name: "com.liferay.project.templates.client.extension", version: "1.0.6-SNAPSHOT"
bladeExtensions group: "com.liferay.blade", name: "com.liferay.project.templates.js.theme", version: "1.0.22-SNAPSHOT"
bladeExtensions group: "com.liferay.blade", name: "com.liferay.project.templates.js.widget", version: "1.0.23-SNAPSHOT"

Expand All @@ -139,16 +140,16 @@ downloadPortal {
onlyIfNewer true
}

downloadProductInfo {
src "https://releases-cdn.liferay.com/tools/workspace/.product_info.json"
downloadReleasesJson {
src "https://releases-cdn.liferay.com/releases.json"
dest buildDir
onlyIfNewer true
}

jar {
dependsOn("unzipPortal")
archiveFileName.set("blade.jar")
from createToolingZip, createWrapperZip, downloadProductInfo
from createToolingZip, createWrapperZip, downloadReleasesJson
}

processResources {
Expand Down Expand Up @@ -323,6 +324,6 @@ unzipPortal {
finalizedBy("processZipsResources")
}

version = "5.0.2-SNAPSHOT"
version = "6.0.0-SNAPSHOT"

apply from: "blade-jar-smoke-tests.gradle"
25 changes: 18 additions & 7 deletions cli/src/main/java/com/liferay/blade/cli/BladeCLI.java
Original file line number Diff line number Diff line change
Expand Up @@ -25,13 +25,14 @@
import com.liferay.blade.cli.command.validator.ParameterValidator;
import com.liferay.blade.cli.command.validator.ValidatorFunctionPredicate;
import com.liferay.blade.cli.gradle.GradleExecutionException;
import com.liferay.blade.cli.util.BladeUtil;
import com.liferay.blade.cli.util.ArrayUtil;
import com.liferay.blade.cli.util.CombinedClassLoader;
import com.liferay.blade.cli.util.FileUtil;
import com.liferay.blade.cli.util.Pair;
import com.liferay.blade.cli.util.ProcessesUtil;
import com.liferay.blade.cli.util.ProductInfo;
import com.liferay.blade.cli.util.Prompter;
import com.liferay.blade.cli.util.ReleaseUtil;
import com.liferay.blade.cli.util.ResourceUtil;

import java.io.BufferedReader;
import java.io.File;
Expand Down Expand Up @@ -406,6 +407,16 @@ public void printUsage(String command, String message) {

public void run(String[] args) throws Exception {
try {
if (ArrayUtil.contains(args, "--trace")) {
ResourceUtil.setTrace(true);
}

if (ArrayUtil.contains(args, "--refresh-releases")) {
System.out.println("Checking for new releases...");

ReleaseUtil.populateReleases(0);
}

_removeOutDatedTempDir();

Extensions extensions = getExtensions();
Expand Down Expand Up @@ -473,7 +484,9 @@ public void run(String[] args) throws Exception {

Object commandArgs = objects.get(0);

_validateParameters((BaseArgs)commandArgs);
BaseArgs baseArgs = (BaseArgs)commandArgs;

_validateParameters(baseArgs);

String parameterMessage = null;

Expand Down Expand Up @@ -862,16 +875,14 @@ private Map<String, String> _buildMavenPossibleValuesMap(

Iterator<String> it = options.iterator();

Map<String, Object> productInfos = BladeUtil.getProductInfos(true, error());

Map<String, String> optionsMap = new LinkedHashMap<>();

for (int x = 1; it.hasNext(); x++) {
String option = it.next();

ProductInfo productInfo = new ProductInfo((Map<String, String>)productInfos.get(option));
ReleaseUtil.ReleaseEntry releaseEntry = ReleaseUtil.getReleaseEntry(option);

optionsMap.put(String.valueOf(x), productInfo.getTargetPlatformVersion());
optionsMap.put(String.valueOf(x), releaseEntry.getTargetPlatformVersion());
}

return optionsMap;
Expand Down
11 changes: 11 additions & 0 deletions cli/src/main/java/com/liferay/blade/cli/command/BaseArgs.java
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,10 @@ public boolean isQuiet() {
return _quiet;
}

public boolean isRefreshReleases() {
return _refreshReleases;
}

public boolean isTrace() {
return _trace;
}
Expand All @@ -52,6 +56,10 @@ public void setQuiet(boolean quiet) {
_quiet = quiet;
}

public void setRefreshReleases(boolean refreshReleases) {
_refreshReleases = refreshReleases;
}

@Parameter(
description = "Specify a new base directory (default working directory).", hidden = true, names = "--base"
)
Expand All @@ -69,6 +77,9 @@ public void setQuiet(boolean quiet) {
@Parameter(description = "Do not print any optional messages to console.", hidden = true, names = {"-q", "--quiet"})
private boolean _quiet;

@Parameter(description = "Force Blade to check for new releases", names = "--refresh-releases")
private boolean _refreshReleases;

@Parameter(description = "Print exception stack traces when they occur.", hidden = true, names = "--trace")
private boolean _trace;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
import com.liferay.blade.cli.util.CopyDirVisitor;
import com.liferay.blade.cli.util.FileUtil;
import com.liferay.blade.cli.util.ListUtil;
import com.liferay.blade.cli.util.ProductInfo;
import com.liferay.blade.cli.util.ReleaseUtil;
import com.liferay.blade.cli.util.StringUtil;
import com.liferay.blade.gradle.model.GradleDependency;
import com.liferay.project.templates.extensions.ProjectTemplatesArgs;
Expand Down Expand Up @@ -66,8 +66,6 @@
import org.apache.tools.ant.Project;
import org.apache.tools.ant.taskdefs.LoadProperties;

import org.json.JSONObject;

import org.w3c.dom.Document;
import org.w3c.dom.Element;
import org.w3c.dom.NamedNodeMap;
Expand Down Expand Up @@ -1160,13 +1158,14 @@ private List<String> _getReleaseApirtifactIds() {

String productKey = productKeyOpt.get();

Optional<String> targetPlatformVersionFromProduct = _getTargetPlatformVersionFromProduct(productKey);
String targetPlatformVersion = ReleaseUtil.withReleaseEntry(
productKey, ReleaseUtil.ReleaseEntry::getTargetPlatformVersion);

if (!targetPlatformVersionFromProduct.isPresent()) {
if (targetPlatformVersion == null) {
return Collections.emptyList();
}

String simplifiedVersion = BladeUtil.simplifyTargetPlatformVersion(targetPlatformVersionFromProduct.get());
String simplifiedVersion = BladeUtil.simplifyTargetPlatformVersion(targetPlatformVersion);

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

Expand Down Expand Up @@ -1202,43 +1201,6 @@ else if (productKey.startsWith("portal")) {
return Collections.emptyList();
}

@SuppressWarnings("unchecked")
private Optional<String> _getTargetPlatformVersionFromProduct(String productKey) {
try {
File userHomeDir = new File(System.getProperty("user.home"));

userHomeDir = userHomeDir.getCanonicalFile();

Path userHomePath = userHomeDir.toPath();

Path productInfoPath = userHomePath.resolve(".liferay/workspace/.product_info.json");

if (!Files.exists(productInfoPath)) {
Map<String, Object> productInfos = BladeUtil.getProductInfos();

ProductInfo productInfo = new ProductInfo((Map<String, String>)productInfos.get(productKey));

return Optional.of(productInfo.getTargetPlatformVersion());
}

JSONObject jsonObject = new JSONObject(new String(Files.readAllBytes(productInfoPath.normalize())));

return Optional.ofNullable(
jsonObject.get(productKey)
).map(
JSONObject.class::cast
).map(
info -> info.get("targetPlatformVersion")
).map(
Object::toString
);
}
catch (Exception exception) {
}

return Optional.empty();
}

private boolean _hasServiceXmlFile(File dir) {
Path dirPath = dir.toPath();

Expand Down
Loading

0 comments on commit 379463c

Please sign in to comment.