-
Notifications
You must be signed in to change notification settings - Fork 0
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
[DAT-3942] Set up files needed for gradle #2
base: upgrade-to-mx9
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,18 +1,35 @@ | ||
/deployment | ||
/GPUCache | ||
#Editors | ||
/.idea/ | ||
/.vscode/ | ||
/.settings/ | ||
*.iml | ||
|
||
#Build | ||
/*.launch | ||
/deployment/ | ||
/packages/ | ||
/releases/ | ||
/theme-cache/ | ||
/.mendix-cache/ | ||
|
||
#Mendix | ||
/userlib/ | ||
/*.mpk | ||
!/CSVAsTable.mpk | ||
/.classpath | ||
/.project | ||
/oqlmodule.mpr.bak | ||
/oqlmodule.mpr.lock | ||
/modeler-merge-marker | ||
/*.lock | ||
/*.bak | ||
/project-settings.user.json | ||
|
||
#Source | ||
/javasource/*/proxies/ | ||
/javasource/system/ | ||
/**/node_modules/ | ||
!/javascriptsource/**/node_modules/ | ||
/nativemobile/builds/ | ||
|
||
#Gradle | ||
.gradle/ | ||
/build/ | ||
/upgraded/ | ||
|
||
#Other | ||
/releases/ |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,48 @@ | ||
# Prepare your development environment | ||
|
||
## Install Mendix | ||
|
||
First determine the correct version using `./gradlew modelerVersion`. | ||
|
||
Windows users can easily go to [this page](https://appstore.home-accp.mendix.com/link/modelers/), find their desired Mendix installation package, download and install it. | ||
|
||
## Set environment variables | ||
|
||
Make sure the following variables are adjusted properly. | ||
|
||
- Mendix installation path variables `MX_INSTALL_PATH` and `MX_INSTALL_VERSION` can be passed either as an environment variable or a java property. | ||
These two variable are only necessary for the **gradle run** and **gradle test** (**MiniAppLauncher**) task to function properly. | ||
|
||
``` | ||
+ $MX_INSTALL_PATH (e.g. "C:\Program Files\Mendix" or "/home/user/.mendix") | ||
+---+ $MX_INSTALL_VERSION (e.g. "7.23.7.55882") | ||
+---+ runtime | ||
+---+ bundles | ||
+---+ *.jar | ||
``` | ||
|
||
- Assign a value to `MX_INSTALL_PATH` only in case your Mendix installation path is different from the default installation path, since it will default to `$PROGRAMFILES/Mendix` on Windows and `$HOME/.mendix` otherwise. | ||
|
||
- As Mendix projects are fully compatible only with the Mendix version they are created with, ensure that the default in `environment.gradle` matches **gradle modelerVersion** and do not set the environment variable. | ||
|
||
## Prepare | ||
|
||
To prepare the project for runtime to be launched we invoke `mxbuild` using Docker or local install of mendix with the command | ||
`./gradlew mxBuild`. | ||
|
||
## Development & running tests | ||
|
||
After running mxBuild, tests can be run with `./gradlew test` | ||
|
||
|
||
## Update dependent Appstore modules | ||
|
||
- For the dependent `Community Commons` module, download a new version of the module and replace the existing version in studio pro. | ||
Make sure to update the dependencies of those module accordingly `gradle.build` file. | ||
|
||
## Exporting and publishing | ||
|
||
- In StudioPro rename the specific version stub folder inside the project to the correct number (by renaming the `DatabaseReplication/_Docs/_version_x.y.z` folder). | ||
- Run `./gradlew exportModule` to test exporting the module | ||
- Run `./gradlew publishModuleToMarketplace` to publish the module (See [gradle-publish-module](https://gitlab.rnd.mendix.com/runtime/gradle-mx-publish-module-plugin) plugin documentation for details) | ||
- Go to [appstore](https://marketplace.mendix.com/link/component/66876) and verify the release details. |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,53 +1,68 @@ | ||
# Description | ||
This module allows you to execute OQL queries from a microflow.It allows setting named parameters which will be properly escaped. | ||
This module allows you to execute OQL queries from a microflow. It allows setting named parameters which will be properly escaped. | ||
|
||
# Typical usage scenario | ||
Query data from the Mendix database and the result will be mapped to a Mendix entity. | ||
The example below is part of the Example module within the project, located on the GitHub repository. | ||
|
||
Considering the following domain model: | ||
As an example, one can execute a query obtaining all objects of `ExamplePerson` as a table. The rows within this table can be converted to non-persistent entities for further usage. A `ExamplePersonResult` non-persistent entity is modeled. | ||
|
||
One can execute a query obtaining all objects of ExamplePerson as a table. The rows within this table can be converted to non persistent entities for further usage. Therefore a ExamplePersonResult non persistent entity is modeled. | ||
|
||
Parameters can be used using their corresponding actions (for each data type there's one activity defined: | ||
|
||
|
||
|
||
All parameters should be added before executing an OQL query. | ||
|
||
|
||
Parameters can be used using their corresponding actions. For each data type there's one activity defined. All parameters should be added before executing an OQL query. | ||
|
||
Adding an parameter requires: | ||
* The name of the parameter, without a $ (e.g. Gender). | ||
* The value. | ||
|
||
The name of the parameter, without a $ (e.g. Gender). | ||
The value. | ||
Executing an OQL query requires: | ||
|
||
The OQL statement. | ||
A resulting entity (e.g. OQLExample.ExamplePersonResult). | ||
Amount. | ||
Offset. | ||
* The OQL statement | ||
* A resulting entity (e.g. OQLExample.ExamplePersonResult) | ||
* Amount | ||
* Offset | ||
|
||
|
||
After executing an OQL query, all previously set parameters are cleared. | ||
|
||
The example query used to obtain the ExamplePersonResults are is: | ||
|
||
``SELECT P.id ExamplePersonResult_ExamplePerson, P.Name Name, P.Number Number, P.DateOfBirth DateOfBirth, P.Age Age, P.LongAge LongAge, P.HeightInFloat HeightInFloat, P.HeightInDecimal HeightInDecimal, P.Active Active, P.Gender Gender FROM OQLExample.ExamplePerson P WHERE P.Active = $Active AND P.Age = $Age AND P.DateOfBirth = $DateOfBirth AND P.Gender = $Gender AND P.HeightInDecimal = $HeightInDecimal AND P.HeightInFloat = $HeightInFloat AND P.LongAge = $LongAge AND P.Name = $Name AND P.Number = $Number AND P/OQL.MarriedTo/OQL.ExamplePerson/ID = $MarriedTo`` | ||
|
||
In the example above, the resulting columns Name, Number, DateOfBirth, Age, etc. are mapped to their corresponding attributes in ExamplePersonResult. The column ExamplePersonResult_ExamplePerson is mapped to the association (so one can retrieve the original persistent entity if needed). | ||
|
||
# Features and limitations | ||
|
||
Named parameters (like Data Set functionality) to avoid injection. | ||
Automatic mapping of result table to a list of objects (of a supplied entity). | ||
Mapping of an ID column to an assocation. | ||
### Example query | ||
|
||
The example query used to obtain the ExamplePersonResults is: | ||
|
||
```sql | ||
SELECT | ||
P.id ExamplePersonResult_ExamplePerson, | ||
P.Name Name, | ||
P.Number Number, | ||
P.DateOfBirth DateOfBirth, | ||
P.Age Age, | ||
P.LongAge LongAge, | ||
P.HeightInFloat HeightInFloat, | ||
P.HeightInDecimal HeightInDecimal, | ||
P.Active Active, | ||
P.Gender Gender | ||
FROM OQLExample.ExamplePerson P | ||
WHERE | ||
P.Active = $Active AND | ||
P.Age = $Age AND P.DateOfBirth = $DateOfBirth AND | ||
P.Gender = $Gender AND | ||
P.HeightInDecimal = $HeightInDecimal AND | ||
P.HeightInFloat = $HeightInFloat AND P.LongAge = $LongAge AND | ||
P.Name = $Name AND P.Number = $Number AND | ||
P/OQL.MarriedTo/OQL.ExamplePerson/ID = $MarriedTo | ||
``` | ||
|
||
In the example above, the resulting columns `Name`, `Number`, `DateOfBirth`, `Age`, etc. are mapped to their corresponding attributes in `ExamplePersonResult`. The column `ExamplePersonResult_ExamplePerson` is mapped to the association, so the original persistent entity can be retrieved if needed. | ||
|
||
# Features | ||
|
||
* Named parameters (like Data Set functionality) to avoid injection. | ||
* Automatic mapping of result table to a list of objects (of a supplied entity). | ||
* Mapping of an ID column to an assocation. | ||
|
||
# Dependencies | ||
Mendix 6.9 or newer | ||
Mendix 9.18.4 or newer | ||
MxCommons Module 10.0 or newer | ||
|
||
# Installation | ||
Download and import into your project. | ||
Download from marketplace and import into your project. | ||
|
||
# Known bugs | ||
A mapped association should be mentioned without its module prefix in an OQL query (e.g. ExamplePersonResult_ExamplePerson instead of OQLExample.ExamplePersonResult_ExamplePerson). | ||
A mapped association should be mentioned without its module prefix in an OQL query (e.g. `ExamplePersonResult_ExamplePerson` instead of `OQLExample.ExamplePersonResult_ExamplePerson`). |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,124 @@ | ||
plugins { | ||
id 'java' | ||
id 'com.mendix.gradle.publish-module-plugin' version '1.15' | ||
id 'net.researchgate.release' version '2.8.1' | ||
} | ||
|
||
apply from: 'environment.gradle' | ||
|
||
sourceCompatibility = '11' | ||
[compileJava, compileTestJava]*.options*.encoding = 'UTF-8' | ||
|
||
repositories { | ||
maven { | ||
url 'https://nexus.rnd.mendix.com/repository/maven-hosted/' | ||
} | ||
maven { | ||
url 'https://nexus.rnd.mendix.com/repository/repo1-proxy/' | ||
} | ||
} | ||
|
||
mxMarketplace { | ||
appNumber = 66876 | ||
appName = "OQLModule" | ||
moduleName = "OQL" | ||
moduleLicense = "Apache V2" | ||
filterWidgets = false | ||
filterRequiredLibs = false | ||
appDirectory = "." | ||
versionPathPrefix = "__Version " // the path prefix within the module to the version folder | ||
} | ||
|
||
configurations { | ||
moduleDirectDependencies | ||
implementation.extendsFrom(moduleDirectDependencies) | ||
} | ||
|
||
dependencies { | ||
//To be included in exported module userlib | ||
moduleDirectDependencies( | ||
[group: 'com.opencsv', name: 'opencsv', version: '5.7.1'] | ||
) | ||
|
||
compileOnly(fileTree(mxRuntimeBundles).include('*.jar')) | ||
|
||
//MxCommons v10.0.0 module dependencies, not included with module release | ||
implementation( | ||
[group: 'com.google.guava', name: 'guava', version: '30.1.1-jre'], | ||
[group: 'com.googlecode.owasp-java-html-sanitizer', name: 'owasp-java-html-sanitizer', version: '20211018.2'], | ||
[group: 'commons-io', name: 'commons-io', version: '2.11.0'], | ||
[group: 'org.apache.pdfbox', name: 'pdfbox', version: '2.0.24'], | ||
[group: 'org.apache.commons', name: 'commons-lang3', version: '3.12.0'], | ||
[group: 'org.apache.commons', name: 'commons-text', version: '1.10.0'] | ||
) | ||
|
||
testImplementation('com.mendix.util:junit-helper:1.1.0') { | ||
exclude group: 'com.mendix', module: 'public-api' | ||
} | ||
|
||
testImplementation( | ||
[group: 'junit', name: 'junit', version: '4.13.1'], | ||
[group: 'org.hamcrest', name: 'hamcrest', version: '2.2'] | ||
) | ||
} | ||
|
||
sourceSets { | ||
main { | ||
java { | ||
srcDir 'javasource' | ||
} | ||
resources { | ||
srcDirs = ['resources', 'build/generated/resources'] | ||
} | ||
} | ||
} | ||
|
||
tasks.register('copyComponents', Copy) { | ||
from file('deployment/run/component.xml') | ||
into 'build/generated/resources/OSGI-INF/' | ||
} | ||
|
||
processResources { | ||
dependsOn copyComponents | ||
} | ||
|
||
test { | ||
useJUnit() | ||
jvmArgs = ["-Djava.io.tmpdir=$temporaryDir"] | ||
environment 'MX_INSTALL_PATH',mxInstallPath | ||
} | ||
|
||
tasks.register('copyDirectDependenciesToUserlib', Copy) { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This one is named There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I believe the issue here is db replication. There is already a task called There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Makes sense. We'll have to fix db replication then. |
||
group "Build" | ||
description "Copies the direct dependencies to the userlib directory." | ||
|
||
dependsOn clean | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. You can also see some logic related to the |
||
|
||
from configurations.moduleDirectDependencies | ||
into 'userlib' | ||
eachFile { fileCopyDetails -> | ||
new File(destinationDir, "${fileCopyDetails.name}.${project.name}.RequiredLib").write '' | ||
} | ||
} | ||
|
||
|
||
clean { | ||
delete 'userlib', 'deployment' | ||
} | ||
|
||
release { | ||
tagTemplate = '$name-$version' | ||
} | ||
|
||
tasks.withType(JavaCompile) { | ||
options.compilerArgs << "-Xlint:deprecation" | ||
} | ||
|
||
exportModule { | ||
dependsOn copyDirectDependenciesToUserlib | ||
dependsOn test | ||
copyDirectDependenciesToUserlib.mustRunAfter copyJarsToUserlib | ||
} | ||
|
||
afterReleaseBuild.dependsOn publishModuleToMarketplacee | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. let's fix the task name |
||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
# This will upgrade the app to the version of Mendix corresponding to APPSTUDIO build number and run tests | ||
# Required environment: | ||
# - APPSTUDIO; | ||
version: "2.2" | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. docker will complain that version is rudimentary |
||
services: | ||
convert: | ||
image: "${DOCKER_REGISTRY_RO_HOST:-nexus-docker-group.rnd.mendix.com}/mxbuild:${APPSTUDIO:-nightly}" | ||
working_dir: /module | ||
entrypoint: /module/entrypoint-convert.sh | ||
volumes: | ||
- ./:/module | ||
environment: | ||
- APPSTUDIO | ||
test: | ||
image: "${DOCKER_REGISTRY_RO_HOST:-nexus-docker-group.rnd.mendix.com}/mendix-runtime:${APPSTUDIO:-nightly}" | ||
volumes: | ||
- ./:/module | ||
working_dir: /module/upgraded | ||
environment: | ||
- APPSTUDIO | ||
- MX_INSTALL_PATH=/var/opt/runtime | ||
entrypoint: /module/upgraded/gradlew test | ||
depends_on: | ||
"convert": | ||
condition: service_completed_successfully |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
#!/bin/sh | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. this file needs execution permissions |
||
|
||
echo "Copying the project ..." | ||
rm -rf ./upgraded | ||
mkdir /tmp/upgraded | ||
cp -r ./* /tmp/upgraded | ||
mkdir upgraded | ||
mv /tmp/upgraded . | ||
cd upgraded | ||
|
||
echo "Converting the project ..." | ||
mx convert --in-place "./" | ||
mxbuild --target=deploy "OQLModule.mpr" |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
def mxPathDefault = (System.getProperty('os.name').startsWith('Windows')) | ||
? "${System.getenv('PROGRAMFILES')}/Mendix" | ||
: "${System.getenv('HOME')}/.mendix" | ||
def mxPath = System.getenv('MX_INSTALL_PATH') ?: System.getProperty('MX_INSTALL_PATH') ?: mxPathDefault | ||
def mxInstallVersion = System.getenv('MODELER_VERSION') ?: System.getenv('MX_INSTALL_VERSION') ?: System.getProperty('MX_INSTALL_VERSION') ?: '9.18.4.62522' | ||
|
||
project.ext.mxInstallPath = "${mxPath}/${mxInstallVersion}" | ||
project.ext.mxRuntimeBundles = new File("${mxInstallPath}/runtime/bundles") |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
version=3.0.0 |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
distributionBase=GRADLE_USER_HOME | ||
distributionPath=wrapper/dists | ||
distributionUrl=https\://services.gradle.org/distributions/gradle-8.5-bin.zip | ||
networkTimeout=10000 | ||
zipStoreBase=GRADLE_USER_HOME | ||
zipStorePath=wrapper/dists |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
File permissions for
gradlew
are-rw-r--r--@
, so I cannot run it out of the box.When I do, I get
./gradlew: /bin/sh^M: bad interpreter: No such file or directory
, so I guess we should have different line end charactersWhen I fix that, I get
> Could not get unknown property 'publishModuleToMarketplacee' for root project 'OQLModule' of type org.gradle.api.Project
, but I'll add that as a separate commentThere was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I get different permissions when running
ls -l
on wsl. Ill try to force execution rights to check if this works