- given that yout root folder is a liferay workspace
- cd into ./modules directory or /modules/my-subdirectory and launch creat-create-app
- follow this tutorial https://help.liferay.com/hc/en-us/articles/360035467712-Adapting-Existing-Apps-to-Run-on-Liferay-DXP
- add extra configuration not mentioned in above tutorial https://gist.github.com/freddi301/6b5261771eedfd53f1f9127aba082862
- fix node_module resolutions in gradle build
- create package.json file in the root directory
{ "private": true, "workspaces": { "packages": [ "modules\\my-subdirectory\\my-react-app-adapted-to-portlet" ] } }
- create .yarnrc file in root direcory
disable-self-update-check true yarn-offline-mirror "./node_modules_cache" yarn-offline-mirror-pruning true
- create package.json file in the root directory
- fix tests by modifying the test script in my-react-app-adapted-to-portlet/package.json
"test": "cross-env CI=true react-scripts test",
- ensure build scripts are present in my-react-app-adapted-to-portlet/package.json
"scripts": { ... "build:liferay": "lnbs-build", "deploy:liferay": "lnbs-deploy"
- add modules/my-subdirectory/my-react-app-adapted-to-portlet/build-gradle file
- test gradle build commands in root directory with
./gradlew -Dorg.gradle.java.home=/opt/jdk/jdk1.8.0_391 modules:my-subdirectory:my-react-app-adapted-to-portlet:deploy --info
./gradlew -Dorg.gradle.java.home=/opt/jdk/jdk1.8.0_391 modules:my-subdirectory:my-react-app-adapted-to-portlet:publishToMavenLocal --info
Last active
February 15, 2024 13:49
-
-
Save freddi301/8be70d2a8e001a363dc63a17e0b64103 to your computer and use it in GitHub Desktop.
Liferay workspace adapt react app portlet
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
apply plugin: 'maven-publish' | |
/* | |
* Fix NodeJS version | |
*/ | |
node.nodeVersion="20.11.1" | |
node.npmVersion="10.2.4" | |
/* | |
* Fix for artifact deploy | |
*/ | |
task checkDeployFolder() { | |
doLast { | |
def npmBuildRc = project.file(".npmbuildrc") | |
if (!npmBuildRc.exists()) { | |
String basePath = properties["liferay.workspace.home.dir"] | |
if (basePath == null) { | |
basePath = "${rootDir}/build" | |
} | |
File file = new File(basePath, "osgi/modules") | |
if (!file.exists()) { | |
mkdir file.path | |
} | |
npmBuildRc.withWriter('UTF-8') { writer -> | |
writer.writeLine("{") | |
writer.writeLine(" \"liferayDir\": \"${basePath}\"") | |
writer.writeLine("}") | |
} | |
println "Generated default .npmbuildrc with ${basePath}" | |
} | |
} | |
} | |
packageRunDeployLiferay.dependsOn(checkDeployFolder) | |
deploy.dependsOn(packageRunDeployLiferay) | |
/* | |
* Fix Nexus Sonatype pubblication | |
*/ | |
// WARNING: Module Version is defined inside package.json | |
def finalVersion = "${project.property('version')}${project.property('registrySuffix')}" | |
def nexusRepository = project.property('nexus.snapshots.url') | |
def artifactName = project.property('archivesBaseName') | |
if (!finalVersion.endsWith("-SNAPSHOT")) { | |
nexusRepository = project.property('nexus.releases.url'); | |
} | |
publishing { | |
publications { | |
mavenJava(MavenPublication) { | |
version = "${finalVersion}" | |
artifactId = artifactName | |
artifact("build.liferay/${artifactName}-${project.property('version')}.jar") | |
} | |
} | |
repositories { | |
maven { | |
url = nexusRepository | |
credentials { | |
username project.property('registryUsername') | |
password project.property('registryPassword') | |
} | |
} | |
} | |
} | |
task showPublishDetails() { | |
def msg = | |
"${project.property('group')}:${project.property('archivesBaseName')}:${project.property('version')}" + | |
" (suffix ${project.property('registrySuffix')})" + | |
" on ${nexusRepository} as ${project.property('registryUsername')}" | |
doLast { | |
println "Published ${msg}" | |
} | |
} | |
publish.dependsOn(packageRunBuildLiferay, showPublishDetails); | |
publishToMavenLocal.dependsOn(packageRunBuildLiferay, showPublishDetails); | |
/* | |
* Fix for distribution (TODO: complete) | |
*/ | |
task packageForDist(dependsOn: packageRunBuildLiferay) { | |
// Empty. Only needed for task dependencies | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment