Skip to content

Commit

Permalink
feat(codegen): Moved the code-generation into a separate profile (#1172)
Browse files Browse the repository at this point in the history
* feat: Moved the code-generation into a separate profile in preparation to supporting reproducible builds

* fix: Moved the declaration of the dependencies needed by the code generation into the code-generation profile.

* fix: Moved the declaration of the dependencies needed by the code generation into the correct profile.

* fix: Removed marking the code-gen artifacts as used.

* fix: Added explicit test-jar dependencies for the protocols, so the copying of resources works with disabled code-generation.

* chore: Activated code-generation in the github action jobs
  • Loading branch information
chrisdutz authored Oct 27, 2023
1 parent fe7d049 commit 063524b
Show file tree
Hide file tree
Showing 128 changed files with 36,441 additions and 7,559 deletions.
4 changes: 2 additions & 2 deletions .github/workflows/c-platform.yml
Original file line number Diff line number Diff line change
Expand Up @@ -125,8 +125,8 @@ 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'with-c,enable-all-checks' -pl :plc4c -am ${{ steps.platform_opts.outputs.platform_opts }} install
./mvnw${{ steps.platform_suffix.outputs.platform_suffix }} ${{ steps.extra_options.outputs.extra_options }} -B -P'with-c,enable-all-checks,update-generated-code' -pl :plc4c -am ${{ steps.platform_opts.outputs.platform_opts }} install
- 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'with-c,skip-bacnet-regression-test' -pl :plc4c -am ${{ steps.platform_opts.outputs.platform_opts }} install
run: ./mvnw${{ steps.platform_suffix.outputs.platform_suffix }} ${{ steps.extra_options.outputs.extra_options }} -B -P'with-c,skip-bacnet-regression-test,update-generated-code' -pl :plc4c -am ${{ steps.platform_opts.outputs.platform_opts }} install
4 changes: 2 additions & 2 deletions .github/workflows/go-platform.yml
Original file line number Diff line number Diff line change
Expand Up @@ -179,7 +179,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'with-go,enable-all-checks' -pl :plc4go -am ${{ steps.platform_opts.outputs.platform_opts }} install
./mvnw${{ steps.platform_suffix.outputs.platform_suffix }} ${{ steps.extra_options.outputs.extra_options }} -B -P'with-go,enable-all-checks,update-generated-code' -pl :plc4go -am ${{ steps.platform_opts.outputs.platform_opts }} install
- name: Upload Test Report (first failure)
uses: actions/upload-artifact@v3
Expand All @@ -192,7 +192,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'with-go,skip-bacnet-regression-test' -pl :plc4go -am ${{ steps.platform_opts.outputs.platform_opts }} install
run: ./mvnw${{ steps.platform_suffix.outputs.platform_suffix }} ${{ steps.extra_options.outputs.extra_options }} -B -P'with-go,skip-bacnet-regression-test,update-generated-code' -pl :plc4go -am ${{ steps.platform_opts.outputs.platform_opts }} install

- name: Upload Test Report
uses: actions/upload-artifact@v3
Expand Down
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' ${{ steps.platform_opts.outputs.platform_opts }} install
./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
- name: Upload Test Report (first failure)
uses: actions/upload-artifact@v3
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' ${{ steps.platform_opts.outputs.platform_opts }} install
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

- name: Upload Test Report
uses: actions/upload-artifact@v3
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/python-platform.yml
Original file line number Diff line number Diff line change
Expand Up @@ -147,7 +147,7 @@ jobs:

- name: Run mvnw
run: |
./mvnw${{ steps.platform_suffix.outputs.platform_suffix }} ${{ steps.extra_options.outputs.extra_options }} -B -P'with-sandbox,with-python,enable-all-checks' -pl :plc4py -am ${{ steps.platform_opts.outputs.platform_opts }} install
./mvnw${{ steps.platform_suffix.outputs.platform_suffix }} ${{ steps.extra_options.outputs.extra_options }} -B -P'with-sandbox,with-python,enable-all-checks,update-generated-code' -pl :plc4py -am ${{ steps.platform_opts.outputs.platform_opts }} install
# - name: Perform CodeQL Analysis
# uses: github/codeql-action/analyze@v2
288 changes: 148 additions & 140 deletions plc4c/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -42,66 +42,6 @@
<option.with-proxies>OFF</option.with-proxies>
</properties>

<profiles>
<!-- When running on jenkins, download the sonar build-wrapper, so we can do a code analysis -->
<profile>
<id>jenkins-build</id>
<!-- This is needed by the groovy hack script -->
<properties>
<cmake.root>${project.build.directory}/dependency/cmake/bin</cmake.root>
</properties>
<build>
<plugins>
<plugin>
<groupId>com.googlecode.maven-download-plugin</groupId>
<artifactId>download-maven-plugin</artifactId>
<executions>
<!-- Get the build-wrapper from our sonarcloud server -->
<execution>
<id>get-build-wrapper</id>
<phase>generate-sources</phase>
<goals>
<goal>wget</goal>
</goals>
<configuration>
<skipCache>true</skipCache>
<url>https://sonarcloud.io/static/cpp/build-wrapper-linux-x86.zip</url>
<unpack>true</unpack>
<outputDirectory>${project.build.directory}</outputDirectory>
<skipCache>true</skipCache>
</configuration>
</execution>
</executions>
</plugin>
<plugin>
<groupId>org.codehaus.gmaven</groupId>
<artifactId>groovy-maven-plugin</artifactId>
<executions>
<!-- rename the cmake binary and generate a script that adds the sonar build-wrapper -->
<execution>
<id>modify-cmake</id>
<phase>process-test-sources</phase>
<goals>
<goal>execute</goal>
</goals>
<configuration>
<source>${project.basedir}/SonarcloudBuildWrapperHack.groovy</source>
</configuration>
</execution>
</executions>
<dependencies>
<dependency>
<groupId>org.apache.groovy</groupId>
<artifactId>groovy</artifactId>
<version>${groovy.version}</version>
</dependency>
</dependencies>
</plugin>
</plugins>
</build>
</profile>
</profiles>
<build>
<plugins>
<plugin>
Expand Down Expand Up @@ -140,55 +80,6 @@
</execution-->
</executions>
</plugin>
<!--
Generate the driver code.
-->
<plugin>
<groupId>org.apache.plc4x.plugins</groupId>
<artifactId>plc4x-maven-plugin</artifactId>
<executions>
<execution>
<id>generate-driver-modbus</id>
<phase>generate-sources</phase>
<goals>
<goal>generate-driver</goal>
</goals>
<configuration>
<protocolName>modbus</protocolName>
<languageName>c</languageName>
<outputFlavor>read-write</outputFlavor>
<outputDir>${project.basedir}/generated-sources</outputDir>
</configuration>
</execution>
<execution>
<id>generate-driver-plc4x</id>
<phase>generate-sources</phase>
<goals>
<goal>generate-driver</goal>
</goals>
<configuration>
<protocolName>plc4x</protocolName>
<protocolVersion>0</protocolVersion>
<languageName>c</languageName>
<outputFlavor>read-write</outputFlavor>
<outputDir>${project.basedir}/generated-sources</outputDir>
</configuration>
</execution>
<execution>
<id>generate-driver-s7</id>
<phase>generate-sources</phase>
<goals>
<goal>generate-driver</goal>
</goals>
<configuration>
<protocolName>s7</protocolName>
<languageName>c</languageName>
<outputFlavor>read-write</outputFlavor>
<outputDir>${project.basedir}/generated-sources</outputDir>
</configuration>
</execution>
</executions>
</plugin>

<!-- Transform the ParserSerializer tests into c code -->
<plugin>
Expand Down Expand Up @@ -379,37 +270,154 @@
</pluginManagement>
</build>

<!-- This dependency is just to ensure thrift is built first -->
<dependencies>
<dependency>
<groupId>org.apache.plc4x</groupId>
<artifactId>plc4x-code-generation-language-c</artifactId>
<version>0.12.0-SNAPSHOT</version>
<!-- Scope is 'provided' as this way it's not shipped with the driver -->
<scope>provided</scope>
</dependency>
<profiles>
<profile>
<id>update-generated-code</id>
<build>
<plugins>
<!--
Generate the driver code.
-->
<plugin>
<groupId>org.apache.plc4x.plugins</groupId>
<artifactId>plc4x-maven-plugin</artifactId>
<executions>
<execution>
<id>generate-driver-modbus</id>
<phase>generate-sources</phase>
<goals>
<goal>generate-driver</goal>
</goals>
<configuration>
<protocolName>modbus</protocolName>
<languageName>c</languageName>
<outputFlavor>read-write</outputFlavor>
<outputDir>${project.basedir}/generated-sources</outputDir>
</configuration>
</execution>
<execution>
<id>generate-driver-plc4x</id>
<phase>generate-sources</phase>
<goals>
<goal>generate-driver</goal>
</goals>
<configuration>
<protocolName>plc4x</protocolName>
<protocolVersion>0</protocolVersion>
<languageName>c</languageName>
<outputFlavor>read-write</outputFlavor>
<outputDir>${project.basedir}/generated-sources</outputDir>
</configuration>
</execution>
<execution>
<id>generate-driver-s7</id>
<phase>generate-sources</phase>
<goals>
<goal>generate-driver</goal>
</goals>
<configuration>
<protocolName>s7</protocolName>
<languageName>c</languageName>
<outputFlavor>read-write</outputFlavor>
<outputDir>${project.basedir}/generated-sources</outputDir>
</configuration>
</execution>
</executions>
</plugin>
</plugins>
</build>


<dependencies>
<dependency>
<groupId>org.apache.plc4x</groupId>
<artifactId>plc4x-code-generation-language-c</artifactId>
<version>0.12.0-SNAPSHOT</version>
<!-- Scope is 'provided' as this way it's not shipped with the driver -->
<scope>provided</scope>
</dependency>

<dependency>
<groupId>org.apache.plc4x</groupId>
<artifactId>plc4x-protocols-modbus</artifactId>
<version>0.12.0-SNAPSHOT</version>
<!-- Scope is 'provided' as this way it's not shipped with the driver -->
<scope>provided</scope>
</dependency>
<dependency>
<groupId>org.apache.plc4x</groupId>
<artifactId>plc4x-protocols-plc4x</artifactId>
<version>0.12.0-SNAPSHOT</version>
<!-- Scope is 'provided' as this way it's not shipped with the driver -->
<scope>provided</scope>
</dependency>
<dependency>
<groupId>org.apache.plc4x</groupId>
<artifactId>plc4x-protocols-s7</artifactId>
<version>0.12.0-SNAPSHOT</version>
<!-- Scope is 'provided' as this way it's not shipped with the driver -->
<scope>provided</scope>
</dependency>
</dependencies>
</profile>

<dependency>
<groupId>org.apache.plc4x</groupId>
<artifactId>plc4x-protocols-modbus</artifactId>
<version>0.12.0-SNAPSHOT</version>
<!-- Scope is 'provided' as this way it's not shipped with the driver -->
<scope>provided</scope>
</dependency>
<dependency>
<groupId>org.apache.plc4x</groupId>
<artifactId>plc4x-protocols-plc4x</artifactId>
<version>0.12.0-SNAPSHOT</version>
<!-- Scope is 'provided' as this way it's not shipped with the driver -->
<scope>provided</scope>
</dependency>
<dependency>
<groupId>org.apache.plc4x</groupId>
<artifactId>plc4x-protocols-s7</artifactId>
<version>0.12.0-SNAPSHOT</version>
<!-- Scope is 'provided' as this way it's not shipped with the driver -->
<scope>provided</scope>
</dependency>
</dependencies>
<!-- When running on jenkins, download the sonar build-wrapper, so we can do a code analysis -->
<profile>
<id>jenkins-build</id>
<!-- This is needed by the groovy hack script -->
<properties>
<cmake.root>${project.build.directory}/dependency/cmake/bin</cmake.root>
</properties>
<build>
<plugins>
<plugin>
<groupId>com.googlecode.maven-download-plugin</groupId>
<artifactId>download-maven-plugin</artifactId>
<executions>
<!-- Get the build-wrapper from our sonarcloud server -->
<execution>
<id>get-build-wrapper</id>
<phase>generate-sources</phase>
<goals>
<goal>wget</goal>
</goals>
<configuration>
<skipCache>true</skipCache>
<url>https://sonarcloud.io/static/cpp/build-wrapper-linux-x86.zip</url>
<unpack>true</unpack>
<outputDirectory>${project.build.directory}</outputDirectory>
<skipCache>true</skipCache>
</configuration>
</execution>
</executions>
</plugin>
<plugin>
<groupId>org.codehaus.gmaven</groupId>
<artifactId>groovy-maven-plugin</artifactId>
<executions>
<!-- rename the cmake binary and generate a script that adds the sonar build-wrapper -->
<execution>
<id>modify-cmake</id>
<phase>process-test-sources</phase>
<goals>
<goal>execute</goal>
</goals>
<configuration>
<source>${project.basedir}/SonarcloudBuildWrapperHack.groovy</source>
</configuration>
</execution>
</executions>
<dependencies>
<dependency>
<groupId>org.apache.groovy</groupId>
<artifactId>groovy</artifactId>
<version>${groovy.version}</version>
</dependency>
</dependencies>
</plugin>
</plugins>
</build>
</profile>
</profiles>
</project>
Loading

0 comments on commit 063524b

Please sign in to comment.