Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 9 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -1374,6 +1374,15 @@ Specification argument resolver is available in the Maven Central:
</dependency>
```

Also, there is an autoconfiguration starter you can use:
```xml
<dependency>
<groupId>net.kaczmarzyk</groupId>
<artifactId>sar-spring-boot-starter</artifactId>
<version>1.0.0</version>
</dependency>
```

If a new version is not yet available in the central repository (or you need a SNAPSHOT version), you can grab it from my private repo:

```xml
Expand Down
235 changes: 235 additions & 0 deletions sar-spring-boot-starter/pom.xml
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>
Copy link
Contributor Author

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?

Copy link
Contributor Author

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

<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 failure

Code 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 failure

Code 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>
13 changes: 13 additions & 0 deletions sar-spring-boot-starter/src/etc/license_header.txt
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.
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();
}
}
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);
}
}
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();
}
}
Loading