.vscode
├── settings.json # list referenced libraries for VSCode
└── sync.js # script to sync, run ./sync.js - require node
nbproject
├── build-impl.xml
├── configs
├── genfiles.properties
├── private
├── project.properties # Netbeans project config
└── project.xml
Created
September 14, 2021 01:21
-
-
Save huynhsamha/a385c3663a1281d98fa2e026c8b0a710 to your computer and use it in GitHub Desktop.
Sync Netbeans JAR dependencies (nbproject/project.properties) to VSCode Reference Libs (.vscode/settings.json)
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/node | |
const fs = require('fs') | |
const path = require('path'); | |
// Netbeans | |
const libs = fs.readFileSync(path.join(__dirname, '../nbproject/project.properties'), { encoding: 'utf-8' }) | |
.split('\n').filter(x => x.startsWith('file.reference.')) | |
.map(x => { const t = x.split('='); return t.length == 2 ? t[1] : null }) | |
.filter(x => !!x) | |
console.log('======================================='); | |
console.log('Read libs from Netbeans'); | |
console.log('======================================='); | |
libs.forEach(x => { console.log('>>> ' + x); }); | |
console.log('======================================='); | |
console.log('...'); | |
// VS Code | |
const vsSettingFile = path.join(__dirname, './settings.json'); | |
const vsSetting = require(vsSettingFile) | |
const key = 'java.project.referencedLibraries'; | |
const curLibs = [... (vsSetting[key] || [])]; | |
console.log('======================================='); | |
console.log('Read libs from VS Settings'); | |
console.log('======================================='); | |
curLibs.forEach(x => { console.log('>>> ' + x); }); | |
console.log('======================================='); | |
console.log('...'); | |
vsSetting[key] = libs; | |
console.log('======================================='); | |
console.log('Write VS Settings'); | |
console.log('======================================='); | |
fs.writeFileSync(vsSettingFile, JSON.stringify(vsSetting, null, 4), { encoding: 'utf-8' }); | |
console.log('Done'); | |
console.log('======================================='); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment