Skip to content
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

build: Fix licence check #694

Merged
merged 3 commits into from
Jul 26, 2023
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
2 changes: 1 addition & 1 deletion .github/workflows/build-maven.yml
Original file line number Diff line number Diff line change
Expand Up @@ -32,4 +32,4 @@ jobs:
${{ runner.os }}-maven-

- name: Run Maven
run: mvn -B clean verify com.mycila:license-maven-plugin:check
run: mvn -B clean -P !autoFormat,checkFormat verify
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🔧 With activeByDefault you don't need to disable the autoFormat profile. Simply by activating the checkFormat profile, the autoFormat profile will already be disabled.

3 changes: 2 additions & 1 deletion .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -134,7 +134,8 @@ jobs:
-DpushChanges=${PUSH_CHANGES} \
-DremoteTagging=${PUSH_CHANGES} \
-DlocalCheckout=${{ inputs.dryRun }} \
-Darguments='-P license-header-check -Dskip.central.release=${SKIP_REPO_DEPLOY} -Dskip.camunda.release=${SKIP_REPO_DEPLOY} -Dgpg.passphrase="${{ steps.secrets.outputs.MAVEN_CENTRAL_GPG_SIGNING_KEY_PASSPHRASE }}"'
-P-autoFormat \
-Darguments='-P-autoFormat -Dskip.central.release=${SKIP_REPO_DEPLOY} -Dskip.camunda.release=${SKIP_REPO_DEPLOY} -Dgpg.passphrase="${{ steps.secrets.outputs.MAVEN_CENTRAL_GPG_SIGNING_KEY_PASSPHRASE }}"'

# switch to the directory to which maven checks out the release tag
# see https://maven.apache.org/maven-release/maven-release-plugin/perform-mojo.html#workingDirectory
Expand Down
116 changes: 73 additions & 43 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -241,14 +241,6 @@
<configuration>
<parameters>--diff</parameters>
</configuration>
<executions>
<execution>
<phase>validate</phase>
<goals>
<goal>format</goal>
</goals>
</execution>
</executions>
</plugin>

<plugin>
Expand Down Expand Up @@ -397,60 +389,98 @@
</executions>
</plugin>

<!-- license plugin -->
<plugin>
<groupId>com.mycila</groupId>
<artifactId>license-maven-plugin</artifactId>
<configuration>
<includes>
<include>**/*.scala</include>
<include>**/*.java</include>
</includes>
<mapping>
<java>SLASHSTAR_STYLE</java>
<scala>SLASHSTAR_STYLE</scala>
</mapping>
</configuration>
</plugin>

</plugins>

</build>

<profiles>
<!-- profile to auto format -->
<profile>
<id>license-header-check</id>
<properties>
<plugin.version.license>4.2</plugin.version.license>
<license.inlineHeader>
Copyright Camunda Services GmbH and/or licensed to Camunda Services GmbH
under one or more contributor license agreements. See the NOTICE file
distributed with this work for additional information regarding copyright
ownership. Camunda licenses this file to you under the Apache License,
Version 2.0; you may not use this file except in compliance with the License.
You may obtain a copy of the License at

http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
</license.inlineHeader>
</properties>
<id>autoFormat</id>
<activation>
<activeByDefault>true</activeByDefault>
</activation>
Comment on lines +416 to +418
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💭 One thing to remember with activeByDefault is that it will be deactivated automatically when any other profile is activated. I always thought this was unexpected. There exist some solutions to deal with this (I personally like activeProfile best), if you wish to take that route.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good to know. Thank you for the hint. 👍

<build>
<plugins>
<!-- license plugin -->
<plugin>
<groupId>org.antipathy</groupId>
<artifactId>mvn-scalafmt_2.12</artifactId>
<executions>
<execution>
<id>scala-format</id>
<phase>validate</phase>
<goals>
<goal>format</goal>
</goals>
</execution>
</executions>
</plugin>

<plugin>
<groupId>com.mycila</groupId>
<artifactId>license-maven-plugin</artifactId>
<version>${plugin.version.license}</version>
<configuration>
<skipExistingHeaders>false</skipExistingHeaders>
<includes>
<include>**/*.scala</include>
<include>**/*.java</include>
</includes>
<mapping>
<java>SLASHSTAR_STYLE</java>
<scala>SLASHSTAR_STYLE</scala>
</mapping>
</configuration>
<executions>
<execution>
<id>add-license-header</id>
<phase>compile</phase>
<id>add-license</id>
<goals>
<goal>format</goal>
</goals>
<phase>process-sources</phase>
</execution>
</executions>
</plugin>
</plugins>
</build>
</profile>

<!-- profile to perform strict validation checks -->
<profile>
<id>checkFormat</id>
<build>
<plugins>
<plugin>
<groupId>org.antipathy</groupId>
<artifactId>mvn-scalafmt_2.12</artifactId>
<executions>
<execution>
<id>scala-format</id>
<phase>validate</phase>
<goals>
<goal>format</goal>
</goals>
</execution>
</executions>
</plugin>

<plugin>
<groupId>com.mycila</groupId>
<artifactId>license-maven-plugin</artifactId>
<executions>
<execution>
<id>check-license</id>
<goals>
<goal>check</goal>
</goals>
<phase>validate</phase>
</execution>
</executions>
</plugin>
</plugins>
</build>
</profile>
Expand Down