diff --git a/.gitignore b/.gitignore index 1dd29a2..c4fce3b 100644 --- a/.gitignore +++ b/.gitignore @@ -2,8 +2,5 @@ *.log # Project directories -arm_am-pom/ -asset-gui/ -CustomLogFormatter/build.properties -CustomLogFormatter/custom-formatter.jar -CustomLogFormatter/build +workspace/ + diff --git a/.vscode/settings.json b/.vscode/settings.json index c5f3f6b..63e0f2f 100644 --- a/.vscode/settings.json +++ b/.vscode/settings.json @@ -1,3 +1,6 @@ { + "svn.delete.ignoredRulesForDeletedFiles": [ + "target" + ], "java.configuration.updateBuildConfiguration": "interactive" } \ No newline at end of file diff --git a/README.md b/README.md index 96a9620..4ac07ce 100644 --- a/README.md +++ b/README.md @@ -2,33 +2,20 @@ ## Richieste -- voglio scaricare il progetto su -- scarica anche +- voglio scaricare il progetto su +- scarica anche - crea un readme con le richieste che ho fatto - crea uno script powershell che fa il build ed il deploy di arm_am-pom su C:\Dev2012\BUILDERS\jboss-eap-7.4 -- il pom è nel folder arm_am-pom +- il pom è nel folder arm_am-pom - java 8 è su C:\Dev2012\BUILDERS\java\jdk1.8.0_291 - aggiorna il readme -- deve usare standalone-IOR-full.xml - +- deve usare standalone-ADVC-full.xml - voglio compilare e lanciare il progetto asset-gui - jboss deve usare le opzioni "-DIDServer=GS -Dbtf.PathToParse=C:\Dev2012\advc0\in -Djava.awt.headless=true -DFilOptimize=true -DMTH_VALID_JB=internal -DskQueueElab=GS -DskQueueWrite=GS -DmtSession=GS" +- C:\Dev2012\BUILDERS\jboss-eap-7.4\bin\add-user.bat -u admin -p admin.123 -g SuperUser --silent +- dir $env:USERPROFILE\.m2\repository\com\armundia -Recurse | Where-Object { $_.Name -like "*.pom" } -## Projects Downloaded - -1. ARM AM POM Project - - ```bash - svn checkout https://svn.armundia.com/svn/PRJarm_am/branches/ISPBEstero/ADV360-IOR-DEMO-JB74_B2025_VUB/arm_am-pom - ``` - -2. Asset GUI Project - - ```bash - svn checkout https://svn.armundia.com/svn/PRJarm_am/branches/ISPBEstero/ADV360-IOR-DEMO-JB74_B2025_VUB/asset-gui - ``` - -Both projects were checked out at revision 132783. +## Projects Downloaded (Sync-Projects.ps1) ## Project Structure @@ -37,32 +24,37 @@ Both projects were checked out at revision 132783. - Java/JEE project containing: - arm_am-ejb: EJB modules and web services - arm_am-jUnit: Test files - - Various resources and configuration files + - arm_am-web: Web application components ### asset-gui - Web application frontend project containing: - Frontend source code in `source` directory - UI libraries (Font Awesome, Bootstrap, amCharts, Roboto fonts) - - Environment configurations (LOCAL, VUB, CIB, PBZ, KOPER) - Build configuration files (gulpfile.js, package.json, babel.config.js) ## Build and Deployment Scripts +### Sync-Projects.ps1 + +PowerShell script to sync projects: + +- Scarica usando svn i progetti arm_am-pom, asset-gui e tutti i moduli utilizzati. +- Esegue il build dei jar dei moduli utilizzati e li aggiunge al repository mvn locale + ### start-jboss.ps1 -PowerShell script to start JBoss EAP 7.4 server: +PowerShell script to start JBoss EAP 8.0 server: -- Uses Java 8 from `C:\Dev2012\BUILDERS\java\jdk1.8.0_291` -- Uses `standalone-IOR-full.xml` configuration -- Starts JBoss in standalone mode with debug enabled -- Binds to all interfaces (0.0.0.0) -- Management console available at -- JBoss logs location: `C:\Dev2012\BUILDERS\jboss-eap-7.4\standalone\log\server.log` +- Uses Java 17 from `C:\Dev2012\BUILDERS\java\jdk-17.0.9` +- Uses `standalone-full-ADV360-BES-EAP_8_POSTGRES.xml` configuration +- Sets required system properties +- Admin console available at +- JBoss logs location: `C:\Dev2012\BUILDERS\jboss-eap-8.0\standalone\log\server-info.log` ### stop-jboss.ps1 -PowerShell script to stop JBoss EAP 7.4 server: +PowerShell script to stop JBoss EAP 8.0 server: - Finds and stops the JBoss process safely - Waits to ensure process is fully stopped @@ -71,13 +63,9 @@ PowerShell script to stop JBoss EAP 7.4 server: PowerShell script to build and deploy the arm_am-pom project: -- Uses Java 8 for building +- Uses Java 17 for building - Uses Maven profile `adv360-DEV` -- Builds modules in correct order: - 1. Parent POM - 2. EJB module - 3. WAR module - 4. EAR module +- Builds the EAR file - Deploys the EAR file to JBoss deployment directory ### build-and-run-asset-gui.ps1 @@ -86,35 +74,34 @@ PowerShell script to build and run the asset-gui project: - Installs Node.js dependencies (npm install) - Builds the project with minification (gulp build --minified) -- Starts the development server (gulp serve) +- Starts development server - Development server will be available at ## Build and Deploy Workflow 1. Start JBoss server: - ```powershell - .\start-jboss.ps1 - ``` +```powershell +.\start-jboss.ps1 +``` 2. Build and deploy the backend: - ```powershell - .\build-and-deploy.ps1 - ``` +```powershell +.\build-and-deploy.ps1 +``` 3. Build and run the frontend: - ```powershell - .\build-and-run-asset-gui.ps1 - ``` +```powershell +.\build-and-run-asset-gui.ps1 +``` -4. Monitor deployment: - - Check JBoss logs at `C:\Dev2012\BUILDERS\jboss-eap-7.4\standalone\log\server.log` - - Access JBoss admin console at - - Access asset-gui frontend at +- Access JBoss admin console at +- Access asset-gui frontend at ## Required Configuration -- JBoss configuration file: `standalone-IOR-full.xml` must be present in `C:\Dev2012\BUILDERS\jboss-eap-7.4\standalone\configuration\` +- JBoss configuration file: `standalone-full-ADV360-BES-EAP_8_POSTGRES.xml` must be present in +`C:\Dev2012\BUILDERS\jboss-eap-8.0\standalone\configuration\` - Node.js must be installed to build and run asset-gui diff --git a/Sync-Projects.ps1 b/Sync-Projects.ps1 new file mode 100644 index 0000000..290870f --- /dev/null +++ b/Sync-Projects.ps1 @@ -0,0 +1,124 @@ +# PowerShell script to checkout arm_am-pom, asset-gui and used modules and to build modules + +# Configuration +$SVN_BASE_URL = "https://svn.armundia.com/svn/PRJarm_am/branches/ISPBEstero/ADV360-BES-JB74" +$SVN_BASE_URL_BW2_LIB = "https://svn.armundia.com/svn/PRJbw2" +$SVN_BASE_URL_ARM_LIB = "https://svn.armundia.com/svn/PRJarm_am" +$WORKSPACE_DIR = Join-Path $PSScriptRoot "workspace" + +# Project paths +$PROJECTS = @{ + # "arm_am-pom" = "$SVN_BASE_URL/arm_am-pom" + # "asset-gui" = "$SVN_BASE_URL/asset-gui" + # "AmazonAWS.S3" = "$SVN_BASE_URL_BW2_LIB/AmazonAWS.S3" + "arm-core-batch" = "$SVN_BASE_URL/batch_module" + "arm-core-document" = "$SVN_BASE_URL_BW2_LIB/branches/arm-core-document/arm-core-document-ispb" + "arm-core-event" = "$SVN_BASE_URL_BW2_LIB/trunk/arm-core-event" + "arm-core-perfo" = "$SVN_BASE_URL/arm-perfo" + "arm-core-print" = "$SVN_BASE_URL/arm-core-print/arm-core-print" + "arm-core-querybuilder" = "$SVN_BASE_URL_ARM_LIB/trunk/arm-core-querybuilder" + "arm-core-quest" = "$SVN_BASE_URL/arm-core-quest" + "arm-core-users" = "$SVN_BASE_URL_ARM_LIB/trunk/arm-core-users/arm-core-users" + "arm-core-utility" = "$SVN_BASE_URL_ARM_LIB/trunk/arm-core-utility" + "arm-core-utility-extra" = "$SVN_BASE_URL_ARM_LIB/trunk/arm-core-utility-extra" + "arm-core-var" = "$SVN_BASE_URL/arm-calcolo-VaR" + "arm-fileExporter" = "$SVN_BASE_URL_ARM_LIB/trunk/arm-fileExporter" + "arm-limiti" = "$SVN_BASE_URL/arm-limiti" + "arm-quadratore-portafogli" = "$SVN_BASE_URL/arm-quadratore-portafogli" + "arm-util" = "$SVN_BASE_URL_ARM_LIB/trunk/arm-util" + "aspose-manager" = "$SVN_BASE_URL/arm-core-print/aspose-manager" + "data-quality" = "$SVN_BASE_URL_ARM_LIB/trunk/data-quality/data-quality-default" + "shared-javaEE" = "$SVN_BASE_URL_BW2_LIB/trunk/Shared-JavaEE" + } + +# Create workspace directory if it doesn't exist +if (-not (Test-Path $WORKSPACE_DIR)) { + New-Item -ItemType Directory -Path $WORKSPACE_DIR -Force +} + +# Function to checkout or update a project +function Sync-Project { + param ( + [string]$projectName, + [string]$svnUrl, + [string]$targetDir + ) + + $projectPath = Join-Path $targetDir $projectName + + if (Test-Path $projectPath) { + Write-Host "Updating $projectName..." -ForegroundColor Yellow + Set-Location $projectPath + svn update + } else { + Write-Host "Checking out $projectName..." -ForegroundColor Yellow + Set-Location $targetDir + svn checkout $svnUrl $projectName + } + + if ($LASTEXITCODE -eq 0) { + Write-Host "$projectName successfully checked out/updated" -ForegroundColor Green + } else { + Write-Host "Error checking out/updating $projectName" -ForegroundColor Red + } +} + +# Store the original directory +$originalDirectory = Get-Location + +try { + # Checkout/update each project + foreach ($project in $PROJECTS.GetEnumerator()) { + Sync-Project -projectName $project.Key -svnUrl $project.Value -targetDir $WORKSPACE_DIR + } + + # Array of projects to build in order + $BUILD_ORDER = @( + # Base libraries + "shared-javaEE", # Base Java EE utilities + "arm-core-utility", # core utilities + "arm-core-utility-extra", # additional utilities + "arm-util", # general utilities + + # Core functionality + "arm-core-document", # Document handling + "arm-core-event", # Event system + "arm-core-users", # User management + "arm-core-querybuilder", # Query building + "arm-core-print", # Printing system + + # Business modules + "arm-core-quest", # Questionnaires + "arm-core-batch", # Batch processing + "arm-core-perfo", # Performance + "arm-core-var", # Risk calculation + "arm-fileExporter", # File export + "arm-limiti", # Limits management + "arm-quadratore-portafogli", # Portfolio management + + # Additional components + "data-quality", # Data quality + "AmazonAWS.S3", # AWS S3 integration + "aspose-manager" # Document processing + ) + + # Build each project in order + foreach ($project in $BUILD_ORDER) { + Write-Host "Building $project..." -ForegroundColor Yellow + Set-Location (Join-Path $WORKSPACE_DIR $project) + mvn clean install -DskipTests + + if ($LASTEXITCODE -eq 0) { + Write-Host "$project successfully built and installed" -ForegroundColor Green + } else { + Write-Host "Error building $project" -ForegroundColor Red + exit 1 + } + } + +} catch { + Write-Host "An error occurred: $_" -ForegroundColor Red +} finally { + # Restore original directory + Set-Location $originalDirectory +} diff --git a/build-and-deploy.ps1 b/build-and-deploy.ps1 index 26c5a63..e99b998 100644 --- a/build-and-deploy.ps1 +++ b/build-and-deploy.ps1 @@ -1,14 +1,22 @@ -# PowerShell script for building and deploying arm_am-pom to JBoss EAP 7.4 +# PowerShell script for building and deploying arm_am-pom to JBoss EAP 8.0 -# Load configuration from JSON file -$config = Get-Content -Raw -Path "$PSScriptRoot\config.json" | ConvertFrom-Json +# Read configuration from config.json +$configPath = Join-Path $PSScriptRoot "config.json" +if (-not (Test-Path $configPath)) { + Write-Host "Error: config.json not found at $configPath" -ForegroundColor Red + exit 1 +} -# Configuration variables from JSON -$JBOSS_HOME = $config.jbossHome +$config = Get-Content $configPath -Raw | ConvertFrom-Json + +# Configuration from config.json +$JBOSS_HOME = $config.jboss.jbossHome +$DEPLOYMENT_DIR = $config.jboss.deploymentDir $PROJECT_DIR = $config.ear.projectDir -$DEPLOYMENT_DIR = $config.deploymentDir $MAVEN_PROFILE = $config.ear.mavenProfile -$JAVA_HOME = $config.javaHome +$JAVA_HOME = $config.jboss.javaHome +$ASSET_GUI_DIR = $config.assetGui.projectDir +$ASSET_GUI_TARGET = $config.assetGui.targetDir # Store the original directory $originalDirectory = Get-Location @@ -21,76 +29,123 @@ function Test-JBossRunning { } Write-Host "Starting build and deploy process..." -ForegroundColor Green +Write-Host "Using configuration:" -ForegroundColor Yellow +Write-Host " Java Home: $JAVA_HOME" -ForegroundColor Yellow +Write-Host " JBoss Home: $JBOSS_HOME" -ForegroundColor Yellow +Write-Host " Project Directory: $PROJECT_DIR" -ForegroundColor Yellow +Write-Host " Maven Profile: $MAVEN_PROFILE" -ForegroundColor Yellow +Write-Host " Asset GUI Directory: $ASSET_GUI_DIR" -ForegroundColor Yellow # Check if Java exists if (-not (Test-Path $JAVA_HOME)) { - Write-Host "Error: Java 8 not found at $JAVA_HOME" -ForegroundColor Red - Set-Location $originalDirectory # Restore original directory + Write-Host "Error: Java not found at $JAVA_HOME" -ForegroundColor Red + Set-Location $originalDirectory exit 1 } # Set JAVA_HOME for the build $env:JAVA_HOME = $JAVA_HOME -Write-Host "Using Java from: $JAVA_HOME" -ForegroundColor Yellow # Check if JBoss directory exists if (-not (Test-Path $JBOSS_HOME)) { Write-Host "Error: JBoss directory not found at $JBOSS_HOME" -ForegroundColor Red - Set-Location $originalDirectory # Restore original directory + Set-Location $originalDirectory exit 1 } -# Check if project directory exists +# Check if project directories exist if (-not (Test-Path $PROJECT_DIR)) { Write-Host "Error: Project directory not found at $PROJECT_DIR" -ForegroundColor Red - Set-Location $originalDirectory # Restore original directory + Set-Location $originalDirectory exit 1 } -# Navigate to project directory +# Check Asset GUI directory and package.json +$skipAssetGui = $false +if (-not (Test-Path $ASSET_GUI_DIR)) { + Write-Host "Warning: Asset GUI directory not found at $ASSET_GUI_DIR" -ForegroundColor Yellow + Write-Host "Skipping Asset GUI build..." -ForegroundColor Yellow + $skipAssetGui = $true +} +elseif (-not (Test-Path (Join-Path $ASSET_GUI_DIR "package.json"))) { + Write-Host "Warning: package.json not found in Asset GUI directory" -ForegroundColor Yellow + Write-Host "Skipping Asset GUI build..." -ForegroundColor Yellow + $skipAssetGui = $true +} + +if (-not $skipAssetGui) { + # Build and deploy Asset GUI + Write-Host "Building Asset GUI..." -ForegroundColor Yellow + Set-Location $ASSET_GUI_DIR + + # Run npm install and build for Asset GUI + Write-Host "Installing Asset GUI dependencies..." -ForegroundColor Yellow + npm install + if ($LASTEXITCODE -ne 0) { + Write-Host "Warning: npm install failed! Skipping Asset GUI build..." -ForegroundColor Yellow + $skipAssetGui = $true + } + + if (-not $skipAssetGui) { + Write-Host "Building Asset GUI..." -ForegroundColor Yellow + npm run build + if ($LASTEXITCODE -ne 0) { + Write-Host "Warning: Asset GUI build failed! Continuing with EAR build..." -ForegroundColor Yellow + $skipAssetGui = $true + } + else { + # Create Asset GUI target directory if it doesn't exist + if (-not (Test-Path $ASSET_GUI_TARGET)) { + New-Item -ItemType Directory -Path $ASSET_GUI_TARGET -Force + } + + # Copy Asset GUI build to target directory + Write-Host "Copying Asset GUI build to target directory..." -ForegroundColor Yellow + Copy-Item -Path "$ASSET_GUI_DIR\dist\*" -Destination $ASSET_GUI_TARGET -Recurse -Force + } + } +} + +# Build EAR project +Write-Host "Building EAR project..." -ForegroundColor Yellow Set-Location $PROJECT_DIR -# Clean and build the project with Maven -Write-Host "Building project with Maven using profile $MAVEN_PROFILE..." -ForegroundColor Yellow -Write-Host "Current directory: $(Get-Location)" -ForegroundColor Yellow - -# First build the parent and modules with debug output -Write-Host "Building parent POM..." -ForegroundColor Yellow -& "$env:JAVA_HOME\bin\java" -version -mvn clean install -N -P$MAVEN_PROFILE +# Build parent +Write-Host "Building parent project..." -ForegroundColor Yellow +mvn clean install -N "-P$MAVEN_PROFILE" if ($LASTEXITCODE -ne 0) { Write-Host "Maven parent build failed!" -ForegroundColor Red - Set-Location $originalDirectory # Restore original directory + Set-Location $originalDirectory exit 1 } -# Build the EJB module first with debug output +# Build EJB module Write-Host "Building EJB module..." -ForegroundColor Yellow Set-Location "$PROJECT_DIR\arm_am-ejb" -mvn clean install -DskipTests -P$MAVEN_PROFILE +mvn clean install -DskipTests "-P$MAVEN_PROFILE" if ($LASTEXITCODE -ne 0) { Write-Host "Maven EJB module build failed!" -ForegroundColor Red - Set-Location $originalDirectory # Restore original directory + Set-Location $originalDirectory exit 1 } -# Build the WAR module with debug output +# Build WAR module Write-Host "Building WAR module..." -ForegroundColor Yellow Set-Location "$PROJECT_DIR\arm_am" -mvn clean install -DskipTests -P$MAVEN_PROFILE +mvn clean install -DskipTests "-P$MAVEN_PROFILE" if ($LASTEXITCODE -ne 0) { Write-Host "Maven WAR module build failed!" -ForegroundColor Red - Set-Location $originalDirectory # Restore original directory + Set-Location $originalDirectory exit 1 } -# Finally build the EAR module with debug output +# Build EAR module Write-Host "Building EAR module..." -ForegroundColor Yellow Set-Location "$PROJECT_DIR\arm_am-ear" -mvn clean package -DskipTests -P$MAVEN_PROFILE +mvn clean package -DskipTests "-P$MAVEN_PROFILE" if ($LASTEXITCODE -ne 0) { Write-Host "Maven EAR module build failed!" -ForegroundColor Red - Set-Location $originalDirectory # Restore original directory + Set-Location $originalDirectory exit 1 } @@ -100,20 +155,66 @@ $earFile = Get-ChildItem -Path "$PROJECT_DIR\arm_am-ear\target\*.ear" -ErrorActi if (-not $earFile) { Write-Host "Error: EAR file not found after build" -ForegroundColor Red Write-Host "Searching in: $PROJECT_DIR\arm_am-ear\target\" -ForegroundColor Yellow - Set-Location $originalDirectory # Restore original directory + Set-Location $originalDirectory exit 1 } # Create deployments directory if it doesn't exist if (-not (Test-Path $DEPLOYMENT_DIR)) { - New-Item -ItemType Directory -Path $DEPLOYMENT_DIR + New-Item -ItemType Directory -Path $DEPLOYMENT_DIR -Force } # Copy EAR file to JBoss deployments directory Write-Host "Deploying EAR to JBoss..." -ForegroundColor Yellow Write-Host "Copying from: $($earFile.FullName)" -ForegroundColor Yellow Write-Host "Copying to: $DEPLOYMENT_DIR" -ForegroundColor Yellow -Copy-Item $earFile.FullName $DEPLOYMENT_DIR + +# Remove existing deployment if present +$deployedEarPath = Join-Path $DEPLOYMENT_DIR $config.ear.deployedFile +if (Test-Path $deployedEarPath) { + Write-Host "Removing existing deployment..." -ForegroundColor Yellow + Remove-Item $deployedEarPath -Force +} + +# Copy new EAR file with the configured name +Copy-Item $earFile.FullName $deployedEarPath + +# Unpack EAR if configured +if ($config.ear.unpackDir) { + Write-Host "Unpacking EAR to: $($config.ear.unpackDir)" -ForegroundColor Yellow + + # Create unpack directory if it doesn't exist + if (-not (Test-Path $config.ear.unpackDir)) { + New-Item -ItemType Directory -Path $config.ear.unpackDir -Force + } + + # Clean existing content + Remove-Item "$($config.ear.unpackDir)\*" -Recurse -Force -ErrorAction SilentlyContinue + + # Use 7-Zip to unpack the EAR (Java JAR files are ZIP format) + try { + $7zPath = "C:\Program Files\7-Zip\7z.exe" + if (Test-Path $7zPath) { + # Use 7-Zip + Start-Process -FilePath $7zPath -ArgumentList "x", "`"$deployedEarPath`"", "-o`"$($config.ear.unpackDir)`"", "-y" -Wait -NoNewWindow + } else { + # Fallback to jar command from Java + $jarPath = Join-Path $JAVA_HOME "bin\jar.exe" + if (Test-Path $jarPath) { + Set-Location $config.ear.unpackDir + Start-Process -FilePath $jarPath -ArgumentList "xf", "`"$deployedEarPath`"" -Wait -NoNewWindow + } else { + Write-Host "Warning: Could not unpack EAR - neither 7-Zip nor jar command found" -ForegroundColor Yellow + } + } + } + catch { + Write-Host "Warning: Failed to unpack EAR: $_" -ForegroundColor Yellow + } + finally { + Set-Location $originalDirectory + } +} # Check if JBoss is running if (Test-JBossRunning) { @@ -122,7 +223,14 @@ if (Test-JBossRunning) { Write-Host "Note: JBoss is not running. Start JBoss to complete deployment" -ForegroundColor Yellow } -Write-Host "Build and deploy process completed!" -ForegroundColor Green +Write-Host "Build and deploy process completed successfully!" -ForegroundColor Green +if (-not $skipAssetGui) { + Write-Host " - Asset GUI deployed to: $ASSET_GUI_TARGET" -ForegroundColor Green +} +Write-Host " - EAR deployed to: $deployedEarPath" -ForegroundColor Green +if ($config.ear.unpackDir) { + Write-Host " - EAR unpacked to: $($config.ear.unpackDir)" -ForegroundColor Green +} # Restore the original directory Set-Location $originalDirectory diff --git a/build-and-run-asset-gui.ps1 b/build-and-run-asset-gui.ps1 index e3a3ac5..2d01198 100644 --- a/build-and-run-asset-gui.ps1 +++ b/build-and-run-asset-gui.ps1 @@ -1,10 +1,7 @@ # PowerShell script to build and run asset-gui -# Load configuration from JSON file -$config = Get-Content -Raw -Path "$PSScriptRoot\config.json" | ConvertFrom-Json - -$projectDir = $config.assetGui.projectDir -$targetDir = $config.assetGui.targetDir +$projectDir = ".\workspace\asset-gui" +$targetDir = ".\workspace\arm_am-pom\arm_am\WebContent\adv" Write-Host "Building asset-gui project..." -ForegroundColor Green @@ -14,9 +11,8 @@ if (-not (Test-Path $targetDir)) { New-Item -ItemType Directory -Path $targetDir -Force } -# Convert to absolute path and change to project directory -$absoluteProjectDir = [System.IO.Path]::GetFullPath((Join-Path $PSScriptRoot $projectDir)) -Push-Location $absoluteProjectDir +# Change to project directory +Push-Location $projectDir try { # Install dependencies @@ -30,19 +26,23 @@ try { # Copy release folder to target directory Write-Host "Copying release folder to $targetDir..." -ForegroundColor Yellow Pop-Location # Return to original directory to use relative paths correctly - $releaseDir = Join-Path $absoluteProjectDir "release" - if (Test-Path $releaseDir) { - $absoluteTargetDir = [System.IO.Path]::GetFullPath((Join-Path $PSScriptRoot $targetDir)) - Copy-Item -Path "$releaseDir\*" -Destination $absoluteTargetDir -Recurse -Force + if (Test-Path ".\workspace\asset-gui\release") { + # Remove existing content in target directory + if (Test-Path $targetDir) { + Remove-Item -Path "$targetDir\*" -Recurse -Force + } + # Copy new content + Copy-Item -Path ".\workspace\asset-gui\release\*" -Destination $targetDir -Recurse -Force + Write-Host "Release folder copied successfully!" -ForegroundColor Green } else { - Write-Host "Error: Release folder not found at $releaseDir" -ForegroundColor Red + Write-Host "Error: Release folder not found at .\workspace\asset-gui\release" -ForegroundColor Red } # Change back to project directory for serving Push-Location $projectDir - # Start development server - Write-Host "Starting development server..." -ForegroundColor Green + # Start the development server + Write-Host "Starting development server..." -ForegroundColor Yellow gulp watch } finally { # Return to original directory diff --git a/config.json b/config.json index ba5fd93..74c5752 100644 --- a/config.json +++ b/config.json @@ -1,9 +1,9 @@ { - "jbossHome": "C:\\Dev2012\\BUILDERS\\jboss-eap-7.4", - "deploymentDir": "C:\\Dev2012\\BUILDERS\\jboss-eap-7.4\\standalone\\deployments", - "javaHome": "C:\\Dev2012\\BUILDERS\\java\\jdk1.8.0_291", "jboss": { - "configFile": "standalone-IOR-full.xml" + "configFile": "standalone-ADVK-full.xml", + "jbossHome": "C:\\Dev2012\\BUILDERS\\jboss-eap-7.4", + "deploymentDir": "C:\\Dev2012\\BUILDERS\\jboss-eap-7.4\\standalone\\deployments", + "javaHome": "C:\\Dev2012\\BUILDERS\\java\\jdk1.8.0_291" }, "customFormatter": { "src": "src", @@ -12,13 +12,13 @@ "jar": "custom-formatter.jar" }, "ear": { - "projectDir": "C:\\Dev2012\\source\\WindSurf\\adv\\arm_am-pom", + "projectDir": "C:\\Dev2012\\source\\WindSurf\\adv7\\workspace\\arm_am-pom", "mavenProfile": "adv360-DEV", "deployedFile": "adv360-ear.ear", - "unpackDir": ".\\arm_am-unpacked" + "unpackDir": "C:\\Dev2012\\source\\WindSurf\\adv7\\workspace\\arm_am-unpacked" }, "assetGui": { - "projectDir": ".\\asset-gui", - "targetDir": ".\\arm_am-pom\\arm_am\\WebContent\\adv" + "projectDir": "C:\\Dev2012\\source\\WindSurf\\adv7\\workspace\\asset-gui", + "targetDir": "C:\\Dev2012\\source\\WindSurf\\adv7\\workspace\\arm_am-pom\\arm_am\\WebContent\\adv" } } diff --git a/config/standalone-ADVK-full.xml b/config/standalone-ADVK-full.xml new file mode 100644 index 0000000..580af8f --- /dev/null +++ b/config/standalone-ADVK-full.xml @@ -0,0 +1,637 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + jdbc:h2:mem:test;DB_CLOSE_DELAY=-1;DB_CLOSE_ON_EXIT=FALSE + h2 + + sa + sa + + + + jdbc:postgresql://localhost:5432/advk?currentSchema=advk_own + postgresql + + postgres + Enea4010 + + + select 1 + true + 300000 + + + 5 + + + + + org.h2.jdbcx.JdbcDataSource + + + org.postgresql.Driver + + + + + + + + + + + + + + + + + false + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + ${jboss.bind.address:127.0.0.1} + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/start-jboss.ps1 b/start-jboss.ps1 index 5a958d3..632d99a 100644 --- a/start-jboss.ps1 +++ b/start-jboss.ps1 @@ -1,13 +1,20 @@ -# PowerShell script to start JBoss EAP 7.4 +# PowerShell script to start JBoss EAP 8.0 -# Load configuration from JSON file -$config = Get-Content -Raw -Path "$PSScriptRoot\config.json" | ConvertFrom-Json +# Read configuration from config.json +$configPath = Join-Path $PSScriptRoot "config.json" +if (-not (Test-Path $configPath)) { + Write-Host "Error: config.json not found at $configPath" -ForegroundColor Red + exit 1 +} -# Configuration variables from JSON -$JBOSS_HOME = $config.jbossHome -$JAVA_HOME = $config.javaHome +$config = Get-Content $configPath -Raw | ConvertFrom-Json -# Function to check if JBoss is already running +# Configuration from config.json +$JBOSS_HOME = $config.jboss.jbossHome +$JAVA_HOME = $config.jboss.javaHome +$CONFIG_FILE = $config.jboss.configFile + +# Function to check if JBoss is running function Test-JBossRunning { $jbossProcess = Get-CimInstance Win32_Process -Filter "Name = 'java.exe'" | Where-Object { $_.CommandLine -like "*jboss.home.dir=$JBOSS_HOME*" } @@ -16,7 +23,7 @@ function Test-JBossRunning { # Check if Java exists if (-not (Test-Path $JAVA_HOME)) { - Write-Host "Error: Java 8 not found at $JAVA_HOME" -ForegroundColor Red + Write-Host "Error: Java not found at $JAVA_HOME" -ForegroundColor Red exit 1 } @@ -26,6 +33,38 @@ if (-not (Test-Path $JBOSS_HOME)) { exit 1 } +# Copy configuration file from local config directory +$localConfigDir = Join-Path $PSScriptRoot "config" +$localConfigFile = Join-Path $localConfigDir (Split-Path $CONFIG_FILE -Leaf) +$jbossConfigDir = Join-Path $JBOSS_HOME "standalone\configuration" + +if (Test-Path $localConfigFile) { + Write-Host "Copying configuration file from local config directory..." -ForegroundColor Yellow + Write-Host "From: $localConfigFile" -ForegroundColor Yellow + Write-Host "To: $jbossConfigDir" -ForegroundColor Yellow + + # Create backup of existing config if it exists + $targetConfigFile = Join-Path $jbossConfigDir (Split-Path $CONFIG_FILE -Leaf) + if (Test-Path $targetConfigFile) { + $backupFile = "$targetConfigFile.backup" + Write-Host "Creating backup of existing config: $backupFile" -ForegroundColor Yellow + Copy-Item $targetConfigFile $backupFile -Force + } + + # Copy the new config file + Copy-Item $localConfigFile $jbossConfigDir -Force +} else { + Write-Host "Warning: Local config file not found at $localConfigFile" -ForegroundColor Yellow + Write-Host "Using existing JBoss configuration" -ForegroundColor Yellow +} + +# Check if configuration file exists in JBoss +$configFile = Join-Path $jbossConfigDir (Split-Path $CONFIG_FILE -Leaf) +if (-not (Test-Path $configFile)) { + Write-Host "Error: Configuration file not found at $configFile" -ForegroundColor Red + exit 1 +} + # Set environment variables $env:JAVA_HOME = $JAVA_HOME $env:JBOSS_HOME = $JBOSS_HOME @@ -34,31 +73,20 @@ $env:NOPAUSE = "true" # Remove this as it might affect logging # $env:LAUNCH_JBOSS_IN_BACKGROUND = "true" -# Get configuration file from config.json -$configFile = $config.jboss.configFile -Write-Host "Configuration file path: $configFile" -ForegroundColor Cyan - -# Copy configuration file from local config directory -$sourceConfig = "$PSScriptRoot\config\$configFile" -$targetConfig = "$JBOSS_HOME\standalone\configuration\$configFile" -if (Test-Path $sourceConfig) { - Write-Host "Copying configuration file from $sourceConfig to $targetConfig" -ForegroundColor Yellow - Copy-Item -Path $sourceConfig -Destination $targetConfig -Force -} - # Check if JBoss is already running if (Test-JBossRunning) { Write-Host "JBoss is already running!" -ForegroundColor Yellow exit 0 } -Write-Host "Starting JBoss EAP 7.4..." -ForegroundColor Green +Write-Host "Starting JBoss EAP 8.0..." -ForegroundColor Green Write-Host "Using Java from: $JAVA_HOME" -ForegroundColor Yellow Write-Host "JBoss Home: $JBOSS_HOME" -ForegroundColor Yellow -Write-Host "Using configuration: $configFile" -ForegroundColor Yellow +Write-Host "Using configuration: $CONFIG_FILE" -ForegroundColor Yellow -# Set JVM options -$jvmOpts = @( +# Start JBoss in standalone mode +$startScript = Join-Path $JBOSS_HOME "bin\standalone.bat" +$jvmOptions = @( "-DIDServer=GS", "-Dbtf.PathToParse=C:\Dev2012\advc0\in", "-Djava.awt.headless=true", @@ -70,18 +98,20 @@ $jvmOpts = @( "-agentlib:jdwp=transport=dt_socket,address=8787,server=y,suspend=n" ) -Write-Host "Starting JBoss with custom JVM options..." -ForegroundColor Yellow -Write-Host "JVM Options: $($jvmOpts -join ' ')" -ForegroundColor Gray +# Add JVM options to JAVA_OPTS +$env:JAVA_OPTS = "$($jvmOptions -join ' ')" + +Write-Host "Starting JBoss with custom JVM options..." -ForegroundColor Green +Write-Host "JVM Options: $env:JAVA_OPTS" -ForegroundColor Yellow +Write-Host "Remote debugging enabled on port 8787" -ForegroundColor Cyan # Create the command line arguments -$jvmOptsString = $jvmOpts -join ' ' -$env:JAVA_OPTS = $jvmOptsString -$cmdArgs = "-c $configFile --debug -b 0.0.0.0 -bmanagement 0.0.0.0" +$cmdArgs = "-c $CONFIG_FILE --debug -b 0.0.0.0 -bmanagement 0.0.0.0" # Start JBoss - Modified to use Start-Process with RedirectStandardOutput -$logFile = Join-Path $JBOSS_HOME "standalone\log\server.log" +$logFile = Join-Path $JBOSS_HOME "standalone\log\server-info.log" $processStartInfo = @{ - FilePath = Join-Path $JBOSS_HOME "bin\standalone.bat" + FilePath = $startScript ArgumentList = $cmdArgs RedirectStandardOutput = $logFile RedirectStandardError = Join-Path $JBOSS_HOME "standalone\log\server_error.log" @@ -90,7 +120,6 @@ $processStartInfo = @{ PassThru = $true } -Write-Host "Remote debugging enabled on port 8787" -ForegroundColor Yellow Write-Host "Starting JBoss and redirecting output to $logFile" -ForegroundColor Yellow $jbossProcess = Start-Process @processStartInfo diff --git a/stop-jboss.ps1 b/stop-jboss.ps1 index db2bfe2..619e84c 100644 --- a/stop-jboss.ps1 +++ b/stop-jboss.ps1 @@ -1,12 +1,19 @@ -# PowerShell script to stop JBoss EAP 7.4 +# PowerShell script to stop JBoss EAP 8.0 -# Load configuration from JSON file -$config = Get-Content -Raw -Path "$PSScriptRoot\config.json" | ConvertFrom-Json +# Read configuration from config.json +$configPath = Join-Path $PSScriptRoot "config.json" +if (-not (Test-Path $configPath)) { + Write-Host "Error: config.json not found at $configPath" -ForegroundColor Red + exit 1 +} -# Configuration variables from JSON -$JBOSS_HOME = $config.jbossHome +$config = Get-Content $configPath -Raw | ConvertFrom-Json -Write-Host "Stopping JBoss EAP 7.4..." -ForegroundColor Yellow +# Configuration from config.json +$JBOSS_HOME = $config.jboss.jbossHome + +Write-Host "Stopping JBoss EAP 8.0..." -ForegroundColor Yellow +Write-Host "JBoss Home: $JBOSS_HOME" -ForegroundColor Yellow # Find and stop JBoss process $jbossProcess = Get-CimInstance Win32_Process -Filter "Name = 'java.exe'" | @@ -14,7 +21,29 @@ $jbossProcess = Get-CimInstance Win32_Process -Filter "Name = 'java.exe'" | if ($jbossProcess) { Write-Host "Found JBoss process (PID: $($jbossProcess.ProcessId))" -ForegroundColor Yellow - Stop-Process -Id $jbossProcess.ProcessId -Force + + # Try graceful shutdown first + Write-Host "Attempting graceful shutdown..." -ForegroundColor Yellow + $jbossCli = Join-Path $JBOSS_HOME "bin\jboss-cli.bat" + $cliCommand = "--connect --command=:shutdown" + + try { + Start-Process -FilePath $jbossCli -ArgumentList $cliCommand -Wait -NoNewWindow + Start-Sleep -Seconds 5 # Give it time for graceful shutdown + + # Check if process is still running + $processStillRunning = Get-Process -Id $jbossProcess.ProcessId -ErrorAction SilentlyContinue + + if ($processStillRunning) { + Write-Host "Graceful shutdown failed, forcing process termination..." -ForegroundColor Yellow + Stop-Process -Id $jbossProcess.ProcessId -Force + } + } + catch { + Write-Host "Graceful shutdown failed, forcing process termination..." -ForegroundColor Yellow + Stop-Process -Id $jbossProcess.ProcessId -Force + } + Write-Host "JBoss process stopped" -ForegroundColor Green } else { Write-Host "No JBoss process found running" -ForegroundColor Yellow @@ -22,3 +51,13 @@ if ($jbossProcess) { # Wait a moment to ensure process is fully stopped Start-Sleep -Seconds 2 + +# Verify JBoss is stopped +$jbossStillRunning = Get-CimInstance Win32_Process -Filter "Name = 'java.exe'" | + Where-Object { $_.CommandLine -like "*jboss.home.dir=$JBOSS_HOME*" } + +if ($jbossStillRunning) { + Write-Host "Warning: JBoss process is still running!" -ForegroundColor Red +} else { + Write-Host "Confirmed: JBoss is fully stopped" -ForegroundColor Green +} diff --git a/unpack_ear.ps1 b/unpack_ear.ps1 index 51c2312..a3977c4 100644 --- a/unpack_ear.ps1 +++ b/unpack_ear.ps1 @@ -1,32 +1,59 @@ -# Load configuration from JSON file -$config = Get-Content -Raw -Path "$PSScriptRoot\config.json" | ConvertFrom-Json +# PowerShell script to unpack EAR file -# Set paths from configuration -$sourceFile = Join-Path $config.deploymentDir $config.ear.deployedFile +# Read configuration from config.json +$configPath = Join-Path $PSScriptRoot "config.json" +if (-not (Test-Path $configPath)) { + Write-Host "Error: config.json not found at $configPath" -ForegroundColor Red + exit 1 +} + +$config = Get-Content $configPath -Raw | ConvertFrom-Json + +# Get paths from config +$sourceFile = Join-Path $config.jboss.jbossHome "standalone\deployments\adv360-ear.ear" $destinationPath = $config.ear.unpackDir +Write-Host "Using configuration:" -ForegroundColor Yellow +Write-Host " Source EAR: $sourceFile" -ForegroundColor Yellow +Write-Host " Destination: $destinationPath" -ForegroundColor Yellow + +# Verify source file exists +if (-not (Test-Path -Path $sourceFile)) { + Write-Host "Error: Source EAR file not found at $sourceFile" -ForegroundColor Red + exit 1 +} + # Remove destination directory if it exists if (Test-Path -Path $destinationPath) { Remove-Item -Path $destinationPath -Recurse -Force - Write-Host "Removed existing directory: $destinationPath" + Write-Host "Removed existing directory: $destinationPath" -ForegroundColor Yellow } # Create destination directory if (-not (Test-Path -Path $destinationPath)) { - New-Item -ItemType Directory -Path $destinationPath -Force + New-Item -ItemType Directory -Path $destinationPath -Force | Out-Null + Write-Host "Created destination directory: $destinationPath" -ForegroundColor Yellow } -# Rename .ear to .zip temporarily to use Expand-Archive -$tempZipPath = $sourceFile -replace '\.ear$', '.zip' -Copy-Item -Path $sourceFile -Destination $tempZipPath +# Try using 7-Zip first, fall back to zip method if not available +$7zPath = "C:\Program Files\7-Zip\7z.exe" +if (Test-Path $7zPath) { + Write-Host "Using 7-Zip to extract EAR..." -ForegroundColor Yellow + Start-Process -FilePath $7zPath -ArgumentList "x", "`"$sourceFile`"", "-o`"$destinationPath`"", "-y" -Wait -NoNewWindow +} else { + Write-Host "7-Zip not found, using PowerShell Expand-Archive..." -ForegroundColor Yellow + # Rename .ear to .zip temporarily to use Expand-Archive + $tempZipPath = $sourceFile -replace '\.ear$', '.zip' + Copy-Item -Path $sourceFile -Destination $tempZipPath + + # Extract the EAR contents + Expand-Archive -Path $tempZipPath -DestinationPath $destinationPath -Force + + # Clean up temporary zip file + Remove-Item -Path $tempZipPath +} -# Extract the EAR contents -Expand-Archive -Path $tempZipPath -DestinationPath $destinationPath -Force - -# Clean up temporary zip file -Remove-Item -Path $tempZipPath - -Write-Host "EAR file extracted to $destinationPath" +Write-Host "EAR file extracted to $destinationPath" -ForegroundColor Green # Function to unpack archive files (war/ejb) function Expand-JavaArchive { @@ -43,10 +70,19 @@ function Expand-JavaArchive { New-Item -ItemType Directory -Path $destinationPath -Force } - # Extract contents - Expand-Archive -Path $tempZipPath -DestinationPath $destinationPath -Force + # Try using 7-Zip first, fall back to zip method if not available + if (Test-Path $7zPath) { + Write-Host "Using 7-Zip to extract $archivePath..." -ForegroundColor Yellow + Start-Process -FilePath $7zPath -ArgumentList "x", "`"$tempZipPath`"", "-o`"$destinationPath`"", "-y" -Wait -NoNewWindow + } else { + Write-Host "7-Zip not found, using PowerShell Expand-Archive..." -ForegroundColor Yellow + # Extract contents + Expand-Archive -Path $tempZipPath -DestinationPath $destinationPath -Force + } + + # Clean up temporary zip file Remove-Item -Path $tempZipPath - Write-Host "Extracted $archivePath to $destinationPath" + Write-Host "Extracted $archivePath to $destinationPath" -ForegroundColor Green } # Find and extract WAR and EJB files