Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
70 changes: 70 additions & 0 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,70 @@
# Licensed to the Apache Software Foundation (ASF) under one
# or more contributor license agreements. See the NOTICE file
# distributed with this work for additional information
# regarding copyright ownership. The ASF licenses this file
# to you under the Apache License, Version 2.0 (the
# "License"); you may not use this file except in compliance
# with the License. You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing,
# software distributed under the License is distributed on an
# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
# KIND, either express or implied. See the License for the
# specific language governing permissions and limitations
# under the License.

name: NetBeans Jackpot 3.0

on:
push:
pull_request:
# unlocked event is used as super secret restart button
types: [opened, synchronize, unlocked]

# cancel other PR workflow run in the same head-base group if it exists (e.g. during PR syncs)
# if this is not a PR run (no github.head_ref and github.base_ref defined), use an UID as group
concurrency:
group: ${{ github.head_ref || github.run_id }}-${{ github.base_ref }}
cancel-in-progress: true

jobs:

# primary build job, most other jobs use the artifact produced here
# artifact is only produced once in the matrix
base-build:
name: Build Jackpot 3.0
runs-on: ubuntu-latest
timeout-minutes: 60
steps:

- name: Checkout ${{ github.ref }} ( ${{ github.sha }} )
uses: actions/checkout@v3
with:
persist-credentials: false
submodules: false

- name: Set up Ubuntu dependencies
run: |
sudo apt install ant ant-optional openjdk-8-jdk openjdk-11-jdk openjdk-17-jdk openjdk-19-jdk
Comment on lines +48 to +50
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

if you want, you could use the setup-java action here.

the advantage is that it is cached and the setup is really fast, you can also pick the vendor.

example:
https://github.com/actions/setup-java#install-multiple-jdks

the locations are also stored in env vars, see example above

- name: Set up NetBeans
run: |
wget -q 'https://dlcdn.apache.org/netbeans/netbeans/17/netbeans-17-bin.zip' -O /tmp/netbeans-17-bin.zip
(cd $HOME; unzip /tmp/netbeans-17-bin.zip)
- name: Run RAT
run: |
echo $PWD
ls -la $PWD
(cd cmdline; ant -Dnbplatform.default.harness.dir=$HOME/netbeans/harness rat)
- name: Do build Jackpot
run: |
export JAVA_HOME=/usr/lib/jvm/java-8-openjdk-amd64
export PATH=$JAVA_HOME/bin:$PATH
export JDK11=/usr/lib/jvm/java-11-openjdk-amd64
export JDK17=/usr/lib/jvm/java-17-openjdk-amd64
export JDK19=/usr/lib/jvm/java-19-openjdk-amd64
(cd cmdline; ant -Dnbplatform.default.harness.dir=$HOME/netbeans/harness -DNETBEANS_PLATFORM=$HOME/netbeans -DJDK11=$JDK11 -DJDK17=$JDK17 -DJDK19=$JDK19 build-and-test)
37 changes: 0 additions & 37 deletions .travis.yml

This file was deleted.

8 changes: 4 additions & 4 deletions cmdline/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -27,22 +27,22 @@ This tool allows to run NetBeans Java code checker without the NetBeans IDE. Thi

#### To Build

* Apache NetBeans 13.0
* JDK 8, JDK 11 and JDK 17
* Apache NetBeans 17
* JDK 8, JDK 11, JDK 17 and JDK 19
* bash
* Apache ant 1.9.9 or above
* Apache Maven 3.3.9 or above

#### To Run

* JDK 8-17
* JDK 8-19

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Great. For purposes of nbjavac I'd need to run on JDK8, but still access JDK17 APIs while refactoring. Is that possible with new version?


### Building

Build using:

```
$ ant -DNETBEANS_PLATFORM=<path-to-NetBeans-13.0> -DJDK11=<path-to-JDK-11> -DJDK17=<path-to-JDK-17> build-and-test
$ ant -DNETBEANS_PLATFORM=<path-to-NetBeans-17> -DJDK11=<path-to-JDK-11> -DJDK17=<path-to-JDK-17> -DJDK19=<path-to-JDK-19> build-and-test
```

The built product is in tool/build/jackpot.
Expand Down
13 changes: 12 additions & 1 deletion cmdline/build.xml
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@
</target>

<target name="build-and-test">
<property name="version" value="13.0" />
<property name="version" value="17.0" />
<condition property="jackpot.root" value="${basedir}" else="${basedir}/..">
<available file="${basedir}/LICENSE" />
</condition>
Expand All @@ -78,6 +78,13 @@
<property name="jackpot.root" location="${jackpot.root}" />
<target name="test" />
</ant>
<ant dir="${basedir}" inheritAll="false" inheritRefs="false">
<property name="nbplatform.default.harness.dir" value="${NETBEANS_PLATFORM}/harness" />
<property name="nbplatform.default.netbeans.dest.dir" value="${NETBEANS_PLATFORM}" />
<property name="test.nbjdk.home" value="${JDK19}" />
<property name="jackpot.root" location="${jackpot.root}" />
<target name="test" />
</ant>
<ant dir="${basedir}/tool" target="create-standalone-tool" inheritAll="false" inheritRefs="false">
<property name="nbplatform.default.harness.dir" value="${NETBEANS_PLATFORM}/harness" />
<property name="nbplatform.default.netbeans.dest.dir" value="${NETBEANS_PLATFORM}" />
Expand All @@ -95,6 +102,10 @@
<env key="JAVA_HOME" path="${JDK17}" />
<env key="PATH" path="${JDK17}/bin:${env.PATH}" />
</exec>
<exec executable="build/test/scripted/run" dir="tool" failonerror="true">
<env key="JAVA_HOME" path="${JDK19}" />
<env key="PATH" path="${JDK19}/bin:${env.PATH}" />
</exec>
<echo>Installing tool to the local maven repository:</echo>
<exec dir="." executable="mvn" failonerror="true">
<arg line="install:install-file -Dfile=tool/build/jackpot/jackpot.jar -DgroupId=org.apache.netbeans.modules.jackpot30 -DartifactId=tool -Dversion=${version} -Dpackaging=jar -DpomFile=tool/scripts/pom.xml" />
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -97,6 +97,8 @@
import org.netbeans.spi.java.hints.Hint;
import org.netbeans.spi.java.queries.CompilerOptionsQueryImplementation;
import org.netbeans.spi.project.ProjectManagerImplementation;
import org.openide.filesystems.FileObject;
import org.openide.filesystems.FileUtil;
import org.openide.filesystems.MIMEResolver;
import org.openide.filesystems.Repository;
import org.openide.util.NbCollections;
Expand Down Expand Up @@ -286,6 +288,7 @@ public InputSource resolveEntity(String publicId, String systemId) throws SAXExc
registrations.add(new MetaInfRegistration(RulesManager.class.getName(), RulesManagerImpl.class.getName()));
registrations.add(new MetaInfRegistration(EntityCatalog.class.getName(), EntityCatalogImpl.class.getName()));
registrations.add(new MetaInfRegistration(CompileWorkerProvider.class.getName(), DefaultCompileWorkerProvider.class.getName()));
registrations.add(new MetaInfRegistration("com.sun.tools.javac.platform.PlatformProvider", escapeJavaxLang(info, "com.sun.tools.javac.platform.JDKPlatformProvider")));

registrations.addAll(info.metaInf);

Expand All @@ -305,6 +308,17 @@ public InputSource resolveEntity(String publicId, String systemId) throws SAXExc
addMETA_INFRegistration(out, info, e.getValue());
}

URL ctSym = this.getClass().getClassLoader().getResource("META-INF/ct.sym");
FileObject ctSymFO = NBJRTURLMapper.findFileObject(ctSym);
FileObject root = ctSymFO.getParent().getParent();
Enumeration<? extends FileObject> children = ctSymFO.getChildren(true);
while (children.hasMoreElements()) {
FileObject file = children.nextElement();
if (file.isData()) {
out.put(FileUtil.getRelativePath(root, file), file.asBytes());
}
}

try (JarOutputStream outStream = new JarOutputStream(new FileOutputStream(targetCompilerFile))) {
Set<String> seenDirs = new HashSet<>();
for (Entry<String, byte[]> e : out.entrySet()) {
Expand Down Expand Up @@ -532,7 +546,8 @@ private static String escapeJavaxLang(Info info, String fileName) throws Unsuppo
NBJRTURLMapper.class.getName(),
VanillaJavacContextEnhancer.class.getName(),
EntityCatalogImpl.class.getName(),
DefaultCompileWorkerProvider.class.getName()
DefaultCompileWorkerProvider.class.getName(),
"com.sun.tools.javac.platform.JDKPlatformProvider"
));

private static final Set<String> COPY_REGISTRATION = new HashSet<String>(Arrays.<String>asList(
Expand Down
2 changes: 1 addition & 1 deletion cmdline/maven/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@

<groupId>org.apache.netbeans.modules.jackpot30</groupId>
<artifactId>jackpot30-maven-plugin</artifactId>
<version>13.0</version>
<version>17.0</version>
<packaging>maven-plugin</packaging>

<name>Jackpot 3.0 Command Line Tool Maven Bridge</name>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ protected void runTest() throws Throwable {

Process p = Runtime.getRuntime().exec(new String[] {
maven,
"-Djackpot.plugin.version=13.0",
"-Djackpot.plugin.version=17.0",
"-q",
"--batch-mode",
"jackpot30:analyze"
Expand Down
2 changes: 1 addition & 1 deletion cmdline/maven/tests/fail-on-warnings/golden
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
${basedir}/src/main/java/test/App.java:24: warning: [Convert_to_Lambda_or_Member_Reference] This anonymous inner class creation can be turned into a lambda expression.
Runnable r = new Runnable() { public void run() { } };
^
[ERROR] Failed to execute goal org.apache.netbeans.modules.jackpot30:jackpot30-maven-plugin:13.0:analyze (default-cli) on project maven-test: jackpo30 failed. -> [Help 1]
[ERROR] Failed to execute goal org.apache.netbeans.modules.jackpot30:jackpot30-maven-plugin:17.0:analyze (default-cli) on project maven-test: jackpo30 failed. -> [Help 1]
[ERROR]
[ERROR] To see the full stack trace of the errors, re-run Maven with the -e switch.
[ERROR] Re-run Maven using the -X switch to enable full debug logging.
Expand Down
2 changes: 1 addition & 1 deletion cmdline/maven/tests/sl-failure/golden
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
unrecognized source level specification: unparseable
[ERROR] Failed to execute goal org.apache.netbeans.modules.jackpot30:jackpot30-maven-plugin:13.0:analyze (default-cli) on project maven-test: jackpo30 failed. -> [Help 1]
[ERROR] Failed to execute goal org.apache.netbeans.modules.jackpot30:jackpot30-maven-plugin:17.0:analyze (default-cli) on project maven-test: jackpo30 failed. -> [Help 1]
[ERROR]
[ERROR] To see the full stack trace of the errors, re-run Maven with the -e switch.
[ERROR] Re-run Maven using the -X switch to enable full debug logging.
Expand Down
4 changes: 2 additions & 2 deletions cmdline/processor/build.xml
Original file line number Diff line number Diff line change
Expand Up @@ -33,8 +33,8 @@
value="NOTHING">
<not>
<or>
<available classpath="${test.nbjdk.home}/lib/ct.sym" resource="H/java.base/java/lang/System.sig" />
<available classpath="${test.nbjdk.home}/lib/ct.sym" resource="H/system-modules" />
<available classpath="${test.nbjdk.home}/lib/ct.sym" resource="J/java.base/java/lang/System.sig" />
<available classpath="${test.nbjdk.home}/lib/ct.sym" resource="J/system-modules" />
</or>
</not>
</condition>
Expand Down
2 changes: 1 addition & 1 deletion cmdline/tool/build.xml
Original file line number Diff line number Diff line change
Expand Up @@ -114,7 +114,7 @@
<!--<condition property="test.bootclasspath.prepend.args"-->
<condition property="test.run.args"
value="--limit-modules=java.base,java.xml,java.prefs,java.management,java.logging,java.desktop,java.instrument,java.naming,jdk.zipfs --add-opens=java.base/java.net=ALL-UNNAMED"
else="-Xbootclasspath/p:${nbplatform.active.dir}/java/modules/ext/nb-javac-jdk-17-api.jar:${nbplatform.active.dir}/java/modules/ext/nb-javac-jdk-17.jar">
else="-Xbootclasspath/p:${nbplatform.active.dir}/java/modules/ext/nb-javac-jdk-19-api.jar:${nbplatform.active.dir}/java/modules/ext/nb-javac-jdk-19.jar">
<or>
<available classpath="${test.nbjdk.home}/lib/ct.sym" resource="B/java.base/java/lang/String.sig" />
<available classpath="${test.nbjdk.home}/lib/ct.sym" resource="B/system-modules" />
Expand Down
2 changes: 1 addition & 1 deletion cmdline/tool/scripts/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@

<groupId>org.apache.netbeans.modules.jackpot30</groupId>
<artifactId>jackpot30-maven-plugin</artifactId>
<version>13.0</version>
<version>17.0</version>
<packaging>maven-plugin</packaging>

<name>Jackpot 3.0 Command Line Tool</name>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -442,7 +442,19 @@ private static GroupResult handleGroup(RootConfiguration rootConfiguration, Prog
WarningsAndErrors wae = new WarningsAndErrors();

ProgressHandleWrapper progress = w.startNextPartWithEmbedding(1);
Preferences settings = globalConfig.configurationPreferences != null ? globalConfig.configurationPreferences : new MemoryPreferences();
Preferences settings = new MemoryPreferences();

if (globalConfig.configurationPreferences != null) {
try {
copyPreferences(globalConfig.configurationPreferences, settings);
} catch (BackingStoreException ex) {
throw new IOException(ex);
}
}

settings.node("org.netbeans.modules.java.hints.bugs.Unused").putBoolean("enabled", false);
settings.node("org.netbeans.modules.java.hints.suggestions.Tiny.inlineRedundantVar").putBoolean("enabled", false);

HintsSettings hintSettings = HintsSettings.createPreferencesBasedHintsSettings(settings, globalConfig.useDefaultEnabledSetting, null);

if (globalConfig.hint != null) {
Expand Down Expand Up @@ -1276,4 +1288,13 @@ private static int[] lineStarts(FileObject file) {
return new int[1];
}
}

private static void copyPreferences(Preferences from, Preferences to) throws BackingStoreException {
for (String key : from.keys()) {
to.put(key, from.get(key, null));
}
for (String child : from.childrenNames()) {
copyPreferences(from.node(child), to.node(child));
}
}
}