diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml new file mode 100644 index 0000000..e006297 --- /dev/null +++ b/.github/workflows/main.yml @@ -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 + + - 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) diff --git a/.travis.yml b/.travis.yml deleted file mode 100644 index 2555715..0000000 --- a/.travis.yml +++ /dev/null @@ -1,37 +0,0 @@ -# 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. -language: java -dist: bionic -addons: - apt: - packages: - - ant - - ant-optional - - openjdk-8-jdk - - openjdk-11-jdk - - openjdk-17-jdk -jdk: - - openjdk8 -before_script: - - wget 'https://downloads.apache.org/netbeans/netbeans/13/netbeans-13-bin.zip' -O /tmp/netbeans-13-bin.zip - - (cd $HOME; unzip /tmp/netbeans-13-bin.zip) - - unset _JAVA_OPTIONS -script: - - export JDK11=/usr/lib/jvm/java-11-openjdk-amd64 - - export JDK17=/usr/lib/jvm/java-17-openjdk-amd64 - - (cd cmdline; ant -Dnbplatform.default.harness.dir=$HOME/netbeans/harness rat) - - (cd cmdline; ant -Dnbplatform.default.harness.dir=$HOME/netbeans/harness -DNETBEANS_PLATFORM=$HOME/netbeans -DJDK11=$JDK11 -DJDK17=$JDK17 build-and-test) diff --git a/cmdline/README.md b/cmdline/README.md index 99a76a5..9aed737 100644 --- a/cmdline/README.md +++ b/cmdline/README.md @@ -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 ### Building Build using: ``` -$ ant -DNETBEANS_PLATFORM= -DJDK11= -DJDK17= build-and-test +$ ant -DNETBEANS_PLATFORM= -DJDK11= -DJDK17= -DJDK19= build-and-test ``` The built product is in tool/build/jackpot. diff --git a/cmdline/build.xml b/cmdline/build.xml index c11008a..a079894 100644 --- a/cmdline/build.xml +++ b/cmdline/build.xml @@ -52,7 +52,7 @@ - + @@ -78,6 +78,13 @@ + + + + + + + @@ -95,6 +102,10 @@ + + + + Installing tool to the local maven repository: diff --git a/cmdline/lib/test/unit/src/org/netbeans/modules/jackpot30/cmdline/lib/CreateStandaloneJar.java b/cmdline/lib/test/unit/src/org/netbeans/modules/jackpot30/cmdline/lib/CreateStandaloneJar.java index ce9bfa4..c2a06e4 100644 --- a/cmdline/lib/test/unit/src/org/netbeans/modules/jackpot30/cmdline/lib/CreateStandaloneJar.java +++ b/cmdline/lib/test/unit/src/org/netbeans/modules/jackpot30/cmdline/lib/CreateStandaloneJar.java @@ -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; @@ -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); @@ -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 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 seenDirs = new HashSet<>(); for (Entry e : out.entrySet()) { @@ -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 COPY_REGISTRATION = new HashSet(Arrays.asList( diff --git a/cmdline/maven/pom.xml b/cmdline/maven/pom.xml index 1b7c813..1e8ef33 100644 --- a/cmdline/maven/pom.xml +++ b/cmdline/maven/pom.xml @@ -21,7 +21,7 @@ org.apache.netbeans.modules.jackpot30 jackpot30-maven-plugin - 13.0 + 17.0 maven-plugin Jackpot 3.0 Command Line Tool Maven Bridge diff --git a/cmdline/maven/src/test/java/org/netbeans/modules/jackpot30/maven/RunJackpot30Test.java b/cmdline/maven/src/test/java/org/netbeans/modules/jackpot30/maven/RunJackpot30Test.java index a1a7536..79b7c99 100644 --- a/cmdline/maven/src/test/java/org/netbeans/modules/jackpot30/maven/RunJackpot30Test.java +++ b/cmdline/maven/src/test/java/org/netbeans/modules/jackpot30/maven/RunJackpot30Test.java @@ -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" diff --git a/cmdline/maven/tests/fail-on-warnings/golden b/cmdline/maven/tests/fail-on-warnings/golden index bea3cf1..b29c488 100644 --- a/cmdline/maven/tests/fail-on-warnings/golden +++ b/cmdline/maven/tests/fail-on-warnings/golden @@ -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. diff --git a/cmdline/maven/tests/sl-failure/golden b/cmdline/maven/tests/sl-failure/golden index 44933b4..6766b13 100644 --- a/cmdline/maven/tests/sl-failure/golden +++ b/cmdline/maven/tests/sl-failure/golden @@ -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. diff --git a/cmdline/processor/build.xml b/cmdline/processor/build.xml index 6224c52..06197a3 100644 --- a/cmdline/processor/build.xml +++ b/cmdline/processor/build.xml @@ -33,8 +33,8 @@ value="NOTHING"> - - + + diff --git a/cmdline/tool/build.xml b/cmdline/tool/build.xml index e756ee1..f71eab0 100644 --- a/cmdline/tool/build.xml +++ b/cmdline/tool/build.xml @@ -114,7 +114,7 @@ + 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"> diff --git a/cmdline/tool/scripts/pom.xml b/cmdline/tool/scripts/pom.xml index 150b29e..8b6cf35 100644 --- a/cmdline/tool/scripts/pom.xml +++ b/cmdline/tool/scripts/pom.xml @@ -21,7 +21,7 @@ org.apache.netbeans.modules.jackpot30 jackpot30-maven-plugin - 13.0 + 17.0 maven-plugin Jackpot 3.0 Command Line Tool diff --git a/cmdline/tool/src/org/netbeans/modules/jackpot30/cmdline/Main.java b/cmdline/tool/src/org/netbeans/modules/jackpot30/cmdline/Main.java index b72e704..aa11f38 100644 --- a/cmdline/tool/src/org/netbeans/modules/jackpot30/cmdline/Main.java +++ b/cmdline/tool/src/org/netbeans/modules/jackpot30/cmdline/Main.java @@ -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) { @@ -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)); + } + } }