Project

General

Profile

dist_fix.patch

Teodor Gorghe, 08/06/2026 03:22 AM

Download (6.31 KB)

View differences:

new/build.gradle 2026-08-06 05:12:25 +0000
791 791
// ============================================================================
792 792
def aopLtwHome = 'com/goldencode/p2j/aspects/ltw'
793 793

  
794
tasks.named('jar') {
795
    dependsOn 'prepareClassesAop', 'makeManifests', 'copyDependencies',
796
              'mergePostgreSQLUDFs', 'mergeMariaDBUDFs', 'mergeSqlServerUDFs',
797
              'copyToolsScripts', 'fwdspiJar', 'fwdaopltwJar',
798
              'createCompileClasspathJar', 'createTestsClasspathJar'
799
    archiveFileName = 'p2j.jar'
800
    destinationDirectory = file("${layout.buildDirectory.get()}/lib")
794
def p2jJarContent = copySpec {
801 795
    from("${layout.buildDirectory.get()}/classes.aop") {
802 796
        include 'com/goldencode/**'
803 797
        include 'rules/**'
......
835 829
        include 'org.slf4j.spi.SLF4JServiceProvider'
836 830
        into 'META-INF/services'
837 831
    }
838
    duplicatesStrategy = DuplicatesStrategy.INCLUDE
839 832
    // UDF SQL files
840 833
    from("${layout.buildDirectory.get()}") {
841 834
        include 'udf/**/udfs.sql'
......
846 839
    from("${layout.buildDirectory.get()}") {
847 840
        include 'tools/scripts/*.sql'
848 841
    }
842
}
843

  
844
tasks.named('jar') {
845
    dependsOn 'prepareClassesAop', 'makeManifests', 'copyDependencies',
846
              'mergePostgreSQLUDFs', 'mergeMariaDBUDFs', 'mergeSqlServerUDFs',
847
              'copyToolsScripts', 'fwdspiJar', 'fwdaopltwJar',
848
              'createCompileClasspathJar', 'createTestsClasspathJar'
849
    archiveFileName = 'p2j.jar'
850
    destinationDirectory = file("${layout.buildDirectory.get()}/lib")
851
    with p2jJarContent
852
    duplicatesStrategy = DuplicatesStrategy.INCLUDE
849 853
    // Manifest must be set at execution time because the version string is
850 854
    // computed by the buildVersion task
851 855
    doFirst {
......
859 863
    }
860 864
}
861 865

  
866
['Client', 'Server'].each { dist ->
867
    tasks.register("p2jJar${dist}", Jar) {
868
        dependsOn 'jar'
869
        archiveFileName = 'p2j.jar'
870
        destinationDirectory = file("${layout.buildDirectory.get()}/lib.${dist.toLowerCase()}")
871
        with p2jJarContent
872
        duplicatesStrategy = DuplicatesStrategy.INCLUDE
873
        doFirst {
874
            manifest {
875
                attributes(
876
                    'Implementation-Version': ant.properties['fwdver'],
877
                    'Main-Class': 'com.goldencode.p2j.Version',
878
                    'Class-Path': configurations.getByName("fwd${dist}").collect { it.name }.join(' ')
879
                )
880
            }
881
        }
882
    }
883
}
884

  
862 885
tasks.register('fwdspiJar', Jar) {
863 886
    dependsOn 'prepareClassesAop', 'makeManifests'
864 887
    archiveFileName = 'fwdspi.jar'
......
1081 1104
}
1082 1105

  
1083 1106
tasks.register('archiveServer', Zip) {
1084
    dependsOn 'allJars', 'buildVersion', 'distribution', 'sheet:war', 'nativeCompile'
1107
    dependsOn 'allJars', 'buildVersion', 'distribution', 'sheet:war', 'nativeCompile',
1108
              'p2jJarServer', 'verifyDistributions'
1085 1109
    doFirst {
1086 1110
        def ver = ant.properties['fwdver'] ?: 'undefined'
1087 1111
        def parts = ver.tokenize('_')
......
1094 1118
    }
1095 1119
    def libname = isWindows ? 'p2j.dll' : 'libp2j.so'
1096 1120
    destinationDirectory = file(distDir)
1121
    from("${layout.buildDirectory.get()}/lib.server") {
1122
        into 'lib'
1123
        include 'p2j.jar'
1124
    }
1097 1125
    from("${layout.buildDirectory.get()}/lib") {
1098 1126
        into 'lib'
1099
        include 'p2j.jar', 'fwdaopltw.jar', 'fwd_sheet.war', libname
1127
        include 'fwdaopltw.jar', 'fwd_sheet.war', libname
1100 1128
    }
1101 1129
    from("${layout.buildDirectory.get()}/lib") {
1102 1130
        into 'lib/spi'
......
1106 1134
}
1107 1135

  
1108 1136
tasks.register('archiveClient', Zip) {
1109
    dependsOn 'allJars', 'buildVersion', 'distribution', 'nativeCompile'
1137
    dependsOn 'allJars', 'buildVersion', 'distribution', 'nativeCompile',
1138
              'p2jJarClient', 'verifyDistributions'
1110 1139
    doFirst {
1111 1140
        def ver = ant.properties['fwdver'] ?: 'undefined'
1112 1141
        def parts = ver.tokenize('_')
......
1119 1148
    }
1120 1149
    def libname = isWindows ? 'p2j.dll' : 'libp2j.so'
1121 1150
    destinationDirectory = file(distDir)
1151
    from("${layout.buildDirectory.get()}/lib.client") {
1152
        into 'lib'
1153
        include 'p2j.jar'
1154
    }
1122 1155
    from("${layout.buildDirectory.get()}/lib") {
1123 1156
        into 'lib'
1124
        include 'p2j.jar', libname
1157
        include libname
1125 1158
    }
1126 1159
    from("${distDir}/client") { into 'lib' }
1127 1160
}
......
1207 1240
    from("${distDir}/docs") { include 'api/**' }
1208 1241
}
1209 1242

  
1243
tasks.register('verifyDistributions') {
1244
    dependsOn 'jar', 'p2jJarClient', 'p2jJarServer', 'distribution'
1245
    doLast {
1246
        def problems = []
1247
        def check = { String dist, File jarFile, File libSet ->
1248
            def classPath = new java.util.jar.JarFile(jarFile).withCloseable { jf ->
1249
                jf.manifest?.mainAttributes?.getValue('Class-Path') ?: ''
1250
            }
1251
            def available = (libSet.listFiles() ?: []).collect { it.name } as Set
1252
            def missing = classPath.tokenize(' ').findAll { !available.contains(it) }
1253
            if (missing) {
1254
                problems << "${dist}: ${jarFile} names ${missing.size()} JAR(s) absent from " +
1255
                            "${libSet}: ${missing.join(', ')}"
1256
            }
1257
        }
1258
        def buildLib = file("${layout.buildDirectory.get()}/lib")
1259
        check('convert', new File(buildLib, 'p2j.jar'), buildLib)
1260
        check('server', file("${layout.buildDirectory.get()}/lib.server/p2j.jar"),
1261
              file("${distDir}/server"))
1262
        check('client', file("${layout.buildDirectory.get()}/lib.client/p2j.jar"),
1263
              file("${distDir}/client"))
1264
        if (problems) {
1265
            throw new GradleException("The p2j.jar Class-Path manifest does not match the " +
1266
                                      "distribution it is shipped in:\n" + problems.join('\n'))
1267
        }
1268
    }
1269
}
1270

  
1210 1271
tasks.register('archiveAll') {
1211 1272
    dependsOn 'archiveConvert', 'archiveServer', 'archiveClient',
1212 1273
              'archiveNative', 'archiveSpawner', 'archiveAdmin', 'archiveDocs'
......
2514 2575
tasks.named('archiveAdmin') { mustRunAfter 'clean' }
2515 2576
tasks.named('archiveDocs') { mustRunAfter 'clean' }
2516 2577
tasks.named('archiveAll') { mustRunAfter 'clean' }
2578
tasks.named('p2jJarClient') { mustRunAfter 'clean' }
2579
tasks.named('p2jJarServer') { mustRunAfter 'clean' }
2580
tasks.named('verifyDistributions') { mustRunAfter 'clean' }