-
Notifications
You must be signed in to change notification settings - Fork 155
Added autoconfiguration support #232
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
Open
rdworak37
wants to merge
1
commit into
tkaczmarzyk:master
Choose a base branch
from
rdworak37:autoconfiguration_support
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,235 @@ | ||
| <?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> | ||
|
|
||
| <groupId>net.kaczmarzyk</groupId> | ||
| <artifactId>sar-spring-boot-starter</artifactId> | ||
| <version>1.0.0-SNAPSHOT</version> | ||
| <packaging>pom</packaging> | ||
| <inceptionYear>2014</inceptionYear> | ||
|
|
||
| <dependencyManagement> | ||
| <dependencies> | ||
| <dependency> | ||
| <groupId>org.springframework.boot</groupId> | ||
| <artifactId>spring-boot-dependencies</artifactId> | ||
| <version>3.0.2</version> | ||
| <type>pom</type> | ||
| <scope>import</scope> | ||
| </dependency> | ||
| </dependencies> | ||
| </dependencyManagement> | ||
|
|
||
| <dependencies> | ||
| <dependency> | ||
| <groupId>net.kaczmarzyk</groupId> | ||
| <artifactId>specification-arg-resolver</artifactId> | ||
| <version>3.0.2-SNAPSHOT</version> | ||
| </dependency> | ||
| <dependency> | ||
| <groupId>org.springframework.boot</groupId> | ||
| <artifactId>spring-boot-autoconfigure</artifactId> | ||
| </dependency> | ||
| <dependency> | ||
| <groupId>org.springdoc</groupId> | ||
| <artifactId>springdoc-openapi-starter-common</artifactId> | ||
| <version>2.0.2</version> | ||
| <optional>true</optional> | ||
| </dependency> | ||
|
|
||
| <dependency> | ||
| <groupId>org.springframework.boot</groupId> | ||
| <artifactId>spring-boot-starter-test</artifactId> | ||
| <scope>test</scope> | ||
| </dependency> | ||
| <dependency> | ||
| <groupId>junit</groupId> | ||
| <artifactId>junit</artifactId> | ||
| <scope>test</scope> | ||
| </dependency> | ||
| <dependency> | ||
| <groupId>org.assertj</groupId> | ||
| <artifactId>assertj-core</artifactId> | ||
| <scope>test</scope> | ||
| </dependency> | ||
| <dependency> | ||
| <groupId>org.springframework</groupId> | ||
| <artifactId>spring-test</artifactId> | ||
| <scope>test</scope> | ||
| </dependency> | ||
| </dependencies> | ||
|
|
||
| <properties> | ||
| <maven.compiler.source>17</maven.compiler.source> | ||
| <maven.compiler.target>17</maven.compiler.target> | ||
| </properties> | ||
|
|
||
| <scm> | ||
| <connection>scm:git:https://github.com/tkaczmarzyk/specification-arg-resolver.git</connection> | ||
| <url>scm:git:https://github.com/tkaczmarzyk/specification-arg-resolver.git</url> | ||
| <developerConnection>scm:git:https://github.com/tkaczmarzyk/specification-arg-resolver.git</developerConnection> | ||
| <tag>HEAD</tag> | ||
| </scm> | ||
|
|
||
| <profiles> | ||
| <profile> | ||
| <id>sonatype</id> | ||
| <activation> | ||
| <activeByDefault>false</activeByDefault> | ||
| </activation> | ||
| <distributionManagement> | ||
| <repository> | ||
| <id>nexus-releases</id> | ||
| <name>Nexus Release Repository</name> | ||
| <url>https://oss.sonatype.org/service/local/staging/deploy/maven2/</url> | ||
| </repository> | ||
| <snapshotRepository> | ||
| <id>nexus-snapshots</id> | ||
| <name>Nexus Snapshot Repository</name> | ||
| <url>https://oss.sonatype.org/content/repositories/snapshots/</url> | ||
| </snapshotRepository> | ||
| </distributionManagement> | ||
| </profile> | ||
| <profile> | ||
| <id>sign</id> | ||
| <activation> | ||
| <activeByDefault>false</activeByDefault> | ||
| </activation> | ||
| <build> | ||
| <plugins> | ||
| <plugin> | ||
| <groupId>org.apache.maven.plugins</groupId> | ||
| <artifactId>maven-gpg-plugin</artifactId> | ||
| <version>3.0.1</version> | ||
| <executions> | ||
| <execution> | ||
| <id>sign-artifacts</id> | ||
| <phase>verify</phase> | ||
| <goals> | ||
| <goal>sign</goal> | ||
| </goals> | ||
| </execution> | ||
| </executions> | ||
| </plugin> | ||
| </plugins> | ||
| </build> | ||
| </profile> | ||
| </profiles> | ||
|
|
||
| <build> | ||
| <plugins> | ||
| <plugin> | ||
| <artifactId>maven-compiler-plugin</artifactId> | ||
| <version>3.10.1</version> | ||
| <configuration> | ||
| <source>17</source> | ||
| <target>17</target> | ||
| </configuration> | ||
| </plugin> | ||
| <plugin> | ||
| <groupId>org.apache.maven.plugins</groupId> | ||
| <artifactId>maven-surefire-plugin</artifactId> | ||
| <version>3.0.0-M8</version> | ||
| </plugin> | ||
| <plugin> | ||
| <groupId>org.apache.maven.plugins</groupId> | ||
| <artifactId>maven-source-plugin</artifactId> | ||
| <version>3.2.1</version> | ||
| <executions> | ||
| <execution> | ||
| <id>attach-sources</id> | ||
| <goals> | ||
| <goal>jar</goal> | ||
| </goals> | ||
| </execution> | ||
| </executions> | ||
| </plugin> | ||
| <plugin> | ||
| <groupId>org.apache.maven.plugins</groupId> | ||
| <artifactId>maven-javadoc-plugin</artifactId> | ||
| <version>3.4.1</version> | ||
| <executions> | ||
| <execution> | ||
| <id>attach-javadocs</id> | ||
| <goals> | ||
| <goal>jar</goal> | ||
| </goals> | ||
| </execution> | ||
| </executions> | ||
| </plugin> | ||
| <plugin> | ||
| <groupId>com.mycila.maven-license-plugin</groupId> | ||
| <artifactId>maven-license-plugin</artifactId> | ||
| <version>1.10.b1</version> | ||
| <configuration> | ||
| <header>src/etc/license_header.txt</header> | ||
| <quiet>false</quiet> | ||
| <failIfMissing>true</failIfMissing> | ||
| <aggregate>false</aggregate> | ||
| <includes> | ||
| <include>src/main/java/**</include> | ||
| <include>src/test/java/**</include> | ||
| </includes> | ||
| <excludes> | ||
| <exclude>src/site</exclude> | ||
| </excludes> | ||
| <useDefaultExcludes>true</useDefaultExcludes> | ||
| <useDefaultMapping>true</useDefaultMapping> | ||
| <properties> | ||
| <year>${project.inceptionYear}-2023</year> | ||
| </properties> | ||
| <encoding>UTF-8</encoding> | ||
| </configuration> | ||
| <executions> | ||
| <execution> | ||
| <phase>test</phase> | ||
| <goals> | ||
| <goal>check</goal> | ||
| </goals> | ||
| </execution> | ||
| </executions> | ||
| </plugin> | ||
| <plugin> | ||
| <artifactId>maven-release-plugin</artifactId> | ||
| <version>2.5.3</version> | ||
| <configuration> | ||
| <tagNameFormat>v@{project.version}</tagNameFormat> | ||
| </configuration> | ||
| <dependencies> | ||
| <dependency> | ||
| <groupId>org.apache.maven.scm</groupId> | ||
| <artifactId>maven-scm-provider-gitexe</artifactId> | ||
| <version>1.13.0</version> | ||
| </dependency> | ||
| <dependency> | ||
| <groupId>org.apache.maven.scm</groupId> | ||
| <artifactId>maven-scm-api</artifactId> | ||
| <version>1.13.0</version> | ||
| </dependency> | ||
| </dependencies> | ||
| </plugin> | ||
| </plugins> | ||
| <extensions> | ||
| <extension> | ||
| <groupId>org.apache.maven.wagon</groupId> | ||
| <artifactId>wagon-ftp</artifactId> | ||
| <version>3.5.3</version> | ||
| </extension> | ||
| </extensions> | ||
| </build> | ||
|
|
||
| <distributionManagement> | ||
| <repository> | ||
| <id>kaczmarzyk.net</id> | ||
| <name>kaczmarzyk.net repository</name> | ||
| <url>ftp://repo.kaczmarzyk.net</url> | ||
| </repository> | ||
|
Comment on lines
+224
to
+228
Check failureCode scanning / CodeQL Failure to use HTTPS or SFTP URL in Maven artifact upload/download
Downloading or uploading artifacts over insecure protocol (eg. http or ftp) to/from repository ftp://repo.kaczmarzyk.net
|
||
| <snapshotRepository> | ||
| <id>kaczmarzyk.net</id> | ||
| <name>kaczmarzyk.net repository</name> | ||
| <url>ftp://repo.kaczmarzyk.net</url> | ||
| </snapshotRepository> | ||
|
Comment on lines
+229
to
+233
Check failureCode scanning / CodeQL Failure to use HTTPS or SFTP URL in Maven artifact upload/download
Downloading or uploading artifacts over insecure protocol (eg. http or ftp) to/from repository ftp://repo.kaczmarzyk.net
|
||
| </distributionManagement> | ||
| </project> | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,13 @@ | ||
| Copyright ${year} the original author or authors. | ||
|
|
||
| Licensed 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. |
58 changes: 58 additions & 0 deletions
58
...java/net/kaczmarzyk/autoconfiguration/SpecificationArgumentResolverAutoConfiguration.java
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,58 @@ | ||
| /** | ||
| * Copyright 2014-2023 the original author or authors. | ||
| * | ||
| * Licensed 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. | ||
| */ | ||
| package net.kaczmarzyk.autoconfiguration; | ||
|
|
||
| import net.kaczmarzyk.spring.data.jpa.swagger.springdoc.SpecificationArgResolverSpringdocOperationCustomizer; | ||
| import net.kaczmarzyk.spring.data.jpa.web.SpecificationArgumentResolver; | ||
| import org.springframework.beans.factory.annotation.Autowired; | ||
| import org.springframework.beans.factory.annotation.Value; | ||
| import org.springframework.boot.autoconfigure.AutoConfiguration; | ||
| import org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean; | ||
| import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty; | ||
| import org.springframework.context.annotation.Bean; | ||
| import org.springframework.context.support.AbstractApplicationContext; | ||
| import org.springframework.data.web.PageableHandlerMethodArgumentResolver; | ||
|
|
||
| import java.util.Locale; | ||
|
|
||
| @AutoConfiguration | ||
| public class SpecificationArgumentResolverAutoConfiguration { | ||
|
|
||
| @Autowired | ||
| AbstractApplicationContext applicationContext; | ||
|
|
||
| @Value(value = "${specification-arg-resolver.locale:EN}") | ||
| String locale; | ||
|
|
||
| @ConditionalOnMissingBean | ||
| @Bean | ||
| public SpecificationArgumentResolver defaultSpecificationArgumentResolver() { | ||
| return new SpecificationArgumentResolver(applicationContext, Locale.forLanguageTag(locale)); | ||
| } | ||
|
|
||
| @ConditionalOnMissingBean | ||
| @Bean | ||
| public PageableHandlerMethodArgumentResolver defaultPageableHandlerMethodArgumentResolver() { | ||
| return new PageableHandlerMethodArgumentResolver(); | ||
| } | ||
|
|
||
| @ConditionalOnMissingBean | ||
| @ConditionalOnProperty(prefix = "specification-arg-resolver", name = "spring-doc-operation-customizer", havingValue = "true") | ||
| @Bean | ||
| public SpecificationArgResolverSpringdocOperationCustomizer defaultSpecificationArgResolverSpringdocOperationCustomizer() { | ||
| return new SpecificationArgResolverSpringdocOperationCustomizer(); | ||
| } | ||
| } |
41 changes: 41 additions & 0 deletions
41
.../java/net/kaczmarzyk/autoconfiguration/SpecificationArgumentResolverWebMvcConfigurer.java
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,41 @@ | ||
| /** | ||
| * Copyright 2014-2023 the original author or authors. | ||
| * | ||
| * Licensed 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. | ||
| */ | ||
| package net.kaczmarzyk.autoconfiguration; | ||
|
|
||
| import net.kaczmarzyk.spring.data.jpa.web.SpecificationArgumentResolver; | ||
| import org.springframework.beans.factory.annotation.Autowired; | ||
| import org.springframework.boot.autoconfigure.AutoConfiguration; | ||
| import org.springframework.data.web.PageableHandlerMethodArgumentResolver; | ||
| import org.springframework.web.method.support.HandlerMethodArgumentResolver; | ||
| import org.springframework.web.servlet.config.annotation.WebMvcConfigurer; | ||
|
|
||
| import java.util.List; | ||
|
|
||
| @AutoConfiguration | ||
| public class SpecificationArgumentResolverWebMvcConfigurer implements WebMvcConfigurer { | ||
|
|
||
| @Autowired | ||
| SpecificationArgumentResolver specificationArgumentResolver; | ||
|
|
||
| @Autowired | ||
| PageableHandlerMethodArgumentResolver pageableHandlerMethodArgumentResolver; | ||
|
|
||
| @Override | ||
| public void addArgumentResolvers(List<HandlerMethodArgumentResolver> argumentResolvers) { | ||
| argumentResolvers.add(specificationArgumentResolver); | ||
| argumentResolvers.add(pageableHandlerMethodArgumentResolver); | ||
| } | ||
| } |
26 changes: 26 additions & 0 deletions
26
...ing-boot-starter/src/test/java/net/kaczmarzyk/autoconfiguration/SarTestConfiguration.java
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,26 @@ | ||
| package net.kaczmarzyk.autoconfiguration; | ||
|
|
||
| import net.kaczmarzyk.spring.data.jpa.swagger.springdoc.SpecificationArgResolverSpringdocOperationCustomizer; | ||
| import net.kaczmarzyk.spring.data.jpa.web.SpecificationArgumentResolver; | ||
| import org.springframework.context.annotation.Bean; | ||
| import org.springframework.context.annotation.Configuration; | ||
| import org.springframework.data.web.PageableHandlerMethodArgumentResolver; | ||
|
|
||
| @Configuration | ||
| public class SarTestConfiguration { | ||
|
|
||
| @Bean | ||
| public SpecificationArgumentResolver differentSpecificationArgumentResolver() { | ||
| return new SpecificationArgumentResolver(); | ||
| } | ||
|
|
||
| @Bean | ||
| public PageableHandlerMethodArgumentResolver differentPageableHandlerMethodArgumentResolver() { | ||
| return new PageableHandlerMethodArgumentResolver(); | ||
| } | ||
|
|
||
| @Bean | ||
| public SpecificationArgResolverSpringdocOperationCustomizer differentSpecificationArgResolverSpringdocOperationCustomizer() { | ||
| return new SpecificationArgResolverSpringdocOperationCustomizer(); | ||
| } | ||
| } |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
Autoconfiguration pom has different version than main pom, but in order to keep the same version for both I would have to create another "core" module and move whole main code base to it. In other case I can't add it as a dependency in this pom. Should I do it?
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.
https://stackoverflow.com/questions/10024320/maven-include-parent-classes <--- additional info on solution to this problem