AutoFirma ins and outs (1). Downloading Autofirma and jmulticard. Using Gradle instead of Maven in jmulticard project
0. Introduction
There are 2 main projects to download clienteafirma and jmulticard
jmulticard should not be necessary to be downloaded, but there is an error in clienteafirma that cannot find the pom.xml of jmulticard, and it is recommended to download the jmulticard project.
Let's begin with creating a workspace folder to store the required files. In this case WS-AUTOFIRMA3
1. clienteafirma download
1. Go to this url https://github.com/ctt-gob-es/clienteafirma and click on tags. You will be sent to
https://github.com/ctt-gob-es/clienteafirma/tags
2. You can select the version you prefer
Let's select the last one (in this case 1.7.2)
and download it to the WS_AUTOFIRMA3 folder and uncompress it in that folder
2. jmulticard download
1. Go to this url https://github.com/ctt-gob-es/jmulticard and click on tags. You will be sent to
https://github.com/ctt-gob-es/jmulticard/tags
Let's select the last one (in this case 1.7)
and download it to the WS_AUTOFIRMA3 folder and uncompress it in that folder
3. Creating a gradle parent project
4. Importing the AutoFirma projects
4.1. Renaming and grouping folders
Once you have uncompressed the files, rename the folder clientafirma-1.7.2 to Afirma
Note that I won't use jmulticard-android.
Copy the folders jmulticard, jmulticard-android, jmulticard-jse, jmulticard-jsr268 and jmulticard-ui from the folder jmulticard-1.7 to the folder Afirma
The content of the Afirma folder is:
afirma-core-keystores afirma-server-triphase-signer
afirma-core-massive afirma-server-triphase-signer-core
afirma-crypto-batch-client afirma-server-triphase-signer-document
afirma-crypto-cades afirma-signature-retriever
afirma-crypto-cades-multi afirma-signature-storage
afirma-crypto-cadestri-client afirma-simple
afirma-crypto-cipher afirma-simple-installer
afirma-crypto-cms afirma-simple-plugins
afirma-crypto-cms-enveloper afirma-simple-plugin-validatecerts
afirma-crypto-core-pkcs7 afirma-standalone
afirma-crypto-core-pkcs7-tsp afirma-standalone-installer
afirma-crypto-core-xml afirma-ui-applet
afirma-crypto-jarverifier afirma-ui-applet-deploy
afirma-crypto-odf afirma-ui-core-jse
afirma-crypto-ooxml afirma-ui-core-jse-keystores
afirma-crypto-padestri-client afirma-ui-miniapplet
afirma-crypto-pdf afirma-ui-miniapplet-deploy
afirma-crypto-pdf-enhancer afirma-ui-simple-configurator
afirma-crypto-validation afirma-ui-simple-webstart
afirma-crypto-xades afirma-windows-store
afirma-crypto-xadestri-client jmulticard
afirma-crypto-xmlsignature jmulticard-jse
afirma-keystores-capiaddressbook jmulticard-jsr268
afirma-keystores-filters jmulticard-ui
afirma-keystores-mozilla license
afirma-keystores-single media
afirma-miniapplet-report pom.xml
afirma-miniapplet-store-testdata README.md
afirma-report-fail-tests settings.gradle
4.2. Creating the build.gradle of the Afirma parent project
//==============================BEGIN CODE============================================= group 'com.ximodante' subprojects { apply plugin: 'eclipse' apply plugin: 'java' apply plugin: 'java-library' project.jar.destinationDirectory = file("$rootDir/../mynewtargets2") //project.archivesBaseName = "$name" project.version = '1.7' eclipse { //Avoids java.smartcardio complaint classpath { file { whenMerged { def jre = entries.find { it.path.contains 'org.eclipse.jdt.launching.JRE_CONTAINER' } jre.entryAttributes['module'] = 'true' jre.entryAttributes['limit-modules'] = 'java.se,jdk.accessibility,jdk.dynalink,jdk.httpserver,jdk.jartool,jdk.javadoc,jdk.jconsole,jdk.jshell,jdk.jsobject,jdk.management.jfr,jdk.net,jdk.nio.mapmode,jdk.sctp,jdk.security.auth,jdk.security.jgss,jdk.unsupported,jdk.unsupported.desktop,jdk.xml.dom,java.smartcardio' jre.entryAttributes['add-modules'] = 'java.smartcardio' //--limit-modules java.se --add-modules java.smartcardio } } } } //Define a task for creating a uber jar foer every project // Just run ./gradlew uberJar in the parent project tasks.register('uberJar', Jar) { destinationDirectory = file("$rootDir/../mynewtargets2") zip64=true archiveClassifier = 'uber1' duplicatesStrategy = DuplicatesStrategy.EXCLUDE manifest.attributes["Main-Class"] = "es.gob.afirma.standalone.SimpleAfirma" from sourceSets.main.output from sourceSets.main.allSource dependsOn configurations.runtimeClasspath from { configurations.runtimeClasspath.findAll { it.name.endsWith('jar') }.collect { zipTree(it) } } } } //==============================END CODE=============================================
4.3. Creating the settings.gradle of the Afirma parent project
//============================BEGIN=======================================================rootProject.name = 'Afirma' //include('lib') include( 'afirma-core', 'afirma-core-keystores', 'afirma-core-massive', 'afirma-crypto-batch-client', 'afirma-crypto-cades', 'afirma-crypto-cades-multi', 'afirma-crypto-cadestri-client', //'afirma-crypto-cipher', 'afirma-crypto-cms', //'afirma-crypto-cms-enveloper', 'afirma-crypto-core-pkcs7', 'afirma-crypto-core-pkcs7-tsp', 'afirma-crypto-core-xml', //'afirma-crypto-jarverifier', 'afirma-crypto-odf', 'afirma-crypto-ooxml', 'afirma-crypto-padestri-client', 'afirma-crypto-pdf', //'afirma-crypto-pdf-enhancer', 'afirma-crypto-validation', 'afirma-crypto-xades', 'afirma-crypto-xadestri-client', 'afirma-crypto-xmlsignature', //'afirma-keystores-capiaddressbook', 'afirma-keystores-filters', 'afirma-keystores-mozilla', //'afirma-keystores-single', //'afirma-miniapplet-report', //'afirma-miniapplet-store-testdata', //'afirma-report-fail-tests', //'afirma-server-simple-webstart', //'afirma-server-triphase-signer', //'afirma-server-triphase-signer-core', //'afirma-server-triphase-signer-document', //'afirma-signature-retriever', //'afirma-signature-storage', 'afirma-simple', //'afirma-simple-installer', 'afirma-simple-plugins', //'afirma-simple-plugin-validatecerts', //'afirma-standalone', //'afirma-standalone-installer', //'afirma-ui-applet', //'afirma-ui-applet-deploy', 'afirma-ui-core-jse', 'afirma-ui-core-jse-keystores', //'afirma-ui-miniapplet', //'afirma-ui-miniapplet-deploy', //'afirma-ui-simple-configurator', //'afirma-ui-simple-webstart', //'afirma-windows-store', 'jmulticard', //'jmulticard-android', 'jmulticard-jse', 'jmulticard-jsr268', 'jmulticard-ui' ) dependencyResolutionManagement { repositories { jcenter() mavenCentral() maven { url "https://jitpack.io" } //@see: https://stackoverflow.com/questions/38905939/how-to-import-library-from-jitpack-io-using-gradle //aspose { url "http://repository.aspose.com/repo/" } NO VA !!! flatDir {dirs "$rootDir/../mynewtargets2"} //@see https://stackoverflow.com/a/25966303 } versionCatalogs { libs { library('junit-jupiter', 'org.junit.jupiter:junit-jupiter:5.9.2') library('junit', 'junit:junit:4.13.2') library('pdfbox', 'org.apache.pdfbox:pdfbox:2.0.27') //2.0.24 library('google.analytics', 'com.dmurph:JGoogleAnalyticsTracker:1.2.0') library('spongycastle.core', 'com.madgag.spongycastle:core:1.58.0.0') library('spongycastle.prov', 'com.madgag.spongycastle:prov:1.58.0.0') library('spongycastle.bcpkix.jdk15on', 'com.madgag.spongycastle:bcpkix-jdk15on:1.58.0.0') library('websocket', 'org.java-websocket:Java-WebSocket:1.5.3') library('json.api', 'javax.json:javax.json-api:1.1.4') library('json', 'org.glassfish:javax.json:1.1.4') library('javahelp', 'javax.help:javahelp:2.0.05') library('proxy.vole', 'com.github.markusbernhardt:proxy-vole:1.0.5') library('jna', 'net.java.dev.jna:jna:5.13.0') library('jpeg2000', 'com.github.jai-imageio:jai-imageio-jpeg2000:1.4.0') library('jxades', 'es.uji.crypto.xades:jxades:0.2.2') library('xom', 'com.io7m.xom:xom:1.2.10') library('xmlsec', 'org.apache.santuario:xmlsec:3.0.1') library('xerces', 'xerces:xercesImpl:2.12.2') library('afirma.itext', 'es.gob.afirma.lib:afirma-lib-itext:1.3') library('jmimemagic', 'es.gob.afirma.lib:afirma-lib-jmimemagic:0.0.6') } } }
//==================================END=================================================
Consulting the pom.xml file from the main project, I am going to generate only the
4.4. Creating the build.gradle files for subprojects "jmulticard*"
These are the build.grade files(consulting the dependencioes from the pom.xml files) for these projects, take into account that the rest of variables (plugins, repositories, jar name, version, are defined in the parent project, and the task uberJar for generating the uber jar:jmulticard://============================BEGIN======================================================= dependencies { /* Spongycastle */ api libs.spongycastle.core api libs.spongycastle.provapi libs.junit
}//==================================END=================================================
jmulticard-jse://============================BEGIN======================================================= dependencies {/* jpeg2000 */ api libs.jpeg2000api libs.junit
api (project(":jmulticard")) api (project(":jmulticard-ui")) api (project(":jmulticard-jsr268")) }//==================================END=================================================
jmulticard-jsr268://============================BEGIN======================================================= dependencies { api libs.junitapi (project(":jmulticard")) }
//==================================END=================================================
jmulticard-ui://============================BEGIN======================================================= dependencies { api libs.junitapi (project(":jmulticard")) }//==================================END=================================================
5. Compiling the project
Goto the terminal and ecxecute./gradlew uberJar
5. ERRORS (java.smartcardio dependency)
This has been solved in the parent gradle.build project see the yellow background lines, in my answer in stackoverflowOLD SOLUTION (Not good as the problem returns when refreshing the gradle project in Eclipse)The error regarding javax.smartcardio.* can be solved partially as in this stackoverflow response
Comments
Post a Comment