-
im trying to use this plugin in a java project, i already have a java to typescript generator, so i only need the pubish capabilities of this plugin im struggling to make it work in my groovy gradle project.
the plugin configuration is as it sttes in the guide:
|
Beta Was this translation helpful? Give feedback.
Replies: 18 comments 12 replies
-
That's odd since registries method takes groovy Action object as an argument. From your report I see one inconsistency: your config uses "npmPublish" block as appropriate, but error log mentions "npmPublishing" which is old and incorrect. Could you double check that the dsl config you've sent is what you actually have in your project? |
Beta Was this translation helpful? Give feedback.
-
Also the package is from v2 of the plugin as well. Could you make sure you're using the latest version of the plugin as well? |
Beta Was this translation helpful? Give feedback.
-
ok so i did take the wrong dependency from maven repo and after i got the right version it still didnt work and i found out why I was taking the example code from youre website documntation: which states the code block as: while the readme file in github states the right syntax of: anyway i have another issue now: i copied your quick start: and i swap the url to my own companys registry but i get this error:
do you mind explaining what should i set instead of npmjs? if i dont pubish it to some public repo but to my own companys private nexus server |
Beta Was this translation helpful? Give feedback.
-
Thnks for spotting typo in the docs! As for your registry issue, the "npmjs" bit is just a domain oblect name and as such can be any string. Not sure why it's crashing though since error log does not orovide much info. I'll try to reproduce it myself tomorrow and get back to you. |
Beta Was this translation helpful? Give feedback.
-
Oh, wait. I know what's up. You're passing in string when an instance of uri is expected. See here https://npm-publish.petuska.dev/3.1/user-guide/quick-start/#__codelineno-0-16 |
Beta Was this translation helpful? Give feedback.
-
Also noticed that kotlin/js tab sample is incorrect as well |
Beta Was this translation helpful? Give feedback.
-
ok that did the trick! now the gradle is compiling. but for some reason i cant see the task 'publishJsPackageToNpmjsRegistry' when doing tasks command on my subproject. infact, any of the listed commands arent on my project... ill show you my entire gradle structure ( no kotlin involved) now i needed to add the ability to publish those generated typescript classes to my private npm i create a new plugin that will contain both your plugin and the typescript plugin to make the developers life easier i made this intro just so you'll understand the structure buildSrc build.gradle
myPlugin.gradle (inside buildSrc module)
this thing compiles succesfully but a subproject that has
when i run tasks on it i dont have the tasks listed and of course when i run Sorry if its way 2 detailed... thanks in advance |
Beta Was this translation helpful? Give feedback.
-
Well you only declared a registry so far. So you told the plugin where to publish, but not what to publish. You need to declare a package too and attach all the files you'd like to publish via its files{} api. The reason it's optional for kotlin js projects is that the plugin autoconfigures a package for each of your kotlin.js target. |
Beta Was this translation helpful? Give feedback.
-
See here https://npm-publish.petuska.dev/3.1/user-guide/quick-start/#__codelineno-2-7 "Standalone" tab is what applies to you. |
Beta Was this translation helpful? Give feedback.
-
ahhh now i understand.... so i added the needed configuration, but the rest i need generated. i made the gradle compile but still i cant see the relevant tasks
this is basically all the info i have... i didnt understand this step:
i simply have a .ts file i want to publish, i dont have a package.json, can the plugin generate it for me? |
Beta Was this translation helpful? Give feedback.
-
You're almost there. However you need to register a package (just like you did with registry) and cofigure it inside there. Key options you'll need to touch are files{}, version main and moduleName |
Beta Was this translation helpful? Give feedback.
-
I have the tasks! i simply forgot the put the register("js")!
and now im looking here and regardless of that - when i run the task it complains about diffrerent values
|
Beta Was this translation helpful? Give feedback.
-
ooohhh i have to run the assemble and pack tasks first? and theres no default for the pack task so i have to manually register it and put the sourcepackagedir! i will try it and update here |
Beta Was this translation helpful? Give feedback.
-
Ok, few things left. packageName is indeed what I meant with moduleName and it's required otherwise you won't be able to install the package later. As for making sure your package files are built and ready for assembly, I recommend just adding whatever task is generating those files as a dependency to your package's assembly task. |
Beta Was this translation helpful? Give feedback.
-
Is your project oss btw? I'm happy to have a look and raise a PR for you with optimal config. |
Beta Was this translation helpful? Give feedback.
-
no unfortunately its not, but im super close and i really really appreciate your help! edit: never mind it was the dry option! i manage to pack it! now im checking the actual publish! |
Beta Was this translation helpful? Give feedback.
-
Can you try this config instead? Hopefully it will make more sense with a specific example. tasks {
// This is just a stub to imitate your ts generation task
register("generateJsFile") {
val outDir = buildDir.resolve("genJs")
// Note that it declares outputs
outputs.dir(outDir)
doFirst {
outDir.mkdirs()
buildDir.resolve("genJs/custom.js").writeText("console.log('hello world')")
}
}
}
npmPublish {
nodeHome.set(File("${System.getProperty("user.home")}/.gradle/nodejs/node-v16.13.0-linux-x64/"))
packages {
register("myPrivatePackage") {
version.set("4.20.69")
packageName.set("my-private-package")
files {
// Since the task declares outputs, we can just source directly from it
// Additionally, it will also add it as a dependency to relevant npm-publish tasks automatically
from(tasks.named("generateJsFile"))
}
}
}
registries {
register("nexus") {
uri.set(uri("http://companynexus"))
authToken.set("obfuscated")
}
}
} |
Beta Was this translation helpful? Give feedback.
-
i tired your suggestion but it didnt work, i will share my current working configuration:
im just waiting for my dev ops guy to send me the actual authkey once ill upload the first package i will try and beautify everything and adjust farther to my needs, i need to assemble and pack from multiple subprojects into one package and only then upload it. and in the end i want to depend the java project publish to those tasks so every publish the js files will also be published |
Beta Was this translation helpful? Give feedback.
Can you try this config instead? Hopefully it will make more sense with a specific example.