We have a maven module where we use com.github.kongchen:swagger-maven-plugin to generate Swagger docs. Now we are migrating our project to Jakarta EE 10. And this maven plugin generates javax.* classes and the build eventually fails.
This is what we have in pom.xml
<dependency>
<groupId>io.swagger</groupId>
<artifactId>swagger-core</artifactId>
<version>1.6.11</version>
<scope>provided</scope>
<exclusions>
<exclusion>
<groupId>jakarta.ws.rs</groupId>
<artifactId>jsr311-api</artifactId>
</exclusion>
<exclusion>
<groupId>com.fasterxml.jackson.core</groupId>
<artifactId>jackson-annotations</artifactId>
</exclusion>
<exclusion>
<groupId>com.fasterxml.jackson.core</groupId>
<artifactId>jackson-databind</artifactId>
</exclusion>
<exclusion>
<groupId>com.fasterxml.jackson.core</groupId>
<artifactId>jackson-core</artifactId>
</exclusion>
</exclusions>
</dependency>
<build>
<plugins>
<plugin>
<groupId>com.github.kongchen</groupId>
<artifactId>swagger-maven-plugin</artifactId>
<configuration>
<apiSources>
<apiSource>
<springmvc>false</springmvc>
<locations>org.more.rest</locations>
<basePath>/myapi/</basePath>
<info>
<title>MY REST API</title>
<version>1.0</version>
<termsOfService>http://swagger.io/terms/</termsOfService>
</info>
<templatePath>${project.basedir}/src/test/resources/swagger-template/strapdown.html.hbs</templatePath>
<outputPath>${project.build.directory}/generated/swagger-html/MoreREST.html</outputPath>
<swaggerDirectory>${project.build.directory}/generated/swagger-ui/</swaggerDirectory>
<securityDefinitions>
<securityDefinition>
<name>basicAuth</name>
<type>basic</type>
</securityDefinition>
</securityDefinitions>
<attachSwaggerArtifact>true</attachSwaggerArtifact>
<outputFormats>json</outputFormats>
</apiSource>
</apiSources>
</configuration>
<executions>
<execution>
<phase>compile</phase>
<goals>
<goal>generate</goal>
</goals>
</execution>
</executions>
</plugin>
</plugins>
</build>
It fails with
[ERROR] Failed to execute goal com.github.kongchen:swagger-maven-plugin:3.1.8:generate (default) on project MyRestServer: Execution default of goal com.github.kongchen:swagger-maven-plugin:3.1.8:generate failed: A required class was missing while executing com.github.kongchen:swagger-maven-plugin:3.1.8:generate: javax/servlet/ServletContext
[ERROR] -----------------------------------------------------
[ERROR] realm = plugin>com.github.kongchen:swagger-maven-plugin:3.1.8
[ERROR] strategy = org.codehaus.plexus.classworlds.strategy.SelfFirstStrategy>
[ERROR] urls[0] = file:/C:/Users/.m2/repository/com/github/kongchen/swagger-maven-plugin/3.1.8/swagger-maven-plugin-3.1.8.jar
[ERROR] Number of foreign imports: 1
[ERROR] import: Entry[import from realm ClassRealm[maven.api, parent: null]]
[ERROR]
[ERROR] -----------------------------------------------------
[ERROR] : javax.servlet.ServletContext
[ERROR] -> [Help 1]
I was referring alternate https://github.com/openapi-tools/swagger-maven-plugin plugin. But look like it also needs javax.* artifacts (https://search.maven.org/artifact/io.openapitools.swagger/swagger-maven-plugin/2.1.6/jar?eh=) We are currently using Swagger 2.0 and migrating to OpenAPI 3.x is not an option.
is there any maven plugin we can use or any hack we can perform to make the plugin work? Any help is appreciated.