kelemen / netbeans-gradle-project

This project is a NetBeans plugin able to open Gradle based Java projects. The implementation is based on Geertjan Wielenga's plugin.
170 stars 57 forks source link

How to build this plugin offline? #410

Open emilianbold opened 5 years ago

emilianbold commented 5 years ago

Hello,

I successfully built the plugin but it downloaded a whole lot of JARs, including files from bits.netbeans.org/trunk.

With Maven we have the nbm-maven-plugin populate task which populates locally the JARs from an existing NetBeans build.

I wonder if something like that exists for Gradle too? I don't want the build to download all those stale JARs, I have a local NetBeans build and I want the compilation to use my JARs.

Is there some way to do this?

giulianisanches commented 5 years ago

I think that one way to do this could be to create a new property in gradle.properties (or adapt the existing one that points out to the netbeans executable) to represent the netbeans home (lets call it netbeans.home :) ).

Adapt the netbeansApi / netbeansModule functions that are defined into the build.gradle to check if this property exists and if so use something like files or fileTree to add the needed jars to the build process.

Another solution could be to use flatDirs inside the repositories.

As soon as possible, I will try to implement and test this.

kelemen commented 5 years ago

I don't know if there is a simple way to do this as the nbm plugin does not support it. Also, I'm only mildly familiar with the nbm building process, so I'm not sure what exactly should be done to properly populate manifest.mf and info.xml (I don't know if there is anything else).

giulianisanches commented 5 years ago

Yep. It's not being a easy task (at last for me) to find out how to use my CoolBeans installation to build the gradle plugin, but i will try to find out how to do this.

giulianisanches commented 5 years ago

Just to let my efforts logged here, what i did so far (besides read a lot of documentation):

I wrote a small shell script just to find out where the dependencies where located in my file system.

Based on this list i added the following to the repositories section:

flatDir name: 'platformModules', dirs: '/home/giuliani/apps/coolbeans/platform/modules'
flatDir name: 'platformCore', dirs: '/home/giuliani/apps/coolbeans/platform/core'
flatDir name: 'platformLib', dirs: '/home/giuliani/apps/coolbeans/platform/lib'
flatDir name: 'harnessModules', dirs: '/home/giuliani/apps/coolbeans/harness/modules'
flatDir name: 'ideModules', dirs: '/home/giuliani/apps/coolbeans/ide/modules'
flatDir name: 'javaModules', dirs: '/home/giuliani/apps/coolbeans/java/modules'
flatDir name: 'javaAntNblib', dirs: '/home/giuliani/apps/coolbeans/java/ant/nblib'
flatDir name: 'nbModulesLocale', dirs: '/home/giuliani/apps/coolbeans/nb/modules/locale'
flatDir name: 'groovyModule', dirs: '/home/giuliani/apps/coolbeans/groovy/modules'

But now i'm sutck with this error:

giuliani@nexus ~/dev/github.com/netbeans-gradle-project
$ ./gradlew test

> Task :netbeans-gradle-plugin:compileJava
/home/giuliani/apps/coolbeans/ide/modules/org-netbeans-modules-editor-lib2.jar(org/netbeans/spi/editor/document/OnSaveTask$Factory.class): warning: Cannot find annotation method 'subfolderName()' in type 'MimeLocation': class file for org.netbeans.spi.editor.mimelookup.MimeLocation not found
warning: Supported source version 'RELEASE_7' from annotation processor 'org.netbeans.api.annotations.common.proc.StaticResourceProcessor' less than -source '1.8'
warning: Supported source version 'RELEASE_7' from annotation processor 'org.netbeans.debugger.registry.DebuggerProcessor' less than -source '1.8'
warning: Supported source version 'RELEASE_7' from annotation processor 'org.netbeans.modules.debugger.jpda.apiregistry.DebuggerProcessor' less than -source '1.8'
warning: Supported source version 'RELEASE_7' from annotation processor 'org.netbeans.modules.templates.TemplateProcessor' less than -source '1.8'
warning: Supported source version 'RELEASE_7' from annotation processor 'org.netbeans.core.multiview.MultiViewProcessor' less than -source '1.8'
warning: Supported source version 'RELEASE_7' from annotation processor 'org.netbeans.modules.editor.lib2.EditorActionRegistrationProcessor' less than -source '1.8'
warning: Supported source version 'RELEASE_7' from annotation processor 'org.netbeans.modules.parsing.impl.EmbeddingProviderRegistrationProcessor' less than -source '1.8'
warning: Supported source version 'RELEASE_7' from annotation processor 'org.netbeans.modules.options.OptionsPanelControllerProcessor' less than -source '1.8'
warning: Supported source version 'RELEASE_7' from annotation processor 'org.netbeans.modules.projectapi.LookupProviderAnnotationProcessor' less than -source '1.8'
warning: Supported source version 'RELEASE_7' from annotation processor 'org.netbeans.modules.project.uiapi.CompositeCategoryProviderAnnotationProcessor' less than -source '1.8'
warning: Supported source version 'RELEASE_7' from annotation processor 'org.netbeans.modules.project.uiapi.NodeFactoryAnnotationProcessor' less than -source '1.8'
warning: Supported source version 'RELEASE_7' from annotation processor 'org.netbeans.modules.project.ui.convertor.ProjectConvertorProcessor' less than -source '1.8'
warning: Supported source version 'RELEASE_7' from annotation processor 'org.netbeans.modules.openide.awt.ActionProcessor' less than -source '1.8'
warning: Supported source version 'RELEASE_7' from annotation processor 'org.netbeans.modules.openide.filesystems.declmime.MIMEResolverProcessor' less than -source '1.8'
warning: Supported source version 'RELEASE_7' from annotation processor 'org.netbeans.modules.openide.loaders.DataObjectFactoryProcessor' less than -source '1.8'
warning: Supported source version 'RELEASE_7' from annotation processor 'org.netbeans.modules.openide.nodes.NodesAnnotationProcessor' less than -source '1.8'
warning: Supported source version 'RELEASE_6' from annotation processor 'org.netbeans.modules.openide.util.NbBundleProcessor' less than -source '1.8'
warning: Supported source version 'RELEASE_7' from annotation processor 'org.netbeans.modules.openide.util.ServiceProviderProcessor' less than -source '1.8'
warning: Supported source version 'RELEASE_7' from annotation processor 'org.netbeans.modules.openide.util.NamedServiceProcessor' less than -source '1.8'
warning: Supported source version 'RELEASE_7' from annotation processor 'org.netbeans.modules.openide.windows.TopComponentProcessor' less than -source '1.8'
warning: Supported source version 'RELEASE_7' from annotation processor 'org.netbeans.junit.internal.RandomlyFailsProcessor' less than -source '1.8'
warning: Supported source version 'RELEASE_6' from annotation processor 'org.netbeans.modules.gsf.testrunner.CoreManagerProcessor' less than -source '1.8'
warning: Supported source version 'RELEASE_7' from annotation processor 'org.netbeans.modules.gsf.testrunner.TestCreatorProviderProcessor' less than -source '1.8'
warning: No processor claimed any of these annotations: MimeRegistration,org.netbeans.gradle.project.api.nodes.ManualRefreshedNodes,org.netbeans.gradle.project.api.nodes.GradleProjectAction,javax.annotation.Nonnull,javax.annotation.CheckForNull,org.netbeans.api.annotations.common.CheckForNull,javax.annotation.Nullable
/home/giuliani/apps/coolbeans/ide/modules/org-netbeans-modules-editor-lib2.jar(org/netbeans/spi/editor/document/OnSaveTask$Factory.class): warning: Cannot find annotation method 'subfolderName()' in type 'MimeLocation': class file for org.netbeans.spi.editor.mimelookup.MimeLocation not found
/home/giuliani/dev/github.com/netbeans-gradle-project/netbeans-gradle-plugin/src/main/java/org/netbeans/gradle/project/java/tasks/CompileOnSaveAction.java:5: error: package org.netbeans.api.editor.mimelookup does not exist
import org.netbeans.api.editor.mimelookup.MimeRegistration;
                                        ^
/home/giuliani/dev/github.com/netbeans-gradle-project/netbeans-gradle-plugin/src/main/java/org/netbeans/gradle/project/java/tasks/CompileOnSaveAction.java:62: error: cannot find symbol
    @MimeRegistration(mimeType = "", service = OnSaveTask.Factory.class, position = 30000)
    ^
symbol:   class MimeRegistration
location: class CompileOnSaveAction
/home/giuliani/apps/coolbeans/ide/modules/org-netbeans-modules-editor-lib2.jar(org/netbeans/spi/editor/document/OnSaveTask$Factory.class): warning: Cannot find annotation method 'subfolderName()' in type 'MimeLocation': class file for org.netbeans.spi.editor.mimelookup.MimeLocation not found
2 errors
27 warnings

FAILURE: Build failed with an exception.

* What went wrong:
Execution failed for task ':netbeans-gradle-plugin:compileJava'.
> Compilation failed; see the compiler error output for details.

* Try:
Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output.

BUILD FAILED in 16s
15 actionable tasks: 8 executed, 7 up-to-date
giuliani@nexus ~/dev/github.com/netbeans-gradle-project
$ 
giulianisanches commented 5 years ago

So, the following error got fixed by adding providedCompile netbeansApi('org-netbeans-modules-editor-mimelookup') at the dependencies section:

/home/giuliani/apps/coolbeans/ide/modules/org-netbeans-modules-editor-lib2.jar(org/netbeans/spi/editor/document/OnSaveTask$Factory.class): warning: Cannot find annotation method 'subfolderName()' in type 'MimeLocation': class file for org.netbeans.spi.editor.mimelookup.MimeLocation not found
/home/giuliani/dev/github.com/netbeans-gradle-project/netbeans-gradle-plugin/src/main/java/org/netbeans/gradle/project/java/tasks/CompileOnSaveAction.java:5: error: package org.netbeans.api.editor.mimelookup does not exist
import org.netbeans.api.editor.mimelookup.MimeRegistration;
                                       ^
/home/giuliani/dev/github.com/netbeans-gradle-project/netbeans-gradle-plugin/src/main/java/org/netbeans/gradle/project/java/tasks/CompileOnSaveAction.java:62: error: cannot find symbol
   @MimeRegistration(mimeType = "", service = OnSaveTask.Factory.class, position = 30000)
   ^
symbol:   class MimeRegistration
location: class CompileOnSaveAction
/home/giuliani/apps/coolbeans/ide/modules/org-netbeans-modules-editor-lib2.jar(org/netbeans/spi/editor/document/OnSaveTask$Factory.class): warning: Cannot find annotation method 'subfolderName()' in type 'MimeLocation': class file for org.netbeans.spi.editor.mimelookup.MimeLocation not found
2 errors

The warnings containing RELEASE_[67] int the message are harmless.

The problem now is that i'm having a few NPE and assertions errors like:

> Task :netbeans-gradle-plugin:test

org.netbeans.gradle.project.properties.ui.PlatformPriorityPanelTest > testInitAndReadBack1 FAILED
    java.lang.NullPointerException at PlatformPriorityPanelTest.java:18

org.netbeans.gradle.project.properties.ui.PlatformPriorityPanelTest > testInitAndReadBack2 FAILED
    java.lang.NullPointerException at PlatformPriorityPanelTest.java:26

org.netbeans.gradle.project.properties.ui.ScriptAndTasksPanelTest > testInitAndReadBack1 FAILED
    java.lang.NullPointerException at ScriptAndTasksPanelTest.java:18

org.netbeans.gradle.project.properties.ui.ScriptAndTasksPanelTest > testInitAndReadBack2 FAILED
    java.lang.NullPointerException at ScriptAndTasksPanelTest.java:27

org.netbeans.gradle.project.java.query.AutoJavaSourceForBinaryQueryTest > testFindZipSource FAILED
    java.lang.AssertionError at AutoJavaSourceForBinaryQueryTest.java:36

org.netbeans.gradle.project.java.query.GradleSourceForBinaryQueryTest > testSourcesForClassesDirs FAILED
    java.lang.AssertionError at GradleSourceForBinaryQueryTest.java:40
        Caused by: java.lang.AssertionError at GradleSourceForBinaryQueryTest.java:75

org.netbeans.gradle.project.java.query.AutoJavaBinaryForSourceQueryTest > testFindBinaryOfZipSource FAILED
    java.lang.AssertionError at AutoJavaBinaryForSourceQueryTest.java:36

org.netbeans.gradle.project.java.test.TestXmlDisplayerTest > classMethod FAILED
    java.lang.NullPointerException

I will try to work around these messages until the end of the week. Cya.

giulianisanches commented 5 years ago

Still fighting to find were the NPE come from.

@kelemen , as a side question, what is the relation between your plugin and this pull request to enable Gradle support in NetBeans ?

Thanks.

kelemen commented 5 years ago

Nothing, that is a completely independent project.