How to customize WAR plugin in subproject in Gradle build script (Kotlin) - kotlin

I create a Gradle project with several sub-modules, and one module needs war plugin, I just want to customize the web app directory, but the code does not work:
apply {
plugin("war")
plugin("org.gretty")
}
// cannot work
tasks.getByName("war") {
from("src/main/webfiles")
}
// cannot work either
tasks.war {
webAppDirName = "src/main/webfiles"
}
//... other code
This is how I code in the sub-project subproject.gradle.kts file, How to solve this? Thanks for any help!

Solved with the code:
configure<WarPluginConvention>{
webAppDirName = "src/main/webfiles"
}

Related

How to setup my KorGE project to use Fleks ECS library?

I want to use Fleks ECS as shown in this example:
https://github.com/korlibs/korge-next/tree/main/samples/fleks-ecs
How to setup my KorGE project to be able to import the Fleks library?
I found that there is a built in function to import the Fleks into KorGE project.
Just configure the build.gradle.kts file as in the example below:
...
korge {
id = "com.example.mygame"
name = "My Game"
supportFleks()
targetJvm()
targetJs()
targetDesktop()
targetIos()
targetAndroidIndirect() // targetAndroidDirect()
}

Change Kotlin Javascript output directory

I have just started using Kotlin to produce Javascript, but cannot find a way to change the Javascript output directory.
This is specifically for a nodejs target, and using Gradle with Kotlin script.
There is an example given in the Kotlin docs for a browser target:
kotlin.target.browser {
distribution {
directory = File("$projectDir/output/")
}
}
but there does not seem to be an equivalent for kotlin.target.nodejs
This is now easy (Kotlin 1.40):
https://kotlinlang.org/docs/reference/js-project-setup.html#distribution-target-directory
kotlin {
js {
browser {
distribution {
directory = File("$projectDir/output/")
}
}
binaries.executable()
// . . .
}
}
Unfortunately, there are no possibilities to do this with NodeJS. I created an issue - https://youtrack.jetbrains.com/issue/KT-40416.

Disable eclipse plugins programmatically

I want to create my own update system and during update I need to remove some plugins but they are in use - how to disable it programmatically?
Get a BundleContext via the bundle activator of the plugin that should stop the other plugin/bundle and do something like:
for (Bundle bundle: bundleContext.getBundles()) {
if ("my.bundle.symbolic.name".equals(bundle.getSymbolicName())) {
bundle.stop();
break;
}
}
See also Bundle.stop(int options)

How to bundle a plugin which requires multiple files in order to work

I'm facing an issue when I try to bundle Aurelia-hammer with the CLI.
The app still keeps pulling hammer-swipe.js, hammer-tap.js,... from the node_modules folder.
When I inspect the plugin's AMD structure, these are defined as global resources:
function configure(frameworkConfig) {
frameworkConfig.globalResources('./hammer-swipe');
frameworkConfig.globalResources('./hammer-tap');
frameworkConfig.globalResources('./hammer-press');
frameworkConfig.globalResources('./hammer-hold');}
Is there any way to bundle these with the CLI? I tried adding these files to the "resources" element in aurelia.json without success.
the plugin author should export those classes: (HammerPressCustomAttribute...) so they could be traced properly. But you can dummy-import theme yourself as a workaround:
import { HammerPressCustomAttribute } from 'aurelia-hammer/hammer-press';
import { HammerSwipeCustomAttribute } from 'aurelia-hammer/hammer-swipe';
import { HammerTapeCustomAttribute } from 'aurelia-hammer/hammer-tap';
normally you have to do this as well:
import { HammerHoldCustomAttribute } from 'aurelia-hammer/hammer-hold';
but the class exported from hammer-hold.js is named HammerPressCustomAttribute (oops looks like copy-paste issue) so just reference the file even with a non existent class.
import { HammerHoldCustomAttribute } from 'aurelia-hammer/hammer-hold';
this should fix your problem (I hope). It's best to open an issue in the plugin repo and ask the author to export those classes (and rename the duplicate one).

Creating a package under source folder when developing an eclipse plugin

I am developing an Eclipse wizard that will be used for creating a project. I can create the folder hieararchy but I cannot create a package under "src" folder. I found this answer How to create packages (folders) in an Eclipse project via plugin here. However, it does not solve my problem. When I create a folder under "src" folder, eclipse does not recognize it as a package. How can I do this?
Try this using JDT API as below.
private void createPackage(IProject project) throws JavaModelException {
IJavaProject javaProject = JavaCore.create(project);
IFolder folder = project.getFolder("src");
// folder.create(true, true, null);
IPackageFragmentRoot srcFolder = javaProject
.getPackageFragmentRoot(folder);
IPackageFragment fragment = srcFolder.createPackageFragment(project.getName(), true, null);
}
for more help please access this link