>From 6125446085b97028d74ffbf147d8c50ae6bc8c0b Mon Sep 17 00:00:00 2001
From: "Endi S. Dewata" <edewata@redhat.com>
Date: Wed, 5 Oct 2016 22:58:16 +0200
Subject: [PATCH] Removed duplicate classes.

The CMake scripts have been modified to store compiled Java classes
in separate folders for each JAR files to avoid duplicates.

https://fedorahosted.org/pki/ticket/2505
---
 CMakeLists.txt                                     | 1 -
 base/ca/src/CMakeLists.txt                         | 4 ++--
 base/common/src/CMakeLists.txt                     | 4 ++--
 base/console/src/CMakeLists.txt                    | 5 ++---
 base/java-tools/src/CMakeLists.txt                 | 4 ++--
 base/kra/src/CMakeLists.txt                        | 4 ++--
 base/ocsp/src/CMakeLists.txt                       | 4 ++--
 base/server/cms/src/CMakeLists.txt                 | 4 ++--
 base/server/cmscore/src/CMakeLists.txt             | 4 ++--
 base/symkey/src/CMakeLists.txt                     | 4 ++--
 base/symkey/src/com/netscape/symkey/CMakeLists.txt | 2 +-
 base/tks/src/CMakeLists.txt                        | 4 ++--
 base/tps/src/CMakeLists.txt                        | 4 ++--
 base/util/src/CMakeLists.txt                       | 8 ++++----
 14 files changed, 27 insertions(+), 29 deletions(-)

diff --git a/CMakeLists.txt b/CMakeLists.txt
index c74605633f09958532f386e709aaa8dd17a6e701..457e144a307d0e58aaf9f57d96efa523456e8ff4 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -54,7 +54,6 @@ macro_ensure_out_of_source_build("${PROJECT_NAME} requires an out of source buil
 include(MacroCopyFile)
 include(Java)
 
-file(MAKE_DIRECTORY ${CMAKE_BINARY_DIR}/classes)
 file(MAKE_DIRECTORY ${CMAKE_BINARY_DIR}/dist)
 
 # required for all PKI components
diff --git a/base/ca/src/CMakeLists.txt b/base/ca/src/CMakeLists.txt
index 854ce28a25f729181a5009af13fde5bf0b4c013f..e612d726e92711b6a25859cc80fe5c460d88c634 100644
--- a/base/ca/src/CMakeLists.txt
+++ b/base/ca/src/CMakeLists.txt
@@ -96,7 +96,7 @@ javac(pki-ca-classes
         ${PKI_CMSUTIL_JAR} ${PKI_NSUTIL_JAR}
         ${PKI_CERTSRV_JAR} ${PKI_CMS_JAR} ${PKI_CMSCORE_JAR}
     OUTPUT_DIR
-        ${CMAKE_BINARY_DIR}/classes
+        ${CMAKE_CURRENT_BINARY_DIR}/classes
     DEPENDS
         symkey-jar pki-nsutil-jar pki-cmsutil-jar pki-certsrv-jar pki-cms-jar pki-cmscore-jar
 )
@@ -114,7 +114,7 @@ jar(pki-ca-jar
     PARAMS
         ${CMAKE_CURRENT_BINARY_DIR}/pki-ca.mf
     INPUT_DIR
-        ${CMAKE_BINARY_DIR}/classes
+        ${CMAKE_CURRENT_BINARY_DIR}/classes
     FILES
         com/netscape/ca/*.class
         org/dogtagpki/server/ca/*.class
diff --git a/base/common/src/CMakeLists.txt b/base/common/src/CMakeLists.txt
index ee41b2f47bdab9495c69167a6467cdc6471d86e3..7ce833c6c75dc7cd8c909c2c0a5a2106f1520d32 100644
--- a/base/common/src/CMakeLists.txt
+++ b/base/common/src/CMakeLists.txt
@@ -131,7 +131,7 @@ javac(pki-certsrv-classes
         ${JAXRS_API_JAR} ${RESTEASY_JAXRS_JAR} ${RESTEASY_ATOM_PROVIDER_JAR} ${RESTEASY_CLIENT_JAR}
         ${HTTPCLIENT_JAR} ${HTTPCORE_JAR}
     OUTPUT_DIR
-        ${CMAKE_BINARY_DIR}/classes
+        ${CMAKE_CURRENT_BINARY_DIR}/classes
     DEPENDS
         pki-nsutil-jar pki-cmsutil-jar
 )
@@ -149,7 +149,7 @@ jar(pki-certsrv-jar
     PARAMS
         ${CMAKE_CURRENT_BINARY_DIR}/pki-certsrv.mf
     INPUT_DIR
-        ${CMAKE_BINARY_DIR}/classes
+        ${CMAKE_CURRENT_BINARY_DIR}/classes
     FILES
         com/netscape/certsrv/*.class
         org/dogtagpki/tps/*.class
diff --git a/base/console/src/CMakeLists.txt b/base/console/src/CMakeLists.txt
index c1a86b7c4c0e6245a3d58675cc63c6287a573ecc..dc5a3e3f792f27a34c389c32e4a92310d7e0c48e 100644
--- a/base/console/src/CMakeLists.txt
+++ b/base/console/src/CMakeLists.txt
@@ -97,13 +97,12 @@ javac(pki-console-classes
     SOURCES
         com/netscape/admin/certsrv/*.java
     CLASSPATH
-        ${CMAKE_BINARY_DIR}/classes
         ${BASE_JAR} ${LDAPJDK_JAR} ${MMC_JAR}
         ${MMC_EN_JAR} ${NMCLF_JAR} ${NMCLF_EN_JAR}
         ${PKI_CMSUTIL_JAR} ${PKI_NSUTIL_JAR} ${PKI_CERTSRV_JAR}
         ${JSS_JAR} ${COMMONS_CODEC_JAR}
     OUTPUT_DIR
-        ${CMAKE_BINARY_DIR}/classes
+        ${CMAKE_CURRENT_BINARY_DIR}/classes
 )
 
 configure_file(
@@ -120,7 +119,7 @@ jar(pki-console-jar
     PARAMS
         ${CMAKE_CURRENT_BINARY_DIR}/pki-console.mf
     INPUT_DIR
-        ${CMAKE_BINARY_DIR}/classes
+        ${CMAKE_CURRENT_BINARY_DIR}/classes
     FILES
         com/netscape/admin/certsrv/*.class
     INPUT_DIR
diff --git a/base/java-tools/src/CMakeLists.txt b/base/java-tools/src/CMakeLists.txt
index e7ca5db627cb3e398c4220029d2a78ade45c1d60..6753102f8064d5878bb11c34a45ef13890d8fb26 100644
--- a/base/java-tools/src/CMakeLists.txt
+++ b/base/java-tools/src/CMakeLists.txt
@@ -100,7 +100,7 @@ javac(pki-tools-classes
         ${JAXRS_API_JAR} ${RESTEASY_JAXRS_JAR} ${RESTEASY_ATOM_PROVIDER_JAR}
         ${HTTPCLIENT_JAR} ${HTTPCORE_JAR}
     OUTPUT_DIR
-        ${CMAKE_BINARY_DIR}/classes
+        ${CMAKE_CURRENT_BINARY_DIR}/classes
     DEPENDS
         pki-nsutil-jar pki-cmsutil-jar pki-certsrv-jar
 )
@@ -118,7 +118,7 @@ jar(pki-tools-jar
     PARAMS
         ${CMAKE_CURRENT_BINARY_DIR}/pki-tools.mf
     INPUT_DIR
-        ${CMAKE_BINARY_DIR}/classes
+        ${CMAKE_CURRENT_BINARY_DIR}/classes
     FILES
         com/netscape/cmstools/*.class
     DEPENDS
diff --git a/base/kra/src/CMakeLists.txt b/base/kra/src/CMakeLists.txt
index 400ec016fe22ea156ea94bbe124ecd5eb8bc684c..c04d7fec9c25a104ad51640298a57f646777a7f3 100644
--- a/base/kra/src/CMakeLists.txt
+++ b/base/kra/src/CMakeLists.txt
@@ -118,7 +118,7 @@ javac(pki-kra-classes
         ${PKI_CMSUTIL_JAR} ${PKI_NSUTIL_JAR}
         ${PKI_CERTSRV_JAR} ${PKI_CMS_JAR} ${PKI_CMSCORE_JAR} ${TOMCAT_CATALINA_JAR}
     OUTPUT_DIR
-        ${CMAKE_BINARY_DIR}/classes
+        ${CMAKE_CURRENT_BINARY_DIR}/classes
     DEPENDS
         symkey-jar pki-nsutil-jar pki-cmsutil-jar pki-certsrv-jar pki-cms-jar pki-cmscore-jar
 )
@@ -136,7 +136,7 @@ jar(pki-kra-jar
     PARAMS
         ${CMAKE_CURRENT_BINARY_DIR}/pki-kra.mf
     INPUT_DIR
-        ${CMAKE_BINARY_DIR}/classes
+        ${CMAKE_CURRENT_BINARY_DIR}/classes
     FILES
         com/netscape/kra/*.class
         org/dogtagpki/server/kra/*.class
diff --git a/base/ocsp/src/CMakeLists.txt b/base/ocsp/src/CMakeLists.txt
index 32fcc92dba9cf0f877af8970890df033de1d2375..78df95f377c8a013e4c7a1773629a3794d33b943 100644
--- a/base/ocsp/src/CMakeLists.txt
+++ b/base/ocsp/src/CMakeLists.txt
@@ -80,7 +80,7 @@ javac(pki-ocsp-classes
         ${LDAPJDK_JAR} ${JAXRS_API_JAR}
         ${JSS_JAR} ${COMMONS_CODEC_JAR} ${SYMKEY_JAR}
     OUTPUT_DIR
-        ${CMAKE_BINARY_DIR}/classes
+        ${CMAKE_CURRENT_BINARY_DIR}/classes
     DEPENDS
         symkey-jar pki-nsutil-jar pki-cmsutil-jar pki-certsrv-jar pki-cms-jar pki-cmscore-jar
 )
@@ -98,7 +98,7 @@ jar(pki-ocsp-jar
     PARAMS
         ${CMAKE_CURRENT_BINARY_DIR}/pki-ocsp.mf
     INPUT_DIR
-        ${CMAKE_BINARY_DIR}/classes
+        ${CMAKE_CURRENT_BINARY_DIR}/classes
     FILES
         com/netscape/ocsp/*.class
         org/dogtagpki/server/ocsp/*.class
diff --git a/base/server/cms/src/CMakeLists.txt b/base/server/cms/src/CMakeLists.txt
index 93f4a8a4a275cc4997da1b9c031b830eee3190b3..447dcb18b0fc25c1ff72c8bb996b88ff599d7837 100644
--- a/base/server/cms/src/CMakeLists.txt
+++ b/base/server/cms/src/CMakeLists.txt
@@ -133,7 +133,7 @@ javac(pki-cms-classes
         ${JAXRS_API_JAR} ${RESTEASY_JAXRS_JAR} ${RESTEASY_ATOM_PROVIDER_JAR}
         ${PKI_NSUTIL_JAR} ${PKI_CMSUTIL_JAR} ${PKI_CERTSRV_JAR} ${PKI_TOMCAT_JAR}
     OUTPUT_DIR
-        ${CMAKE_BINARY_DIR}/classes
+        ${CMAKE_CURRENT_BINARY_DIR}/classes
     DEPENDS
         pki-nsutil-jar pki-cmsutil-jar pki-certsrv-jar pki-tomcat-jar
 )
@@ -151,7 +151,7 @@ jar(pki-cms-jar
     PARAMS
         ${CMAKE_CURRENT_BINARY_DIR}/pki-cms.mf
     INPUT_DIR
-        ${CMAKE_BINARY_DIR}/classes
+        ${CMAKE_CURRENT_BINARY_DIR}/classes
     FILES
         com/netscape/cms/*.class
         org/dogtagpki/server/*.class
diff --git a/base/server/cmscore/src/CMakeLists.txt b/base/server/cmscore/src/CMakeLists.txt
index 32e4351ca947580ee75bd887bf78d1f1b5064181..fe8dba2077734468d983e850201150f88cb129f4 100644
--- a/base/server/cmscore/src/CMakeLists.txt
+++ b/base/server/cmscore/src/CMakeLists.txt
@@ -133,7 +133,7 @@ javac(pki-cmscore-classes
         ${HTTPCLIENT_JAR} ${HTTPCORE_JAR}
         ${NUXWDOG_JAR}
     OUTPUT_DIR
-        ${CMAKE_BINARY_DIR}/classes
+        ${CMAKE_CURRENT_BINARY_DIR}/classes
     DEPENDS
         pki-nsutil-jar pki-cmsutil-jar pki-certsrv-jar pki-cms-jar pki-tomcat-jar
 )
@@ -151,7 +151,7 @@ jar(pki-cmscore-jar
     PARAMS
         ${CMAKE_CURRENT_BINARY_DIR}/pki-cmscore.mf
     INPUT_DIR
-        ${CMAKE_BINARY_DIR}/classes
+        ${CMAKE_CURRENT_BINARY_DIR}/classes
     FILES
         com/netscape/cmscore/*.class
     DEPENDS
diff --git a/base/symkey/src/CMakeLists.txt b/base/symkey/src/CMakeLists.txt
index 9a4e10fdaa78ce6b7023b83f144b4039616f3216..8455d592e3969dea720bf0a82d4d7a0cd743a0b3 100644
--- a/base/symkey/src/CMakeLists.txt
+++ b/base/symkey/src/CMakeLists.txt
@@ -15,14 +15,14 @@ javac(symkey-classes
     CLASSPATH
         ${JSS_JAR}
     OUTPUT_DIR
-        ${CMAKE_BINARY_DIR}/classes
+        ${CMAKE_CURRENT_BINARY_DIR}/classes
 )
 
 jar(symkey-jar
     CREATE
         ${CMAKE_BINARY_DIR}/dist/symkey.jar
     INPUT_DIR
-        ${CMAKE_BINARY_DIR}/classes
+        ${CMAKE_CURRENT_BINARY_DIR}/classes
     FILES
         com/netscape/symkey/*.class
     DEPENDS
diff --git a/base/symkey/src/com/netscape/symkey/CMakeLists.txt b/base/symkey/src/com/netscape/symkey/CMakeLists.txt
index 590a7d8802db99284be74f214bf3dedfdd0d7378..6915ee93a2eff5324b8b4c136436c28a14cbd5a6 100644
--- a/base/symkey/src/com/netscape/symkey/CMakeLists.txt
+++ b/base/symkey/src/com/netscape/symkey/CMakeLists.txt
@@ -42,7 +42,7 @@ add_custom_command(
         ${symkey_library_HDRS}
     COMMAND
         ${Java_JAVAH_EXECUTABLE}
-            -classpath ${CMAKE_BINARY_DIR}/classes:${JAVA_LIB_INSTALL_DIR}/jss4.jar
+            -classpath ${CMAKE_CURRENT_BINARY_DIR}/../../../classes:${JAVA_LIB_INSTALL_DIR}/jss4.jar
             -jni -d ${CMAKE_CURRENT_BINARY_DIR}
             com.netscape.symkey.SessionKey
 )
diff --git a/base/tks/src/CMakeLists.txt b/base/tks/src/CMakeLists.txt
index 51f98c9b4ae4f9588e6d8d04295f20de90b75c5b..146e70ada49c9431156d447d2d08e4d505bda8fa 100644
--- a/base/tks/src/CMakeLists.txt
+++ b/base/tks/src/CMakeLists.txt
@@ -118,7 +118,7 @@ javac(pki-tks-classes
         ${PKI_CMSUTIL_JAR} ${PKI_NSUTIL_JAR}
         ${PKI_CERTSRV_JAR} ${PKI_CMS_JAR} ${PKI_CMSCORE_JAR}
     OUTPUT_DIR
-        ${CMAKE_BINARY_DIR}/classes
+        ${CMAKE_CURRENT_BINARY_DIR}/classes
     DEPENDS
         symkey-jar pki-nsutil-jar pki-cmsutil-jar pki-certsrv-jar pki-cms-jar pki-cmscore-jar
 )
@@ -136,7 +136,7 @@ jar(pki-tks-jar
     PARAMS
         ${CMAKE_CURRENT_BINARY_DIR}/pki-tks.mf
     INPUT_DIR
-        ${CMAKE_BINARY_DIR}/classes
+        ${CMAKE_CURRENT_BINARY_DIR}/classes
     FILES
         com/netscape/tks/*.class
         org/dogtagpki/server/tks/*.class
diff --git a/base/tps/src/CMakeLists.txt b/base/tps/src/CMakeLists.txt
index 5e51f609c68f487fa9db1b0b4782a3627aab3cc6..f517a63c4cd480809d04e33ff3394b7c93dcf9ef 100644
--- a/base/tps/src/CMakeLists.txt
+++ b/base/tps/src/CMakeLists.txt
@@ -121,7 +121,7 @@ javac(pki-tps-classes
         ${PKI_CMSUTIL_JAR} ${PKI_NSUTIL_JAR}
         ${PKI_CERTSRV_JAR} ${PKI_CMS_JAR} ${PKI_CMSCORE_JAR}
     OUTPUT_DIR
-        ${CMAKE_BINARY_DIR}/classes
+        ${CMAKE_CURRENT_BINARY_DIR}/classes
     DEPENDS
         symkey-jar pki-nsutil-jar pki-cmsutil-jar pki-certsrv-jar pki-cms-jar pki-cmscore-jar
 )
@@ -139,7 +139,7 @@ jar(pki-tps-jar
     PARAMS
         ${CMAKE_CURRENT_BINARY_DIR}/pki-tps.mf
     INPUT_DIR
-        ${CMAKE_BINARY_DIR}/classes
+        ${CMAKE_CURRENT_BINARY_DIR}/classes
     FILES
         org/dogtagpki/server/tps/*.class
     DEPENDS
diff --git a/base/util/src/CMakeLists.txt b/base/util/src/CMakeLists.txt
index f374c01def727eab178ed04320b1e8ed5fa1cb77..bf531d43203d0f986ceb92e04917bcc9d535ba6d 100644
--- a/base/util/src/CMakeLists.txt
+++ b/base/util/src/CMakeLists.txt
@@ -76,7 +76,7 @@ javac(pki-nsutil-classes
         ${APACHE_COMMONS_LANG_JAR} ${LDAPJDK_JAR} ${XALAN_JAR} ${XERCES_JAR}
         ${JSS_JAR} ${COMMONS_CODEC_JAR}
     OUTPUT_DIR
-        ${CMAKE_BINARY_DIR}/classes
+        ${CMAKE_CURRENT_BINARY_DIR}/classes
 )
 
 configure_file(
@@ -92,7 +92,7 @@ jar(pki-nsutil-jar
     PARAMS
         ${CMAKE_CURRENT_BINARY_DIR}/pki-nsutil.mf
     INPUT_DIR
-        ${CMAKE_BINARY_DIR}/classes
+        ${CMAKE_CURRENT_BINARY_DIR}/classes
     FILES
         netscape/*.class
     DEPENDS
@@ -118,7 +118,7 @@ javac(pki-cmsutil-classes
         ${LDAPJDK_JAR} ${XALAN_JAR} ${XERCES_JAR}
         ${JSS_JAR} ${COMMONS_CODEC_JAR} ${NUXWDOG_JAR}
     OUTPUT_DIR
-        ${CMAKE_BINARY_DIR}/classes
+        ${CMAKE_CURRENT_BINARY_DIR}/classes
     DEPENDS
         pki-nsutil-jar
 )
@@ -136,7 +136,7 @@ jar(pki-cmsutil-jar
     PARAMS
         ${CMAKE_CURRENT_BINARY_DIR}/pki-cmsutil.mf
     INPUT_DIR
-        ${CMAKE_BINARY_DIR}/classes
+        ${CMAKE_CURRENT_BINARY_DIR}/classes
     FILES
         com/netscape/cmsutil/*.class
     DEPENDS
-- 
2.7.4

