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

added optional configuration param 'translationsFile' that can be use… #149

Merged
merged 9 commits into from
May 5, 2022

Conversation

treblereel
Copy link
Collaborator

…d to pass XTB translation file to closure compiler

Copy link
Member

@niloc132 niloc132 left a comment

Choose a reason for hiding this comment

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

Please add an integration test that confirms that this works, possibly building more than one locale if convenient.

@treblereel
Copy link
Collaborator Author

hmm, looks like i have to revert my last commit (useFileConfig fix) coz it leads to:

[ERROR] Failed to execute goal com.vertispan.j2cl:j2cl-maven-plugin:0.20-SNAPSHOT:test (test-js) on project test: Failed to run tests: Bad artifact coordinates src/main/java/org/treblereel/test/MyTranslationBundle.xtb, expected format is <groupId>:<artifactId>[:<extension>[:<classifier>]]:<version> -> [Help 1]

and it doesn't matter where i put MyTranslationBundle.xtb

@niloc132
Copy link
Member

That error comes when a) the string is first used as a set of maven coords, and if that fails, b) the string is used as a path to pick out a local file. The idea is that you might want to point at an external artifact

        public File readFile() {
            String pathOrCoords = readString();
            if (pathOrCoords == null) {
                return null;
            }
            File f;
            // try to resolve as maven coords first
            try {
                f = getFileWithMavenCoords(pathOrCoords);
            } catch (ArtifactResolutionException e) {
                // handle as a file instead
                f = new File(pathOrCoords);
            }
            log.debug(getPath() + " => " + f.getAbsolutePath());
            return f;
        }

Probably you need to specify ${project.baseDir}/src/... on your file, so that it is clear what the real path to the file is? I could see it being ambiguous, such as a generated xtb file from some other source, like merged properties files?


TranslationService.format = function () {
return MSG_SOMETHING_HAPPENED;
}
Copy link
Member

Choose a reason for hiding this comment

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

semicolon, trailing newline

*/
goog.provide('holder');
/** @define {string} */
holder.value = goog.define('holder.value', 'unknown');
Copy link
Member

Choose a reason for hiding this comment

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

trailing newline, copyright notice not required (following current repo conventions anyway - i might be wrong about it, but i'm not going to object if this file is copied without permission).

* 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.
*/
Copy link
Member

Choose a reason for hiding this comment

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

not required to put this in (and you seem inconsistent about where you add these?)

<module>pom_default.xml</module>
<module>pom_cz.xml</module>
<module>pom_fr.xml</module>
</modules>
Copy link
Member

Choose a reason for hiding this comment

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

consider one more project with three blocks, one for each test, each with its own block to specify the expected file, path

Copy link
Member

Choose a reason for hiding this comment

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

This is what I'm talking about, more than one execution in the same pom file, with different xtb file and local specified per execution - so that the user doesnt have to copy the whole pom file, just the execution.

@treblereel
Copy link
Collaborator Author

@niloc132 thanks for youe reviews, now it works well with your #152 so i am going to rebase this branch with it once it ll be merged.

  • removed useless elemental2-dom
  • packages renamed to example.test
  • translation folder renamed to translationsFile
  • fixed typos
  • added more test cases

…d to pass XTB translation file to closure compiler
* removed useless elemental2-dom
* packages renamed to example.test
* translation folder renamed to translationsFile
* fixed typos
* added more test cases
@Override
public Optional<File> getTranslationsFile() {
ConfigValueProvider.ConfigNode node = config.findNode("translationsFile");
if (node == null) {
Copy link
Member

Choose a reason for hiding this comment

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

your call here, but you could drop the null check if you just used ofNullable below ;)

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

old school, forever old school :)


<build>
<resources>
<resource>
Copy link
Member

Choose a reason for hiding this comment

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

i dont understand what purpose this serves? might be necessary if you put the translations file into a jar, but not requires in this project right?

@@ -54,6 +54,7 @@ public Task resolve(Project project, Config config) {
Collections.emptyList(),
Collections.emptyMap(),
Collections.emptyList(),
config.getTranslationsFile(),
Copy link
Member

Choose a reason for hiding this comment

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

This won't work I think, it should error out actually - did you confirm that BUNDLE_JAR behaves when there is a translations file?

Copy link
Member

Choose a reason for hiding this comment

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

So two notes, first of all you can never make calls on config inside the lambda - it should error out (and i'm surprised it doesn't even with a non-empty translations file... worth looking into, that means nulls don't affect the cache), and second this is a BUNDLE so you should just give it Optional.empty()

@@ -96,6 +96,7 @@ public Task resolve(Project project, Config config) {
Collections.emptyList(),
Collections.emptyMap(),
Collections.emptyList(),//TODO actually pass these in when we can restrict and cache them sanely
config.getTranslationsFile(),
Copy link
Member

Choose a reason for hiding this comment

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

as with JsZipBundleTask this shouldnt work, replace with Optional.empty()

@@ -244,6 +244,9 @@
@Parameter(defaultValue = "false")
protected boolean enableSourcemaps;

@Parameter
Copy link
Member

Choose a reason for hiding this comment

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

docs? can follow up in a later release, but it should be the same as BuildMojo

Copy link
Member

Choose a reason for hiding this comment

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

technically this property should be added to WatchMojo too, so that it is doc'd correctly, and can be set at the parent - see how languageOut, checkAssertions, rewritePolyfills are all declared but unused

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

are we going to run WatchMojo in advanced mode ? anyway, i ll add it

Copy link
Member

Choose a reason for hiding this comment

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

Yes, that's a thing, I'm not going to tell people they can't do it...

Copy link
Member

Choose a reason for hiding this comment

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

Reading it now, it looks like you did miss WatchMojo?

@@ -112,6 +114,15 @@ public boolean compile(
jscompArgs.add(extern);
}

translationsFile.ifPresent(file -> {
if(compilationLevel.equals(CompilationLevel.ADVANCED_OPTIMIZATIONS)) {
Copy link
Member

Choose a reason for hiding this comment

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

stupid question perhaps, but are we sure this doesnt work with other modes?

...with that said, I dont think WHITESPACE_ONLY works at all right now, and I think SIMPLE is broken on windows

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

@niloc132 in this case we should create a check list of available modes and test PR againt them. I think, we can allow translationFiles to work with ADVANCED mode only.

Copy link
Member

Choose a reason for hiding this comment

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

Sounds good, defer it to another issue?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

yes, i think so

@treblereel treblereel added this to the 0.20 milestone Apr 19, 2022
@treblereel treblereel added the enhancement New feature or request label Apr 19, 2022
@treblereel treblereel self-assigned this Apr 19, 2022
@niloc132
Copy link
Member

I approved this, but please be sure to file that issue.

@niloc132 niloc132 merged commit 4f092d0 into Vertispan:main May 5, 2022
treblereel added a commit to treblereel/j2clmavenplugin that referenced this pull request May 6, 2022
…ertispan#149)

Closure-library offers some i18n features that closure-compiler will
support at compile time by replacing strings based on the selected
locale. This patch passes the required .xtb file to the closure
compiler so that projects which use this feature can be specialized
per-locale. With Vertispan#119, this could get more efficient, by optionally
breaking up stage 3 closure compiler work into its own task.
treblereel added a commit to treblereel/j2clmavenplugin that referenced this pull request Jun 3, 2022
…ertispan#149)

Closure-library offers some i18n features that closure-compiler will
support at compile time by replacing strings based on the selected
locale. This patch passes the required .xtb file to the closure
compiler so that projects which use this feature can be specialized
per-locale. With Vertispan#119, this could get more efficient, by optionally
breaking up stage 3 closure compiler work into its own task.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants