From 800a6d7ba5af745ad5677972b01a7911fe7214ed Mon Sep 17 00:00:00 2001 From: Damian Jankowski Date: Fri, 13 Nov 2026 09:27:46 +0100 Subject: [PATCH] build: reduce Maven Central release size Cut the per-release upload to Maven Central from ~51 MB to ~23 MB: - stop publishing swagger-generator: exclude it from the Central Portal bundle via the central-publishing plugin's excludeArtifacts (the plugin ignores maven.deploy.skip). The WAR is only consumed by the swagger-generator Docker images, which are built from target/, and it is not usable as a library dependency. The module is still built. - exclude resources from sources jars: the templates already ship in the main jar, which made swagger-codegen-sources.jar ~3 MB instead of 0.5 MB - slim the CLI shaded jar by removing lambdaj (and with it hamcrest-all, cglib and objenesis); its uses in Langs and Meta are replaced with Java 8 streams - remove commented-out formatter and checkstyle config from the root pom --- modules/swagger-codegen-cli/pom.xml | 5 -- .../java/io/swagger/codegen/cmd/Langs.java | 12 ++-- .../java/io/swagger/codegen/cmd/Meta.java | 69 ++++++++----------- pom.xml | 48 +++---------- 4 files changed, 45 insertions(+), 89 deletions(-) diff --git a/modules/swagger-codegen-cli/pom.xml b/modules/swagger-codegen-cli/pom.xml index 4b0f1731d82..a0a022036e8 100644 --- a/modules/swagger-codegen-cli/pom.xml +++ b/modules/swagger-codegen-cli/pom.xml @@ -85,11 +85,6 @@ airline 0.9 - - com.googlecode.lambdaj - lambdaj - 2.3.3 - org.slf4j slf4j-simple diff --git a/modules/swagger-codegen-cli/src/main/java/io/swagger/codegen/cmd/Langs.java b/modules/swagger-codegen-cli/src/main/java/io/swagger/codegen/cmd/Langs.java index 007da38d2f6..559beda5c67 100644 --- a/modules/swagger-codegen-cli/src/main/java/io/swagger/codegen/cmd/Langs.java +++ b/modules/swagger-codegen-cli/src/main/java/io/swagger/codegen/cmd/Langs.java @@ -1,11 +1,12 @@ package io.swagger.codegen.cmd; -import ch.lambdaj.collection.LambdaIterable; import io.airlift.airline.Command; import io.swagger.codegen.CodegenConfig; -import static ch.lambdaj.Lambda.on; -import static ch.lambdaj.collection.LambdaCollections.with; +import java.util.List; +import java.util.stream.Collectors; +import java.util.stream.StreamSupport; + import static java.util.ServiceLoader.load; /** @@ -15,8 +16,9 @@ public class Langs implements Runnable { @Override public void run() { - LambdaIterable langs = - with(load(CodegenConfig.class)).extract(on(CodegenConfig.class).getName()); + List langs = StreamSupport.stream(load(CodegenConfig.class).spliterator(), false) + .map(CodegenConfig::getName) + .collect(Collectors.toList()); System.out.printf("Available languages: %s%n", langs); } } diff --git a/modules/swagger-codegen-cli/src/main/java/io/swagger/codegen/cmd/Meta.java b/modules/swagger-codegen-cli/src/main/java/io/swagger/codegen/cmd/Meta.java index b8fe42f3853..22f1a5ee574 100644 --- a/modules/swagger-codegen-cli/src/main/java/io/swagger/codegen/cmd/Meta.java +++ b/modules/swagger-codegen-cli/src/main/java/io/swagger/codegen/cmd/Meta.java @@ -1,6 +1,5 @@ package io.swagger.codegen.cmd; -import ch.lambdaj.function.convert.Converter; import com.google.common.base.CaseFormat; import com.google.common.collect.ImmutableList; import com.google.common.collect.ImmutableMap; @@ -20,7 +19,6 @@ import java.util.List; import java.util.Map; -import static ch.lambdaj.collection.LambdaCollections.with; import static com.google.common.base.Joiner.on; /** @@ -79,51 +77,44 @@ public void run() { .put("swaggerCodegenVersion", swaggerVersion).build(); - with(supportingFiles).convert(processFiles(targetDir, data)); + DefaultGenerator generator = new DefaultGenerator(); + supportingFiles.forEach(f -> processFile(generator, f, targetDir, data)); } /** - * Converter method to process supporting files: execute with mustache, or simply copy to - * destination directory + * Processes a supporting file: execute with mustache, or simply copy to destination directory * + * @param generator - generator used to read templates + * @param support - supporting file to process * @param targetDir - destination directory * @param data - map with additional params needed to process templates - * @return converter object to pass to lambdaj */ - private static Converter processFiles(final File targetDir, - final Map data) { - return new Converter() { - private DefaultGenerator generator = new DefaultGenerator(); - - @Override - public File convert(SupportingFile support) { - try { - File destinationFolder = - new File(new File(targetDir.getAbsolutePath()), support.folder); - File outputFile = new File(destinationFolder, support.destinationFilename); - - String template = - generator.readTemplate(new File(TEMPLATE_DIR_CLASSPATH, - support.templateFile).getPath()); - String formatted = template; - - if (support.templateFile.endsWith(MUSTACHE_EXTENSION)) { - LOGGER.info("writing file to {}", outputFile.getAbsolutePath()); - formatted = - Mustache.compiler().withLoader(loader(generator)).defaultValue("") - .compile(template).execute(data); - } else { - LOGGER.info("copying file to {}", outputFile.getAbsolutePath()); - } - - FileUtils.writeStringToFile(outputFile, formatted, StandardCharsets.UTF_8); - return outputFile; - - } catch (IOException e) { - throw new RuntimeException("Can't generate project", e); - } + private static void processFile(DefaultGenerator generator, SupportingFile support, + final File targetDir, final Map data) { + try { + File destinationFolder = + new File(new File(targetDir.getAbsolutePath()), support.folder); + File outputFile = new File(destinationFolder, support.destinationFilename); + + String template = + generator.readTemplate(new File(TEMPLATE_DIR_CLASSPATH, + support.templateFile).getPath()); + String formatted = template; + + if (support.templateFile.endsWith(MUSTACHE_EXTENSION)) { + LOGGER.info("writing file to {}", outputFile.getAbsolutePath()); + formatted = + Mustache.compiler().withLoader(loader(generator)).defaultValue("") + .compile(template).execute(data); + } else { + LOGGER.info("copying file to {}", outputFile.getAbsolutePath()); } - }; + + FileUtils.writeStringToFile(outputFile, formatted, StandardCharsets.UTF_8); + + } catch (IOException e) { + throw new RuntimeException("Can't generate project", e); + } } /** diff --git a/pom.xml b/pom.xml index f4af9990d67..6919cfe2053 100644 --- a/pom.xml +++ b/pom.xml @@ -62,50 +62,10 @@ net.revelc.code formatter-maven-plugin - - LF - org.apache.maven.plugins maven-surefire-plugin @@ -178,6 +138,10 @@ org.apache.maven.plugins maven-source-plugin ${maven-source-plugin-version} + + + true + attach-sources @@ -218,6 +182,10 @@ true published 3600 + + + swagger-generator +