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

BLADE-743 Support initializing the quarterly releases #320

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
48 commits
Select commit Hold shift + click to select a range
77cc0e5
BLADE-743 cli: build.gradle: updates json dependencies
drewbrokke Mar 29, 2024
c9fb711
BLADE-743 cli: build.gradle: bumps project templates version
drewbrokke Mar 29, 2024
02eadfc
BLADE-743 cli: build.gradle: adds idea plugin to generate IDE files
drewbrokke Mar 29, 2024
0c50c33
BLADE-743 cli: build.gradle, bnd.bnd: adds releases.json into the jar…
drewbrokke Apr 3, 2024
c43add9
BLADE-743 cli: bnd.bnd: includes json lib
drewbrokke Mar 29, 2024
b4d98fb
BLADE-743 cli: adds ResourceUtil
drewbrokke Mar 29, 2024
60ff1aa
BLADE-743 cli: adds ReleaseUtil
drewbrokke Mar 29, 2024
9e25ca5
BLADE-743 cli: adds flag to force Blade to check for new releases
drewbrokke Mar 29, 2024
9da0a8c
BLADE-743 cli: BladeCLI: refreshes releases if the refreshReleases fl…
drewbrokke Mar 29, 2024
6573bd1
BLADE-743 cli: BladeCLI: uses ReleaseUtil to get target platform version
drewbrokke Mar 29, 2024
2b43930
BLADE-743 cli: ConvertCommand: uses ReleaseUtil
drewbrokke Mar 29, 2024
eb06764
BLADE-743 cli: CreateCommand: provides exception for quarterly versions
drewbrokke Mar 29, 2024
602c08b
BLADE-743 cli: InitCommand: uses ReleaseUtil
drewbrokke Mar 29, 2024
4bbc561
BLADE-743 cli: LiferayDefaultVersionValidator: uses ReleaseUtil
drewbrokke Mar 29, 2024
1d2e6c1
BLADE-743 cli: LiferayMoreVersionValidator: uses ReleaseUtil
drewbrokke Mar 29, 2024
b659fbc
BLADE-743 cli: GradleWorkspaceProvider: uses ReleaseUtil
drewbrokke Mar 29, 2024
fb11aaf
BLADE-743 extensions: ClientExtensionProjectTemplateCustomizer: uses …
drewbrokke Mar 29, 2024
e7575bb
BLADE-743 cli: BladeUtil: removes unused methods and fields
drewbrokke Mar 29, 2024
de19eb8
BLADE-743 cli: JavaProcesses: source formatting
drewbrokke Mar 29, 2024
74efac8
BLADE-743 cli: BladeTest: adds helper method and ensures that the con…
drewbrokke Apr 1, 2024
fd45963
BLADE-743 cli: InitCommandTest: fixes test cases
drewbrokke Mar 29, 2024
1b05f9c
BLADE-743 cli: UtilTest: fixes test cases
drewbrokke Apr 1, 2024
109f69b
BLADE-743 cli: CreateCommandTest: fixes test cases
drewbrokke Apr 1, 2024
51d31ed
BLADE-743 cli: CreateCommandTest: fix the heap size failure
drewbrokke Apr 1, 2024
949214e
BLADE-743 cli: SamplesCommandTest: ignores tests that break because o…
drewbrokke Apr 2, 2024
66403e6
BLADE-743 cli: ServerStartCommandTest: fixes test case
drewbrokke Apr 2, 2024
63a6c76
BLADE-743 cli: LiferayMoreVersionValidatorTest: fixes test cases
drewbrokke Apr 2, 2024
96bf2a9
BLADE-743 liferay-blade-cli: build.gradle: major version bump
drewbrokke Apr 2, 2024
ac9d561
BLADE-743 extensions: removes content-targeting extensions
drewbrokke Apr 3, 2024
327816f
BLADE-743 extensions: removes project-templates-client-extension
drewbrokke Apr 3, 2024
9638e81
BLADE-743 liferay-blade-cli: removes references to deleted extensions
drewbrokke Apr 3, 2024
ee13e98
BLADE-743 extensions: bumps com.liferay.project.templates.extensions …
drewbrokke Apr 3, 2024
77211e2
BLADE-743 cli: InitCommand: use fallback matching on the version
drewbrokke Apr 3, 2024
064a52e
BLADE-743 cli: removes unused ProductKey classes
drewbrokke Apr 3, 2024
eb63e34
BLADE-743 cli: BladeTest: removes unused field
drewbrokke Apr 3, 2024
6b64416
BLADE-743 cli: ReleaseUtil: removes unused methods and classes
drewbrokke Apr 3, 2024
2fb3877
BLADE-743 cli: updates expected values in smoke tests
drewbrokke Apr 3, 2024
712de2d
BLADE-743 extensions: SampleTemplatesTest: fixes test case
drewbrokke Apr 3, 2024
ac30f96
BLADE-743 cli: ArrayUtil: adds contains helper method
drewbrokke Apr 4, 2024
40df81f
BLADE-743 cli: BladeCLI: ResourceUtil follows the trace arg
drewbrokke Apr 4, 2024
664823d
BLADE-743 cli: ReleaseUtil: adjusts priority, and adds an option for …
drewbrokke Apr 4, 2024
e031f4f
BLADE-743 liferay-blade-cli: TestUtil: adds helper methods for updati…
drewbrokke Apr 4, 2024
1bef013
BLADE-743 liferay-blade-cli: CreateCommandTest: update usage
drewbrokke Apr 4, 2024
b8c3f21
BLADE-743 liferay-blade-cli: ServerStartCommandTest: apply Gradle mem…
drewbrokke Apr 4, 2024
386284c
BLADE-743 liferay-blade-cli: ReleaseUtil: initialize releases if none…
drewbrokke Apr 5, 2024
a9dfcca
BLADE-743 liferay-blade-cli: BladeCLI: simplify
drewbrokke Apr 5, 2024
ea8883a
BLADE-743 liferay-blade-cli: StringUtil: fixes NPE - allows null strings
drewbrokke Apr 5, 2024
f4911ea
BLADE-743 cli: BladeTest: temporarily hard-codes the value
drewbrokke Apr 5, 2024
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
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
Loading