Skip to content
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

updated PegasusPlugin to still register restModel tasks even if IDL files dir is empty #924

Merged
merged 2 commits into from
Jul 21, 2023
Merged
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
7 changes: 6 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,10 @@ and what APIs have changed, if applicable.

## [Unreleased]

## [29.43.9] - 2023-07-18
- add `rest.idl.processEmptyIdlDir` property in `PegasusPlugin` to support IDL files auto generation
- If this property is true, plugin will create rest client gradle tasks even if IDL dir is empty.

## [29.43.8] - 2023-07-13
- Add support for gRPC-downstream extension annotations (`@grpcExtension`, `@grpcService`).

Expand Down Expand Up @@ -5502,7 +5506,8 @@ patch operations can re-use these classes for generating patch messages.

## [0.14.1]

[Unreleased]: https://github.com/linkedin/rest.li/compare/v29.43.8...master
[Unreleased]: https://github.com/linkedin/rest.li/compare/v29.43.9...master
[29.43.9]: https://github.com/linkedin/rest.li/compare/v29.43.8...v29.43.9
[29.43.8]: https://github.com/linkedin/rest.li/compare/v29.43.7...v29.43.8
[29.43.7]: https://github.com/linkedin/rest.li/compare/v29.43.6...v29.43.7
[29.43.6]: https://github.com/linkedin/rest.li/compare/v29.43.5...v29.43.6
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -562,6 +562,7 @@ public class PegasusPlugin implements Plugin<Project>
private static final Pattern TEST_DIR_REGEX = Pattern.compile("^(integ)?[Tt]est");
private static final String SNAPSHOT_NO_PUBLISH = "rest.model.noPublish";
private static final String SNAPSHOT_FORCE_PUBLISH = "rest.model.forcePublish";
private static final String PROCESS_EMPTY_IDL_DIR = "rest.idl.processEmptyIdlDir";
private static final String IDL_NO_PUBLISH = "rest.idl.noPublish";
private static final String IDL_FORCE_PUBLISH = "rest.idl.forcePublish";
private static final String SKIP_IDL_CHECK = "rest.idl.skipCheck";
Expand Down Expand Up @@ -1991,11 +1992,11 @@ protected void configureRestClientGeneration(Project project, SourceSet sourceSe
{
// idl directory for api project
File idlDir = project.file(getIdlPath(project, sourceSet));
if (SharedFileUtils.getSuffixedFiles(project, idlDir, IDL_FILE_SUFFIX).isEmpty())
if (SharedFileUtils.getSuffixedFiles(project, idlDir, IDL_FILE_SUFFIX).isEmpty() && !isPropertyTrue(project,
PROCESS_EMPTY_IDL_DIR))
{
return;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

will there be downsides for packing an empty jar?

why will you need a jar that is empty? Can your logic assume it empty when it doesn't exist?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

no downsides or compatibility issues. just some negligible space will be used for PDL only projects to publish empty jars.
We will never use the empty jar. only the jars with IDL/ restmodels will be used by clients.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

updated PR as per offline discussion @junchuanwang @mchen07

}

File generatedRestClientDir = project.file(getGeneratedDirPath(project, sourceSet, REST_GEN_TYPE)
+ File.separatorChar + "java");

Expand Down
2 changes: 1 addition & 1 deletion gradle.properties
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
version=29.43.8
version=29.43.9
group=com.linkedin.pegasus
org.gradle.configureondemand=true
org.gradle.parallel=true
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@

package com.linkedin.restli.tools.idlgen;


import com.linkedin.pegasus.generator.GeneratorResult;
import com.linkedin.restli.common.RestConstants;
import com.linkedin.restli.internal.server.model.ResourceModel;
Expand All @@ -27,22 +26,16 @@
import com.linkedin.restli.restspec.RestSpecCodec;
import com.linkedin.restli.server.RestLiConfig;
import com.linkedin.restli.server.util.FileClassNameScanner;

import java.io.File;
import java.io.FileOutputStream;
import java.io.IOException;
import java.io.PrintWriter;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collection;
import java.util.Collections;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.Map.Entry;

import org.apache.commons.io.output.NullWriter;
import org.apache.commons.lang.StringUtils;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

Expand All @@ -59,7 +52,7 @@ public class RestLiResourceModelExporter

/**
* @param apiName the name of the API
* @param classpath classpath to to load the resources. this is purely for Javadoc Doclet {@link RestLiDoclet}
* @param classpath classpath to load the resources. this is purely for Javadoc Doclet {@link RestLiDoclet}
* @param sourcePaths paths to scan for resource Java source files. this is purely for Javadoc Doclet {@link RestLiDoclet}
* @param resourcePackages packages to scan for resources
* @param outdir directory in which to output the IDL files
Expand Down Expand Up @@ -110,7 +103,7 @@ public GeneratorResult export(String apiName,

/**
* @param apiName the name of the API
* @param classpath classpath to to load the resources. this is purely for Javadoc Doclet {@link RestLiDoclet}
* @param classpath classpath to load the resources. this is purely for Javadoc Doclet {@link RestLiDoclet}
* @param sourcePaths paths to scan for resource Java source files. this is purely for Javadoc Doclet {@link RestLiDoclet}
* if both resourcePackages and resourceClasses is null, all classes defined in the directories will be scanned
* @param resourcePackages packages to scan for resources
Expand Down
Loading