Been looking around on <kotlinlang.org> to know wh...
# javascript
h
Been looking around on kotlinlang.org to know where gradle will output different files when compiling/building, but can't see it specified anywhere. After a build, the
build/
folder has .js files all over the place. Can anyone point me to a readable table that specifies which files are where after a build? There seems to be "raw" js files and DCE'ed js files, of course, but alas, several of them and in different sub folders. Some may be only drafts while others (hopefully only one of each) are the final compiled .js files ...
b
No table, but main directories are rootProject.buildDir/js/packages & project.buildDir/distributions
One contains dce outputs, other webpack output
h
Thanks! Actually, in /build/js/packages/projectname/kotlin-dce/, I find kotlin.js, supportlibrary.js and projectname.js in files that are probably DCE'ed (judging by the folder name), and in /build/distributions, there is one single projectname.js file. Can I assume then, that this latter file is a concatenation of the other three?
b
Later file is your final output after webpack does its magic. Essentially the one you want to deploy with your html
If your project is a library, however, I recommend using npm-publish plugin to assemble all required files for you
💯 1
❤️ 1
h
Looks really neat, but I can't easily figure out how to publish an artifact to my own Sonatype Nexus repository. Shouldn't it be as simple as stating
repository("private ") { registry = ... }
? Also, is there a way to pass credentials as username/pw instead of an authToken?
b
it is as simple as
repository("private ") { registry = ... }
. As for credentials, it currently supports only authToken I'm affraid 😕
But you can publish plugin's output manually
run
gradle assembleJsPublication
and then run
npm publish
in
build/publications/npm/js
Can you not generate authToken for your Sonartype repo? It's a recommended approach for npm authorisation.
Otherwise I could look into adding support for basic authorization next week
h
Well, I should check the token approach in the meanwhile.
But there is one more thing, and that is
Could not find method repository() for arguments [Sannsyn common, build_136xq3q0kc9r5h6esiv5m49l5$_run_closure4$_closure25$_closure26@7d7e491d] on NpmRepository container of type org.gradle.api.internal.FactoryNamedDomainObjectContainer.
This is when trying to use the very first, minimal example in the readme on https://gitlab.com/lt.petuska/npm-publish ...
b
Odd, can you send me your gradlefile?
I suspect you're using groovy. Examples in the repo are for kotlin (should probably indicate that better)
h
Yes, Groovy. So it's a simple syntax problem?
b
For groovy you should be able to use create("name") {} instead of repository ("name") {}
h
Well, converting to .kts is too much work. So just using
create
instead of
repository
helped a lot.
b
Thought so 😀 so everything is working now?
h
Yes and no. I'm sure your stuff works well, but I'm going to get my old thing working, where I construct a webjar (because the project that depends on this, assumes it's a webjar). And on my way to that webjar, I concatenate all the files (dependencies) into one and run them through the Google Closure Compiler.
But at least now I find my way through Gradle's output folders and know what files to grab. Thanks again.
b
Sounds reasonable. Glad I could help! You can check out this repo for an example how to quickly setup your web-jars