Skip to content

Commit

Permalink
chore(build): add a with-java profile to speed up build
Browse files Browse the repository at this point in the history
And make every Language equal so there is no favorite child
  • Loading branch information
sruehl committed Feb 6, 2024
1 parent f8a4a33 commit 29aad05
Show file tree
Hide file tree
Showing 16 changed files with 69 additions and 38 deletions.
4 changes: 2 additions & 2 deletions .github/workflows/java-platform.yml
Original file line number Diff line number Diff line change
Expand Up @@ -132,7 +132,7 @@ jobs:
# Note: due to github has no concept of recovering from a fail even if we have our fallback below we append a second un-parallel run behind this to be sure that it works with all checks. Only if that fails too we are ok with a "red" (which should be yellow) cross indicating a problem
- name: Run mvnw
run: |
./mvnw${{ steps.platform_suffix.outputs.platform_suffix }} ${{ steps.extra_options.outputs.extra_options }} -B -P'enable-all-checks,update-generated-code' ${{ steps.platform_opts.outputs.platform_opts }} install
./mvnw${{ steps.platform_suffix.outputs.platform_suffix }} ${{ steps.extra_options.outputs.extra_options }} -B -P'with-java,enable-all-checks,update-generated-code' ${{ steps.platform_opts.outputs.platform_opts }} install
- name: Upload Test Report (first failure)
uses: actions/upload-artifact@v4
Expand All @@ -145,7 +145,7 @@ jobs:
- name: Run mvnv without BacNet regression tests
if: ${{ failure() }}
run: ./mvnw${{ steps.platform_suffix.outputs.platform_suffix }} ${{ steps.extra_options.outputs.extra_options }} -B -P'skip-bacnet-regression-test,update-generated-code' ${{ steps.platform_opts.outputs.platform_opts }} install
run: ./mvnw${{ steps.platform_suffix.outputs.platform_suffix }} ${{ steps.extra_options.outputs.extra_options }} -B -P'with-java,skip-bacnet-regression-test,update-generated-code' ${{ steps.platform_opts.outputs.platform_opts }} install

- name: Upload Test Report
uses: actions/upload-artifact@v4
Expand Down
6 changes: 3 additions & 3 deletions Jenkinsfile
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,7 @@ pipeline {
}
steps {
echo 'Building'
sh './mvnw -B -P${JENKINS_PROFILE},skip-prerequisite-check,with-sandbox,with-c,with-go ${MVN_TEST_FAIL_IGNORE} ${MVN_LOCAL_REPO_OPT} clean install'
sh './mvnw -B -P${JENKINS_PROFILE},skip-prerequisite-check,with-sandbox,with-c,with-go,with-java ${MVN_TEST_FAIL_IGNORE} ${MVN_LOCAL_REPO_OPT} clean install'
}
post {
always {
Expand All @@ -117,7 +117,7 @@ pipeline {

// We'll deploy to a relative directory so we can save
// that and deploy in a later step on a different node
sh './mvnw -U -P${JENKINS_PROFILE},skip-prerequisite-check,with-sandbox,with-c,with-go,enable-all-checks ${MVN_TEST_FAIL_IGNORE} ${JQASSISTANT_NEO4J_VERSION} -DaltDeploymentRepository=snapshot-repo::default::file:./local-snapshots-dir clean deploy'
sh './mvnw -U -P${JENKINS_PROFILE},skip-prerequisite-check,with-sandbox,with-c,with-go,with-java,enable-all-checks ${MVN_TEST_FAIL_IGNORE} ${JQASSISTANT_NEO4J_VERSION} -DaltDeploymentRepository=snapshot-repo::default::file:./local-snapshots-dir clean deploy'

// Stash the build results so we can deploy them on another node
stash name: 'plc4x-build-snapshots', includes: 'local-snapshots-dir/**'
Expand All @@ -138,7 +138,7 @@ pipeline {
echo 'Checking Code Quality on SonarCloud'
withCredentials([string(credentialsId: 'chris-sonarcloud-token', variable: 'SONAR_TOKEN')]) {
//sh './mvnw -B -P${JENKINS_PROFILE},skip-prerequisite-check,with-python,with-proxies,with-sandbox sonar:sonar ${SONARCLOUD_PARAMS} -Dsonar.login=${SONAR_TOKEN}'
sh './mvnw -B -P${JENKINS_PROFILE},skip-prerequisite-check,with-c,with-go,with-sandbox sonar:sonar ${SONARCLOUD_PARAMS} -Dsonar.token=${SONAR_TOKEN}'
sh './mvnw -B -P${JENKINS_PROFILE},skip-prerequisite-check,with-c,with-go,with-java,with-sandbox sonar:sonar ${SONARCLOUD_PARAMS} -Dsonar.token=${SONAR_TOKEN}'
}
}
}
Expand Down
8 changes: 7 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -184,6 +184,12 @@ The `Go` drivers can be built by enabling the `with-go` profile:
./mvnw -P with-go install
```

The `Java` drivers can be built by enabling the `with-java` profile:

```
./mvnw -P with-java install
```

The `C# / .Net` implementation is currently in a `work in progress` state.
In order to be able to build the `C# / .Net` module, you currently need to activate the:
`with-dotnet` profiles.
Expand All @@ -203,7 +209,7 @@ In order to be able to build the Python module, you currently need to activate t
In order to build everything the following command should work:

```
./mvnw -P with-c,with-dotnet,with-go,with-python,with-sandbox,enable-all-checks install
./mvnw -P with-c,with-dotnet,with-go,with-java,with-python,with-sandbox,enable-all-checks install
```

## Community
Expand Down
2 changes: 1 addition & 1 deletion build-reproducible.sh
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@
# Run a standard build
function build() {
echo "Building ..."
mvn -U -P apache-release,with-c,with-dotnet,with-go,with-python,with-sandbox -DaltDeploymentRepository=snapshot-repo::default::file:./local-snapshots-dir clean deploy
mvn -U -P apache-release,with-c,with-dotnet,with-go,with-java,with-python,with-sandbox -DaltDeploymentRepository=snapshot-repo::default::file:./local-snapshots-dir clean deploy
echo "Done"
}

Expand Down
8 changes: 7 additions & 1 deletion code-generation/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,6 @@

<modules>
<module>language-base-freemarker</module>
<module>language-java</module>
<module>protocol-base-mspec</module>
<module>protocol-test</module>
</modules>
Expand All @@ -66,6 +65,13 @@
</modules>
</profile>

<profile>
<id>with-java</id>
<modules>
<module>language-java</module>
</modules>
</profile>

<profile>
<id>with-python</id>
<modules>
Expand Down
6 changes: 6 additions & 0 deletions code-generation/tests/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,12 @@
</modules>
</profile>

<profile>
<id>with-java</id>
<modules>
</modules>
</profile>

<profile>
<id>with-python</id>
<modules>
Expand Down
2 changes: 1 addition & 1 deletion docker-compose.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ services:
build:
context: .
dockerfile: Dockerfile
command: ["/ws/mvnw", "-e", "-Dskip-pgp-signing=true", "-P", "with-c,with-dotnet,with-go,with-python,with-sandbox,enable-all-checks,apache-release", "-Dmaven.repo.local=/ws/out/.repository", "clean", "install"]
command: ["/ws/mvnw", "-e", "-Dskip-pgp-signing=true", "-P", "with-c,with-dotnet,with-go,with-java,with-python,with-sandbox,enable-all-checks,apache-release", "-Dmaven.repo.local=/ws/out/.repository", "clean", "install"]
volumes:
# Bind the local directory as "/ws"
- type: bind
Expand Down
4 changes: 2 additions & 2 deletions plc4j/examples/hello-docker/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -63,10 +63,10 @@ RUN dos2unix .mvn/wrapper/maven-wrapper.properties
# Tell Maven to fetch all needed dependencies first, so they can get cached
# (Tried a patched version of the plugin to allow exclusion of inner artifacts.
# See https://issues.apache.org/jira/browse/MDEP-568 for details)
RUN ./mvnw -P with-c,with-dotnet,with-go,with-sandbox com.offbytwo.maven.plugins:maven-dependency-plugin:3.1.1.MDEP568:go-offline -DexcludeGroupIds=org.apache.plc4x,org.apache.plc4x.examples,org.apache.plc4x.sandbox
RUN ./mvnw -P with-c,with-dotnet,with-go,with-java,with-sandbox com.offbytwo.maven.plugins:maven-dependency-plugin:3.1.1.MDEP568:go-offline -DexcludeGroupIds=org.apache.plc4x,org.apache.plc4x.examples,org.apache.plc4x.sandbox

# Build everything with all tests
RUN ./mvnw -P with-c,with-dotnet,with-go,with-sandbox install
RUN ./mvnw -P with-c,with-dotnet,with-go,with-java,with-sandbox install

# Get the version of the project and save it in a local file on the container
RUN ./mvnw org.apache.maven.plugins:maven-help-plugin:3.2.0:evaluate -Dexpression=project.version -DforceStdout -q -pl . > project_version
Expand Down
34 changes: 22 additions & 12 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,8 @@
specific language governing permissions and limitations
under the License.
-->
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">

<modelVersion>4.0.0</modelVersion>

Expand Down Expand Up @@ -96,7 +97,8 @@

<!-- Exclude all generated code -->
<sonar.exclusions>**/generated-sources</sonar.exclusions>
<sonar.cfamily.build-wrapper-output>${project.basedir}/plc4c/target/build-wrapper-output</sonar.cfamily.build-wrapper-output>
<sonar.cfamily.build-wrapper-output>${project.basedir}/plc4c/target/build-wrapper-output
</sonar.cfamily.build-wrapper-output>

<plc4x-code-generation.version>1.7.0</plc4x-code-generation.version>

Expand Down Expand Up @@ -170,9 +172,6 @@
<modules>
<!-- Definition of the protocol message formats -->
<module>protocols</module>

<!-- Build the Java part of plc4x -->
<module>plc4j</module>
</modules>

<dependencyManagement>
Expand Down Expand Up @@ -929,7 +928,7 @@
</goals>
<configuration>
<rules>
<dependencyConvergence />
<dependencyConvergence/>
</rules>
</configuration>
</execution>
Expand Down Expand Up @@ -1240,9 +1239,11 @@
<!-- It seems that when going to 3.3.0 the apache-rat-plugin fails when the shade plugin is also being run -->
<version>3.2.4</version>
<configuration>
<outputFile>${project.build.directory}/${project.artifactId}-${project.version}-uber-jar.${project.packaging}</outputFile>
<outputFile>
${project.build.directory}/${project.artifactId}-${project.version}-uber-jar.${project.packaging}
</outputFile>
<transformers>
<transformer implementation="org.apache.maven.plugins.shade.resource.ServicesResourceTransformer" />
<transformer implementation="org.apache.maven.plugins.shade.resource.ServicesResourceTransformer"/>
</transformers>
<filters>
<filter>
Expand All @@ -1258,7 +1259,8 @@
</excludes>
</filter>
</filters>
<dependencyReducedPomLocation>${project.build.directory}/dependency-reduced-pom.xml</dependencyReducedPomLocation>
<dependencyReducedPomLocation>${project.build.directory}/dependency-reduced-pom.xml
</dependencyReducedPomLocation>
</configuration>
</plugin>

Expand Down Expand Up @@ -1474,7 +1476,7 @@
<issueLinkUrl>https://issues.apache.org/jira/browse/%ISSUE%</issueLinkUrl>
</configuration>
</plugin-->
</plugins>
</plugins>
</reporting>

<!-- Make Snapshots of Apache projects available -->
Expand Down Expand Up @@ -1584,6 +1586,14 @@
</modules>
</profile>

<!-- Build PLC4X including the Java modules -->
<profile>
<id>with-java</id>
<modules>
<module>plc4j</module>
</modules>
</profile>

<!-- Build PLC4X including the .Net modules -->
<profile>
<id>with-dotnet</id>
Expand Down Expand Up @@ -1767,7 +1777,7 @@
<properties>
<skip-code-generation-tests>false</skip-code-generation-tests>
<enable-all-tests>true</enable-all-tests>
<excluded-test-groups />
<excluded-test-groups/>
</properties>
</profile>

Expand All @@ -1776,7 +1786,7 @@
<properties>
<skip-code-generation-tests>false</skip-code-generation-tests>
<enable-all-tests>true</enable-all-tests>
<excluded-test-groups />
<excluded-test-groups/>
</properties>
</profile>

Expand Down
4 changes: 3 additions & 1 deletion src/main/script/prerequisiteCheck.groovy
Original file line number Diff line number Diff line change
Expand Up @@ -376,7 +376,7 @@ def cEnabled = false
def dotnetEnabled = false
def goEnabled = false
// Java is always enabled ...
def javaEnabled = true
def javaEnabled = false
def pythonEnabled = false
def sandboxEnabled = false
def apacheReleaseEnabled = false
Expand All @@ -388,6 +388,8 @@ for (def activeProfile : activeProfiles) {
dotnetEnabled = true
} else if (activeProfile == "with-go") {
goEnabled = true
} else if (activeProfile == "with-java") {
javaEnabled = true
} else if (activeProfile == "with-python") {
pythonEnabled = true
} else if (activeProfile == "with-sandbox") {
Expand Down
5 changes: 3 additions & 2 deletions src/site/asciidoc/developers/building.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,7 @@ The following profiles are available (*They have to be enabled additionally to t
- `with-c`: Builds all C related modules, integrations and examples
- `with-dotnet`: Builds all C# and .Net related modules, integrations and examples
- `with-go`: Builds all Go related modules, integrations and examples
- `with-java`: Builds all Java related modules, integrations and examples
- `with-python`: Builds all Python related modules, integrations and examples (Also requires `with-sandbox`)
- `with-sandbox`: Builds the modules which are not yet considered stable enough to become part of the main distribution

Expand All @@ -95,13 +96,13 @@ If you want to skip the running of tests (even if this is not encouraged) you ca

All Apache PLC4X modules are built by executing the following command:

mvn -P with-c,with-dotnet,with-go,with-python,with-sandbox install
mvn -P with-c,with-dotnet,with-go,with-java,with-python,with-sandbox install

This not only builds the artifacts and creates the jar files, but also runs all unit- and integration-tests.

If you want to skip the running of tests (even if this is not encouraged) you can skip them all together.

mvn -P with-c,with-dotnet,with-go,with-python,with-sandbox install -DskipTests
mvn -P with-c,with-dotnet,with-go,with-java,with-python,with-sandbox install -DskipTests

This will not skip the compilation of tests, however.

Expand Down
16 changes: 8 additions & 8 deletions src/site/asciidoc/developers/release/release.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -29,14 +29,14 @@ IMPORTANT: Please be sure to execute the release with a Java version 11 or the K
* [ ] Create release branch:
[subs="verbatim,attributes"]
----
mvn release:branch -P with-c,with-dotnet,with-go,with-python,with-sandbox,enable-all-checks -DbranchName=rel/{current-short-version}
mvn release:branch -P with-c,with-dotnet,with-go,with-java,with-python,with-sandbox,enable-all-checks -DbranchName=rel/{current-short-version}
----
[%interactive]
* [ ] Add a new section to the `RELEASE_NOTES` on `develop`
* [ ] Prepare the release:
[subs="verbatim,attributes"]
----
mvn release:prepare -P with-c,with-dotnet,with-go,with-python,with-sandbox,enable-all-checks
mvn release:prepare -P with-c,with-dotnet,with-go,with-java,with-python,with-sandbox,enable-all-checks
----
[%interactive]
* [ ] Perform the release:
Expand Down Expand Up @@ -157,14 +157,14 @@ This is the version the `develop` branch will be changed to.
In contrast to normal builds, it is important to enable all profiles when creating the branch as only this way will all modules versions be updated.
Otherwise, the non-default modules on develop will reference the old version which will cause problems when building.

mvn release:branch -P with-c,with-dotnet,with-go,with-python,with-sandbox,enable-all-checks -DbranchName=rel/{minor-version}
mvn release:branch -P with-c,with-dotnet,with-go,with-java,with-python,with-sandbox,enable-all-checks -DbranchName=rel/{minor-version}

Per default the plugin suggests the next bugfix version as working version, however we want it to use the next minor version.
So in case of preparing the release branch for `{current-full-version}-SNAPSHOT` the command would be the following:

[subs="verbatim,attributes"]
----
mvn release:branch -P with-c,with-dotnet,with-go,with-python,with-sandbox,enable-all-checks -DbranchName=rel/{current-short-version}
mvn release:branch -P with-c,with-dotnet,with-go,with-java,with-python,with-sandbox,enable-all-checks -DbranchName=rel/{current-short-version}
----

The plugin will then aks for the version:
Expand Down Expand Up @@ -229,9 +229,9 @@ In order to prepare a release-candidate, the first step is switching to the corr
After that, the following command will to all preparation steps for the release:
mvn release:prepare -P with-c,with-dotnet,with-go,with-python,with-sandbox,enable-all-checks
mvn release:prepare -P with-c,with-dotnet,with-go,with-java,with-python,with-sandbox,enable-all-checks
(The `-P with-c,with-dotnet,with-go,with-python,with-sandbox,enable-all-checks` tells maven to activate the all profiles that partition the build and makes sure the versions of all modules are updated as part of the release)
(The `-P with-c,with-dotnet,with-go,with-java,with-python,with-sandbox,enable-all-checks` tells maven to activate the all profiles that partition the build and makes sure the versions of all modules are updated as part of the release)
In general the plugin will now ask you 3 questions:
1. The version we want to release as (It will suggest the version you get by omitting the `-SNAPSHOT` suffix)
Expand Down Expand Up @@ -279,7 +279,7 @@ NOTE: If the commit history doesn't look like this, something went wrong.
If something goes wrong, you can always execute:
mvn release:rollback -P with-c,with-dotnet,with-go,with-python,with-sandbox,enable-all-checks
mvn release:rollback -P with-c,with-dotnet,with-go,with-java,with-python,with-sandbox,enable-all-checks
It will change the versions back and commit and push things.
Expand Down Expand Up @@ -464,7 +464,7 @@ If however for some reason it is needed to prepare a new RC for the release. Ple
- Set the versions of the release branch to the previous version by using the `versions:set` plugin:
mvn versions:set -DprocessAllModules=true -P with-c,with-dotnet,with-go,with-python,with-sandbox,enable-all-checks
mvn versions:set -DprocessAllModules=true -P with-c,with-dotnet,with-go,with-java,with-python,with-sandbox,enable-all-checks
- Delete the tag locally:
Expand Down
2 changes: 1 addition & 1 deletion tools/docker-compose.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ services:
context: ..
dockerfile: Dockerfile
# Builds all modules and uses an alternate maven local repo and deploys artifacts to a local directory.
command: ["/ws/mvnw", "-e", "-Dskip-pgp-signing=true", "-P", "with-c,with-dotnet,with-go,with-python,with-sandbox,enable-all-checks,apache-release", "-Dmaven.repo.local=/ws/out/.repository", "-DaltDeploymentRepository=snapshot-repo::default::file:/ws/out/.local-snapshots-dir", "clean", "deploy"]
command: ["/ws/mvnw", "-e", "-Dskip-pgp-signing=true", "-P", "with-c,with-dotnet,with-go,with-java,with-python,with-sandbox,enable-all-checks,apache-release", "-Dmaven.repo.local=/ws/out/.repository", "-DaltDeploymentRepository=snapshot-repo::default::file:/ws/out/.local-snapshots-dir", "clean", "deploy"]
volumes:
# Bind the local directory as "/ws"
- type: bind
Expand Down
2 changes: 1 addition & 1 deletion tools/release-0-update-generated-code.sh
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ rm -r "$DIRECTORY/plc4c/generated-sources"
# TODO: Possibly check, if the year in the NOTICE is outdated

# 3. Run the maven build for all modules with "update-generated-code" enabled (Docker container)
docker compose run --rm releaser bash /ws/mvnw -e -P with-c,with-dotnet,with-go,with-python,with-sandbox,enable-all-checks,update-generated-code -Dmaven.repo.local=/ws/out/.repository clean package
docker compose run --rm releaser bash /ws/mvnw -e -P with-c,with-dotnet,with-go,with-java,with-python,with-sandbox,enable-all-checks,update-generated-code -Dmaven.repo.local=/ws/out/.repository clean package
if [ $? -ne 0 ]; then
echo "Got non-0 exit code from docker compose, aborting."
exit 1
Expand Down
2 changes: 1 addition & 1 deletion tools/release-1-create-branch.sh
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ case $yn in
esac

# 3. Do a simple maven branch command with pushChanges=false (inside the Docker container)
docker compose run --rm releaser bash /ws/mvnw -e -P with-c,with-dotnet,with-go,with-python,with-sandbox -Dmaven.repo.local=/ws/out/.repository release:branch -DautoVersionSubmodules=true -DpushChanges=false -DdevelopmentVersion="$NEW_VERSION" -DbranchName="$BRANCH_NAME"
docker compose run --rm releaser bash /ws/mvnw -e -P with-c,with-dotnet,with-go,with-java,with-python,with-sandbox -Dmaven.repo.local=/ws/out/.repository release:branch -DautoVersionSubmodules=true -DpushChanges=false -DdevelopmentVersion="$NEW_VERSION" -DbranchName="$BRANCH_NAME"
if [ $? -ne 0 ]; then
echo "Got non-0 exit code from docker compose, aborting."
exit 1
Expand Down
Loading

0 comments on commit 29aad05

Please sign in to comment.