-
Notifications
You must be signed in to change notification settings - Fork 167
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
Added support to customizable the projectFileExtensions
.
#19550
Changes from all commits
b74c97b
23df89c
3b80e08
6123290
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -278,6 +278,13 @@ public abstract class VaadinFlowPluginExtension @Inject constructor(private val | |
|
||
public abstract val cleanFrontendFiles: Property<Boolean> | ||
|
||
/** | ||
* The list of extra file extensions that are considered project files. | ||
* Hashes are calculated for these files as part of detecting if a new prod | ||
* bundle should be generated. | ||
*/ | ||
public abstract val extraProjectFileExtensions: ListProperty<String> | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I'm still not convinced by the setting name. It still seems too generic to me. @mshabarov what do you think? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
|
||
|
||
public fun filterClasspath(@DelegatesTo(value = ClasspathFilter::class, strategy = Closure.DELEGATE_FIRST) block: Closure<*>) { | ||
block.delegate = classpathFilter | ||
block.resolveStrategy = Closure.DELEGATE_FIRST | ||
|
@@ -427,6 +434,10 @@ public class PluginEffectiveConfiguration( | |
|
||
public val cleanFrontendFiles: Property<Boolean> = extension.cleanFrontendFiles | ||
.convention(true) | ||
|
||
public val extraProjectFileExtensions: ListProperty<String> = extension.extraProjectFileExtensions | ||
.convention(emptyList()) | ||
|
||
/** | ||
* Finds the value of a boolean property. It searches in gradle and system properties. | ||
* | ||
|
@@ -476,6 +487,7 @@ public class PluginEffectiveConfiguration( | |
"frontendHotdeploy=${frontendHotdeploy.get()}," + | ||
"reactEnable=${reactEnable.get()}," + | ||
"cleanFrontendFiles=${cleanFrontendFiles.get()}" + | ||
"extraProjectFileExtensions=${extraProjectFileExtensions.get()}" + | ||
")" | ||
public companion object { | ||
public fun get(project: Project): PluginEffectiveConfiguration = | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -25,6 +25,7 @@ | |
import java.net.URISyntaxException; | ||
import java.nio.file.Path; | ||
import java.nio.file.Paths; | ||
import java.util.Collections; | ||
import java.util.List; | ||
import java.util.Set; | ||
import java.util.function.Function; | ||
|
@@ -232,6 +233,9 @@ public abstract class FlowModeAbstractMojo extends AbstractMojo | |
@Parameter(property = InitParameters.REACT_ENABLE, defaultValue = "${null}") | ||
private Boolean reactEnable; | ||
|
||
@Parameter(defaultValue = "${null}") | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I would add a There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Also, the field needs Javadoc. IIRC they are used for maven goal documentation |
||
private List<String> extraProjectFileExtensions; | ||
|
||
/** | ||
* Generates a List of ClasspathElements (Run and CompileTime) from a | ||
* MavenProject. | ||
|
@@ -522,4 +526,14 @@ public boolean isReactEnabled() { | |
File frontendDirectory = BuildFrontendUtil.getFrontendDirectory(this); | ||
return FrontendUtils.isReactRouterRequired(frontendDirectory); | ||
} | ||
|
||
@Override | ||
public List<String> extraProjectFileExtensions() { | ||
if (extraProjectFileExtensions != null) { | ||
return extraProjectFileExtensions; | ||
} | ||
|
||
return Collections.emptyList(); | ||
} | ||
|
||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -326,4 +326,11 @@ default Lookup createLookup(ClassFinder classFinder) { | |
* router and excluding React dependencies | ||
*/ | ||
boolean isReactEnabled(); | ||
|
||
/** | ||
* Get the list of project file extensions. | ||
* | ||
* @return list of project file extensions | ||
Comment on lines
+331
to
+333
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. We should add a note on the expected extension format here (e.g. no initial dot) with a simple example list. |
||
*/ | ||
List<String> extraProjectFileExtensions(); | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -82,6 +82,8 @@ public class Options implements Serializable { | |
|
||
private boolean compressBundle = true; | ||
|
||
private List<String> extraProjectFileExtensions = null; | ||
|
||
/** | ||
* The node.js version to be used when node.js is installed automatically by | ||
* Vaadin, for example <code>"v16.0.0"</code>. Defaults to | ||
|
@@ -954,4 +956,26 @@ public Options withCleanOldGeneratedFiles(boolean clean) { | |
public boolean isCleanOldGeneratedFiles() { | ||
return cleanOldGeneratedFiles; | ||
} | ||
|
||
/** | ||
* Sets the extra project file extensions. | ||
* | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. We need to provide additional detail on the expected extension format and perhaps a simple example |
||
* @param extraProjectFileExtensions | ||
* the project file extensions | ||
* @return this builder | ||
*/ | ||
public Options withExtraProjectFileExtensions( | ||
List<String> extraProjectFileExtensions) { | ||
this.extraProjectFileExtensions = extraProjectFileExtensions; | ||
return this; | ||
} | ||
|
||
/** | ||
* Gets the project file extensions. | ||
* | ||
* @return the project file extensions | ||
*/ | ||
public List<String> getExtraProjectFileExtensions() { | ||
return extraProjectFileExtensions; | ||
} | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -22,10 +22,14 @@ | |
import java.io.UncheckedIOException; | ||
import java.net.URL; | ||
import java.nio.charset.StandardCharsets; | ||
import java.util.Collections; | ||
import java.util.Optional; | ||
import java.util.Set; | ||
import java.util.stream.Collectors; | ||
|
||
import org.apache.commons.io.FileUtils; | ||
import org.apache.commons.io.IOUtils; | ||
import org.atmosphere.util.StringEscapeUtils; | ||
import org.slf4j.Logger; | ||
import org.slf4j.LoggerFactory; | ||
|
||
|
@@ -127,7 +131,17 @@ private void createGeneratedConfig() throws IOException { | |
.replace("#webComponentTags#", | ||
webComponentTags == null || webComponentTags.isEmpty() | ||
? "" | ||
: String.join(";", webComponentTags)); | ||
: String.join(";", webComponentTags)) | ||
.replace("#extraProjectFileExtensions#", Optional | ||
.ofNullable(options.getExtraProjectFileExtensions()) | ||
.orElse(Collections.emptyList()).stream().map(ext -> { | ||
try { | ||
return "'" + StringEscapeUtils.escapeJava(ext) | ||
+ "'"; | ||
Comment on lines
+139
to
+140
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. It looks like to me that |
||
} catch (Exception e) { | ||
throw new RuntimeException(e); | ||
} | ||
}).collect(Collectors.joining(", "))); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The result of this string seems not correct; it will be appended to the existing list without a coma.
An option could be the following, for example
|
||
template = updateFileSystemRouterVitePlugin(template); | ||
|
||
FileIOUtils.writeIfChanged(generatedConfigFile, template); | ||
|
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.
We should add a note on expected extension format and a simple example list.