diff --git a/.github/workflows/verify.yml b/.github/workflows/verify.yml index 729183867..f84d0d246 100644 --- a/.github/workflows/verify.yml +++ b/.github/workflows/verify.yml @@ -81,7 +81,7 @@ jobs: - name: Setup Java 11 uses: actions/setup-java@v3 with: - java-version: 11 + java-version: 11.0.19 distribution: 'zulu' cache: gradle - name: Cache @@ -120,7 +120,7 @@ jobs: - name: Setup Java 11 uses: actions/setup-java@v3 with: - java-version: 11 + java-version: 11.0.19 distribution: 'zulu' cache: gradle - name: Cache diff --git a/cli/build.gradle b/cli/build.gradle index 46a6e066c..485c797c2 100644 --- a/cli/build.gradle +++ b/cli/build.gradle @@ -75,7 +75,7 @@ createWrapperZip { dependencies { api group: "biz.aQute.bnd", name: "biz.aQute.bndlib", version: "5.3.0" api group: "com.liferay", name: "com.liferay.gogo.shell.client", version: "1.0.0" - api group: "com.liferay", name: "com.liferay.project.templates", version: "latest.release" + api group: "com.liferay", name: "com.liferay.project.templates", version: "5.0.237" api group: "commons-beanutils", name: "commons-beanutils", version: "1.9.4" api group: "commons-io", name: "commons-io", version: "2.6" api group: "commons-lang", name: "commons-lang", version: "2.6" @@ -132,6 +132,10 @@ dependencies { testImplementation project(":gradle-tooling") } +compileTestJava{ + dependsOn("unzipPortal") +} + downloadPortal { src "https://releases-cdn.liferay.com/portal/7.4.3.4-ga4/liferay-ce-portal-tomcat-7.4.3.4-ga4-20211020095956970.tar.gz" dest new File("${System.getProperty('user.home')}/.liferay/bundles", 'liferay-ce-portal-tomcat-7.4.3.4-ga4-20211020095956970.tar.gz') @@ -315,6 +319,10 @@ unzipManifest { finalizedBy("compileTestJava") } +processZipsResources{ + dependsOn("unzipPortal") +} + unzipPortal { dependsOn downloadPortal from tarTree(resources.gzip(downloadPortal.dest)) diff --git a/cli/src/test/java/com/liferay/blade/cli/BladeTest.java b/cli/src/test/java/com/liferay/blade/cli/BladeTest.java index 76c97fea3..3d5ae915e 100644 --- a/cli/src/test/java/com/liferay/blade/cli/BladeTest.java +++ b/cli/src/test/java/com/liferay/blade/cli/BladeTest.java @@ -50,6 +50,8 @@ public class BladeTest extends BladeCLI { public static final String LIFERAY_VERSION_73101 = "7.3.10.u15"; + public static final String LIFERAY_VERSION_PORTAL_7456 = "7.4.3.56"; + public static final String PRODUCT_VERSION_COMMERCE_206 = "commerce-2.0.6"; public static final String PRODUCT_VERSION_COMMERCE_207 = "commerce-2.0.7-7.2"; diff --git a/cli/src/test/java/com/liferay/blade/cli/command/InitCommandTest.java b/cli/src/test/java/com/liferay/blade/cli/command/InitCommandTest.java index 8673c370f..1b2830a10 100644 --- a/cli/src/test/java/com/liferay/blade/cli/command/InitCommandTest.java +++ b/cli/src/test/java/com/liferay/blade/cli/command/InitCommandTest.java @@ -38,7 +38,6 @@ import org.junit.Assert; import org.junit.Before; -import org.junit.Ignore; import org.junit.Rule; import org.junit.Test; import org.junit.rules.TemporaryFolder; @@ -499,7 +498,6 @@ public void testInitWithLiferayVersionUnset() throws Exception { TestUtil.runBlade(_workspaceDir, _extensionsDir, args); } - @Ignore @Test public void testInitWithNameWorkspaceDirectoryEmpty() throws Exception { String[] args = { @@ -681,7 +679,7 @@ private void _verifyGradleBuild() throws Exception { GradleRunnerUtil.verifyBuildOutput(projectPath.toString(), "foo-1.0.0.jar"); } - private static final String _GRADLE_PLUGINS_WORKSPACE_VERSION = "8.0.0"; + private static final String _GRADLE_PLUGINS_WORKSPACE_VERSION = "8.0.3"; private File _extensionsDir = null; private File _workspaceDir = null; diff --git a/cli/test-resources/projects/testws1/settings.gradle b/cli/test-resources/projects/testws1/settings.gradle index b8fb58c77..81885d591 100644 --- a/cli/test-resources/projects/testws1/settings.gradle +++ b/cli/test-resources/projects/testws1/settings.gradle @@ -4,7 +4,7 @@ buildscript { classpath group: "biz.aQute.bnd", name: "biz.aQute.bnd", version: "5.3.0" classpath group: "com.github.docker-java", name: "docker-java-transport", version: "3.2.8" - classpath(group: "com.liferay", name: "com.liferay.gradle.plugins.workspace", version: "7.0.2") { + classpath(group: "com.liferay", name: "com.liferay.gradle.plugins.workspace", version: "latest.release") { exclude group: "biz.aQute.bnd", module: "biz.aQute.bnd" } } diff --git a/extensions/maven-profile/src/test/java/com/liferay/blade/extensions/maven/profile/DeployCommandMavenTest.java b/extensions/maven-profile/src/test/java/com/liferay/blade/extensions/maven/profile/DeployCommandMavenTest.java index d9b08bcaf..58ac06b48 100644 --- a/extensions/maven-profile/src/test/java/com/liferay/blade/extensions/maven/profile/DeployCommandMavenTest.java +++ b/extensions/maven-profile/src/test/java/com/liferay/blade/extensions/maven/profile/DeployCommandMavenTest.java @@ -42,11 +42,13 @@ public void testInstallJar() throws Exception { File workspaceDir = temporaryFolder.newFolder(); String[] args = { - "--base", workspaceDir.getPath(), "init", "-P", "maven", "-v", BladeTest.LIFERAY_VERSION_72107 + "--base", workspaceDir.getPath(), "init", "-P", "maven", "-v", BladeTest.LIFERAY_VERSION_PORTAL_7456 }; TestUtil.runBlade(workspaceDir, _extensionsDir, args); + XMLTestUtil.updateWorkspaceBundleUrl(workspaceDir, BladeTest.LIFERAY_VERSION_PORTAL_7456); + args = new String[] {"--base", workspaceDir.getPath(), "server", "init"}; String workspacePath = workspaceDir.getAbsolutePath(); @@ -79,7 +81,7 @@ public void testInstallJar() throws Exception { args = new String[] { "--base", modulesDirectory.getAbsolutePath(), "create", "-t", "mvc-portlet", "foo", "-v", - BladeTest.LIFERAY_VERSION_72107 + BladeTest.LIFERAY_VERSION_PORTAL_7456 }; TestUtil.runBlade(workspaceDir, _extensionsDir, args); @@ -104,11 +106,13 @@ public void testInstallWar() throws Exception { File workspaceDir = temporaryFolder.newFolder(); String[] args = { - "--base", workspaceDir.getPath(), "init", "-P", "maven", "-v", BladeTest.LIFERAY_VERSION_72107 + "--base", workspaceDir.getPath(), "init", "-P", "maven", "-v", BladeTest.LIFERAY_VERSION_PORTAL_7456 }; TestUtil.runBlade(workspaceDir, _extensionsDir, args); + XMLTestUtil.updateWorkspaceBundleUrl(workspaceDir, BladeTest.LIFERAY_VERSION_PORTAL_7456); + args = new String[] {"--base", workspaceDir.getPath(), "server", "init"}; String workspacePath = workspaceDir.getAbsolutePath(); @@ -137,7 +141,7 @@ public void testInstallWar() throws Exception { args = new String[] { "--base", modulesDirectory.getAbsolutePath(), "create", "-t", "war-mvc-portlet", "foo", "-v", - BladeTest.LIFERAY_VERSION_72107 + BladeTest.LIFERAY_VERSION_PORTAL_7456 }; TestUtil.runBlade(workspaceDir, _extensionsDir, args); diff --git a/extensions/maven-profile/src/test/java/com/liferay/blade/extensions/maven/profile/ServerCommandsMavenTest.java b/extensions/maven-profile/src/test/java/com/liferay/blade/extensions/maven/profile/ServerCommandsMavenTest.java index 48cade911..6556bd708 100644 --- a/extensions/maven-profile/src/test/java/com/liferay/blade/extensions/maven/profile/ServerCommandsMavenTest.java +++ b/extensions/maven-profile/src/test/java/com/liferay/blade/extensions/maven/profile/ServerCommandsMavenTest.java @@ -42,7 +42,7 @@ public void testServerInit() throws Exception { File workspaceDir = temporaryFolder.newFolder("build", "test", "workspace"); String[] args = { - "--base", workspaceDir.getPath(), "init", "-f", "-P", "maven", "-v", BladeTest.LIFERAY_VERSION_741 + "--base", workspaceDir.getPath(), "init", "-f", "-P", "maven", "-v", BladeTest.LIFERAY_VERSION_PORTAL_7456 }; TestUtil.runBlade(workspaceDir, extensionsDir, args); @@ -58,6 +58,8 @@ public void testServerInit() throws Exception { _addNexusRepositoriesElement(document, "pluginRepositories", "pluginRepository"); }); + XMLTestUtil.updateWorkspaceBundleUrl(workspaceDir, BladeTest.LIFERAY_VERSION_PORTAL_7456); + args = new String[] {"--base", workspaceDir.getPath(), "server", "init"}; File bundlesDir = new File(workspaceDir.getPath(), "bundles"); diff --git a/extensions/maven-profile/src/test/java/com/liferay/blade/extensions/maven/profile/XMLTestUtil.java b/extensions/maven-profile/src/test/java/com/liferay/blade/extensions/maven/profile/XMLTestUtil.java index b447ef0d8..0fd3e1700 100644 --- a/extensions/maven-profile/src/test/java/com/liferay/blade/extensions/maven/profile/XMLTestUtil.java +++ b/extensions/maven-profile/src/test/java/com/liferay/blade/extensions/maven/profile/XMLTestUtil.java @@ -17,12 +17,18 @@ package com.liferay.blade.extensions.maven.profile; import java.io.File; +import java.io.FileReader; +import java.io.FileWriter; +import java.io.IOException; import java.io.StringWriter; import java.nio.file.Path; import java.util.ArrayList; +import java.util.HashMap; import java.util.List; +import java.util.Map; +import java.util.Properties; import java.util.function.Consumer; import javax.xml.parsers.DocumentBuilder; @@ -35,6 +41,12 @@ import javax.xml.transform.dom.DOMSource; import javax.xml.transform.stream.StreamResult; +import org.apache.maven.model.Model; +import org.apache.maven.model.io.xpp3.MavenXpp3Reader; +import org.apache.maven.model.io.xpp3.MavenXpp3Writer; + +import org.codehaus.plexus.util.xml.pull.XmlPullParserException; + import org.junit.Assert; import org.w3c.dom.Document; @@ -48,6 +60,22 @@ */ public class XMLTestUtil { + public static final String BUNDLE_URL_PROPERTY = "liferay.workspace.bundle.url"; + + public static final String LIFERAY_PORTAL_URL = "https://releases-cdn.liferay.com/portal/"; + + public static final Map liferayBundleUrlVersions = new HashMap() { + { + put("7.0.6-2", LIFERAY_PORTAL_URL + "7.0.6-ga7/liferay-ce-portal-tomcat-7.0-ga7-20180507111753223.zip"); + put("7.1.2", LIFERAY_PORTAL_URL + "7.1.2-ga3/liferay-ce-portal-tomcat-7.1.2-ga3-20190107144105508.tar.gz"); + put("7.2.0", LIFERAY_PORTAL_URL + "7.2.0-ga1/liferay-ce-portal-tomcat-7.2.0-ga1-20190531153709761.tar.gz"); + put("7.3.7", LIFERAY_PORTAL_URL + "7.3.7-ga8/liferay-ce-portal-tomcat-7.3.7-ga8-20210610183559721.tar.gz"); + put( + "7.4.3.56", + LIFERAY_PORTAL_URL + "7.4.3.56-ga56/liferay-ce-portal-tomcat-7.4.3.56-ga56-20221222175515613.tar.gz"); + } + }; + public static void editXml(File xmlFile, Consumer consumer) throws Exception { TransformerFactory transformerFactory = TransformerFactory.newInstance(); @@ -123,6 +151,14 @@ public static List getChildElements(Element element) { return elements; } + public static Model getMavenModel(File pomFile) throws IOException, XmlPullParserException { + MavenXpp3Reader mavenReader = new MavenXpp3Reader(); + + mavenReader.setAddDefaultEntities(true); + + return mavenReader.read(new FileReader(pomFile)); + } + public static void testXmlElement( Path path, String parentElementString, List elements, int index, String expectedTagName, String expectedTextContent) @@ -164,6 +200,35 @@ public static String toString(Element element) throws TransformerException { return stringWriter.toString(); } + public static void updateMavenPom(Model model, File file) throws IOException { + MavenXpp3Writer mavenWriter = new MavenXpp3Writer(); + + FileWriter fileWriter = new FileWriter(file); + + mavenWriter.write(fileWriter, model); + } + + public static void updateWorkspaceBundleUrl(File workspaceDir, String liferayVersion) throws Exception { + try { + File workspacePomFile = new File(workspaceDir, "pom.xml"); + + if (!workspacePomFile.exists()) { + throw new Exception("Can not find workspace pom.xml file"); + } + + Model pomModel = getMavenModel(workspacePomFile); + + Properties properties = pomModel.getProperties(); + + properties.setProperty(BUNDLE_URL_PROPERTY, liferayBundleUrlVersions.get(liferayVersion)); + + updateMavenPom(pomModel, workspacePomFile); + } + catch (Exception exception) { + throw new Exception(exception); + } + } + private static final Transformer _transformer; static { diff --git a/extensions/project-templates-activator/build.gradle b/extensions/project-templates-activator/build.gradle index 4a7c07d8b..1bb54dfab 100644 --- a/extensions/project-templates-activator/build.gradle +++ b/extensions/project-templates-activator/build.gradle @@ -38,7 +38,14 @@ eclipse { } } +compileJava{ + dependsOn(":cli:unzipPortal") + dependsOn(":cli:unzipManifest") +} + jar{ + dependsOn(":cli:unzipPortal") + archiveBaseName.set("com.liferay.project.templates.activator") } diff --git a/extensions/project-templates-client-extension/build.gradle b/extensions/project-templates-client-extension/build.gradle index ce7732785..7b39cd9ea 100644 --- a/extensions/project-templates-client-extension/build.gradle +++ b/extensions/project-templates-client-extension/build.gradle @@ -30,7 +30,14 @@ dependencies { testImplementation project(path: ":cli", configuration: "testApi") } +compileJava{ + dependsOn(":cli:unzipPortal") + dependsOn(":cli:unzipManifest") +} + jar{ + dependsOn(":cli:unzipPortal") + archiveBaseName.set("com.liferay.project.templates.client.extension") } diff --git a/extensions/project-templates-content-targeting-report/build.gradle b/extensions/project-templates-content-targeting-report/build.gradle index 9f39a6d95..04261e544 100644 --- a/extensions/project-templates-content-targeting-report/build.gradle +++ b/extensions/project-templates-content-targeting-report/build.gradle @@ -38,7 +38,14 @@ eclipse { } } +compileJava{ + dependsOn(":cli:unzipPortal") + dependsOn(":cli:unzipManifest") +} + jar{ + dependsOn(":cli:unzipPortal") + archiveBaseName.set("com.liferay.project.templates.content.targeting.report") } diff --git a/extensions/project-templates-content-targeting-rule/build.gradle b/extensions/project-templates-content-targeting-rule/build.gradle index c28fc0312..378745a07 100644 --- a/extensions/project-templates-content-targeting-rule/build.gradle +++ b/extensions/project-templates-content-targeting-rule/build.gradle @@ -38,7 +38,14 @@ eclipse { } } +compileJava{ + dependsOn(":cli:unzipPortal") + dependsOn(":cli:unzipManifest") +} + jar{ + dependsOn(":cli:unzipPortal") + archiveBaseName.set("com.liferay.project.templates.content.targeting.rule") } diff --git a/extensions/project-templates-content-targeting-tracking-action/build.gradle b/extensions/project-templates-content-targeting-tracking-action/build.gradle index 39e34a893..da5cb5610 100644 --- a/extensions/project-templates-content-targeting-tracking-action/build.gradle +++ b/extensions/project-templates-content-targeting-tracking-action/build.gradle @@ -38,7 +38,14 @@ eclipse { } } +compileJava{ + dependsOn(":cli:unzipPortal") + dependsOn(":cli:unzipManifest") +} + jar{ + dependsOn(":cli:unzipPortal") + archiveBaseName.set("com.liferay.project.templates.content.targeting.tracking.action") } diff --git a/extensions/project-templates-freemarker-portlet/build.gradle b/extensions/project-templates-freemarker-portlet/build.gradle index d849bdc0d..d4f48be1c 100644 --- a/extensions/project-templates-freemarker-portlet/build.gradle +++ b/extensions/project-templates-freemarker-portlet/build.gradle @@ -38,7 +38,14 @@ eclipse { } } +compileJava{ + dependsOn(":cli:unzipPortal") + dependsOn(":cli:unzipManifest") +} + jar{ + dependsOn(":cli:unzipPortal") + archiveBaseName.set("com.liferay.project.templates.freemarker.portlet") } diff --git a/extensions/project-templates-js-theme/build.gradle b/extensions/project-templates-js-theme/build.gradle index 85c4b0720..b821a138f 100644 --- a/extensions/project-templates-js-theme/build.gradle +++ b/extensions/project-templates-js-theme/build.gradle @@ -32,6 +32,7 @@ dependencies { compileJava{ dependsOn(":cli:unzipPortal") + dependsOn(":cli:unzipManifest") } jar{ diff --git a/extensions/project-templates-js-widget/build.gradle b/extensions/project-templates-js-widget/build.gradle index c8acbe7f0..eb4b44d98 100644 --- a/extensions/project-templates-js-widget/build.gradle +++ b/extensions/project-templates-js-widget/build.gradle @@ -32,6 +32,7 @@ dependencies { compileJava{ dependsOn(":cli:unzipPortal") + dependsOn(":cli:unzipManifest") } jar{ diff --git a/extensions/project-templates-social-bookmark/build.gradle b/extensions/project-templates-social-bookmark/build.gradle index dd5431827..c4694a59e 100644 --- a/extensions/project-templates-social-bookmark/build.gradle +++ b/extensions/project-templates-social-bookmark/build.gradle @@ -38,6 +38,11 @@ eclipse { } } +compileJava{ + dependsOn(":cli:unzipPortal") + dependsOn(":cli:unzipManifest") +} + jar{ dependsOn(":cli:unzipPortal") diff --git a/extensions/sample-command/build.gradle b/extensions/sample-command/build.gradle index c13db540f..cb0d693db 100644 --- a/extensions/sample-command/build.gradle +++ b/extensions/sample-command/build.gradle @@ -31,10 +31,12 @@ dependencies { compileJava{ dependsOn(":cli:unzipPortal") + dependsOn(":cli:unzipManifest") } jar{ dependsOn(":cli:unzipPortal") + dependsOn(":cli:unzipManifest") } test { diff --git a/extensions/sample-profile/build.gradle b/extensions/sample-profile/build.gradle index 1c7299c37..e6d7c4d13 100644 --- a/extensions/sample-profile/build.gradle +++ b/extensions/sample-profile/build.gradle @@ -21,10 +21,12 @@ apply plugin: 'biz.aQute.bnd.builder' compileJava{ dependsOn(":cli:unzipPortal") + dependsOn(":cli:unzipManifest") } jar{ dependsOn(":cli:unzipPortal") + dependsOn(":cli:unzipManifest") } dependencies { diff --git a/extensions/sample-template/build.gradle b/extensions/sample-template/build.gradle index 97a61a4e0..23f28f4d7 100644 --- a/extensions/sample-template/build.gradle +++ b/extensions/sample-template/build.gradle @@ -34,8 +34,14 @@ eclipse { } } +compileJava{ + dependsOn(":cli:unzipPortal") + dependsOn(":cli:unzipManifest") +} + jar{ dependsOn(":cli:unzipPortal") + dependsOn(":cli:unzipManifest") archiveBaseName.set("com.liferay.project.templates.sample") } diff --git a/extensions/sample-workspace-template/build.gradle b/extensions/sample-workspace-template/build.gradle index a879833a9..968ba61fe 100644 --- a/extensions/sample-workspace-template/build.gradle +++ b/extensions/sample-workspace-template/build.gradle @@ -34,8 +34,14 @@ eclipse { } } +compileJava{ + dependsOn(":cli:unzipPortal") + dependsOn(":cli:unzipManifest") +} + jar{ dependsOn(":cli:unzipPortal") + dependsOn(":cli:unzipManifest") archiveBaseName.set("com.liferay.project.templates.workspace.sample") }