Skip to content

Commit

Permalink
Merge branch 'release/2.4.0-rc1'
Browse files Browse the repository at this point in the history
  • Loading branch information
Jenkins committed Jul 12, 2023
2 parents 7593544 + 155258a commit 9676420
Show file tree
Hide file tree
Showing 187 changed files with 1,086 additions and 452 deletions.
3 changes: 2 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -18,4 +18,5 @@ target
# IntelliJ
.idea/
*.iml
README.md
README.md
gradle-enterprise-workspace-id
7 changes: 7 additions & 0 deletions .mvn/extensions.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
<extensions>
<extension>
<groupId>com.gradle</groupId>
<artifactId>gradle-enterprise-maven-extension</artifactId>
<version>1.17.4</version>
</extension>
</extensions>
16 changes: 16 additions & 0 deletions .mvn/gradle-enterprise.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
<gradleEnterprise
xmlns="https://www.gradle.com/gradle-enterprise-maven" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="https://www.gradle.com/gradle-enterprise-maven https://www.gradle.com/schema/gradle-enterprise-maven.xsd">
<buildScan>
<termsOfService>
<url>https://gradle.com/terms-of-service</url>
<accept>true</accept>
</termsOfService>
<backgroundBuildScanUpload>#{env['CI'] == null}</backgroundBuildScanUpload>
</buildScan>
<buildCache>
<local>
<enabled>true</enabled>
</local>
</buildCache>
</gradleEnterprise>
18 changes: 17 additions & 1 deletion .mvn/wrapper/maven-wrapper.properties
Original file line number Diff line number Diff line change
@@ -1,2 +1,18 @@
distributionUrl=https://repo.maven.apache.org/maven2/org/apache/maven/apache-maven/3.9.2/apache-maven-3.9.2-bin.zip
# Licensed to the Apache Software Foundation (ASF) under one
# or more contributor license agreements. See the NOTICE file
# distributed with this work for additional information
# regarding copyright ownership. The ASF licenses this file
# to you under the Apache License, Version 2.0 (the
# "License"); 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.
distributionUrl=https://repo.maven.apache.org/maven2/org/apache/maven/apache-maven/3.9.3/apache-maven-3.9.3-bin.zip
wrapperUrl=https://repo.maven.apache.org/maven2/org/apache/maven/wrapper/maven-wrapper/3.2.0/maven-wrapper-3.2.0.jar
15 changes: 10 additions & 5 deletions Jenkinsfile
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
pipeline {
options {
disableConcurrentBuilds()
options {
disableConcurrentBuilds()
}
agent {
docker {
Expand All @@ -15,12 +15,12 @@ pipeline {
stages {
stage('Build') {
steps {
sh 'mvn -B clean verify'
sh 'mvn -B clean install -Pwith-coverage'
}
}
stage('Coverage') {
steps {
sh 'mvn -B jacoco:report jacoco:report-integration coveralls:report -DrepoToken=$COVERALLS_REPO_TOKEN'
sh 'mvn -B jacoco:report jacoco:report-integration coveralls:report -DrepoToken=$COVERALLS_REPO_TOKEN -Pwith-coverage'
}
}
stage('javadoc') {
Expand All @@ -33,8 +33,13 @@ pipeline {
branch 'develop'
}
steps {
sh 'mvn -B -Prelease -DskipTests -Dgpg.passphrase=${GPG_SECRET} deploy'
sh 'mvn -B -Prelease -DskipTests=true -Dgpg.passphrase=${GPG_SECRET} deploy'
}
}
}
post {
always {
junit (testResults: '**/target/surefire-reports/**.xml,**/target/*/reports/**.xml', allowEmptyResults: true)
}
}
}
16 changes: 11 additions & 5 deletions JenkinsfileRelease
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
pipeline {
options {
disableConcurrentBuilds()
options {
disableConcurrentBuilds()
}
agent {
docker {
Expand All @@ -14,6 +14,9 @@ pipeline {
GITHUB_RELEASE_TOKEN = credentials('github_registry_release')
GIT_ASKPASS='./.git-askpass'
}
parameters {
booleanParam(name: 'PUBLISH_GITHUB', defaultValue: true, description: 'Whether to publish a GitHub release')
}
stages {
stage ('Ensure dev branch') {
when {
Expand Down Expand Up @@ -43,7 +46,7 @@ pipeline {
}
stage('Verify release') {
steps {
sh 'mvn -B -Prelease -Dgpg.passphrase=${GPG_SECRET} verify'
sh 'mvn -B -Prelease -Dgpg.passphrase=${GPG_SECRET} install'
}
}
stage('Update readme') {
Expand All @@ -54,13 +57,16 @@ pipeline {
}
stage('Perform release') {
steps {
sh "mvn -B gitflow:release-finish -DargLine=\"-Prelease -B -Dgpg.passphrase=${GPG_SECRET} -DskipTests\""
sh "mvn -B gitflow:release-finish -DargLine=\"-Prelease -B -Dgpg.passphrase=${GPG_SECRET} -DskipTests=true\""
}
}
stage('Create GitHub release') {
when {
expression { params.PUBLISH_GITHUB }
}
steps {
sh 'git checkout master'
sh "mvn -B github-release:github-release -Dgithub.release-token=${GITHUB_RELEASE_TOKEN}"
sh "mvn -B -N github-release:github-release -Dgithub.release-token=${GITHUB_RELEASE_TOKEN}"
}
}
}
Expand Down
83 changes: 57 additions & 26 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<!-- This file is auto generated during release from readme/README.md -->

[![Maven Central](https://img.shields.io/static/v1?label=MavenCentral&message=2.3.1&color=blue)](https://search.maven.org/artifact/de.skuzzle.enforcer/restrict-imports-enforcer-rule/2.3.1/jar)
[![JavaDoc](https://img.shields.io/static/v1?label=JavaDoc&message=2.3.1&color=orange)](http://www.javadoc.io/doc/de.skuzzle.enforcer/restrict-imports-enforcer-rule/2.3.1)
[![Maven Central](https://img.shields.io/static/v1?label=MavenCentral&message=2.4.0-rc1&color=blue)](https://search.maven.org/artifact/de.skuzzle.enforcer/restrict-imports-enforcer-rule/2.4.0-rc1/jar)
[![JavaDoc](https://img.shields.io/static/v1?label=JavaDoc&message=2.4.0-rc1&color=orange)](http://www.javadoc.io/doc/de.skuzzle.enforcer/restrict-imports-enforcer-rule/2.4.0-rc1)
[![Coverage Status](https://coveralls.io/repos/github/skuzzle/restrict-imports-enforcer-rule/badge.svg?branch=master)](https://coveralls.io/github/skuzzle/restrict-imports-enforcer-rule?branch=master)
[![Twitter Follow](https://img.shields.io/twitter/follow/skuzzleOSS.svg?style=social)](https://twitter.com/skuzzleOSS)

Expand All @@ -13,6 +13,8 @@ usage of unwanted classes! [More](#rationale)
- [x] Groovy (since 0.15)
- [ ] Scala (see [Issue 24](https://github.com/skuzzle/restrict-imports-enforcer-rule/issues/24))

Tested against _maven-enforcer-plugin_ versions `1.4.1` and `3.3.0`.

## Simple usage
This is a minimal usage example. Please scroll down for detailed configuration
information.
Expand All @@ -25,8 +27,8 @@ information.
<dependencies>
<dependency>
<groupId>de.skuzzle.enforcer</groupId>
<artifactId>restrict-imports-enforcer-rule</artifactId>
<version>2.3.1</version>
<artifactId>restrict-imports-enforcer-rule-parent</artifactId>
<version>2.4.0-rc1</version>
</dependency>
</dependencies>
<executions>
Expand Down Expand Up @@ -57,6 +59,7 @@ information.
* [Rationale](#rationale)
* Usage
* [Includes and Excludes](#includes-and-excludes)
* [Not fixable imports](#not-fixable-imports)
* [Rule groups](#rule-groups)
* [Static imports](#static-imports)
* [Test code](#test-code)
Expand Down Expand Up @@ -87,7 +90,7 @@ application without having to exclude whole artifacts from your classpath.

## Includes and Excludes
To refine the classes that are banned you may use the `allowedImports` tag in addition to
the `bannedImports` tag. For example you can exclude a whole sub package using a wildcard
the `bannedImports` tag. For example, you can exclude a whole sub package using a wildcard
operator but still allow some concrete classes:

```xml
Expand Down Expand Up @@ -148,6 +151,35 @@ possible to define multiple banned imports/exclusions/allowed imports or base pa
</configuration>
```

## Not-fixable imports
> **Note**
> This is an experimental feature added in 2.4.0
In certain situations you might not be able to avoid using a banned import. For example if you implement an
interface which requires a banned type as either return- or parameter type. Instead of globally allowing such imports,
you can allow them to be used only in some explicitly configured locations.

```xml
<configuration>
<rules>
<RestrictImports>
<bannedImport>com.foo.BannedClass</bannedImport>
<notFixable>
<in>com.yourdomain.persistence.SomeClass</in>
<allowedImports>
<allowedImport>com.foo.BannedClass</allowedImport>
</allowedImports>
<because>Type required by implemented interface</because>
</notFixable>
</RestrictImports>
</rules>
</configuration>
```

> **Note**
> Not fixable definitions can not be nested in `<groups>` (see _Rule groups_ below). Not-fixables apply globally per
> `RestrictImports` rule instance.
## Rule groups
Rule groups add another level of refining which imports will be matched. You can group
the `bannedImport(s)`, `allowedImport(s)` and `basePackage(s)` tags and specify multiple
Expand Down Expand Up @@ -195,7 +227,8 @@ more specific `basePackage` of the second group. In that case, only the definiti
class.

## Static imports
(*Note:* Behavior has been changed in version 2.0.0)
> **Note**
> Behavior of static import detection has been changed with version 2.0.0
Every package pattern also automatically matches `static` imports. However, it is possible to explicitly mention the
`static` keyword in the pattern. In that case, the pattern will only match a resp. static import.
Expand Down Expand Up @@ -225,6 +258,8 @@ analysis of test code using the `includeTestCode` option.
</configuration>
```

You can add multiple _not-fixable_ definitions if you nest them in `<notFixables></notFixables>`.

## Skipping
Using the configuration option `skip` you are able to temporarily disable a rule
instance.
Expand Down Expand Up @@ -276,9 +311,6 @@ is not limited to `${project.basedir}/src/main/java`, `${project.basedir}/src/te
```

## Parallel Analysis
(*Note:* This is an experimental feature and not thoroughly tested. Syntax and behavior
changes in upcoming versions are likely)

We support basic parallelization of the analysis. This is disabled by default but can be enabled either in the pom file
using the `<parallel>` option or by passing `-Drestrictimports.parallel` to the maven build.
```xml
Expand All @@ -293,7 +325,8 @@ using the `<parallel>` option or by passing `-Drestrictimports.parallel` to the
```

## Detecting full qualified class usage
(*Note:* This is an experimental feature)
> **Note**
> This is an experimental feature
To overcome some of the limitations mentioned [here](#limitation), you can enable 'full compilation unit' parsing
mode using
Expand Down Expand Up @@ -375,26 +408,24 @@ statement. Thus if your `exclusion` pattern points to a concrete class like
with the exact name `ClassName.java`. The same applies in case you use a base package
pattern with no wild cards.

### Experimental full compilation unit parsing


## Configuration options

Overview of all configuration parameters:

| Parameter | Type | Required | Default | Since |
|----------------------------|---------------------------|----------|-----------------------------------|----------|
| `basePackage(s)` | (List of) package pattern | no | `**` | |
| `bannedImport(s)` | (List of) package pattern | yes | | |
| `allowedImport(s)` | (List of) package pattern | no | empty list | |
| `exclusion(s)` | (List of) package pattern | no | empty list | |
| `includeTestCode` | Boolean | no | `false` | `0.7.0` |
| `reason` | String | no | empty String | `0.8.0` |
| `failBuild` | Boolean | no | `true` | `0.17.0` |
| `skip` | Boolean | no | `false` | `0.17.0` |
| `includeCompileCode` | Boolean | no | `true` | `1.2.0` |
| `excludedSourceRoot(s)` | (List of) java.io.File | no | empty list | `1.3.0` |
| `parseFullCompilationUnit` | Boolean | no | `false` | `2.1.0` |
| Parameter | Type | Required | Default | Since |
|----------------------------|--------------------------------|----------|--------------|----------|
| `basePackage(s)` | (List of) package pattern | no | `**` | |
| `bannedImport(s)` | (List of) package pattern | yes | | |
| `allowedImport(s)` | (List of) package pattern | no | empty list | |
| `exclusion(s)` | (List of) package pattern | no | empty list | |
| `includeTestCode` | Boolean | no | `false` | `0.7.0` |
| `reason` | String | no | empty String | `0.8.0` |
| `failBuild` | Boolean | no | `true` | `0.17.0` |
| `skip` | Boolean | no | `false` | `0.17.0` |
| `includeCompileCode` | Boolean | no | `true` | `1.2.0` |
| `excludedSourceRoot(s)` | (List of) java.io.File | no | empty list | `1.3.0` |
| `parseFullCompilationUnit` | Boolean | no | `false` | `2.1.0` |
| `notFixable(s)` | (List of) NotFixableDefinition | no | empty list | `2.4.0` |

## Versioning, Deprecations and Compatibility
This project adheres to version 2 of the [semantic version specification](http://semver.org) with regards to the
Expand Down
7 changes: 4 additions & 3 deletions RELEASE_NOTES.md
Original file line number Diff line number Diff line change
@@ -1,14 +1,15 @@
[![Maven Central](https://img.shields.io/static/v1?label=MavenCentral&message=2.3.1&color=blue)](https://search.maven.org/artifact/de.skuzzle.enforcer/restrict-imports-enforcer-rule/2.3.1/jar) [![JavaDoc](https://img.shields.io/static/v1?label=JavaDoc&message=2.3.1&color=orange)](http://www.javadoc.io/doc/de.skuzzle.enforcer/restrict-imports-enforcer-rule/2.3.1)
[![Maven Central](https://img.shields.io/static/v1?label=MavenCentral&message=2.4.0-rc1&color=blue)](https://search.maven.org/artifact/de.skuzzle.enforcer/restrict-imports-enforcer-rule/2.4.0-rc1/jar) [![JavaDoc](https://img.shields.io/static/v1?label=JavaDoc&message=2.4.0-rc1&color=orange)](http://www.javadoc.io/doc/de.skuzzle.enforcer/restrict-imports-enforcer-rule/2.4.0-rc1)

### Bug fixes
* [#79](https://github.com/skuzzle/restrict-imports-enforcer-rule/issues/79) Recognize full qualified annotation use
* [#55](https://github.com/skuzzle/restrict-imports-enforcer-rule/issues/55) Make parallel analysis the default
* [#63](https://github.com/skuzzle/restrict-imports-enforcer-rule/issues/63) Support for ignoring classes that cannot be fixed

Maven Central coordinates for this release:

```xml
<dependency>
<groupId>de.skuzzle.enforcer</groupId>
<artifactId>restrict-imports-enforcer-rule</artifactId>
<version>2.3.1</version>
<version>2.4.0-rc1</version>
</dependency>
```
70 changes: 70 additions & 0 deletions core/pom.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,70 @@
<?xml version="1.0" encoding="UTF-8"?>
<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>
<parent>
<groupId>de.skuzzle.enforcer</groupId>
<artifactId>restrict-imports-enforcer-rule-parent</artifactId>
<version>2.4.0-rc1</version>
</parent>
<artifactId>restrict-imports-enforcer-rule-core</artifactId>
<packaging>jar</packaging>
<name>Restrict Imports Enforcer Rule Core</name>

<dependencies>
<dependency>
<groupId>org.slf4j</groupId>
<artifactId>slf4j-api</artifactId>
</dependency>
<dependency>
<groupId>com.github.javaparser</groupId>
<artifactId>javaparser-core</artifactId>
</dependency>
<dependency>
<groupId>org.mockito</groupId>
<artifactId>mockito-core</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>net.bytebuddy</groupId>
<artifactId>byte-buddy</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>net.bytebuddy</groupId>
<artifactId>byte-buddy-agent</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.junit.jupiter</groupId>
<artifactId>junit-jupiter</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.junit.jupiter</groupId>
<artifactId>junit-jupiter-params</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.junit.jupiter</groupId>
<artifactId>junit-jupiter-api</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>nl.jqno.equalsverifier</groupId>
<artifactId>equalsverifier</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>com.google.jimfs</groupId>
<artifactId>jimfs</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.assertj</groupId>
<artifactId>assertj-core</artifactId>
<scope>test</scope>
</dependency>
</dependencies>

</project>
Loading

0 comments on commit 9676420

Please sign in to comment.