编译 NetBeans 11.0 源代码时出现的问题:

huangapple go评论92阅读模式
英文:

problems when compiling netbeans from source 11.0

问题

以下是翻译好的部分:

我正在尝试从源代码构建Netbeans 11.0,遇到了一些问题。首先,我尝试使用JDK 13.02构建Netbeans 11.0,但是出现了一些问题。我认为JDK版本不兼容,于是我下载了JDK 11.0.6版本,但仍然出现了相同的错误。因此,我下载了JDK 8u241版本,编译似乎最终成功了,但是在经过几分钟的编译后,出现了下一个令人费解的错误,这就是我来这里寻求帮助的原因。
构建失败
C:\Program Files\Netbeans\nbbuild\build.xml:514: 在执行此行时发生以下错误:
C:\Program Files\Netbeans\nbbuild\build.xml:509: 在执行此行时发生以下错误:
C:\Program Files\Netbeans\nbbuild\build.xml:556: 在执行此行时发生以下错误:
C:\Program Files\Netbeans\nb\updatecenters\build.xml:44: exec 返回:1

总时间:32 分钟 28 秒

我还包括了它显示的xml文件中的代码行。

C:\Program Files\Netbeans\nbbuild\build.xml:514 :
<!-- language-all: lang-xml -->

513   &lt;target name=&quot;build-clusters&quot; depends=&quot;init&quot;&gt;
514       &lt;run-depend-build clusters-to-build=&quot;${nb.clusters.list}&quot;/&gt; 
515   &lt;/target&gt;

C:\Program Files\Netbeans\nbbuild\build.xml:509 :

506   &lt;macrodef name=&quot;run-depend-build&quot;&gt;
507      &lt;attribute name=&quot;clusters-to-build&quot;/&gt;
508      &lt;sequential&gt;
509         &lt;repeat target=&quot;build-one-cluster&quot; name=&quot;one.cluster.name&quot; values=&quot;@{clusters-to-build}&quot; /&gt; 
510      &lt;/sequential&gt;
511   &lt;/macrodef&gt;

C:\Program Files\Netbeans\nbbuild\build.xml:556 :

537   &lt;target name=&quot;build-one-cluster&quot; unless=&quot;${one.cluster.name}-is-built&quot; depends=&quot;build-one-cluster-check&quot;&gt;
538      &lt;echo message=&quot;正在构建 ${one.cluster.name} 模块&quot;/&gt;
539      &lt;resolve name=&quot;one-cluster-modules&quot; value=&quot;${one.cluster.name}&quot;/&gt;
540      &lt;resolve name=&quot;one-cluster-dependencies&quot; value=&quot;${one.cluster.name}.depends&quot;/&gt;
541      &lt;echo&gt;${one-cluster-modules}&lt;/echo&gt;
542      &lt;echo&gt;依赖项:${one-cluster-dependencies}&lt;/echo&gt;
543      &lt;insert-module-all-targets/&gt; &lt;!-- 我们在一个子项目中,因此需要重新插入目标... XXX &lt;antcall&gt; 和因此 &lt;repeat&gt; 显然会从磁盘重新解析Ant脚本! --&gt;
544      &lt;antcall target=&quot;build-one-cluster-dependencies&quot; inheritAll=&quot;false&quot;&gt;
545        &lt;param name=&quot;one.cluster.dependencies&quot; value=&quot;${one-cluster-dependencies}&quot;/&gt;
546        &lt;param name=&quot;one.cluster.name&quot; value=&quot;${one.cluster.name}&quot;/&gt;
547        &lt;param name=&quot;ext.binaries.downloaded&quot; value=&quot;true&quot;/&gt;
548      &lt;/antcall&gt;
549      &lt;mkdir dir=&quot;${netbeans.dest.dir}&quot;/&gt;
550      &lt;nbmerge failonerror=&quot;${stop.when.broken.modules}&quot; 
551               dest=&quot;${netbeans.dest.dir}&quot; 
552               topdir=&quot;${nb_all}&quot; 
553               fixedmodules=&quot;${one-cluster-modules}&quot;
554               builtmodulesproperty=&quot;${built.modules.property}&quot; 
555               targetprefix=&quot;all-&quot; 
556               mergedependentmodules=&quot;false&quot;&gt;
557      &lt;/nbmerge&gt;
558      &lt;touch file=&quot;${netbeans.dest.dir}/${one.cluster.name}.built&quot;/&gt;
559   &lt;/target&gt;

C:\Program Files\Netbeans\nb\updatecenters\build.xml:44 :

44   &lt;exec executable=&quot;${java.home}/bin/keytool&quot; failonerror=&quot;true&quot;&gt;
45           &lt;arg value=&quot;-exportcert&quot;/&gt;
46           &lt;arg line=&quot;-keystore ${netbeans.bundled.ks}&quot;/&gt;
47           &lt;arg line=&quot;-alias netbeans-bundled&quot;/&gt;
48           &lt;arg line=&quot;-storepass ${netbeans.bundled.ks}&quot;/&gt;
49           &lt;arg line=&quot;-file ${netbeans.bundled.cert}&quot;/&gt;
50   &lt;/exec&gt;

PS1:我知道已经有可用的二进制版本,而且更加容易,但是我很固执,想要编译源代码版本(笑)。

PS2:我已经对以下环境变量进行了更改:JAVA_HOME,JAVA_PATH,ANT_HOME,PATH。


<details>
<summary>英文:</summary>

I&#39;m trying to building Netbeans 11.0 from source, and i&#39;m having some problems. Firstly i&#39;ve try to build the netbeans 11.0 with JDK 13.02 but some problems appeared and I believed that the JDK version was not compatible, so I downloaded the JDK 11.0.6 version and the same errors happened. So, I downloaded the JDK 8u241 version and the compilation finally seemed work, but, after minutes of compilation, the next intriguing error, which is why I come here to ask for help.

BUILD FAILED
C:\Program Files\Netbeans\nbbuild\build.xml:514: The following error occurred while executing this line:
C:\Program Files\Netbeans\nbbuild\build.xml:509: The following error occurred while executing this line:
C:\Program Files\Netbeans\nbbuild\build.xml:556: The following error occurred while executing this line:
C:\Program Files\Netbeans\nb\updatecenters\build.xml:44: exec returned: 1

Total time: 32 minutes 28 seconds

I also included the code lines of xml archives that it showed.

C:\Program Files\Netbeans\nbbuild\build.xml:514 :
&lt;!-- language-all: lang-xml --&gt;

513 <target name="build-clusters" depends="init">
514 <run-depend-build clusters-to-build="${nb.clusters.list}"/>
515 </target>

C:\Program Files\Netbeans\nbbuild\build.xml:509 :

506 <macrodef name="run-depend-build">
507 <attribute name="clusters-to-build"/>
508 <sequential>
509 <repeat target="build-one-cluster" name="one.cluster.name" values="@{clusters-to-build}" />
510 </sequential>
511 </macrodef>

C:\Program Files\Netbeans\nbbuild\build.xml:556 :

537 <target name="build-one-cluster" unless="${one.cluster.name}-is-built" depends="build-one-cluster-check">
538 <echo message="Building ${one.cluster.name} modules"/>
539 <resolve name="one-cluster-modules" value="${one.cluster.name}"/>
540 <resolve name="one-cluster-dependencies" value="${one.cluster.name}.depends"/>
541 <echo>${one-cluster-modules}</echo>
542 <echo>Dependencies: ${one-cluster-dependencies}</echo>
543 <insert-module-all-targets/> <!-- we are in a subproject, so need to reinsert the targets... XXX <antcall> and thus <repeat> apparently reparses the Ant script from disk! -->
544 <antcall target="build-one-cluster-dependencies" inheritAll="false">
545 <param name="one.cluster.dependencies" value="${one-cluster-dependencies}"/>
546 <param name="one.cluster.name" value="${one.cluster.name}"/>
547 <param name="ext.binaries.downloaded" value="true"/>
548 </antcall>
549 <mkdir dir="${netbeans.dest.dir}"/>
550 <nbmerge failonerror="${stop.when.broken.modules}"
551 dest="${netbeans.dest.dir}"
552 topdir="${nb_all}"
553 fixedmodules="${one-cluster-modules}"
554 builtmodulesproperty="${built.modules.property}"
555 targetprefix="all-"
556 mergedependentmodules="false">
557 </nbmerge>
558 <touch file="${netbeans.dest.dir}/${one.cluster.name}.built"/>
559 </target>

C:\Program Files\Netbeans\nb\updatecenters\build.xml:44 :

44 <exec executable="${java.home}/bin/keytool" failonerror="true">
45 <arg value="-exportcert"/>
46 <arg line="-keystore ${netbeans.bundled.ks}"/>
47 <arg line="-alias netbeans-bundled"/>
48 <arg line="-storepass ${netbeans.bundled.ks}"/>
49 <arg line="-file ${netbeans.bundled.cert}"/>
50 </exec>


PS1: I know that the binary version is available and it is much easier but I am stubborn and I want to compile the source version LOL

PS2: I made changes to the follow environment variables: JAVA_HOME, JAVA_PATH, ANT_HOME, PATH.








</details>


# 答案1
**得分**: 1

遇到了使用 Ant 1.10.2 时出现完全相同的构建错误,使用 OpenJDK 1.8_322 编译 netbeans-12.6-source.zip 源代码时也是如此。我决定尝试使用 Ant 1.10.12(目前最新版本),发现通过将我的(Windows 10)%PATH% 上的 ANT_HOME 从旧的 1.10.2 路径切换到新的 1.10.12 路径,以某种方式修复了这些错误。不太清楚 Ant 1.10.2 和 1.10.12 之间的区别,但源代码构建中肯定使用了在 1.10.2 中不存在的新的 Ant 功能。

<details>
<summary>英文:</summary>

Ran into these same exact build errors when using Ant 1.10.2, with OpenJDK 1.8_322 to compile netbeans-12.6-source.zip source. I decided to try Ant 1.10.12 (latest at this time) and found that by switching ANT_HOME on my (Windows 10) %PATH% from the old 1.10.2 path to the new 1.10.12 path fixed the errors somehow. Not sure what the difference is between Ant 1.10.2 and 1.10.12, but something within the source build must definitely be using new Ant features that do not exist in 1.10.2.

</details>



# 答案2
**得分**: 0

很难根据提供的信息确定你遇到了什么问题,但我按照在 Windows 10 上构建 NetBeans 11.3 的[源码构建][1]说明进行操作,一切都正常工作:

[![BuildSuccessful][2]][2]

因此,更有帮助的做法可能是简单记录我所做的步骤,然后你可以解决任何差异:

- [从 GitHub 下载并解压 NetBeans 11.3 源码][3] 到 `D:\Downloads\NetBeans source\netbeans-master`。
- [下载并解压 Ant 1.10.7][4] 到 `C:\ApacheAnt`。
- 我(错误地!)将 **ANT_HOME** 设置为 `C:\ApacheAnt` 而不是 `C:\ApacheAnt\bin`,但似乎并没有关系。
- 将 **JAVA_HOME** 设置为 `C:\Java\jdk1.8.0_221`,并确保它是 `PATH` 中唯一的 JDK。
- 打开 **命令提示符** 窗口,并输入以下内容:

&gt;     D:
&gt; 
&gt;     cd D:\Downloads\NetBeans source\netbeans-master
&gt; 
&gt;     C:\ApacheAnt\bin\ant build

注意:

- NetBeans 的[*源码构建*][1]说明中提到“*安装 Java 开发工具的 LTS 版本*”,因此你的选择实际上只有 JDK 8 或 JDK 11。
- 构建 NetBeans 会在控制台上生成大量输出,因此最好将输出重定向到文件。这样做会稍微加快速度,并且如果你需要查看构建内容,它也会很有用。
- 我没有 `JAVA_PATH` 环境变量。
- [Ant 文档][4] 中提到“*我们建议在构建过程中使用 1.10.x,除非你需要在构建过程中使用 Java8 之前的版本*”,因此避免使用 Ant 1.9.x。

如果问题仍然存在,请更新你的问题并提供以下信息:

- 你的 `JAVA_HOME` 和 `ANT_HOME` 设置。
- 你用于构建 NetBeans 的指南链接。
- 你用于下载 NetBeans 源码的页面链接。
- 从控制台提交 `java -version` 命令的输出。

  [1]: https://netbeans.apache.org/download/dev/index.html
  [2]: https://i.stack.imgur.com/HPj9K.png
  [3]: https://github.com/apache/netbeans
  [4]: https://ant.apache.org/bindownload.cgi

<details>
<summary>英文:</summary>

It&#39;s tough to state why you are having a problem based on the information provided, but I followed the [Building from source][1] instructions for NetBeans 11.3 on Windows 10 and everything worked:

[![BuildSuccessful][2]][2]

Therefore it might be more helpful to simply document what I did, and you can address any differences:

- [Download and unzip NetBeans 11.3 source from GitHub][3] into `D:\Downloads\NetBeans source\netbeans-master`.
- [Download and unzip Ant 1.10.7][4] into `C:\ApacheAnt`.
- I (incorrectly!) set **ANT_HOME** to `C:\ApacheAnt` instead of `C:\ApacheAnt\bin`, but it didn&#39;t seem to matter.
- Set **JAVA_HOME** to `C:\Java\jdk1.8.0_221`, and ensure that it is the only JDK on the `PATH`.
- Open a **Command Prompt** window and submit the following:

&gt;     D:
&gt; 
&gt;     cd D:\Downloads\NetBeans source\netbeans-master
&gt; 
&gt;     C:\ApacheAnt\bin\ant build

Notes:

- The [*Building from source*][1] instructions for NetBeans state &quot;*Install an LTS release of the Java Development Kit*&quot;, so effectively your only choices are JDK 8 or JDK 11.
- Building NetBeans generates a lot of output to the console, so it is probably better to redirect the output to a file. This will speed things up a bit, and will be useful if you need to review the build.
- I don&#39;t have a `JAVA_PATH` environment variable.
- [The Ant documentation][4] states &quot;*We recommend using 1.10.x unless you are required to use versions of Java prior to Java8 during the build process.*&quot;, so avoid using Ant 1.9.x.


If you continue to have problems then update your question with the following information: 

- Your settings for `JAVA_HOME` and `ANT_HOME`. 
- A link to the instructions you followed for building NetBeans.
- A link to the page you used to download the source of NetBeans.
- The output from submitting `java -version` from the console.

  [1]: https://netbeans.apache.org/download/dev/index.html
  [2]: https://i.stack.imgur.com/HPj9K.png
  [3]: https://github.com/apache/netbeans
  [4]: https://ant.apache.org/bindownload.cgi

</details>



# 答案3
**得分**: 0

我在使用jdk-19构建时遇到了相同的问题。只需将其更改为jdk-17即可。
Gradle Tooling是使用Gradle 7.4构建的,不支持Java 19。
https://github.com/apache/netbeans/discussions/4801

<details>
<summary>英文:</summary>

I got the same issue while building using jdk-19. Just change it to jdk-17
The Gradle Tooling is built with Gradle 7.4, that does not support Java 19.
https://github.com/apache/netbeans/discussions/4801

</details>



huangapple
  • 本文由 发表于 2020年4月6日 02:13:28
  • 转载请务必保留本文链接:https://go.coder-hub.com/61047265.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定