Setting the type of a NetBeans Module - netbeans-7

I have been developing a couple of NetBeans modules in parallel using the NetBeans IDE. Yesterday (Dec. 12, 2012) the IDE updated and now I can not get any of them to manifest when I run the platform. The platform loads up with no errors but my modules do not appear. If I attempt to explicitly enable them I get:
java.lang.IllegalArgumentException: Not all requested modules can be enabled: [StandardModule:com.foo jarFile: D:\bar.jar]
at org.netbeans.ModuleManager.enable(ModuleManager.java:1024)
I see that the module.xml file looks like this:
<?xml version="1.0" encoding="UTF-8"?>
<nbm>
<!--
<moduleType>autoload</moduleType>
<codeNameBase>com.foo/1</codeNameBase>
<licenseName>Apache License, Version 2.0</licenseName>
<licenseFile>license.txt</licenseFile>
-->
</nbm>
This is all auto-generated and it looks to be commented out, but it looks like it was attempting to set the module as an autoload module. This is odd because it looks to me like the module is behaving as an autoload module.
So my question, which seems like it should be simple but I can't seem to figure out, how do I explicitly define the type of a module?

I think, that problem may be between module dependencies.
Open your module project
Remove all module dependencies
Check your selected NB platform (or change)
Add all your module dependencies
Clean and build and install your module again

Related

Plugin '*' is compatible with IntelliJ IDEA only because it doesn't define any explicit module dependencies

I am writing a small plugin for PhpStorm. During development, I run it in IDEA and everything works fine there. However, after I try to enable it in PhpStorm I get the following error:
Plugin 'name' is compatible with IntelliJ IDEA only because it doesn't define any explicit module dependencies
How can this problem be solved?
The documentation plugin compatibility says that if your plugin does not have module dependencies (built-in plugins that are non-removable parts of the IDE), then it is considered legacy and will load only in IDEA, as reported by the error message.
In order to fix this error, you need to explicitly add a dependency to one of the modules. For example, com.intellij.modules.platform:
Add the following line to plugin.xml:
<depends>com.intellij.modules.platform</depends>
And the plugin should load successfully in PhpStorm.

Kotlin/IntelliJ Modules with Shared Content Root

I'm working on a project in IntelliJ Idea using Kotlin. I'm trying to create a unit test for a Kotlin class, and I can create the class, except that when I run the test, I get an error that there is no JDK configured. I go into the project structure and change the JDK for the module, but when I click on Apply, I get a message saying that :
Content root
"C:\Users\2rtmar\Documents\xproject\xproject\examples\src\main" is
defined for modules "xproject-examples-utils_main" and
"xproject-examples-java_main". Two modules in a project cannot share
the same content root.
Another team member had said that these modules were faulty, and that they couldn't be used, but I'm not using them and still prevent me from running my code. I tried to unmark this module as a sources root, but did not fix the problem. I went as far as to removing the xproject\examples module entirely, but received the same message when trying to set the JDK of my module.
Any help is appreciated!
In my case I was trying to setup a multi-module Gradle project by adding a new module to my root Gradle project.
Despite adding an include ':my-submodule' to my settings.gradle, it
was always telling me gradle wrapper not found, because the submodule was kind of outside of the context of the root module.
This however is IntelliJ-specific
When I looked into Right-Click on module -> Open Module Settings - > Modules I was seeing the following hierarchy:
my-root
-> my-submodule
my-submodule
For whatever reason, IntelliJ has added the new module as a child and as a standalone module, and this caused the issue Two modules cannot have the same content root, as my-root:my-submodule and my-submodule are now both pointing to the same src/main directory.
This is IntelliJ's out of the box behaviour when adding a new
submodule, which is in my opinion totally wrong and likely a bug! You
cannot even fix it within the module settings
Solution
But I discovered a way to fix it.
Right-click on the module
Load/Unload Modules
Now unload the module that is not below the my-root
After that, there is just one single root pointing at the src directory and the active module is now within the parent's Gradle scope.
I hope Jetbrains fixes these issues. Those problems exist for a while now and are not pleasant to solve.
I got this issue recently.
The very first check should be to check if any other module with the same content root is added or not.[you can check this in Project Structure -> Modules]
If YES, remove the other project by clicking on - (minus) button at the top.
If you're using Intellij and have modified / are modifying the pom.xml files directly:
Go to the affected sources' pom.xml files
Go to the following area:
...
<build>
...
<resources>
<resource>
...
<directory>[DIRECTORY]</directory>
...
<includes>
...
</includes>
...
</resource>
</resources>
...
</build>
...
Change the [DIRECTORY] to something unique. For instance, I was referencing ../plugin-outputs. As such, I changed it to ../plugin-outputs/[specific sub-directory], wherein I named the sub directory as I wished.
Delete any "modules" listing the specific output directory. No, they aren't modules... however, they have the module icon applied to this, preventing the pom.xml files' changes to be updated while editing modules through the standard project structure tab.
I know this thread is 2 years old; however, there are MANY people who still read these artifacts... hopefully this helps someone.
-Dan

How to add org.eclipse.swt (and other plugin dependencies) as an automatic Java9 module?

In order to be able to use my Eclipse plugin "treezCore" also as a Java9 module I created a module-info.java in my src folder.
Furthermore, I moved the Plug-in Dependencies from the Classpath to the Modulepath. I can see a module "org.eclipse.swt.3.106.1.v20170926" in the plugin dependencies:
However, I am not able to reference that module in my module-info.java. I tried
require org.eclipse.swt.3.106.1.v20170926;
require org.eclipse.swt;
require swt;
None of those options worked. The jar file \plugins\org.eclipse.swt_3.106.1.v20170926-0519.jar that is used by Eclipse does not contain a module definition and
jar --file org.eclipse.swt_3.106.1.v20170926-0519.jar -d
says that the module descriptor can not be derived. Also see
Unable to derive module descriptor for auto generated module names in Java 9?
If I download a newer version of swt.jar from
http://download.eclipse.org/eclipse/downloads/drops4/R-4.7.1a-201710090410/download.php?dropFile=swt-4.7.1a-win32-win32-x86_64.zip
I get following output that looks promising:
swt automatic
requires java.base mandated
contains org.eclipse.swt
contains org.eclipse.swt.accessibility
contains org.eclipse.swt.awt
contains org.eclipse.swt.browser
contains org.eclipse.swt.custom
contains org.eclipse.swt.dnd
contains org.eclipse.swt.events
contains org.eclipse.swt.graphics
contains org.eclipse.swt.internal
contains org.eclipse.swt.internal.gdip
contains org.eclipse.swt.internal.image
contains org.eclipse.swt.internal.mozilla
contains org.eclipse.swt.internal.mozilla.init
contains org.eclipse.swt.internal.ole.win32
contains org.eclipse.swt.internal.opengl.win32
contains org.eclipse.swt.internal.webkit
contains org.eclipse.swt.internal.win32
contains org.eclipse.swt.layout
contains org.eclipse.swt.ole.win32
contains org.eclipse.swt.opengl
contains org.eclipse.swt.printing
contains org.eclipse.swt.program
contains org.eclipse.swt.widgets
I also depend on org.eclipse.jface and could not find a seperate download for it.
=> Do I really have to wait for a new release of Eclipse that uses new plugin versions including module definitions?
Or can I somehow reference the old version of swt from the plugins folder, even if it does not include a module definition? I looked for an easy way to define an alias or a fallback dependency e.g.
requires ../plugins/org.eclipse.swt_3.106.1.v20170926-0519.jar as 'org.eclipse.swt'
or
requires org.eclipse.swt fallback ../plugins/org.eclipse.swt_3.106.1.v20170926-0519.jar
but module-info.java does not seem to support such a syntax.
I have about 20 plugin dependencies and do not want to manually download each of them (if it would be possible) and include them as external jar file. Nor do I want to hack the individual Manifest/jar files in the Eclipse plugin folder. There are many jar files I would need to alter and an update of Eclipse would break that hack.
I am using Eclipse for RCP and RAP Developers, Version: Oxygen.1a Release (4.7.1a), Build id: 20171005-1200
Edit
When using Version: Photon Milestone 4 (4.8.0M4) Build id: 20171214-1849, the error in module-info.java vanishes when using
require org.eclipse.swt;
and having the Plug-in Dependencies in the Modulepath.
However, my imports do not work yet, see following image. If I move the Plug-in Dependencies from the Modulepath to the Classpath, the imports work but the error in module-info.java reappears.
I created a min example at
https://github.com/stefaneidelloth/Java9EclipsePluginExample/tree/master/MyPlugin
and I filed a bug report at
https://bugs.eclipse.org/bugs/show_bug.cgi?id=529089
Related questions:
How to use 3rd party library in Java9 module?
Unable to derive module descriptor for auto generated module names in Java 9?
Force Eclipse (Helios) to use a newer version of SWT at application runtime
JFace libraries stand-alone download (not picked from Eclipse plug-ins)
New Keywords in Java 9
What you observe is tracked in bug 525660, which starts with the observation that all existing (OSGi) artifacts of Eclipse don't work as automatic modules, because Java 9 fails to derive a valid module name from jar filenames of the shape org.eclipse.swt_3.106.1.v20170926-0519.jar.
Since this was discovered too late to request improving the algorithm for automatic module name derivation, this can only be fixed by adding Automatic-Module-Name headers to the manifests of future releases.
This header is present starting from Photon M4 as can be seen in org.eclipse.swt_3.107.0.v20171205-0742.jar, containing:
Automatic-Module-Name: org.eclipse.swt

Play 2 dependency on a local module in Intellij Idea

I am kind of new to PlayFramework 2 and can not figure out how to resolve play 2 application dependencies. I need to add dependency on a local module loaded in IntellijIdea, not a jar file or repository.
While adding module dependencies in Idea project setting works just fine and ide itself is able to resolve them (autocompletion, imports etc are working), when trying to run in play2, its compiler cannot resolve any dependencies.
I manually configured Build.scala (adding val appDependencies = Seq("" % "" % "")) but am puzzled as to what resolvers I should use. I cannot point to a jar file, as it is a work in progress and such a file should be updated too often. Doing so would defeat the whole purpose of managed dependencies.
Play's main build mechanism uses SBT, which needs to know how to find all sources required for the build. There are several options for this:
make your module an SBT project itself and publish it to your local ivy repository. However that might be somewhat complex at this stage, and would involve adding your local ivy repository to the resolvers and re-publishing every time you change something in the module
declare your module as a sub-project. Play's documentation describes the process of working with sub-projects, I think this is the way you'd like to try out since then the idea command on Play's console will generate the IntelliJ configuration for the main application and the module.

IntelliJ IDEA and PlayFramework modules

After a lot of good comment about IDEA, I decided to give it a try. I downloaded the Community Edition and would like to use it for PlayFramework development.
I have followed official documentation and some other information gathered around, but I have not succeeded completely. When using a project with differents (play) modules, the different classes are not found.
For example when using Secure module, IDEA keeps complaining about not finding Secure.class. It has to be a classpath issue. I tried to attach Java source & classes ($PLAY/modules/secure/) in module settings (F4), class is still not found. Did I miss something?
BTW, I have done a play dependencies and play idealize, which seems to add another module Secure into project in IDEA.
Thanks,
The answer is to run the following:
play deps
play idealize
This forces the IDEA .iml project file to be refreshed with the updated class path entries for the new module (in this case Secure).
A issue I came across using IntelliJ and Playframework.
The log4j.properties file or log4j.xml file are not in classpath by default. You have to add the conf as a source folder in module settings.
You need to add the Secure module you have created in IDEA as a dependency to the main application module:
Go to File -> Project Structure
Choose the main module
Choose the Dependencies tab
Click Add -> Module Dependency
Choose the IDEA Module you created for the Play Secure module
Also make sure you have the correct source path selected for the Secure module in IDEA.