diff --git a/.gitignore b/.gitignore index 593d94f6..cc70f47c 100644 --- a/.gitignore +++ b/.gitignore @@ -3,7 +3,7 @@ /deps/ /bin/app/data/projects/ignored/ -/bin/app/data/java/ +/bin/app/data/java/lib/ /bin/app/user/log/ /bin/app/user/ApplicationSettings.xml /bin/app/user/window_settings.ini diff --git a/bin/app/data/3rd_party_licenses/license_gradle.txt b/bin/app/data/3rd_party_licenses/license_gradle.txt new file mode 100644 index 00000000..1e35fb32 --- /dev/null +++ b/bin/app/data/3rd_party_licenses/license_gradle.txt @@ -0,0 +1,994 @@ + + Apache License + Version 2.0, January 2004 + http://www.apache.org/licenses/ + + TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION + + 1. Definitions. + + "License" shall mean the terms and conditions for use, reproduction, + and distribution as defined by Sections 1 through 9 of this document. + + "Licensor" shall mean the copyright owner or entity authorized by + the copyright owner that is granting the License. + + "Legal Entity" shall mean the union of the acting entity and all + other entities that control, are controlled by, or are under common + control with that entity. For the purposes of this definition, + "control" means (i) the power, direct or indirect, to cause the + direction or management of such entity, whether by contract or + otherwise, or (ii) ownership of fifty percent (50%) or more of the + outstanding shares, or (iii) beneficial ownership of such entity. + + "You" (or "Your") shall mean an individual or Legal Entity + exercising permissions granted by this License. + + "Source" form shall mean the preferred form for making modifications, + including but not limited to software source code, documentation + source, and configuration files. + + "Object" form shall mean any form resulting from mechanical + transformation or translation of a Source form, including but + not limited to compiled object code, generated documentation, + and conversions to other media types. + + "Work" shall mean the work of authorship, whether in Source or + Object form, made available under the License, as indicated by a + copyright notice that is included in or attached to the work + (an example is provided in the Appendix below). + + "Derivative Works" shall mean any work, whether in Source or Object + form, that is based on (or derived from) the Work and for which the + editorial revisions, annotations, elaborations, or other modifications + represent, as a whole, an original work of authorship. For the purposes + of this License, Derivative Works shall not include works that remain + separable from, or merely link (or bind by name) to the interfaces of, + the Work and Derivative Works thereof. + + "Contribution" shall mean any work of authorship, including + the original version of the Work and any modifications or additions + to that Work or Derivative Works thereof, that is intentionally + submitted to Licensor for inclusion in the Work by the copyright owner + or by an individual or Legal Entity authorized to submit on behalf of + the copyright owner. For the purposes of this definition, "submitted" + means any form of electronic, verbal, or written communication sent + to the Licensor or its representatives, including but not limited to + communication on electronic mailing lists, source code control systems, + and issue tracking systems that are managed by, or on behalf of, the + Licensor for the purpose of discussing and improving the Work, but + excluding communication that is conspicuously marked or otherwise + designated in writing by the copyright owner as "Not a Contribution." + + "Contributor" shall mean Licensor and any individual or Legal Entity + on behalf of whom a Contribution has been received by Licensor and + subsequently incorporated within the Work. + + 2. Grant of Copyright License. Subject to the terms and conditions of + this License, each Contributor hereby grants to You a perpetual, + worldwide, non-exclusive, no-charge, royalty-free, irrevocable + copyright license to reproduce, prepare Derivative Works of, + publicly display, publicly perform, sublicense, and distribute the + Work and such Derivative Works in Source or Object form. + + 3. Grant of Patent License. Subject to the terms and conditions of + this License, each Contributor hereby grants to You a perpetual, + worldwide, non-exclusive, no-charge, royalty-free, irrevocable + (except as stated in this section) patent license to make, have made, + use, offer to sell, sell, import, and otherwise transfer the Work, + where such license applies only to those patent claims licensable + by such Contributor that are necessarily infringed by their + Contribution(s) alone or by combination of their Contribution(s) + with the Work to which such Contribution(s) was submitted. If You + institute patent litigation against any entity (including a + cross-claim or counterclaim in a lawsuit) alleging that the Work + or a Contribution incorporated within the Work constitutes direct + or contributory patent infringement, then any patent licenses + granted to You under this License for that Work shall terminate + as of the date such litigation is filed. + + 4. Redistribution. You may reproduce and distribute copies of the + Work or Derivative Works thereof in any medium, with or without + modifications, and in Source or Object form, provided that You + meet the following conditions: + + (a) You must give any other recipients of the Work or + Derivative Works a copy of this License; and + + (b) You must cause any modified files to carry prominent notices + stating that You changed the files; and + + (c) You must retain, in the Source form of any Derivative Works + that You distribute, all copyright, patent, trademark, and + attribution notices from the Source form of the Work, + excluding those notices that do not pertain to any part of + the Derivative Works; and + + (d) If the Work includes a "NOTICE" text file as part of its + distribution, then any Derivative Works that You distribute must + include a readable copy of the attribution notices contained + within such NOTICE file, excluding those notices that do not + pertain to any part of the Derivative Works, in at least one + of the following places: within a NOTICE text file distributed + as part of the Derivative Works; within the Source form or + documentation, if provided along with the Derivative Works; or, + within a display generated by the Derivative Works, if and + wherever such third-party notices normally appear. The contents + of the NOTICE file are for informational purposes only and + do not modify the License. You may add Your own attribution + notices within Derivative Works that You distribute, alongside + or as an addendum to the NOTICE text from the Work, provided + that such additional attribution notices cannot be construed + as modifying the License. + + You may add Your own copyright statement to Your modifications and + may provide additional or different license terms and conditions + for use, reproduction, or distribution of Your modifications, or + for any such Derivative Works as a whole, provided Your use, + reproduction, and distribution of the Work otherwise complies with + the conditions stated in this License. + + 5. Submission of Contributions. Unless You explicitly state otherwise, + any Contribution intentionally submitted for inclusion in the Work + by You to the Licensor shall be under the terms and conditions of + this License, without any additional terms or conditions. + Notwithstanding the above, nothing herein shall supersede or modify + the terms of any separate license agreement you may have executed + with Licensor regarding such Contributions. + + 6. Trademarks. This License does not grant permission to use the trade + names, trademarks, service marks, or product names of the Licensor, + except as required for reasonable and customary use in describing the + origin of the Work and reproducing the content of the NOTICE file. + + 7. Disclaimer of Warranty. Unless required by applicable law or + agreed to in writing, Licensor provides the Work (and each + Contributor provides its Contributions) on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or + implied, including, without limitation, any warranties or conditions + of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A + PARTICULAR PURPOSE. You are solely responsible for determining the + appropriateness of using or redistributing the Work and assume any + risks associated with Your exercise of permissions under this License. + + 8. Limitation of Liability. In no event and under no legal theory, + whether in tort (including negligence), contract, or otherwise, + unless required by applicable law (such as deliberate and grossly + negligent acts) or agreed to in writing, shall any Contributor be + liable to You for damages, including any direct, indirect, special, + incidental, or consequential damages of any character arising as a + result of this License or out of the use or inability to use the + Work (including but not limited to damages for loss of goodwill, + work stoppage, computer failure or malfunction, or any and all + other commercial damages or losses), even if such Contributor + has been advised of the possibility of such damages. + + 9. Accepting Warranty or Additional Liability. While redistributing + the Work or Derivative Works thereof, You may choose to offer, + and charge a fee for, acceptance of support, warranty, indemnity, + or other liability obligations and/or rights consistent with this + License. However, in accepting such obligations, You may act only + on Your own behalf and on Your sole responsibility, not on behalf + of any other Contributor, and only if You agree to indemnify, + defend, and hold each Contributor harmless for any liability + incurred by, or claims asserted against, such Contributor by reason + of your accepting any such warranty or additional liability. + + END OF TERMS AND CONDITIONS + + APPENDIX: How to apply the Apache License to your work. + + To apply the Apache License to your work, attach the following + boilerplate notice, with the fields enclosed by brackets "{}" + replaced with your own identifying information. (Don't include + the brackets!) The text should be enclosed in the appropriate + comment syntax for the file format. We also recommend that a + file or class name and description of purpose be included on the + same "printed page" as the copyright notice for easier + identification within third-party archives. + + Copyright {yyyy} {name of copyright owner} + + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. + + + +============================================================================== +Gradle Subcomponents: + +------------------------------------------------------------------------------ +License for the slf4j package +------------------------------------------------------------------------------ +SLF4J License + +Copyright (c) 2004-2007 QOS.ch +All rights reserved. + +Permission is hereby granted, free of charge, to any person obtaining +a copy of this software and associated documentation files (the +"Software"), to deal in the Software without restriction, including +without limitation the rights to use, copy, modify, merge, publish, +distribute, sublicense, and/or sell copies of the Software, and to +permit persons to whom the Software is furnished to do so, subject to +the following conditions: + +The above copyright notice and this permission notice shall be +included in all copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, +EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF +MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND +NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE +LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION +OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION +WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + +These terms are identical to those of the MIT License, also called the X License or the X11 License, +which is a simple, permissive non-copyleft free software license. It is deemed compatible with virtually +all types of licenses, commercial or otherwise. In particular, the Free Software Foundation has declared it +compatible with GNU GPL. It is also known to be approved by the Apache Software Foundation as compatible +with Apache Software License. + + +------------------------------------------------------------------------------ +License for the JUnit package +------------------------------------------------------------------------------ +THE ACCOMPANYING PROGRAM IS PROVIDED UNDER THE TERMS OF THIS COMMON PUBLIC +LICENSE ("AGREEMENT"). ANY USE, REPRODUCTION OR DISTRIBUTION OF THE PROGRAM +CONSTITUTES RECIPIENT'S ACCEPTANCE OF THIS AGREEMENT. + +1. DEFINITIONS + +"Contribution" means: + +a) in the case of the initial Contributor, the initial code and +documentation distributed under this Agreement, and + +b) in the case of each subsequent Contributor: + +i) changes to the Program, and + +ii) additions to the Program; + +where such changes and/or additions to the Program originate from and are +distributed by that particular Contributor. A Contribution 'originates' from a +Contributor if it was added to the Program by such Contributor itself or anyone +acting on such Contributor's behalf. Contributions do not include additions to +the Program which: (i) are separate modules of software distributed in +conjunction with the Program under their own license agreement, and (ii) are not +derivative works of the Program. + +"Contributor" means any person or entity that distributes the Program. + +"Licensed Patents " mean patent claims licensable by a Contributor which are +necessarily infringed by the use or sale of its Contribution alone or when +combined with the Program. + +"Program" means the Contributions distributed in accordance with this Agreement. + +"Recipient" means anyone who receives the Program under this Agreement, +including all Contributors. + +2. GRANT OF RIGHTS + +a) Subject to the terms of this Agreement, each Contributor hereby grants +Recipient a non-exclusive, worldwide, royalty-free copyright license to +reproduce, prepare derivative works of, publicly display, publicly perform, +distribute and sublicense the Contribution of such Contributor, if any, and such +derivative works, in source code and object code form. + +b) Subject to the terms of this Agreement, each Contributor hereby grants +Recipient a non-exclusive, worldwide, royalty-free patent license under Licensed +Patents to make, use, sell, offer to sell, import and otherwise transfer the +Contribution of such Contributor, if any, in source code and object code form. +This patent license shall apply to the combination of the Contribution and the +Program if, at the time the Contribution is added by the Contributor, such +addition of the Contribution causes such combination to be covered by the +Licensed Patents. The patent license shall not apply to any other combinations +which include the Contribution. No hardware per se is licensed hereunder. + +c) Recipient understands that although each Contributor grants the licenses +to its Contributions set forth herein, no assurances are provided by any +Contributor that the Program does not infringe the patent or other intellectual +property rights of any other entity. Each Contributor disclaims any liability to +Recipient for claims brought by any other entity based on infringement of +intellectual property rights or otherwise. As a condition to exercising the +rights and licenses granted hereunder, each Recipient hereby assumes sole +responsibility to secure any other intellectual property rights needed, if any. +For example, if a third party patent license is required to allow Recipient to +distribute the Program, it is Recipient's responsibility to acquire that license +before distributing the Program. + +d) Each Contributor represents that to its knowledge it has sufficient +copyright rights in its Contribution, if any, to grant the copyright license set +forth in this Agreement. + +3. REQUIREMENTS + +A Contributor may choose to distribute the Program in object code form under its +own license agreement, provided that: + +a) it complies with the terms and conditions of this Agreement; and + +b) its license agreement: + +i) effectively disclaims on behalf of all Contributors all warranties and +conditions, express and implied, including warranties or conditions of title and +non-infringement, and implied warranties or conditions of merchantability and +fitness for a particular purpose; + +ii) effectively excludes on behalf of all Contributors all liability for +damages, including direct, indirect, special, incidental and consequential +damages, such as lost profits; + +iii) states that any provisions which differ from this Agreement are offered +by that Contributor alone and not by any other party; and + +iv) states that source code for the Program is available from such +Contributor, and informs licensees how to obtain it in a reasonable manner on or +through a medium customarily used for software exchange. + +When the Program is made available in source code form: + +a) it must be made available under this Agreement; and + +b) a copy of this Agreement must be included with each copy of the Program. + +Contributors may not remove or alter any copyright notices contained within the +Program. + +Each Contributor must identify itself as the originator of its Contribution, if +any, in a manner that reasonably allows subsequent Recipients to identify the +originator of the Contribution. + +4. COMMERCIAL DISTRIBUTION + +Commercial distributors of software may accept certain responsibilities with +respect to end users, business partners and the like. While this license is +intended to facilitate the commercial use of the Program, the Contributor who +includes the Program in a commercial product offering should do so in a manner +which does not create potential liability for other Contributors. Therefore, if +a Contributor includes the Program in a commercial product offering, such +Contributor ("Commercial Contributor") hereby agrees to defend and indemnify +every other Contributor ("Indemnified Contributor") against any losses, damages +and costs (collectively "Losses") arising from claims, lawsuits and other legal +actions brought by a third party against the Indemnified Contributor to the +extent caused by the acts or omissions of such Commercial Contributor in +connection with its distribution of the Program in a commercial product +offering. The obligations in this section do not apply to any claims or Losses +relating to any actual or alleged intellectual property infringement. In order +to qualify, an Indemnified Contributor must: a) promptly notify the Commercial +Contributor in writing of such claim, and b) allow the Commercial Contributor to +control, and cooperate with the Commercial Contributor in, the defense and any +related settlement negotiations. The Indemnified Contributor may participate in +any such claim at its own expense. + +For example, a Contributor might include the Program in a commercial product +offering, Product X. That Contributor is then a Commercial Contributor. If that +Commercial Contributor then makes performance claims, or offers warranties +related to Product X, those performance claims and warranties are such +Commercial Contributor's responsibility alone. Under this section, the +Commercial Contributor would have to defend claims against the other +Contributors related to those performance claims and warranties, and if a court +requires any other Contributor to pay any damages as a result, the Commercial +Contributor must pay those damages. + +5. NO WARRANTY + +EXCEPT AS EXPRESSLY SET FORTH IN THIS AGREEMENT, THE PROGRAM IS PROVIDED ON AN +"AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, EITHER EXPRESS OR +IMPLIED INCLUDING, WITHOUT LIMITATION, ANY WARRANTIES OR CONDITIONS OF TITLE, +NON-INFRINGEMENT, MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE. Each +Recipient is solely responsible for determining the appropriateness of using and +distributing the Program and assumes all risks associated with its exercise of +rights under this Agreement, including but not limited to the risks and costs of +program errors, compliance with applicable laws, damage to or loss of data, +programs or equipment, and unavailability or interruption of operations. + +6. DISCLAIMER OF LIABILITY + +EXCEPT AS EXPRESSLY SET FORTH IN THIS AGREEMENT, NEITHER RECIPIENT NOR ANY +CONTRIBUTORS SHALL HAVE ANY LIABILITY FOR ANY DIRECT, INDIRECT, INCIDENTAL, +SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING WITHOUT LIMITATION LOST +PROFITS), HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, +STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY +OUT OF THE USE OR DISTRIBUTION OF THE PROGRAM OR THE EXERCISE OF ANY RIGHTS +GRANTED HEREUNDER, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. + +7. GENERAL + +If any provision of this Agreement is invalid or unenforceable under applicable +law, it shall not affect the validity or enforceability of the remainder of the +terms of this Agreement, and without further action by the parties hereto, such +provision shall be reformed to the minimum extent necessary to make such +provision valid and enforceable. + +If Recipient institutes patent litigation against a Contributor with respect to +a patent applicable to software (including a cross-claim or counterclaim in a +lawsuit), then any patent licenses granted by that Contributor to such Recipient +under this Agreement shall terminate as of the date such litigation is filed. In +addition, if Recipient institutes patent litigation against any entity +(including a cross-claim or counterclaim in a lawsuit) alleging that the Program +itself (excluding combinations of the Program with other software or hardware) +infringes such Recipient's patent(s), then such Recipient's rights granted under +Section 2(b) shall terminate as of the date such litigation is filed. + +All Recipient's rights under this Agreement shall terminate if it fails to +comply with any of the material terms or conditions of this Agreement and does +not cure such failure in a reasonable period of time after becoming aware of +such noncompliance. If all Recipient's rights under this Agreement terminate, +Recipient agrees to cease use and distribution of the Program as soon as +reasonably practicable. However, Recipient's obligations under this Agreement +and any licenses granted by Recipient relating to the Program shall continue and +survive. + +Everyone is permitted to copy and distribute copies of this Agreement, but in +order to avoid inconsistency the Agreement is copyrighted and may only be +modified in the following manner. The Agreement Steward reserves the right to +publish new versions (including revisions) of this Agreement from time to time. +No one other than the Agreement Steward has the right to modify this Agreement. +IBM is the initial Agreement Steward. IBM may assign the responsibility to serve +as the Agreement Steward to a suitable separate entity. Each new version of the +Agreement will be given a distinguishing version number. The Program (including +Contributions) may always be distributed subject to the version of the Agreement +under which it was received. In addition, after a new version of the Agreement +is published, Contributor may elect to distribute the Program (including its +Contributions) under the new version. Except as expressly stated in Sections +2(a) and 2(b) above, Recipient receives no rights or licenses to the +intellectual property of any Contributor under this Agreement, whether +expressly, by implication, estoppel or otherwise. All rights in the Program not +expressly granted under this Agreement are reserved. + +This Agreement is governed by the laws of the State of New York and the +intellectual property laws of the United States of America. No party to this +Agreement will bring a legal action under this Agreement more than one year +after the cause of action arose. Each party waives its rights to a jury trial in +any resulting litigation. + +------------------------------------------------------------------------------ +License for the JCIFS package +------------------------------------------------------------------------------ +JCIFS License + + GNU LESSER GENERAL PUBLIC LICENSE + Version 2.1, February 1999 + + Copyright (C) 1991, 1999 Free Software Foundation, Inc. + 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + Everyone is permitted to copy and distribute verbatim copies + of this license document, but changing it is not allowed. + +[This is the first released version of the Lesser GPL. It also counts + as the successor of the GNU Library Public License, version 2, hence + the version number 2.1.] + + Preamble + + The licenses for most software are designed to take away your +freedom to share and change it. By contrast, the GNU General Public +Licenses are intended to guarantee your freedom to share and change +free software--to make sure the software is free for all its users. + + This license, the Lesser General Public License, applies to some +specially designated software packages--typically libraries--of the +Free Software Foundation and other authors who decide to use it. You +can use it too, but we suggest you first think carefully about whether +this license or the ordinary General Public License is the better +strategy to use in any particular case, based on the explanations below. + + When we speak of free software, we are referring to freedom of use, +not price. Our General Public Licenses are designed to make sure that +you have the freedom to distribute copies of free software (and charge +for this service if you wish); that you receive source code or can get +it if you want it; that you can change the software and use pieces of +it in new free programs; and that you are informed that you can do +these things. + + To protect your rights, we need to make restrictions that forbid +distributors to deny you these rights or to ask you to surrender these +rights. These restrictions translate to certain responsibilities for +you if you distribute copies of the library or if you modify it. + + For example, if you distribute copies of the library, whether gratis +or for a fee, you must give the recipients all the rights that we gave +you. You must make sure that they, too, receive or can get the source +code. If you link other code with the library, you must provide +complete object files to the recipients, so that they can relink them +with the library after making changes to the library and recompiling +it. And you must show them these terms so they know their rights. + + We protect your rights with a two-step method: (1) we copyright the +library, and (2) we offer you this license, which gives you legal +permission to copy, distribute and/or modify the library. + + To protect each distributor, we want to make it very clear that +there is no warranty for the free library. Also, if the library is +modified by someone else and passed on, the recipients should know +that what they have is not the original version, so that the original +author's reputation will not be affected by problems that might be +introduced by others. + + Finally, software patents pose a constant threat to the existence of +any free program. We wish to make sure that a company cannot +effectively restrict the users of a free program by obtaining a +restrictive license from a patent holder. Therefore, we insist that +any patent license obtained for a version of the library must be +consistent with the full freedom of use specified in this license. + + Most GNU software, including some libraries, is covered by the +ordinary GNU General Public License. This license, the GNU Lesser +General Public License, applies to certain designated libraries, and +is quite different from the ordinary General Public License. We use +this license for certain libraries in order to permit linking those +libraries into non-free programs. + + When a program is linked with a library, whether statically or using +a shared library, the combination of the two is legally speaking a +combined work, a derivative of the original library. The ordinary +General Public License therefore permits such linking only if the +entire combination fits its criteria of freedom. The Lesser General +Public License permits more lax criteria for linking other code with +the library. + + We call this license the "Lesser" General Public License because it +does Less to protect the user's freedom than the ordinary General +Public License. It also provides other free software developers Less +of an advantage over competing non-free programs. These disadvantages +are the reason we use the ordinary General Public License for many +libraries. However, the Lesser license provides advantages in certain +special circumstances. + + For example, on rare occasions, there may be a special need to +encourage the widest possible use of a certain library, so that it becomes +a de-facto standard. To achieve this, non-free programs must be +allowed to use the library. A more frequent case is that a free +library does the same job as widely used non-free libraries. In this +case, there is little to gain by limiting the free library to free +software only, so we use the Lesser General Public License. + + In other cases, permission to use a particular library in non-free +programs enables a greater number of people to use a large body of +free software. For example, permission to use the GNU C Library in +non-free programs enables many more people to use the whole GNU +operating system, as well as its variant, the GNU/Linux operating +system. + + Although the Lesser General Public License is Less protective of the +users' freedom, it does ensure that the user of a program that is +linked with the Library has the freedom and the wherewithal to run +that program using a modified version of the Library. + + The precise terms and conditions for copying, distribution and +modification follow. Pay close attention to the difference between a +"work based on the library" and a "work that uses the library". The +former contains code derived from the library, whereas the latter must +be combined with the library in order to run. + + GNU LESSER GENERAL PUBLIC LICENSE + TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION + + 0. This License Agreement applies to any software library or other +program which contains a notice placed by the copyright holder or +other authorized party saying it may be distributed under the terms of +this Lesser General Public License (also called "this License"). +Each licensee is addressed as "you". + + A "library" means a collection of software functions and/or data +prepared so as to be conveniently linked with application programs +(which use some of those functions and data) to form executables. + + The "Library", below, refers to any such software library or work +which has been distributed under these terms. A "work based on the +Library" means either the Library or any derivative work under +copyright law: that is to say, a work containing the Library or a +portion of it, either verbatim or with modifications and/or translated +straightforwardly into another language. (Hereinafter, translation is +included without limitation in the term "modification".) + + "Source code" for a work means the preferred form of the work for +making modifications to it. For a library, complete source code means +all the source code for all modules it contains, plus any associated +interface definition files, plus the scripts used to control compilation +and installation of the library. + + Activities other than copying, distribution and modification are not +covered by this License; they are outside its scope. The act of +running a program using the Library is not restricted, and output from +such a program is covered only if its contents constitute a work based +on the Library (independent of the use of the Library in a tool for +writing it). Whether that is true depends on what the Library does +and what the program that uses the Library does. + + 1. You may copy and distribute verbatim copies of the Library's +complete source code as you receive it, in any medium, provided that +you conspicuously and appropriately publish on each copy an +appropriate copyright notice and disclaimer of warranty; keep intact +all the notices that refer to this License and to the absence of any +warranty; and distribute a copy of this License along with the +Library. + + You may charge a fee for the physical act of transferring a copy, +and you may at your option offer warranty protection in exchange for a +fee. + + 2. You may modify your copy or copies of the Library or any portion +of it, thus forming a work based on the Library, and copy and +distribute such modifications or work under the terms of Section 1 +above, provided that you also meet all of these conditions: + + a) The modified work must itself be a software library. + + b) You must cause the files modified to carry prominent notices + stating that you changed the files and the date of any change. + + c) You must cause the whole of the work to be licensed at no + charge to all third parties under the terms of this License. + + d) If a facility in the modified Library refers to a function or a + table of data to be supplied by an application program that uses + the facility, other than as an argument passed when the facility + is invoked, then you must make a good faith effort to ensure that, + in the event an application does not supply such function or + table, the facility still operates, and performs whatever part of + its purpose remains meaningful. + + (For example, a function in a library to compute square roots has + a purpose that is entirely well-defined independent of the + application. Therefore, Subsection 2d requires that any + application-supplied function or table used by this function must + be optional: if the application does not supply it, the square + root function must still compute square roots.) + +These requirements apply to the modified work as a whole. If +identifiable sections of that work are not derived from the Library, +and can be reasonably considered independent and separate works in +themselves, then this License, and its terms, do not apply to those +sections when you distribute them as separate works. But when you +distribute the same sections as part of a whole which is a work based +on the Library, the distribution of the whole must be on the terms of +this License, whose permissions for other licensees extend to the +entire whole, and thus to each and every part regardless of who wrote +it. + +Thus, it is not the intent of this section to claim rights or contest +your rights to work written entirely by you; rather, the intent is to +exercise the right to control the distribution of derivative or +collective works based on the Library. + +In addition, mere aggregation of another work not based on the Library +with the Library (or with a work based on the Library) on a volume of +a storage or distribution medium does not bring the other work under +the scope of this License. + + 3. You may opt to apply the terms of the ordinary GNU General Public +License instead of this License to a given copy of the Library. To do +this, you must alter all the notices that refer to this License, so +that they refer to the ordinary GNU General Public License, version 2, +instead of to this License. (If a newer version than version 2 of the +ordinary GNU General Public License has appeared, then you can specify +that version instead if you wish.) Do not make any other change in +these notices. + + Once this change is made in a given copy, it is irreversible for +that copy, so the ordinary GNU General Public License applies to all +subsequent copies and derivative works made from that copy. + + This option is useful when you wish to copy part of the code of +the Library into a program that is not a library. + + 4. You may copy and distribute the Library (or a portion or +derivative of it, under Section 2) in object code or executable form +under the terms of Sections 1 and 2 above provided that you accompany +it with the complete corresponding machine-readable source code, which +must be distributed under the terms of Sections 1 and 2 above on a +medium customarily used for software interchange. + + If distribution of object code is made by offering access to copy +from a designated place, then offering equivalent access to copy the +source code from the same place satisfies the requirement to +distribute the source code, even though third parties are not +compelled to copy the source along with the object code. + + 5. A program that contains no derivative of any portion of the +Library, but is designed to work with the Library by being compiled or +linked with it, is called a "work that uses the Library". Such a +work, in isolation, is not a derivative work of the Library, and +therefore falls outside the scope of this License. + + However, linking a "work that uses the Library" with the Library +creates an executable that is a derivative of the Library (because it +contains portions of the Library), rather than a "work that uses the +library". The executable is therefore covered by this License. +Section 6 states terms for distribution of such executables. + + When a "work that uses the Library" uses material from a header file +that is part of the Library, the object code for the work may be a +derivative work of the Library even though the source code is not. +Whether this is true is especially significant if the work can be +linked without the Library, or if the work is itself a library. The +threshold for this to be true is not precisely defined by law. + + If such an object file uses only numerical parameters, data +structure layouts and accessors, and small macros and small inline +functions (ten lines or less in length), then the use of the object +file is unrestricted, regardless of whether it is legally a derivative +work. (Executables containing this object code plus portions of the +Library will still fall under Section 6.) + + Otherwise, if the work is a derivative of the Library, you may +distribute the object code for the work under the terms of Section 6. +Any executables containing that work also fall under Section 6, +whether or not they are linked directly with the Library itself. + + 6. As an exception to the Sections above, you may also combine or +link a "work that uses the Library" with the Library to produce a +work containing portions of the Library, and distribute that work +under terms of your choice, provided that the terms permit +modification of the work for the customer's own use and reverse +engineering for debugging such modifications. + + You must give prominent notice with each copy of the work that the +Library is used in it and that the Library and its use are covered by +this License. You must supply a copy of this License. If the work +during execution displays copyright notices, you must include the +copyright notice for the Library among them, as well as a reference +directing the user to the copy of this License. Also, you must do one +of these things: + + a) Accompany the work with the complete corresponding + machine-readable source code for the Library including whatever + changes were used in the work (which must be distributed under + Sections 1 and 2 above); and, if the work is an executable linked + with the Library, with the complete machine-readable "work that + uses the Library", as object code and/or source code, so that the + user can modify the Library and then relink to produce a modified + executable containing the modified Library. (It is understood + that the user who changes the contents of definitions files in the + Library will not necessarily be able to recompile the application + to use the modified definitions.) + + b) Use a suitable shared library mechanism for linking with the + Library. A suitable mechanism is one that (1) uses at run time a + copy of the library already present on the user's computer system, + rather than copying library functions into the executable, and (2) + will operate properly with a modified version of the library, if + the user installs one, as long as the modified version is + interface-compatible with the version that the work was made with. + + c) Accompany the work with a written offer, valid for at + least three years, to give the same user the materials + specified in Subsection 6a, above, for a charge no more + than the cost of performing this distribution. + + d) If distribution of the work is made by offering access to copy + from a designated place, offer equivalent access to copy the above + specified materials from the same place. + + e) Verify that the user has already received a copy of these + materials or that you have already sent this user a copy. + + For an executable, the required form of the "work that uses the +Library" must include any data and utility programs needed for +reproducing the executable from it. However, as a special exception, +the materials to be distributed need not include anything that is +normally distributed (in either source or binary form) with the major +components (compiler, kernel, and so on) of the operating system on +which the executable runs, unless that component itself accompanies +the executable. + + It may happen that this requirement contradicts the license +restrictions of other proprietary libraries that do not normally +accompany the operating system. Such a contradiction means you cannot +use both them and the Library together in an executable that you +distribute. + + 7. You may place library facilities that are a work based on the +Library side-by-side in a single library together with other library +facilities not covered by this License, and distribute such a combined +library, provided that the separate distribution of the work based on +the Library and of the other library facilities is otherwise +permitted, and provided that you do these two things: + + a) Accompany the combined library with a copy of the same work + based on the Library, uncombined with any other library + facilities. This must be distributed under the terms of the + Sections above. + + b) Give prominent notice with the combined library of the fact + that part of it is a work based on the Library, and explaining + where to find the accompanying uncombined form of the same work. + + 8. You may not copy, modify, sublicense, link with, or distribute +the Library except as expressly provided under this License. Any +attempt otherwise to copy, modify, sublicense, link with, or +distribute the Library is void, and will automatically terminate your +rights under this License. However, parties who have received copies, +or rights, from you under this License will not have their licenses +terminated so long as such parties remain in full compliance. + + 9. You are not required to accept this License, since you have not +signed it. However, nothing else grants you permission to modify or +distribute the Library or its derivative works. These actions are +prohibited by law if you do not accept this License. Therefore, by +modifying or distributing the Library (or any work based on the +Library), you indicate your acceptance of this License to do so, and +all its terms and conditions for copying, distributing or modifying +the Library or works based on it. + + 10. Each time you redistribute the Library (or any work based on the +Library), the recipient automatically receives a license from the +original licensor to copy, distribute, link with or modify the Library +subject to these terms and conditions. You may not impose any further +restrictions on the recipients' exercise of the rights granted herein. +You are not responsible for enforcing compliance by third parties with +this License. + + 11. If, as a consequence of a court judgment or allegation of patent +infringement or for any other reason (not limited to patent issues), +conditions are imposed on you (whether by court order, agreement or +otherwise) that contradict the conditions of this License, they do not +excuse you from the conditions of this License. If you cannot +distribute so as to satisfy simultaneously your obligations under this +License and any other pertinent obligations, then as a consequence you +may not distribute the Library at all. For example, if a patent +license would not permit royalty-free redistribution of the Library by +all those who receive copies directly or indirectly through you, then +the only way you could satisfy both it and this License would be to +refrain entirely from distribution of the Library. + +If any portion of this section is held invalid or unenforceable under any +particular circumstance, the balance of the section is intended to apply, +and the section as a whole is intended to apply in other circumstances. + +It is not the purpose of this section to induce you to infringe any +patents or other property right claims or to contest validity of any +such claims; this section has the sole purpose of protecting the +integrity of the free software distribution system which is +implemented by public license practices. Many people have made +generous contributions to the wide range of software distributed +through that system in reliance on consistent application of that +system; it is up to the author/donor to decide if he or she is willing +to distribute software through any other system and a licensee cannot +impose that choice. + +This section is intended to make thoroughly clear what is believed to +be a consequence of the rest of this License. + + 12. If the distribution and/or use of the Library is restricted in +certain countries either by patents or by copyrighted interfaces, the +original copyright holder who places the Library under this License may add +an explicit geographical distribution limitation excluding those countries, +so that distribution is permitted only in or among countries not thus +excluded. In such case, this License incorporates the limitation as if +written in the body of this License. + + 13. The Free Software Foundation may publish revised and/or new +versions of the Lesser General Public License from time to time. +Such new versions will be similar in spirit to the present version, +but may differ in detail to address new problems or concerns. + +Each version is given a distinguishing version number. If the Library +specifies a version number of this License which applies to it and +"any later version", you have the option of following the terms and +conditions either of that version or of any later version published by +the Free Software Foundation. If the Library does not specify a +license version number, you may choose any version ever published by +the Free Software Foundation. + + 14. If you wish to incorporate parts of the Library into other free +programs whose distribution conditions are incompatible with these, +write to the author to ask for permission. For software which is +copyrighted by the Free Software Foundation, write to the Free +Software Foundation; we sometimes make exceptions for this. Our +decision will be guided by the two goals of preserving the free status +of all derivatives of our free software and of promoting the sharing +and reuse of software generally. + + NO WARRANTY + + 15. BECAUSE THE LIBRARY IS LICENSED FREE OF CHARGE, THERE IS NO +WARRANTY FOR THE LIBRARY, TO THE EXTENT PERMITTED BY APPLICABLE LAW. +EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR +OTHER PARTIES PROVIDE THE LIBRARY "AS IS" WITHOUT WARRANTY OF ANY +KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE +IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR +PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE +LIBRARY IS WITH YOU. SHOULD THE LIBRARY PROVE DEFECTIVE, YOU ASSUME +THE COST OF ALL NECESSARY SERVICING, REPAIR OR CORRECTION. + + 16. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN +WRITING WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY +AND/OR REDISTRIBUTE THE LIBRARY AS PERMITTED ABOVE, BE LIABLE TO YOU +FOR DAMAGES, INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR +CONSEQUENTIAL DAMAGES ARISING OUT OF THE USE OR INABILITY TO USE THE +LIBRARY (INCLUDING BUT NOT LIMITED TO LOSS OF DATA OR DATA BEING +RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD PARTIES OR A +FAILURE OF THE LIBRARY TO OPERATE WITH ANY OTHER SOFTWARE), EVEN IF +SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH +DAMAGES. + + END OF TERMS AND CONDITIONS + + How to Apply These Terms to Your New Libraries + + If you develop a new library, and you want it to be of the greatest +possible use to the public, we recommend making it free software that +everyone can redistribute and change. You can do so by permitting +redistribution under these terms (or, alternatively, under the terms of the +ordinary General Public License). + + To apply these terms, attach the following notices to the library. It is +safest to attach them to the start of each source file to most effectively +convey the exclusion of warranty; and each file should have at least the +"copyright" line and a pointer to where the full notice is found. + + + Copyright (C) + + This library is free software; you can redistribute it and/or + modify it under the terms of the GNU Lesser General Public + License as published by the Free Software Foundation; either + version 2.1 of the License, or (at your option) any later version. + + This library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public + License along with this library; if not, write to the Free Software + Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + +Also add information on how to contact you by electronic and paper mail. + +You should also get your employer (if you work as a programmer) or your +school, if any, to sign a "copyright disclaimer" for the library, if +necessary. Here is a sample; alter the names: + + Yoyodyne, Inc., hereby disclaims all copyright interest in the + library `Frob' (a library for tweaking knobs) written by James Random Hacker. + + , 1 April 1990 + Ty Coon, President of Vice + +That's all there is to it! + +------------------------------------------------------------------------------ +License for the JGit package +------------------------------------------------------------------------------ +Copyright (c) 2007, Eclipse Foundation, Inc. and its licensors. + +All rights reserved. + +Redistribution and use in source and binary forms, with or without +modification, are permitted provided that the following conditions are met: + + * Redistributions of source code must retain the above copyright notice, + this list of conditions and the following disclaimer. + * Redistributions in binary form must reproduce the above copyright notice, + this list of conditions and the following disclaimer in the documentation + and/or other materials provided with the distribution. + * Neither the name of the Eclipse Foundation, Inc. nor the names of its + contributors may be used to endorse or promote products derived from this + software without specific prior written permission. + +THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" +AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE +IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE +DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE +FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL +DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR +SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER +CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, +OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. diff --git a/bin/app/data/java/gradle/init.gradle b/bin/app/data/java/gradle/init.gradle new file mode 100644 index 00000000..cc698da0 --- /dev/null +++ b/bin/app/data/java/gradle/init.gradle @@ -0,0 +1,42 @@ +allprojects { pp -> + task printMainSrcDirs << { + if (project.hasProperty("sourceSets")) { + project.sourceSets.main.java.srcDirs.each { dir -> + println "${dir}" + } + } + } + + task printTestSrcDirs << { + if (project.hasProperty("sourceSets")) { + project.sourceSets.test.java.srcDirs.each { dir -> + println "${dir}" + } + } + } + + task copyCompileLibs << { + File rootDir = pp.getRootDir() + String destination = project.hasProperty('sourcetrail_lib_path') ? project.property('sourcetrail_lib_path').replace("\"", "") : rootDir.getPath() + rootDir.separator + "lib" + println destination; + if (pp.configurations.hasProperty("compile")) { + copy { + into destination + from pp.configurations.compile + eachFile { println "copying file \"" + it.file.name + "\" to \"" + destination + "\"" } + } + } + } + + task copyTestCompileLibs << { + File rootDir = pp.getRootDir() + String destination = project.hasProperty('sourcetrail_lib_path') ? project.property('sourcetrail_lib_path') : rootDir.getPath() + rootDir.separator + "lib" + if (pp.configurations.hasProperty("testCompile")) { + copy { + into destination + from pp.configurations.testCompile + eachFile { println "copying file \"" + it.file.name + "\" to \"" + destination + "\"" } + } + } + } +} \ No newline at end of file diff --git a/cmake/licenses.cmake b/cmake/licenses.cmake index d989edef..5af4b322 100644 --- a/cmake/licenses.cmake +++ b/cmake/licenses.cmake @@ -26,6 +26,7 @@ AddLicense("Botan" "http://botan.randombit.net/" "${LICENSEFOLDER}/license_botan AddLicense("Clang" "http://clang.llvm.org/" "${LICENSEFOLDER}/license_clang.txt") AddLicense("CppSQLite" "http://www.codeproject.com/Articles/6343/CppSQLite-C-Wrapper-for-SQLite" "${LICENSEFOLDER}/license_cpp_sqlite.txt") AddLicense("Eclipse" "https://github.com/eclipse/eclipse.jdt.core" "${LICENSEFOLDER}/license_eclipse.txt") +AddLicense("Gradle" "https://github.com/gradle/gradle" "${LICENSEFOLDER}/license_gradle.txt") AddLicense("OpenSSL" "https://www.openssl.org/" "${LICENSEFOLDER}/license_openssl.txt") AddLicense("Qt" "http://qt.io" "${LICENSEFOLDER}/license_qt.txt") AddLicense("TinyXML" "http://www.grinninglizard.com/tinyxml2/" "${LICENSEFOLDER}/license_tinyxml.txt") diff --git a/deployment/windows/wixSetup/installDir.wxs b/deployment/windows/wixSetup/installDir.wxs index 1d6b3358..c8f8da62 100644 --- a/deployment/windows/wixSetup/installDir.wxs +++ b/deployment/windows/wixSetup/installDir.wxs @@ -271,6 +271,12 @@ + + + + + + @@ -762,55 +768,68 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/deployment/windows/wixSetup/sourcetrail.wxs b/deployment/windows/wixSetup/sourcetrail.wxs index 2d789e10..7137192b 100644 --- a/deployment/windows/wixSetup/sourcetrail.wxs +++ b/deployment/windows/wixSetup/sourcetrail.wxs @@ -237,6 +237,8 @@ + + @@ -387,7 +389,10 @@ - + + + + @@ -403,7 +408,9 @@ - + + + diff --git a/java_indexer/lib/gradle-api-4.0.1.jar b/java_indexer/lib/gradle-api-4.0.1.jar new file mode 100644 index 00000000..aef7a9cc Binary files /dev/null and b/java_indexer/lib/gradle-api-4.0.1.jar differ diff --git a/java_indexer/lib/java-symbol-solver-core.jar b/java_indexer/lib/java-symbol-solver-core.jar deleted file mode 100644 index 6f0ff967..00000000 Binary files a/java_indexer/lib/java-symbol-solver-core.jar and /dev/null differ diff --git a/java_indexer/lib/java-symbol-solver-logic.jar b/java_indexer/lib/java-symbol-solver-logic.jar deleted file mode 100644 index 0e1f23a5..00000000 Binary files a/java_indexer/lib/java-symbol-solver-logic.jar and /dev/null differ diff --git a/java_indexer/lib/java-symbol-solver-model.jar b/java_indexer/lib/java-symbol-solver-model.jar deleted file mode 100644 index 0c7adbe7..00000000 Binary files a/java_indexer/lib/java-symbol-solver-model.jar and /dev/null differ diff --git a/java_indexer/pom.xml b/java_indexer/pom.xml index 3d612075..cce7cebc 100644 --- a/java_indexer/pom.xml +++ b/java_indexer/pom.xml @@ -24,11 +24,37 @@ + + + mvnrepository + mvnrepository + http://www.mvnrepository.com + + + repo_gradle + repo_gradle + http://repo.gradle.org/gradle/libs-releases-local + + + org.eclipse.jdt org.eclipse.jdt.core 3.12.3 + + + org.gradle + gradle-tooling-api + 4.2 + + + + org.slf4j + slf4j-simple + 1.7.10 + test + diff --git a/java_indexer/src/main/java/com/sourcetrail/gradle/InfoRetriever.java b/java_indexer/src/main/java/com/sourcetrail/gradle/InfoRetriever.java new file mode 100644 index 00000000..b32dbada --- /dev/null +++ b/java_indexer/src/main/java/com/sourcetrail/gradle/InfoRetriever.java @@ -0,0 +1,133 @@ +package com.sourcetrail.gradle; + +import java.io.BufferedReader; +import java.io.ByteArrayInputStream; +import java.io.ByteArrayOutputStream; +import java.io.File; +import java.io.IOException; +import java.io.InputStreamReader; +import java.io.PrintStream; +import java.io.StringReader; +import java.util.ArrayList; +import java.util.Arrays; +import java.util.List; + +import org.gradle.tooling.BuildLauncher; +import org.gradle.tooling.GradleConnector; +import org.gradle.tooling.ProjectConnection; + +public class InfoRetriever +{ + public static String getMainSrcDirs(String projectRootPath, String initScriptPath) + { + String ret = ""; + + List srcDirs = getSrcDirs("printMainSrcDirs", projectRootPath, initScriptPath); + for (int i = 0; i < srcDirs.size(); i++) + { + if (i != 0) + { + ret += ";"; + } + ret += srcDirs.get(i); + } + + return ret; + } + + public static String getTestSrcDirs(String projectRootPath, String initScriptPath) + { + String ret = ""; + + List srcDirs = getSrcDirs("printTestSrcDirs", projectRootPath, initScriptPath); + for (int i = 0; i < srcDirs.size(); i++) + { + if (i != 0) + { + ret += ";"; + } + ret += srcDirs.get(i); + } + + return ret; + } + + public static void copyCompileLibs(String projectRootPath, String initScriptPath, String targetPath) + { + executeTask("copyCompileLibs", projectRootPath, initScriptPath, Arrays.asList("-Psourcetrail_lib_path=" + targetPath)); + } + + public static void copyTestCompileLibs(String projectRootPath, String initScriptPath, String targetPath) + { + executeTask("copyTestCompileLibs", projectRootPath, initScriptPath, Arrays.asList("-Psourcetrail_lib_path=" + targetPath)); + } + + private static List getSrcDirs(String taskName, String projectRootPath, String initScriptPath) + { + String output = executeTask(taskName, projectRootPath, initScriptPath, null); + + List paths = new ArrayList<>(); + + try (BufferedReader reader = new BufferedReader(new StringReader(output))) + { + String line; + while ((line = reader.readLine()) != null) + { + paths.add(line); + } + } + catch (IOException e) + { + // TODO: LOGERROR + } + + return paths; + } + + private static String executeTask(String taskName, String projectRootPath, String initScriptPath, List additionalArguments) + { + ProjectConnection connection = GradleConnector + .newConnector() + .forProjectDirectory(new File(projectRootPath)) + .connect(); + + ByteArrayOutputStream outputStream = new ByteArrayOutputStream(); + ByteArrayOutputStream errorStream = new ByteArrayOutputStream(); + + try + { + List arguments = new ArrayList<>(); + arguments.add("--init-script"); + arguments.add(initScriptPath); +// arguments.add("-q"); + + if (additionalArguments != null) + { + arguments.addAll(additionalArguments); + } + + BuildLauncher Launcher = connection.newBuild().forTasks(taskName) + .withArguments(arguments) + .setStandardOutput(new PrintStream(outputStream)) + .setStandardError(new PrintStream(errorStream)); + + Launcher.run(); + } + catch (Exception e) + { + // TODO: LOGERROR + } + finally + { + connection.close(); + } + + if (!errorStream.toString().isEmpty()) + { + // TODO: handle this by sending the error to cpp + System.out.println("Error: " + errorStream.toString()); // TODO: remove this later + } + + return outputStream.toString(); + } +} diff --git a/script/update_java_indexer.sh b/script/update_java_indexer.sh index f3bcc336..f1e01c12 100755 --- a/script/update_java_indexer.sh +++ b/script/update_java_indexer.sh @@ -35,7 +35,7 @@ mvn clean package dependency:copy-dependencies cd ../ echo -e $INFO "copy jars" -mkdir -p bin/app/data/java -rm -rf bin/app/data/java/* -cp -r java_indexer/target/java-indexer-1.0.jar bin/app/data/java/java-indexer.jar -cp -r java_indexer/target/dependency/*.jar bin/app/data/java +mkdir -p bin/app/data/java/lib/ +rm -rf bin/app/data/java/lib/* +cp -r java_indexer/target/java-indexer-1.0.jar bin/app/data/java/lib/java-indexer.jar +cp -r java_indexer/target/dependency/*.jar bin/app/data/java/lib diff --git a/src/app/main.cpp b/src/app/main.cpp index bbf36481..e2b795bd 100644 --- a/src/app/main.cpp +++ b/src/app/main.cpp @@ -9,8 +9,7 @@ #include "data/indexer/IndexerFactoryModuleCxxManual.h" #include "LicenseChecker.h" #include "project/SourceGroupFactory.h" -#include "project/SourceGroupFactoryModuleC.h" -#include "project/SourceGroupFactoryModuleCpp.h" +#include "project/SourceGroupFactoryModuleCxx.h" #include "project/SourceGroupFactoryModuleJava.h" #include "qt/network/QtNetworkFactory.h" #include "qt/QtApplication.h" @@ -167,8 +166,7 @@ void prefillPaths() void addLanguageModules() { - SourceGroupFactory::getInstance()->addModule(std::make_shared()); - SourceGroupFactory::getInstance()->addModule(std::make_shared()); + SourceGroupFactory::getInstance()->addModule(std::make_shared()); SourceGroupFactory::getInstance()->addModule(std::make_shared()); IndexerFactory::getInstance()->addModule(std::make_shared()); diff --git a/src/lib/CMakeLists.txt b/src/lib/CMakeLists.txt index 881f49c2..3d58a8fe 100644 --- a/src/lib/CMakeLists.txt +++ b/src/lib/CMakeLists.txt @@ -296,8 +296,18 @@ add_files( settings/SourceGroupSettings.h settings/SourceGroupSettingsCxx.cpp settings/SourceGroupSettingsCxx.h + settings/SourceGroupSettingsCxxCdb.cpp + settings/SourceGroupSettingsCxxCdb.h + settings/SourceGroupSettingsCxxEmpty.cpp + settings/SourceGroupSettingsCxxEmpty.h settings/SourceGroupSettingsJava.cpp settings/SourceGroupSettingsJava.h + settings/SourceGroupSettingsJavaEmpty.cpp + settings/SourceGroupSettingsJavaEmpty.h + settings/SourceGroupSettingsJavaGradle.cpp + settings/SourceGroupSettingsJavaGradle.h + settings/SourceGroupSettingsJavaMaven.cpp + settings/SourceGroupSettingsJavaMaven.h settings/SourceGroupType.cpp settings/SourceGroupType.h diff --git a/src/lib/project/Project.cpp b/src/lib/project/Project.cpp index 4223c9d9..f5e130b0 100644 --- a/src/lib/project/Project.cpp +++ b/src/lib/project/Project.cpp @@ -45,7 +45,6 @@ Project::Project(std::shared_ptr settings, StorageAccessProxy* { } - Project::~Project() { } @@ -53,7 +52,7 @@ Project::~Project() bool Project::refresh(bool forceRefresh) { if (m_state == PROJECT_STATE_NOT_LOADED) - { + { return false; } diff --git a/src/lib/project/SourceGroup.cpp b/src/lib/project/SourceGroup.cpp index 12ce9895..ebaffa13 100644 --- a/src/lib/project/SourceGroup.cpp +++ b/src/lib/project/SourceGroup.cpp @@ -1,5 +1,7 @@ #include "project/SourceGroup.h" +#include "settings/SourceGroupSettings.h" +#include "utility/file/FileManager.h" #include "utility/file/FilePath.h" SourceGroup::~SourceGroup() @@ -21,6 +23,18 @@ bool SourceGroup::prepareIndexing() return true; } +void SourceGroup::fetchAllSourceFilePaths() +{ + m_sourceFilePathsToIndex.clear(); + FileManager fileManager; + fileManager.update( + getAllSourcePaths(), + getSourceGroupSettings()->getExcludePathsExpandedAndAbsolute(), + getSourceGroupSettings()->getSourceExtensions() + ); + m_allSourceFilePaths = fileManager.getAllSourceFilePaths(); +} + void SourceGroup::fetchSourceFilePathsToIndex(const std::set& staticSourceFilePaths) { for (const FilePath& sourceFilePath: m_allSourceFilePaths) diff --git a/src/lib/project/SourceGroup.h b/src/lib/project/SourceGroup.h index 1ced05aa..396d1fd7 100644 --- a/src/lib/project/SourceGroup.h +++ b/src/lib/project/SourceGroup.h @@ -10,6 +10,7 @@ class FilePath; class IndexerCommand; +class SourceGroupSettings; class SourceGroup { @@ -22,7 +23,7 @@ public: virtual bool prepareRefresh(); virtual bool prepareIndexing(); - virtual void fetchAllSourceFilePaths() = 0; + void fetchAllSourceFilePaths(); void fetchSourceFilePathsToIndex(const std::set& staticSourceFilePaths); std::set getAllSourceFilePaths() const; @@ -34,6 +35,10 @@ public: protected: std::set m_allSourceFilePaths; std::set m_sourceFilePathsToIndex; + +private: + virtual std::shared_ptr getSourceGroupSettings() = 0; + virtual std::vector getAllSourcePaths() const = 0; }; #endif // SOURCE_GROUP_H diff --git a/src/lib/settings/LanguageType.cpp b/src/lib/settings/LanguageType.cpp index 23abad90..f2a84081 100644 --- a/src/lib/settings/LanguageType.cpp +++ b/src/lib/settings/LanguageType.cpp @@ -49,6 +49,8 @@ LanguageType getLanguageTypeForSourceGroupType(SourceGroupType t) return LANGUAGE_JAVA; case SOURCE_GROUP_JAVA_MAVEN: return LANGUAGE_JAVA; + case SOURCE_GROUP_JAVA_GRADLE: + return LANGUAGE_JAVA; default: break; } diff --git a/src/lib/settings/ProjectSettings.cpp b/src/lib/settings/ProjectSettings.cpp index 1dd0547a..2b9ac7ff 100644 --- a/src/lib/settings/ProjectSettings.cpp +++ b/src/lib/settings/ProjectSettings.cpp @@ -3,8 +3,12 @@ #include "settings/migration/SettingsMigrationDeleteKey.h" #include "settings/migration/SettingsMigrationLambda.h" #include "settings/migration/SettingsMigrationMoveKey.h" -#include "settings/SourceGroupSettingsCxx.h" -#include "settings/SourceGroupSettingsJava.h" +#include "settings/SourceGroupSettingsCxxCdb.h" +#include "settings/SourceGroupSettingsCxxEmpty.h" +#include "settings/SourceGroupSettingsJavaEmpty.h" +#include "settings/SourceGroupSettingsJavaMaven.h" +#include "settings/SourceGroupSettingsJavaGradle.h" +#include "utility/logging/logging.h" #include "utility/utilityString.h" #include "utility/utilityUuid.h" @@ -135,7 +139,7 @@ std::vector> ProjectSettings::getAllSourceG std::vector> allSettings; for (const std::string& key: m_config->getSublevelKeys("source_groups")) { - const std::string id = key.substr(std::string("source_groups/source_group_").length()); + const std::string id = key.substr(std::string(SourceGroupSettings::s_keyPrefix).length()); const SourceGroupType type = stringToSourceGroupType(getValue(key + "/type", "")); std::shared_ptr settings; @@ -143,62 +147,36 @@ std::vector> ProjectSettings::getAllSourceG switch (type) { case SOURCE_GROUP_C_EMPTY: + settings = std::make_shared(id, SOURCE_GROUP_C_EMPTY, this); + break; case SOURCE_GROUP_CPP_EMPTY: + settings = std::make_shared(id, SOURCE_GROUP_CPP_EMPTY, this); + break; case SOURCE_GROUP_CXX_CDB: - { - std::shared_ptr cxxSettings = std::make_shared(id, type, this); - cxxSettings->setHeaderSearchPaths(getPathValues(key + "/header_search_paths/header_search_path")); - cxxSettings->setFrameworkSearchPaths(getPathValues(key + "/framework_search_paths/framework_search_path")); - cxxSettings->setCompilerFlags(getValues(key + "/compiler_flags/compiler_flag", std::vector())); - cxxSettings->setUseSourcePathsForHeaderSearch(getValue(key + "/use_source_paths_for_header_search", false)); - cxxSettings->setHasDefinedUseSourcePathsForHeaderSearch(isValueDefined(key + "/use_source_paths_for_header_search")); - if (type == SOURCE_GROUP_CXX_CDB) - { - cxxSettings->setCompilationDatabasePath(FilePath(getValue(key + "/build_file_path/compilation_db_path", ""))); - } - if (type == SOURCE_GROUP_C_EMPTY || type == SOURCE_GROUP_CPP_EMPTY) - { - cxxSettings->setTargetOptionsEnabled(getValue(key + "/cross_compilation/target_options_enabled", false)); - cxxSettings->setTargetArch(getValue(key + "/cross_compilation/target/arch", "")); - cxxSettings->setTargetVendor(getValue(key + "/cross_compilation/target/vendor", "")); - cxxSettings->setTargetSys(getValue(key + "/cross_compilation/target/sys", "")); - cxxSettings->setTargetAbi(getValue(key + "/cross_compilation/target/abi", "")); - } - cxxSettings->setShouldApplyAnonymousTypedefTransformation(getValue(key + "/should_apply_anonymous_typedef_transformation", true)); - settings = cxxSettings; - } + settings = std::make_shared(id, this); break; case SOURCE_GROUP_JAVA_EMPTY: + settings = std::make_shared(id, this); + break; case SOURCE_GROUP_JAVA_MAVEN: - { - std::shared_ptr javaSettings = std::make_shared(id, type, this); - javaSettings->setClasspath(getPathValues(key + "/class_paths/class_path")); - javaSettings->setUseJreSystemLibrary(getValue(key + "/use_jre_system_library", true)); - if (type == SOURCE_GROUP_JAVA_MAVEN) - { - javaSettings->setMavenProjectFilePath(FilePath(getValue(key + "/maven/project_file_path", ""))); - javaSettings->setMavenDependenciesDirectory(FilePath(getValue(key + "/maven/dependencies_directory", ""))); - javaSettings->setShouldIndexMavenTests(getValue(key + "/maven/should_index_tests", false)); - } - settings = javaSettings; - } + settings = std::make_shared(id, this); + break; + case SOURCE_GROUP_JAVA_GRADLE: + settings = std::make_shared(id, this); break; default: continue; } - const std::string name = getValue(key + "/name", ""); - if (name.size()) + if (settings) { - settings->setName(name); + settings->load(m_config); + allSettings.push_back(settings); + } + else + { + LOG_WARNING("Sourcegroup with id \"" + id + "\" could not be loaded."); } - - settings->setStandard(getValue(key + "/standard", "")); - settings->setSourcePaths(getPathValues(key + "/source_paths/source_path")); - settings->setExcludePaths(getPathValues(key + "/exclude_paths/exclude_path")); - settings->setSourceExtensions(getValues(key + "/source_extensions/source_extension", std::vector())); - - allSettings.push_back(settings); } return allSettings; @@ -213,63 +191,11 @@ void ProjectSettings::setAllSourceGroupSettings(const std::vector& settings: allSettings) { - const std::string key = "source_groups/source_group_" + settings->getId(); + const std::string key = SourceGroupSettings::s_keyPrefix + settings->getId(); const SourceGroupType type = settings->getType(); - setValue(key + "/type", sourceGroupTypeToString(type)); - setValue(key + "/name", settings->getName()); - setValue(key + "/standard", settings->getStandard()); - setPathValues(key + "/source_paths/source_path", settings->getSourcePaths()); - setPathValues(key + "/exclude_paths/exclude_path", settings->getExcludePaths()); - setValues(key + "/source_extensions/source_extension", settings->getSourceExtensions()); - switch (type) - { - case SOURCE_GROUP_C_EMPTY: - case SOURCE_GROUP_CPP_EMPTY: - case SOURCE_GROUP_CXX_CDB: - if (std::shared_ptr cxxSettings = std::dynamic_pointer_cast(settings)) - { - setPathValues(key + "/header_search_paths/header_search_path", cxxSettings->getHeaderSearchPaths()); - setPathValues(key + "/framework_search_paths/framework_search_path", cxxSettings->getFrameworkSearchPaths()); - setValues(key + "/compiler_flags/compiler_flag", cxxSettings->getCompilerFlags()); - if (cxxSettings->getHasDefinedUseSourcePathsForHeaderSearch()) - { - setValue(key + "/use_source_paths_for_header_search", cxxSettings->getUseSourcePathsForHeaderSearch()); - } - if (type == SOURCE_GROUP_CXX_CDB) - { - setValue(key + "/build_file_path/compilation_db_path", cxxSettings->getCompilationDatabasePath().str()); - } - if (type == SOURCE_GROUP_C_EMPTY || type == SOURCE_GROUP_CPP_EMPTY) - { - setValue(key + "/cross_compilation/target_options_enabled", cxxSettings->getTargetOptionsEnabled()); - setValue(key + "/cross_compilation/target/arch", cxxSettings->getTargetArch()); - setValue(key + "/cross_compilation/target/vendor", cxxSettings->getTargetVendor()); - setValue(key + "/cross_compilation/target/sys", cxxSettings->getTargetSys()); - setValue(key + "/cross_compilation/target/abi", cxxSettings->getTargetAbi()); - } - setValue(key + "/should_apply_anonymous_typedef_transformation", cxxSettings->getShouldApplyAnonymousTypedefTransformation()); - } - break; - case SOURCE_GROUP_JAVA_EMPTY: - case SOURCE_GROUP_JAVA_MAVEN: - if (std::shared_ptr javaSettings = std::dynamic_pointer_cast(settings)) - { - setPathValues(key + "/class_paths/class_path", javaSettings->getClasspath()); - setValue(key + "/use_jre_system_library", javaSettings->getUseJreSystemLibrary()); - - if (type == SOURCE_GROUP_JAVA_MAVEN) - { - setValue(key + "/maven/project_file_path", javaSettings->getMavenProjectFilePath().str()); - setValue(key + "/maven/dependencies_directory", javaSettings->getMavenDependenciesDirectory().str()); - setValue(key + "/maven/should_index_tests", javaSettings->getShouldIndexMavenTests()); - } - } - break; - default: - continue; - } + settings->save(m_config); } } @@ -373,6 +299,11 @@ SettingsMigrator ProjectSettings::getMigrations() const { type = SOURCE_GROUP_JAVA_MAVEN; } + const std::string gradleProjectFilePath = migration->getValueFromSettings(settings, sourceGroupKey + "/gradle/project_file_path", ""); + if (!gradleProjectFilePath.empty()) + { + type = SOURCE_GROUP_JAVA_GRADLE; + } else { type = SOURCE_GROUP_JAVA_EMPTY; diff --git a/src/lib/settings/Settings.cpp b/src/lib/settings/Settings.cpp index c804d87a..08adddf9 100644 --- a/src/lib/settings/Settings.cpp +++ b/src/lib/settings/Settings.cpp @@ -118,9 +118,9 @@ std::vector Settings::getPathValues(const std::string& key) const values = getValues(key, values); std::vector paths; - for (const std::string& path : values) + for (const std::string& value : values) { - paths.push_back(FilePath(path)); + paths.push_back(FilePath(value)); } return paths; } diff --git a/src/lib/settings/SourceGroupSettings.cpp b/src/lib/settings/SourceGroupSettings.cpp index 705a20d2..b5139954 100644 --- a/src/lib/settings/SourceGroupSettings.cpp +++ b/src/lib/settings/SourceGroupSettings.cpp @@ -2,6 +2,8 @@ #include "utility/utility.h" +std::string SourceGroupSettings::s_keyPrefix = "source_groups/source_group_"; + SourceGroupSettings::SourceGroupSettings(const std::string& id, SourceGroupType type, const ProjectSettings* projectSettings) : m_projectSettings(projectSettings) , m_id(id) @@ -18,6 +20,33 @@ SourceGroupSettings::~SourceGroupSettings() { } +void SourceGroupSettings::load(std::shared_ptr config) +{ + const std::string key = s_keyPrefix + getId(); + + const std::string name = getValue(key + "/name", "", config); + if (!name.empty()) + { + setName(name); + } + + setStandard(getValue(key + "/standard", "", config)); + setSourcePaths(getPathValues(key + "/source_paths/source_path", config)); + setExcludePaths(getPathValues(key + "/exclude_paths/exclude_path", config)); + setSourceExtensions(getValues(key + "/source_extensions/source_extension", std::vector(), config)); +} + +void SourceGroupSettings::save(std::shared_ptr config) +{ + const std::string key = s_keyPrefix + getId(); + + setValue(key + "/name", getName(), config); + setValue(key + "/standard", getStandard(), config); + setPathValues(key + "/source_paths/source_path", getSourcePaths(), config); + setPathValues(key + "/exclude_paths/exclude_path", getExcludePaths(), config); + setValues(key + "/source_extensions/source_extension", getSourceExtensions(), config); +} + bool SourceGroupSettings::equals(std::shared_ptr other) const { return ( @@ -128,3 +157,27 @@ void SourceGroupSettings::setSourceExtensions(const std::vector& so { m_sourceExtensions = sourceExtensions; } + +std::vector SourceGroupSettings::getPathValues(const std::string& key, std::shared_ptr config) +{ + std::vector values; + values = getValues(key, values, config); + + std::vector paths; + for (const std::string& value : values) + { + paths.push_back(FilePath(value)); + } + return paths; +} + +bool SourceGroupSettings::setPathValues(const std::string& key, const std::vector& paths, std::shared_ptr config) +{ + std::vector values; + for (const FilePath& path : paths) + { + values.push_back(path.str()); + } + + return setValues(key, values, config); +} diff --git a/src/lib/settings/SourceGroupSettings.h b/src/lib/settings/SourceGroupSettings.h index 4b9ffd44..de440ae1 100644 --- a/src/lib/settings/SourceGroupSettings.h +++ b/src/lib/settings/SourceGroupSettings.h @@ -12,9 +12,14 @@ class ProjectSettings; class SourceGroupSettings { public: + static std::string s_keyPrefix; + SourceGroupSettings(const std::string& id, SourceGroupType type, const ProjectSettings* projectSettings); virtual ~SourceGroupSettings(); + virtual void load(std::shared_ptr config); + virtual void save(std::shared_ptr config); + virtual bool equals(std::shared_ptr other) const; std::string getId() const; @@ -45,6 +50,22 @@ public: void setSourceExtensions(const std::vector& sourceExtensions); protected: + template + static T getValue(const std::string& key, T defaultValue, std::shared_ptr config); + + template + static std::vector getValues(const std::string& key, std::vector defaultValues, std::shared_ptr config); + + static std::vector getPathValues(const std::string& key, std::shared_ptr config); + + template + static bool setValue(const std::string& key, T value, std::shared_ptr config); + + template + static bool setValues(const std::string& key, std::vector values, std::shared_ptr config); + + static bool setPathValues(const std::string& key, const std::vector& paths, std::shared_ptr config); + const ProjectSettings* m_projectSettings; private: @@ -61,4 +82,54 @@ private: std::vector m_sourceExtensions; }; +template +T SourceGroupSettings::getValue(const std::string& key, T defaultValue, std::shared_ptr config) +{ + if (config) + { + T value; + if (config->getValue(key, value)) + { + return value; + } + } + return defaultValue; +} + +template +std::vector SourceGroupSettings::getValues(const std::string& key, std::vector defaultValues, std::shared_ptr config) +{ + if (config) + { + std::vector values; + if (config->getValues(key, values)) + { + return values; + } + } + return defaultValues; +} + +template +bool SourceGroupSettings::setValue(const std::string& key, T value, std::shared_ptr config) +{ + if (config) + { + config->setValue(key, value); + return true; + } + return false; +} + +template +bool SourceGroupSettings::setValues(const std::string& key, std::vector values, std::shared_ptr config) +{ + if (config) + { + config->setValues(key, values); + return true; + } + return false; +} + #endif // SOURCE_GROUP_SETTINGS_H diff --git a/src/lib/settings/SourceGroupSettingsCxx.cpp b/src/lib/settings/SourceGroupSettingsCxx.cpp index b854ed1b..68375921 100644 --- a/src/lib/settings/SourceGroupSettingsCxx.cpp +++ b/src/lib/settings/SourceGroupSettingsCxx.cpp @@ -3,156 +3,11 @@ #include "utility/utility.h" #include "utility/utilityApp.h" -std::vector SourceGroupSettingsCxx::getAvailableArchTypes() -{ - return { - "aarch64", - "aarch64_be", - "arm", - "armeb", - "avr", - "bpfel", - "bpfeb", - "hexagon", - "mips", - "mipsel", - "mips64", - "mips64el", - "msp430", - "powerpc64", - "powerpc64le", - "powerpc", - "r600", - "amdgcn", - "riscv32", - "riscv64", - "sparc", - "sparcv9", - "sparcel", - "s390x", - "tce", - "tcele", - "thumb", - "thumbeb", - "i386", - "x86_64", - "xcore", - "nvptx", - "nvptx64", - "le32", - "le64", - "amdil", - "amdil64", - "hsail", - "hsail64", - "spir", - "spir64", - "kalimba", - "lanai", - "shave", - "wasm32", - "wasm64", - "renderscript32", - "renderscript64", - }; -} - -std::vector SourceGroupSettingsCxx::getAvailableVendorTypes() -{ - return { - "unknown", - "apple", - "pc", - "scei", - "bgp", - "bgq", - "fsl", - "ibm", - "img", - "mti", - "nvidia", - "csr", - "myriad", - "amd", - "mesa" - }; -} - -std::vector SourceGroupSettingsCxx::getAvailableOsTypes() -{ - return { - "unknown", - "cloudabi", - "darwin", - "dragonfly", - "freebsd", - "fuchsia", - "ios", - "kfreebsd", - "linux", - "lv2", - "macosx", - "netbsd", - "openbsd", - "solaris", - "windows", - "haiku", - "minix", - "rtems", - "nacl", - "cnk", - "bitrig", - "aix", - "cuda", - "nvcl", - "amdhsa", - "ps4", - "elfiamcu", - "tvos", - "watchos", - "mesa3d", - "contiki" - }; -} - -std::vector SourceGroupSettingsCxx::getAvailableEnvironmentTypes() -{ - return { - "unknown", - "gnu", - "gnuabi64", - "gnueabihf", - "gnueabi", - "gnux32", - "code16", - "eabi", - "eabihf", - "android", - "musl", - "musleabi", - "musleabihf", - "msvc", - "itanium", - "cygnus", - "amdopencl", - "coreclr", - "opencl" - }; -} - SourceGroupSettingsCxx::SourceGroupSettingsCxx(const std::string& id, SourceGroupType type, const ProjectSettings* projectSettings) : SourceGroupSettings(id, type, projectSettings) , m_headerSearchPaths(std::vector()) , m_frameworkSearchPaths(std::vector()) - , m_targetOptionsEnabled(false) - , m_targetArch("") - , m_targetVendor("") - , m_targetSys("") - , m_targetAbi("") , m_compilerFlags(std::vector()) - , m_useSourcePathsForHeaderSearch(false) - , m_hasDefinedUseSourcePathsForHeaderSearch(false) - , m_compilationDatabasePath(FilePath()) , m_shouldApplyAnonymousTypedefTransformation(true) { } @@ -161,6 +16,30 @@ SourceGroupSettingsCxx::~SourceGroupSettingsCxx() { } +void SourceGroupSettingsCxx::load(std::shared_ptr config) +{ + SourceGroupSettings::load(config); + + const std::string key = s_keyPrefix + getId(); + + setHeaderSearchPaths(getPathValues(key + "/header_search_paths/header_search_path", config)); + setFrameworkSearchPaths(getPathValues(key + "/framework_search_paths/framework_search_path", config)); + setCompilerFlags(getValues(key + "/compiler_flags/compiler_flag", std::vector(), config)); + setShouldApplyAnonymousTypedefTransformation(getValue(key + "/should_apply_anonymous_typedef_transformation", true, config)); +} + +void SourceGroupSettingsCxx::save(std::shared_ptr config) +{ + SourceGroupSettings::save(config); + + const std::string key = s_keyPrefix + getId(); + + setPathValues(key + "/header_search_paths/header_search_path", getHeaderSearchPaths(), config); + setPathValues(key + "/framework_search_paths/framework_search_path", getFrameworkSearchPaths(), config); + setValues(key + "/compiler_flags/compiler_flag", getCompilerFlags(), config); + setValue(key + "/should_apply_anonymous_typedef_transformation", getShouldApplyAnonymousTypedefTransformation(), config); +} + bool SourceGroupSettingsCxx::equals(std::shared_ptr other) const { std::shared_ptr otherCxx = std::dynamic_pointer_cast(other); @@ -170,11 +49,7 @@ bool SourceGroupSettingsCxx::equals(std::shared_ptr other) SourceGroupSettings::equals(other) && utility::isPermutation(m_headerSearchPaths, otherCxx->m_headerSearchPaths) && utility::isPermutation(m_frameworkSearchPaths, otherCxx->m_frameworkSearchPaths) && - utility::isPermutation(m_compilerFlags, otherCxx->m_compilerFlags) && - m_useSourcePathsForHeaderSearch == otherCxx->m_useSourcePathsForHeaderSearch && - m_hasDefinedUseSourcePathsForHeaderSearch == otherCxx->m_hasDefinedUseSourcePathsForHeaderSearch && - m_compilationDatabasePath == otherCxx->m_compilationDatabasePath && - getTargetFlag() == otherCxx->getTargetFlag() + utility::isPermutation(m_compilerFlags, otherCxx->m_compilerFlags) ); } @@ -271,70 +146,6 @@ void SourceGroupSettingsCxx::setFrameworkSearchPaths(const std::vector m_frameworkSearchPaths = frameworkSearchPaths; } -bool SourceGroupSettingsCxx::getTargetOptionsEnabled() const -{ - return m_targetOptionsEnabled; -} - -void SourceGroupSettingsCxx::setTargetOptionsEnabled(bool targetOptionsEnabled) -{ - m_targetOptionsEnabled = targetOptionsEnabled; -} - -std::string SourceGroupSettingsCxx::getTargetArch() const -{ - return m_targetArch; -} - -void SourceGroupSettingsCxx::setTargetArch(const std::string& arch) -{ - m_targetArch = arch; -} - -std::string SourceGroupSettingsCxx::getTargetVendor() const -{ - return m_targetVendor; -} - -void SourceGroupSettingsCxx::setTargetVendor(const std::string& vendor) -{ - m_targetVendor = vendor; -} - -std::string SourceGroupSettingsCxx::getTargetSys() const -{ - return m_targetSys; -} - -void SourceGroupSettingsCxx::setTargetSys(const std::string& sys) -{ - m_targetSys = sys; -} - -std::string SourceGroupSettingsCxx::getTargetAbi() const -{ - return m_targetAbi; -} - -void SourceGroupSettingsCxx::setTargetAbi(const std::string& abi) -{ - m_targetAbi = abi; -} - -std::string SourceGroupSettingsCxx::getTargetFlag() const -{ - std::string targetFlag = ""; - if (m_targetOptionsEnabled && !m_targetArch.empty()) - { - targetFlag = "--target="; - targetFlag += m_targetArch; - targetFlag += "-" + (m_targetVendor.empty() ? "unknown" : m_targetVendor); - targetFlag += "-" + (m_targetSys.empty() ? "unknown" : m_targetSys); - targetFlag += "-" + (m_targetAbi.empty() ? "unknown" : m_targetAbi); - } - return targetFlag; -} - std::vector SourceGroupSettingsCxx::getCompilerFlags() const { return m_compilerFlags; @@ -345,41 +156,6 @@ void SourceGroupSettingsCxx::setCompilerFlags(const std::vector& co m_compilerFlags = compilerFlags; } -bool SourceGroupSettingsCxx::getUseSourcePathsForHeaderSearch() const -{ - return m_useSourcePathsForHeaderSearch; -} - -void SourceGroupSettingsCxx::setUseSourcePathsForHeaderSearch(bool useSourcePathsForHeaderSearch) -{ - m_useSourcePathsForHeaderSearch = useSourcePathsForHeaderSearch; -} - -bool SourceGroupSettingsCxx::getHasDefinedUseSourcePathsForHeaderSearch() const -{ - return m_hasDefinedUseSourcePathsForHeaderSearch; -} - -void SourceGroupSettingsCxx::setHasDefinedUseSourcePathsForHeaderSearch(bool hasDefinedUseSourcePathsForHeaderSearch) -{ - m_hasDefinedUseSourcePathsForHeaderSearch = hasDefinedUseSourcePathsForHeaderSearch; -} - -FilePath SourceGroupSettingsCxx::getCompilationDatabasePath() const -{ - return m_compilationDatabasePath; -} - -FilePath SourceGroupSettingsCxx::getCompilationDatabasePathExpandedAndAbsolute() const -{ - return m_projectSettings->makePathExpandedAndAbsolute(getCompilationDatabasePath()); -} - -void SourceGroupSettingsCxx::setCompilationDatabasePath(const FilePath& compilationDatabasePath) -{ - m_compilationDatabasePath = compilationDatabasePath; -} - bool SourceGroupSettingsCxx::getShouldApplyAnonymousTypedefTransformation() const { return m_shouldApplyAnonymousTypedefTransformation; diff --git a/src/lib/settings/SourceGroupSettingsCxx.h b/src/lib/settings/SourceGroupSettingsCxx.h index 86780edc..2ccf175d 100644 --- a/src/lib/settings/SourceGroupSettingsCxx.h +++ b/src/lib/settings/SourceGroupSettingsCxx.h @@ -7,14 +7,12 @@ class SourceGroupSettingsCxx : public SourceGroupSettings { public: - static std::vector getAvailableArchTypes(); - static std::vector getAvailableVendorTypes(); - static std::vector getAvailableOsTypes(); - static std::vector getAvailableEnvironmentTypes(); - SourceGroupSettingsCxx(const std::string& id, SourceGroupType type, const ProjectSettings* projectSettings); virtual ~SourceGroupSettingsCxx(); + virtual void load(std::shared_ptr config); + virtual void save(std::shared_ptr config); + virtual bool equals(std::shared_ptr other) const; virtual std::vector getAvailableLanguageStandards() const; @@ -27,37 +25,9 @@ public: std::vector getFrameworkSearchPathsExpandedAndAbsolute() const; void setFrameworkSearchPaths(const std::vector& frameworkSearchPaths); - bool getTargetOptionsEnabled() const; - void setTargetOptionsEnabled(bool targetOptionsEnabled); - - std::string getTargetArch() const; - void setTargetArch(const std::string& arch); - - std::string getTargetVendor() const; - void setTargetVendor(const std::string& vendor); - - std::string getTargetSys() const; - void setTargetSys(const std::string& sys); - - std::string getTargetAbi() const; - void setTargetAbi(const std::string& abi); - - std::string getTargetFlag() const; - std::vector getCompilerFlags() const; void setCompilerFlags(const std::vector& compilerFlags); - // deprecated begin - bool getUseSourcePathsForHeaderSearch() const; - void setUseSourcePathsForHeaderSearch(bool useSourcePathsForHeaderSearch); - bool getHasDefinedUseSourcePathsForHeaderSearch() const; - void setHasDefinedUseSourcePathsForHeaderSearch(bool hasDefinedUseSourcePathsForHeaderSearch); - // deprecated end - - FilePath getCompilationDatabasePath() const; - FilePath getCompilationDatabasePathExpandedAndAbsolute() const; - void setCompilationDatabasePath(const FilePath& compilationDatabasePath); - bool getShouldApplyAnonymousTypedefTransformation() const; void setShouldApplyAnonymousTypedefTransformation(bool shouldApplyAnonymousTypedefTransformation); @@ -67,15 +37,7 @@ private: std::vector m_headerSearchPaths; std::vector m_frameworkSearchPaths; - bool m_targetOptionsEnabled; - std::string m_targetArch; - std::string m_targetVendor; - std::string m_targetSys; - std::string m_targetAbi; std::vector m_compilerFlags; - bool m_useSourcePathsForHeaderSearch; - bool m_hasDefinedUseSourcePathsForHeaderSearch; - FilePath m_compilationDatabasePath; bool m_shouldApplyAnonymousTypedefTransformation; }; diff --git a/src/lib/settings/SourceGroupSettingsCxxCdb.cpp b/src/lib/settings/SourceGroupSettingsCxxCdb.cpp new file mode 100644 index 00000000..6baa49bb --- /dev/null +++ b/src/lib/settings/SourceGroupSettingsCxxCdb.cpp @@ -0,0 +1,58 @@ +#include "settings/SourceGroupSettingsCxxCdb.h" + +#include "utility/utility.h" +#include "utility/utilityApp.h" + +SourceGroupSettingsCxxCdb::SourceGroupSettingsCxxCdb(const std::string& id, const ProjectSettings* projectSettings) + : SourceGroupSettingsCxx(id, SOURCE_GROUP_CXX_CDB, projectSettings) + , m_compilationDatabasePath(FilePath()) +{ +} + +SourceGroupSettingsCxxCdb::~SourceGroupSettingsCxxCdb() +{ +} + +void SourceGroupSettingsCxxCdb::load(std::shared_ptr config) +{ + SourceGroupSettingsCxx::load(config); + + const std::string key = s_keyPrefix + getId(); + + setCompilationDatabasePath(FilePath(getValue(key + "/build_file_path/compilation_db_path", "", config))); +} + +void SourceGroupSettingsCxxCdb::save(std::shared_ptr config) +{ + SourceGroupSettingsCxx::save(config); + + const std::string key = s_keyPrefix + getId(); + + setValue(key + "/build_file_path/compilation_db_path", getCompilationDatabasePath().str(), config); +} + +bool SourceGroupSettingsCxxCdb::equals(std::shared_ptr other) const +{ + std::shared_ptr otherCxxCdb = std::dynamic_pointer_cast(other); + + return ( + otherCxxCdb && + SourceGroupSettingsCxx::equals(other) && + m_compilationDatabasePath == otherCxxCdb->m_compilationDatabasePath + ); +} + +FilePath SourceGroupSettingsCxxCdb::getCompilationDatabasePath() const +{ + return m_compilationDatabasePath; +} + +FilePath SourceGroupSettingsCxxCdb::getCompilationDatabasePathExpandedAndAbsolute() const +{ + return m_projectSettings->makePathExpandedAndAbsolute(getCompilationDatabasePath()); +} + +void SourceGroupSettingsCxxCdb::setCompilationDatabasePath(const FilePath& compilationDatabasePath) +{ + m_compilationDatabasePath = compilationDatabasePath; +} diff --git a/src/lib/settings/SourceGroupSettingsCxxCdb.h b/src/lib/settings/SourceGroupSettingsCxxCdb.h new file mode 100644 index 00000000..c1905a66 --- /dev/null +++ b/src/lib/settings/SourceGroupSettingsCxxCdb.h @@ -0,0 +1,26 @@ +#ifndef SOURCE_GROUP_SETTINGS_CXX_CDB_H +#define SOURCE_GROUP_SETTINGS_CXX_CDB_H + +#include "settings/SourceGroupSettingsCxx.h" + +class SourceGroupSettingsCxxCdb + : public SourceGroupSettingsCxx +{ +public: + SourceGroupSettingsCxxCdb(const std::string& id, const ProjectSettings* projectSettings); + virtual ~SourceGroupSettingsCxxCdb(); + + virtual void load(std::shared_ptr config); + virtual void save(std::shared_ptr config); + + virtual bool equals(std::shared_ptr other) const; + + FilePath getCompilationDatabasePath() const; + FilePath getCompilationDatabasePathExpandedAndAbsolute() const; + void setCompilationDatabasePath(const FilePath& compilationDatabasePath); + +private: + FilePath m_compilationDatabasePath; +}; + +#endif // SOURCE_GROUP_SETTINGS_CXX_CDB_H diff --git a/src/lib/settings/SourceGroupSettingsCxxEmpty.cpp b/src/lib/settings/SourceGroupSettingsCxxEmpty.cpp new file mode 100644 index 00000000..0a9e34f6 --- /dev/null +++ b/src/lib/settings/SourceGroupSettingsCxxEmpty.cpp @@ -0,0 +1,256 @@ +#include "settings/SourceGroupSettingsCxxEmpty.h" + +#include "utility/utility.h" +#include "utility/utilityApp.h" + +std::vector SourceGroupSettingsCxxEmpty::getAvailableArchTypes() +{ + return { + "aarch64", + "aarch64_be", + "arm", + "armeb", + "avr", + "bpfel", + "bpfeb", + "hexagon", + "mips", + "mipsel", + "mips64", + "mips64el", + "msp430", + "powerpc64", + "powerpc64le", + "powerpc", + "r600", + "amdgcn", + "riscv32", + "riscv64", + "sparc", + "sparcv9", + "sparcel", + "s390x", + "tce", + "tcele", + "thumb", + "thumbeb", + "i386", + "x86_64", + "xcore", + "nvptx", + "nvptx64", + "le32", + "le64", + "amdil", + "amdil64", + "hsail", + "hsail64", + "spir", + "spir64", + "kalimba", + "lanai", + "shave", + "wasm32", + "wasm64", + "renderscript32", + "renderscript64", + }; +} + +std::vector SourceGroupSettingsCxxEmpty::getAvailableVendorTypes() +{ + return { + "unknown", + "apple", + "pc", + "scei", + "bgp", + "bgq", + "fsl", + "ibm", + "img", + "mti", + "nvidia", + "csr", + "myriad", + "amd", + "mesa" + }; +} + +std::vector SourceGroupSettingsCxxEmpty::getAvailableOsTypes() +{ + return { + "unknown", + "cloudabi", + "darwin", + "dragonfly", + "freebsd", + "fuchsia", + "ios", + "kfreebsd", + "linux", + "lv2", + "macosx", + "netbsd", + "openbsd", + "solaris", + "windows", + "haiku", + "minix", + "rtems", + "nacl", + "cnk", + "bitrig", + "aix", + "cuda", + "nvcl", + "amdhsa", + "ps4", + "elfiamcu", + "tvos", + "watchos", + "mesa3d", + "contiki" + }; +} + +std::vector SourceGroupSettingsCxxEmpty::getAvailableEnvironmentTypes() +{ + return { + "unknown", + "gnu", + "gnuabi64", + "gnueabihf", + "gnueabi", + "gnux32", + "code16", + "eabi", + "eabihf", + "android", + "musl", + "musleabi", + "musleabihf", + "msvc", + "itanium", + "cygnus", + "amdopencl", + "coreclr", + "opencl" + }; +} + +SourceGroupSettingsCxxEmpty::SourceGroupSettingsCxxEmpty(const std::string& id, SourceGroupType type, const ProjectSettings* projectSettings) + : SourceGroupSettingsCxx(id, type, projectSettings) + , m_targetOptionsEnabled(false) + , m_targetArch("") + , m_targetVendor("") + , m_targetSys("") + , m_targetAbi("") +{ +} + +SourceGroupSettingsCxxEmpty::~SourceGroupSettingsCxxEmpty() +{ +} + +void SourceGroupSettingsCxxEmpty::load(std::shared_ptr config) +{ + SourceGroupSettingsCxx::load(config); + + const std::string key = s_keyPrefix + getId(); + + setTargetOptionsEnabled(getValue(key + "/cross_compilation/target_options_enabled", false, config)); + setTargetArch(getValue(key + "/cross_compilation/target/arch", "", config)); + setTargetVendor(getValue(key + "/cross_compilation/target/vendor", "", config)); + setTargetSys(getValue(key + "/cross_compilation/target/sys", "", config)); + setTargetAbi(getValue(key + "/cross_compilation/target/abi", "", config)); +} + +void SourceGroupSettingsCxxEmpty::save(std::shared_ptr config) +{ + SourceGroupSettingsCxx::save(config); + + const std::string key = s_keyPrefix + getId(); + + setValue(key + "/cross_compilation/target_options_enabled", getTargetOptionsEnabled(), config); + setValue(key + "/cross_compilation/target/arch", getTargetArch(), config); + setValue(key + "/cross_compilation/target/vendor", getTargetVendor(), config); + setValue(key + "/cross_compilation/target/sys", getTargetSys(), config); + setValue(key + "/cross_compilation/target/abi", getTargetAbi(), config); +} + +bool SourceGroupSettingsCxxEmpty::equals(std::shared_ptr other) const +{ + std::shared_ptr otherCxxEmpty = std::dynamic_pointer_cast(other); + + return ( + otherCxxEmpty && + SourceGroupSettingsCxx::equals(other) && + getTargetFlag() == otherCxxEmpty->getTargetFlag() + ); +} + +bool SourceGroupSettingsCxxEmpty::getTargetOptionsEnabled() const +{ + return m_targetOptionsEnabled; +} + +void SourceGroupSettingsCxxEmpty::setTargetOptionsEnabled(bool targetOptionsEnabled) +{ + m_targetOptionsEnabled = targetOptionsEnabled; +} + +std::string SourceGroupSettingsCxxEmpty::getTargetArch() const +{ + return m_targetArch; +} + +void SourceGroupSettingsCxxEmpty::setTargetArch(const std::string& arch) +{ + m_targetArch = arch; +} + +std::string SourceGroupSettingsCxxEmpty::getTargetVendor() const +{ + return m_targetVendor; +} + +void SourceGroupSettingsCxxEmpty::setTargetVendor(const std::string& vendor) +{ + m_targetVendor = vendor; +} + +std::string SourceGroupSettingsCxxEmpty::getTargetSys() const +{ + return m_targetSys; +} + +void SourceGroupSettingsCxxEmpty::setTargetSys(const std::string& sys) +{ + m_targetSys = sys; +} + +std::string SourceGroupSettingsCxxEmpty::getTargetAbi() const +{ + return m_targetAbi; +} + +void SourceGroupSettingsCxxEmpty::setTargetAbi(const std::string& abi) +{ + m_targetAbi = abi; +} + +std::string SourceGroupSettingsCxxEmpty::getTargetFlag() const +{ + std::string targetFlag = ""; + if (m_targetOptionsEnabled && !m_targetArch.empty()) + { + targetFlag = "--target="; + targetFlag += m_targetArch; + targetFlag += "-" + (m_targetVendor.empty() ? "unknown" : m_targetVendor); + targetFlag += "-" + (m_targetSys.empty() ? "unknown" : m_targetSys); + targetFlag += "-" + (m_targetAbi.empty() ? "unknown" : m_targetAbi); + } + return targetFlag; +} diff --git a/src/lib/settings/SourceGroupSettingsCxxEmpty.h b/src/lib/settings/SourceGroupSettingsCxxEmpty.h new file mode 100644 index 00000000..cdb747d6 --- /dev/null +++ b/src/lib/settings/SourceGroupSettingsCxxEmpty.h @@ -0,0 +1,48 @@ +#ifndef SOURCE_GROUP_SETTINGS_CXX_EMPTY_H +#define SOURCE_GROUP_SETTINGS_CXX_EMPTY_H + +#include "settings/SourceGroupSettingsCxx.h" + +class SourceGroupSettingsCxxEmpty + : public SourceGroupSettingsCxx +{ +public: + static std::vector getAvailableArchTypes(); + static std::vector getAvailableVendorTypes(); + static std::vector getAvailableOsTypes(); + static std::vector getAvailableEnvironmentTypes(); + + SourceGroupSettingsCxxEmpty(const std::string& id, SourceGroupType type, const ProjectSettings* projectSettings); + virtual ~SourceGroupSettingsCxxEmpty(); + + virtual void load(std::shared_ptr config); + virtual void save(std::shared_ptr config); + + virtual bool equals(std::shared_ptr other) const; + + bool getTargetOptionsEnabled() const; + void setTargetOptionsEnabled(bool targetOptionsEnabled); + + std::string getTargetArch() const; + void setTargetArch(const std::string& arch); + + std::string getTargetVendor() const; + void setTargetVendor(const std::string& vendor); + + std::string getTargetSys() const; + void setTargetSys(const std::string& sys); + + std::string getTargetAbi() const; + void setTargetAbi(const std::string& abi); + + std::string getTargetFlag() const; + +private: + bool m_targetOptionsEnabled; + std::string m_targetArch; + std::string m_targetVendor; + std::string m_targetSys; + std::string m_targetAbi; +}; + +#endif // SOURCE_GROUP_SETTINGS_CXX_EMPTY_H diff --git a/src/lib/settings/SourceGroupSettingsJava.cpp b/src/lib/settings/SourceGroupSettingsJava.cpp index 2bcef532..743345a5 100644 --- a/src/lib/settings/SourceGroupSettingsJava.cpp +++ b/src/lib/settings/SourceGroupSettingsJava.cpp @@ -4,10 +4,8 @@ SourceGroupSettingsJava::SourceGroupSettingsJava(const std::string& id, SourceGroupType type, const ProjectSettings* projectSettings) : SourceGroupSettings(id, type, projectSettings) + , m_useJreSystemLibrary(true) , m_classpath(std::vector()) - , m_mavenProjectFilePath(FilePath()) - , m_mavenDependenciesDirectory(FilePath()) - , m_shouldIndexMavenTests(false) { } @@ -15,6 +13,26 @@ SourceGroupSettingsJava::~SourceGroupSettingsJava() { } +void SourceGroupSettingsJava::load(std::shared_ptr config) +{ + SourceGroupSettings::load(config); + + const std::string key = s_keyPrefix + getId(); + + setClasspath(getPathValues(key + "/class_paths/class_path", config)); + setUseJreSystemLibrary(getValue(key + "/use_jre_system_library", true, config)); +} + +void SourceGroupSettingsJava::save(std::shared_ptr config) +{ + SourceGroupSettings::save(config); + + const std::string key = s_keyPrefix + getId(); + + setPathValues(key + "/class_paths/class_path", getClasspath(), config); + setValue(key + "/use_jre_system_library", getUseJreSystemLibrary(), config); +} + bool SourceGroupSettingsJava::equals(std::shared_ptr other) const { std::shared_ptr otherJava = std::dynamic_pointer_cast(other); @@ -22,11 +40,8 @@ bool SourceGroupSettingsJava::equals(std::shared_ptr other) return ( otherJava && SourceGroupSettings::equals(other) && - utility::isPermutation(m_classpath, otherJava->m_classpath) && m_useJreSystemLibrary == otherJava->m_useJreSystemLibrary && - m_mavenProjectFilePath == otherJava->m_mavenProjectFilePath && - m_mavenDependenciesDirectory == otherJava->m_mavenDependenciesDirectory && - m_shouldIndexMavenTests == otherJava->m_shouldIndexMavenTests + utility::isPermutation(m_classpath, otherJava->m_classpath) ); } @@ -59,47 +74,6 @@ void SourceGroupSettingsJava::setClasspath(const std::vector& classpat { m_classpath = classpath; } - -FilePath SourceGroupSettingsJava::getMavenProjectFilePath() const -{ - return m_mavenProjectFilePath; -} - -FilePath SourceGroupSettingsJava::getMavenProjectFilePathExpandedAndAbsolute() const -{ - return m_projectSettings->makePathExpandedAndAbsolute(getMavenProjectFilePath()); -} - -void SourceGroupSettingsJava::setMavenProjectFilePath(const FilePath& path) -{ - m_mavenProjectFilePath = path; -} - -FilePath SourceGroupSettingsJava::getMavenDependenciesDirectory() const -{ - return m_mavenDependenciesDirectory; -} - -FilePath SourceGroupSettingsJava::getMavenDependenciesDirectoryExpandedAndAbsolute() const -{ - return m_projectSettings->makePathExpandedAndAbsolute(getMavenDependenciesDirectory()); -} - -void SourceGroupSettingsJava::setMavenDependenciesDirectory(const FilePath& path) -{ - m_mavenDependenciesDirectory = path; -} - -bool SourceGroupSettingsJava::getShouldIndexMavenTests() const -{ - return m_shouldIndexMavenTests; -} - -void SourceGroupSettingsJava::setShouldIndexMavenTests(bool value) -{ - m_shouldIndexMavenTests = value; -} - std::vector SourceGroupSettingsJava::getDefaultSourceExtensions() const { return std::vector(1, ".java"); diff --git a/src/lib/settings/SourceGroupSettingsJava.h b/src/lib/settings/SourceGroupSettingsJava.h index 996b7401..477a39e6 100644 --- a/src/lib/settings/SourceGroupSettingsJava.h +++ b/src/lib/settings/SourceGroupSettingsJava.h @@ -13,6 +13,9 @@ public: SourceGroupSettingsJava(const std::string& id, SourceGroupType type, const ProjectSettings* projectSettings); virtual ~SourceGroupSettingsJava(); + virtual void load(std::shared_ptr config); + virtual void save(std::shared_ptr config); + virtual bool equals(std::shared_ptr other) const; virtual std::vector getAvailableLanguageStandards() const; @@ -24,26 +27,12 @@ public: std::vector getClasspathExpandedAndAbsolute() const; void setClasspath(const std::vector& classpath); - FilePath getMavenProjectFilePath() const; - FilePath getMavenProjectFilePathExpandedAndAbsolute() const; - void setMavenProjectFilePath(const FilePath& path); - - FilePath getMavenDependenciesDirectory() const; - FilePath getMavenDependenciesDirectoryExpandedAndAbsolute() const; - void setMavenDependenciesDirectory(const FilePath& path); - - bool getShouldIndexMavenTests() const; - void setShouldIndexMavenTests(bool value); - private: virtual std::vector getDefaultSourceExtensions() const; virtual std::string getDefaultStandard() const; bool m_useJreSystemLibrary; std::vector m_classpath; - FilePath m_mavenProjectFilePath; - FilePath m_mavenDependenciesDirectory; - bool m_shouldIndexMavenTests; }; #endif // SOURCE_GROUP_SETTINGS_JAVA_H diff --git a/src/lib/settings/SourceGroupSettingsJavaEmpty.cpp b/src/lib/settings/SourceGroupSettingsJavaEmpty.cpp new file mode 100644 index 00000000..763199eb --- /dev/null +++ b/src/lib/settings/SourceGroupSettingsJavaEmpty.cpp @@ -0,0 +1,10 @@ +#include "settings/SourceGroupSettingsJavaEmpty.h" + +SourceGroupSettingsJavaEmpty::SourceGroupSettingsJavaEmpty(const std::string& id, const ProjectSettings* projectSettings) + : SourceGroupSettingsJava(id, SOURCE_GROUP_JAVA_EMPTY, projectSettings) +{ +} + +SourceGroupSettingsJavaEmpty::~SourceGroupSettingsJavaEmpty() +{ +} diff --git a/src/lib/settings/SourceGroupSettingsJavaEmpty.h b/src/lib/settings/SourceGroupSettingsJavaEmpty.h new file mode 100644 index 00000000..0d6139ab --- /dev/null +++ b/src/lib/settings/SourceGroupSettingsJavaEmpty.h @@ -0,0 +1,14 @@ +#ifndef SOURCE_GROUP_SETTINGS_JAVA_EMPTY_H +#define SOURCE_GROUP_SETTINGS_JAVA_EMPTY_H + +#include "settings/SourceGroupSettingsJava.h" + +class SourceGroupSettingsJavaEmpty + : public SourceGroupSettingsJava +{ +public: + SourceGroupSettingsJavaEmpty(const std::string& id, const ProjectSettings* projectSettings); + virtual ~SourceGroupSettingsJavaEmpty(); +}; + +#endif // SOURCE_GROUP_SETTINGS_JAVA_EMPTY_H diff --git a/src/lib/settings/SourceGroupSettingsJavaGradle.cpp b/src/lib/settings/SourceGroupSettingsJavaGradle.cpp new file mode 100644 index 00000000..c7787cb8 --- /dev/null +++ b/src/lib/settings/SourceGroupSettingsJavaGradle.cpp @@ -0,0 +1,88 @@ +#include "settings/SourceGroupSettingsJavaGradle.h" + +SourceGroupSettingsJavaGradle::SourceGroupSettingsJavaGradle(const std::string& id, const ProjectSettings* projectSettings) + : SourceGroupSettingsJava(id, SOURCE_GROUP_JAVA_GRADLE, projectSettings) + , m_gradleProjectFilePath(FilePath()) + , m_gradleDependenciesDirectory(FilePath()) + , m_shouldIndexGradleTests(false) +{ +} + +SourceGroupSettingsJavaGradle::~SourceGroupSettingsJavaGradle() +{ +} + +void SourceGroupSettingsJavaGradle::load(std::shared_ptr config) +{ + SourceGroupSettingsJava::load(config); + + const std::string key = s_keyPrefix + getId(); + + setGradleProjectFilePath(FilePath(getValue(key + "/gradle/project_file_path", "", config))); + setGradleDependenciesDirectory(FilePath(getValue(key + "/gradle/dependencies_directory", "", config))); + setShouldIndexGradleTests(getValue(key + "/gradle/should_index_tests", false, config)); +} + +void SourceGroupSettingsJavaGradle::save(std::shared_ptr config) +{ + SourceGroupSettingsJava::save(config); + + const std::string key = s_keyPrefix + getId(); + + setValue(key + "/gradle/project_file_path", getGradleProjectFilePath().str(), config); + setValue(key + "/gradle/dependencies_directory", getGradleDependenciesDirectory().str(), config); + setValue(key + "/gradle/should_index_tests", getShouldIndexGradleTests(), config); +} + +bool SourceGroupSettingsJavaGradle::equals(std::shared_ptr other) const +{ + std::shared_ptr otherJavaGradle = std::dynamic_pointer_cast(other); + + return ( + otherJavaGradle && + SourceGroupSettingsJava::equals(other) && + m_gradleProjectFilePath == otherJavaGradle->m_gradleProjectFilePath && + m_gradleDependenciesDirectory == otherJavaGradle->m_gradleDependenciesDirectory && + m_shouldIndexGradleTests == otherJavaGradle->m_shouldIndexGradleTests + ); +} + +FilePath SourceGroupSettingsJavaGradle::getGradleProjectFilePath() const +{ + return m_gradleProjectFilePath; +} + +FilePath SourceGroupSettingsJavaGradle::getGradleProjectFilePathExpandedAndAbsolute() const +{ + return m_projectSettings->makePathExpandedAndAbsolute(getGradleProjectFilePath()); +} + +void SourceGroupSettingsJavaGradle::setGradleProjectFilePath(const FilePath& path) +{ + m_gradleProjectFilePath = path; +} + +FilePath SourceGroupSettingsJavaGradle::getGradleDependenciesDirectory() const +{ + return m_gradleDependenciesDirectory; +} + +FilePath SourceGroupSettingsJavaGradle::getGradleDependenciesDirectoryExpandedAndAbsolute() const +{ + return m_projectSettings->makePathExpandedAndAbsolute(getGradleDependenciesDirectory()); +} + +void SourceGroupSettingsJavaGradle::setGradleDependenciesDirectory(const FilePath& path) +{ + m_gradleDependenciesDirectory = path; +} + +bool SourceGroupSettingsJavaGradle::getShouldIndexGradleTests() const +{ + return m_shouldIndexGradleTests; +} + +void SourceGroupSettingsJavaGradle::setShouldIndexGradleTests(bool value) +{ + m_shouldIndexGradleTests = value; +} diff --git a/src/lib/settings/SourceGroupSettingsJavaGradle.h b/src/lib/settings/SourceGroupSettingsJavaGradle.h new file mode 100644 index 00000000..3bcf26e9 --- /dev/null +++ b/src/lib/settings/SourceGroupSettingsJavaGradle.h @@ -0,0 +1,35 @@ +#ifndef SOURCE_GROUP_SETTINGS_JAVA_GRADLE_H +#define SOURCE_GROUP_SETTINGS_JAVA_GRADLE_H + +#include "settings/SourceGroupSettingsJava.h" + +class SourceGroupSettingsJavaGradle + : public SourceGroupSettingsJava +{ +public: + SourceGroupSettingsJavaGradle(const std::string& id, const ProjectSettings* projectSettings); + virtual ~SourceGroupSettingsJavaGradle(); + + virtual void load(std::shared_ptr config); + virtual void save(std::shared_ptr config); + + virtual bool equals(std::shared_ptr other) const; + + FilePath getGradleProjectFilePath() const; + FilePath getGradleProjectFilePathExpandedAndAbsolute() const; + void setGradleProjectFilePath(const FilePath& path); + + FilePath getGradleDependenciesDirectory() const; + FilePath getGradleDependenciesDirectoryExpandedAndAbsolute() const; + void setGradleDependenciesDirectory(const FilePath& path); + + bool getShouldIndexGradleTests() const; + void setShouldIndexGradleTests(bool value); + +private: + FilePath m_gradleProjectFilePath; + FilePath m_gradleDependenciesDirectory; + bool m_shouldIndexGradleTests; +}; + +#endif // SOURCE_GROUP_SETTINGS_JAVA_GRADLE_H diff --git a/src/lib/settings/SourceGroupSettingsJavaMaven.cpp b/src/lib/settings/SourceGroupSettingsJavaMaven.cpp new file mode 100644 index 00000000..f9d25217 --- /dev/null +++ b/src/lib/settings/SourceGroupSettingsJavaMaven.cpp @@ -0,0 +1,88 @@ +#include "settings/SourceGroupSettingsJavaMaven.h" + +SourceGroupSettingsJavaMaven::SourceGroupSettingsJavaMaven(const std::string& id, const ProjectSettings* projectSettings) + : SourceGroupSettingsJava(id, SOURCE_GROUP_JAVA_MAVEN, projectSettings) + , m_mavenProjectFilePath(FilePath()) + , m_mavenDependenciesDirectory(FilePath()) + , m_shouldIndexMavenTests(false) +{ +} + +SourceGroupSettingsJavaMaven::~SourceGroupSettingsJavaMaven() +{ +} + +void SourceGroupSettingsJavaMaven::load(std::shared_ptr config) +{ + SourceGroupSettingsJava::load(config); + + const std::string key = s_keyPrefix + getId(); + + setMavenProjectFilePath(FilePath(getValue(key + "/maven/project_file_path", "", config))); + setMavenDependenciesDirectory(FilePath(getValue(key + "/maven/dependencies_directory", "", config))); + setShouldIndexMavenTests(getValue(key + "/maven/should_index_tests", false, config)); +} + +void SourceGroupSettingsJavaMaven::save(std::shared_ptr config) +{ + SourceGroupSettingsJava::save(config); + + const std::string key = s_keyPrefix + getId(); + + setValue(key + "/maven/project_file_path", getMavenProjectFilePath().str(), config); + setValue(key + "/maven/dependencies_directory", getMavenDependenciesDirectory().str(), config); + setValue(key + "/maven/should_index_tests", getShouldIndexMavenTests(), config); +} + +bool SourceGroupSettingsJavaMaven::equals(std::shared_ptr other) const +{ + std::shared_ptr otherJavaMaven = std::dynamic_pointer_cast(other); + + return ( + otherJavaMaven && + SourceGroupSettingsJava::equals(other) && + m_mavenProjectFilePath == otherJavaMaven->m_mavenProjectFilePath && + m_mavenDependenciesDirectory == otherJavaMaven->m_mavenDependenciesDirectory && + m_shouldIndexMavenTests == otherJavaMaven->m_shouldIndexMavenTests + ); +} + +FilePath SourceGroupSettingsJavaMaven::getMavenProjectFilePath() const +{ + return m_mavenProjectFilePath; +} + +FilePath SourceGroupSettingsJavaMaven::getMavenProjectFilePathExpandedAndAbsolute() const +{ + return m_projectSettings->makePathExpandedAndAbsolute(getMavenProjectFilePath()); +} + +void SourceGroupSettingsJavaMaven::setMavenProjectFilePath(const FilePath& path) +{ + m_mavenProjectFilePath = path; +} + +FilePath SourceGroupSettingsJavaMaven::getMavenDependenciesDirectory() const +{ + return m_mavenDependenciesDirectory; +} + +FilePath SourceGroupSettingsJavaMaven::getMavenDependenciesDirectoryExpandedAndAbsolute() const +{ + return m_projectSettings->makePathExpandedAndAbsolute(getMavenDependenciesDirectory()); +} + +void SourceGroupSettingsJavaMaven::setMavenDependenciesDirectory(const FilePath& path) +{ + m_mavenDependenciesDirectory = path; +} + +bool SourceGroupSettingsJavaMaven::getShouldIndexMavenTests() const +{ + return m_shouldIndexMavenTests; +} + +void SourceGroupSettingsJavaMaven::setShouldIndexMavenTests(bool value) +{ + m_shouldIndexMavenTests = value; +} diff --git a/src/lib/settings/SourceGroupSettingsJavaMaven.h b/src/lib/settings/SourceGroupSettingsJavaMaven.h new file mode 100644 index 00000000..89ee5356 --- /dev/null +++ b/src/lib/settings/SourceGroupSettingsJavaMaven.h @@ -0,0 +1,35 @@ +#ifndef SOURCE_GROUP_SETTINGS_JAVA_MAVEN_H +#define SOURCE_GROUP_SETTINGS_JAVA_MAVEN_H + +#include "settings/SourceGroupSettingsJava.h" + +class SourceGroupSettingsJavaMaven + : public SourceGroupSettingsJava +{ +public: + SourceGroupSettingsJavaMaven(const std::string& id, const ProjectSettings* projectSettings); + virtual ~SourceGroupSettingsJavaMaven(); + + virtual void load(std::shared_ptr config); + virtual void save(std::shared_ptr config); + + virtual bool equals(std::shared_ptr other) const; + + FilePath getMavenProjectFilePath() const; + FilePath getMavenProjectFilePathExpandedAndAbsolute() const; + void setMavenProjectFilePath(const FilePath& path); + + FilePath getMavenDependenciesDirectory() const; + FilePath getMavenDependenciesDirectoryExpandedAndAbsolute() const; + void setMavenDependenciesDirectory(const FilePath& path); + + bool getShouldIndexMavenTests() const; + void setShouldIndexMavenTests(bool value); + +private: + FilePath m_mavenProjectFilePath; + FilePath m_mavenDependenciesDirectory; + bool m_shouldIndexMavenTests; +}; + +#endif // SOURCE_GROUP_SETTINGS_JAVA_MAVEN_H diff --git a/src/lib/settings/SourceGroupType.cpp b/src/lib/settings/SourceGroupType.cpp index a0f99398..c76a41e4 100644 --- a/src/lib/settings/SourceGroupType.cpp +++ b/src/lib/settings/SourceGroupType.cpp @@ -16,6 +16,8 @@ std::string sourceGroupTypeToString(SourceGroupType v) return "Java Source Group"; case SOURCE_GROUP_JAVA_MAVEN: return "Java Source Group from Maven"; + case SOURCE_GROUP_JAVA_GRADLE: + return "Java Source Group from Gradle"; case SOURCE_GROUP_UNKNOWN: break; } @@ -38,6 +40,8 @@ std::string sourceGroupTypeToProjectSetupString(SourceGroupType v) return "Empty Java Source Group"; case SOURCE_GROUP_JAVA_MAVEN: return "Java Source Group from Maven"; + case SOURCE_GROUP_JAVA_GRADLE: + return "Java Source Group from Gradle"; case SOURCE_GROUP_UNKNOWN: break; } @@ -70,6 +74,10 @@ SourceGroupType stringToSourceGroupType(std::string v) { return SOURCE_GROUP_JAVA_MAVEN; } + else if (v == sourceGroupTypeToString(SOURCE_GROUP_JAVA_GRADLE)) + { + return SOURCE_GROUP_JAVA_GRADLE; + } return SOURCE_GROUP_UNKNOWN; } diff --git a/src/lib/settings/SourceGroupType.h b/src/lib/settings/SourceGroupType.h index 9d83e101..a070e973 100644 --- a/src/lib/settings/SourceGroupType.h +++ b/src/lib/settings/SourceGroupType.h @@ -11,6 +11,7 @@ enum SourceGroupType SOURCE_GROUP_CXX_VS, SOURCE_GROUP_JAVA_EMPTY, SOURCE_GROUP_JAVA_MAVEN, + SOURCE_GROUP_JAVA_GRADLE, SOURCE_GROUP_UNKNOWN }; diff --git a/src/lib_cxx/CMakeLists.txt b/src/lib_cxx/CMakeLists.txt index efb47c57..384e4c24 100644 --- a/src/lib_cxx/CMakeLists.txt +++ b/src/lib_cxx/CMakeLists.txt @@ -84,10 +84,12 @@ add_files( project/IncludeValidation.h project/SourceGroupCxx.cpp project/SourceGroupCxx.h - project/SourceGroupFactoryModuleCpp.cpp - project/SourceGroupFactoryModuleCpp.h - project/SourceGroupFactoryModuleC.cpp - project/SourceGroupFactoryModuleC.h + project/SourceGroupCxxCdb.cpp + project/SourceGroupCxxCdb.h + project/SourceGroupCxxEmpty.cpp + project/SourceGroupCxxEmpty.h + project/SourceGroupFactoryModuleCxx.cpp + project/SourceGroupFactoryModuleCxx.h utility/CompilationDatabase.cpp utility/CompilationDatabase.h diff --git a/src/lib_cxx/project/SourceGroupCxx.cpp b/src/lib_cxx/project/SourceGroupCxx.cpp index cb15d471..ef57ccc5 100644 --- a/src/lib_cxx/project/SourceGroupCxx.cpp +++ b/src/lib_cxx/project/SourceGroupCxx.cpp @@ -14,8 +14,7 @@ #include "Application.h" -SourceGroupCxx::SourceGroupCxx(std::shared_ptr settings) - : m_settings(settings) +SourceGroupCxx::SourceGroupCxx() { } @@ -23,185 +22,7 @@ SourceGroupCxx::~SourceGroupCxx() { } -SourceGroupType SourceGroupCxx::getType() const +std::shared_ptr SourceGroupCxx::getSourceGroupSettings() { - return m_settings->getType(); -} - -bool SourceGroupCxx::prepareRefresh() -{ - FilePath cdbPath = m_settings->getCompilationDatabasePathExpandedAndAbsolute(); - if (!cdbPath.empty() && !cdbPath.exists()) - { - MessageStatus("Can't refresh project").dispatch(); - - if (std::shared_ptr application = Application::getInstance()) - { - if (application->hasGUI()) - { - std::vector options; - options.push_back("Ok"); - application->handleDialog( - "Can't refresh. The compilation database of the project does not exist anymore: " + cdbPath.str(), - options - ); - } - } - return false; - } - return true; -} - -void SourceGroupCxx::fetchAllSourceFilePaths() -{ - std::vector sourcePaths; - - FilePath cdbPath = m_settings->getCompilationDatabasePathExpandedAndAbsolute(); - if (cdbPath.exists()) - { - sourcePaths = IndexerCommandCxxCdb::getSourceFilesFromCDB(cdbPath); - } - else - { - sourcePaths = m_settings->getSourcePathsExpandedAndAbsolute(); - } - - m_sourceFilePathsToIndex.clear(); - FileManager fileManager; - fileManager.update(sourcePaths, m_settings->getExcludePathsExpandedAndAbsolute(), m_settings->getSourceExtensions()); - m_allSourceFilePaths = fileManager.getAllSourceFilePaths(); -} - -std::vector> SourceGroupCxx::getIndexerCommands( - std::set* filesToIndex, bool fullRefresh) -{ - std::shared_ptr appSettings = ApplicationSettings::getInstance(); - - std::vector systemHeaderSearchPaths; - utility::append(systemHeaderSearchPaths, m_settings->getHeaderSearchPathsExpandedAndAbsolute()); - utility::append(systemHeaderSearchPaths, appSettings->getHeaderSearchPathsExpanded()); - - // Add the source paths as HeaderSearchPaths as well, so clang will also look here when searching include files. - for (const FilePath& sourcePath: m_settings->getSourcePathsExpandedAndAbsolute()) - { - if (sourcePath.isDirectory()) - { - systemHeaderSearchPaths.push_back(sourcePath); - } - } - - // Add all subdirectories of the header search paths - if (m_settings->getUseSourcePathsForHeaderSearch()) - { - std::vector headerSearchSubPaths; - for (const FilePath& sourcePath : m_settings->getSourcePathsExpandedAndAbsolute()) - { - utility::append(headerSearchSubPaths, FileSystem::getSubDirectories(sourcePath)); - } - - utility::append(systemHeaderSearchPaths, utility::unique(headerSearchSubPaths)); - } - - std::vector frameworkSearchPaths; - utility::append(frameworkSearchPaths, m_settings->getFrameworkSearchPathsExpandedAndAbsolute()); - utility::append(frameworkSearchPaths, appSettings->getFrameworkSearchPathsExpanded()); - - std::vector compilerFlags; - { - const std::string targetFlag = m_settings->getTargetFlag(); - if (!targetFlag.empty()) - { - compilerFlags.push_back(targetFlag); - } - } - - utility::append(compilerFlags, m_settings->getCompilerFlags()); - - std::set indexedPaths; - for (const FilePath& p : m_settings->getSourcePathsExpandedAndAbsolute()) - { - if (p.exists()) - { - indexedPaths.insert(p); - } - } - - std::set excludedPaths; - for (const FilePath& p: m_settings->getExcludePathsExpandedAndAbsolute()) - { - if (p.exists()) - { - excludedPaths.insert(p); - } - } - - const std::set& sourceFilePathsToIndex = (fullRefresh ? getAllSourceFilePaths() : getSourceFilePathsToIndex()); - - std::vector> indexerCommands; - - FilePath cdbPath = m_settings->getCompilationDatabasePathExpandedAndAbsolute(); - if (cdbPath.exists()) - { - std::string error; - std::shared_ptr cdb = std::shared_ptr - (clang::tooling::JSONCompilationDatabase::loadFromFile(cdbPath.str(), error, clang::tooling::JSONCommandLineSyntax::AutoDetect)); - if (!error.empty()) - { - const std::string message = "Loading Clang compilation database failed with error: \"" + error + "\""; - LOG_ERROR(message); - MessageStatus(message, true).dispatch(); - } - - for (const clang::tooling::CompileCommand& command: cdb->getAllCompileCommands()) - { - FilePath sourcePath = FilePath(command.Filename).canonical(); - if (!sourcePath.isAbsolute()) - { - sourcePath = FilePath(command.Directory + '/' + command.Filename).canonical(); - } - - if (filesToIndex->find(sourcePath) != filesToIndex->end() && - sourceFilePathsToIndex.find(sourcePath) != sourceFilePathsToIndex.end()) - { - std::vector currentCompilerFlags = compilerFlags; - currentCompilerFlags.insert(currentCompilerFlags.end(), command.CommandLine.begin(), command.CommandLine.end()); - - indexerCommands.push_back(std::make_shared( - sourcePath, - indexedPaths, - excludedPaths, - FilePath(command.Directory), - currentCompilerFlags, - systemHeaderSearchPaths, - frameworkSearchPaths, - m_settings->getShouldApplyAnonymousTypedefTransformation() - )); - - filesToIndex->erase(sourcePath); - } - } - } - else - { - for (const FilePath& sourcePath: sourceFilePathsToIndex) - { - if (filesToIndex->find(sourcePath) != filesToIndex->end()) - { - indexerCommands.push_back(std::make_shared( - sourcePath, - indexedPaths, - excludedPaths, - m_settings->getStandard(), - systemHeaderSearchPaths, - frameworkSearchPaths, - compilerFlags, - m_settings->getShouldApplyAnonymousTypedefTransformation() - )); - - filesToIndex->erase(sourcePath); - } - } - } - - return indexerCommands; + return getSourceGroupSettingsCxx(); } diff --git a/src/lib_cxx/project/SourceGroupCxx.h b/src/lib_cxx/project/SourceGroupCxx.h index ff40b879..75f5bd16 100644 --- a/src/lib_cxx/project/SourceGroupCxx.h +++ b/src/lib_cxx/project/SourceGroupCxx.h @@ -10,20 +10,12 @@ class SourceGroupCxx: public SourceGroup { public: - SourceGroupCxx(std::shared_ptr settings); + SourceGroupCxx(); virtual ~SourceGroupCxx(); - virtual SourceGroupType getType() const; - - virtual bool prepareRefresh(); - - virtual void fetchAllSourceFilePaths(); - - virtual std::vector> getIndexerCommands( - std::set* filesToIndex, bool fullRefresh); - private: - std::shared_ptr m_settings; + virtual std::shared_ptr getSourceGroupSettingsCxx() = 0; + virtual std::shared_ptr getSourceGroupSettings(); }; #endif // SOURCE_GROUP_CXX_H diff --git a/src/lib_cxx/project/SourceGroupCxxCdb.cpp b/src/lib_cxx/project/SourceGroupCxxCdb.cpp new file mode 100644 index 00000000..854ee57b --- /dev/null +++ b/src/lib_cxx/project/SourceGroupCxxCdb.cpp @@ -0,0 +1,159 @@ +#include "project/SourceGroupCxxCdb.h" + +#include "clang/Tooling/Tooling.h" +#include "clang/Tooling/CompilationDatabase.h" +#include "clang/Tooling/JSONCompilationDatabase.h" +#include "data/indexer/IndexerCommandCxxCdb.h" +#include "settings/ApplicationSettings.h" +#include "utility/messaging/type/MessageStatus.h" +#include "utility/utility.h" +#include "Application.h" + +SourceGroupCxxCdb::SourceGroupCxxCdb(std::shared_ptr settings) + : m_settings(settings) +{ +} + +SourceGroupCxxCdb::~SourceGroupCxxCdb() +{ +} + +SourceGroupType SourceGroupCxxCdb::getType() const +{ + return SOURCE_GROUP_CXX_CDB; +} + +bool SourceGroupCxxCdb::prepareRefresh() +{ + FilePath cdbPath = m_settings->getCompilationDatabasePathExpandedAndAbsolute(); + if (!cdbPath.empty() && !cdbPath.exists()) + { + MessageStatus("Can't refresh project").dispatch(); + + if (std::shared_ptr application = Application::getInstance()) + { + if (application->hasGUI()) + { + std::vector options; + options.push_back("Ok"); + application->handleDialog( + "Can't refresh. The compilation database of the project does not exist anymore: " + cdbPath.str(), + options + ); + } + } + return false; + } + return true; +} + +std::vector> SourceGroupCxxCdb::getIndexerCommands( + std::set* filesToIndex, bool fullRefresh) +{ + std::shared_ptr appSettings = ApplicationSettings::getInstance(); + + std::vector systemHeaderSearchPaths; + utility::append(systemHeaderSearchPaths, m_settings->getHeaderSearchPathsExpandedAndAbsolute()); + utility::append(systemHeaderSearchPaths, appSettings->getHeaderSearchPathsExpanded()); + + // Add the source paths as HeaderSearchPaths as well, so clang will also look here when searching include files. + for (const FilePath& sourcePath: m_settings->getSourcePathsExpandedAndAbsolute()) + { + if (sourcePath.isDirectory()) + { + systemHeaderSearchPaths.push_back(sourcePath); + } + } + + std::vector frameworkSearchPaths; + utility::append(frameworkSearchPaths, m_settings->getFrameworkSearchPathsExpandedAndAbsolute()); + utility::append(frameworkSearchPaths, appSettings->getFrameworkSearchPathsExpanded()); + + std::vector compilerFlags; + utility::append(compilerFlags, m_settings->getCompilerFlags()); + + std::set indexedPaths; + for (const FilePath& p : m_settings->getSourcePathsExpandedAndAbsolute()) + { + if (p.exists()) + { + indexedPaths.insert(p); + } + } + + std::set excludedPaths; + for (const FilePath& p: m_settings->getExcludePathsExpandedAndAbsolute()) + { + if (p.exists()) + { + excludedPaths.insert(p); + } + } + + const std::set& sourceFilePathsToIndex = (fullRefresh ? getAllSourceFilePaths() : getSourceFilePathsToIndex()); + + std::vector> indexerCommands; + + FilePath cdbPath = m_settings->getCompilationDatabasePathExpandedAndAbsolute(); + if (cdbPath.exists()) + { + std::string error; + std::shared_ptr cdb = std::shared_ptr + (clang::tooling::JSONCompilationDatabase::loadFromFile(cdbPath.str(), error, clang::tooling::JSONCommandLineSyntax::AutoDetect)); + if (!error.empty()) + { + const std::string message = "Loading Clang compilation database failed with error: \"" + error + "\""; + LOG_ERROR(message); + MessageStatus(message, true).dispatch(); + } + + for (const clang::tooling::CompileCommand& command: cdb->getAllCompileCommands()) + { + FilePath sourcePath = FilePath(command.Filename).canonical(); + if (!sourcePath.isAbsolute()) + { + sourcePath = FilePath(command.Directory + '/' + command.Filename).canonical(); + } + + if (filesToIndex->find(sourcePath) != filesToIndex->end() && + sourceFilePathsToIndex.find(sourcePath) != sourceFilePathsToIndex.end()) + { + std::vector currentCompilerFlags = compilerFlags; + currentCompilerFlags.insert(currentCompilerFlags.end(), command.CommandLine.begin(), command.CommandLine.end()); + + indexerCommands.push_back(std::make_shared( + sourcePath, + indexedPaths, + excludedPaths, + FilePath(command.Directory), + currentCompilerFlags, + systemHeaderSearchPaths, + frameworkSearchPaths, + m_settings->getShouldApplyAnonymousTypedefTransformation() + )); + + filesToIndex->erase(sourcePath); + } + } + } + + return indexerCommands; +} + +std::shared_ptr SourceGroupCxxCdb::getSourceGroupSettingsCxx() +{ + return m_settings; +} + +std::vector SourceGroupCxxCdb::getAllSourcePaths() const +{ + std::vector sourcePaths; + + FilePath cdbPath = m_settings->getCompilationDatabasePathExpandedAndAbsolute(); + if (cdbPath.exists()) + { + sourcePaths = IndexerCommandCxxCdb::getSourceFilesFromCDB(cdbPath); + } + + return sourcePaths; +} diff --git a/src/lib_cxx/project/SourceGroupCxxCdb.h b/src/lib_cxx/project/SourceGroupCxxCdb.h new file mode 100644 index 00000000..0b6250a6 --- /dev/null +++ b/src/lib_cxx/project/SourceGroupCxxCdb.h @@ -0,0 +1,30 @@ +#ifndef SOURCE_GROUP_CXX_CDB_H +#define SOURCE_GROUP_CXX_CDB_H + +#include +#include + +#include "project/SourceGroupCxx.h" +#include "settings/SourceGroupSettingsCxxCdb.h" + +class SourceGroupCxxCdb: public SourceGroupCxx +{ +public: + SourceGroupCxxCdb(std::shared_ptr settings); + virtual ~SourceGroupCxxCdb(); + + virtual SourceGroupType getType() const; + + virtual bool prepareRefresh(); + + virtual std::vector> getIndexerCommands( + std::set* filesToIndex, bool fullRefresh); + +private: + virtual std::shared_ptr getSourceGroupSettingsCxx(); + virtual std::vector getAllSourcePaths() const; + + std::shared_ptr m_settings; +}; + +#endif // SOURCE_GROUP_CXX_CDB_H diff --git a/src/lib_cxx/project/SourceGroupCxxEmpty.cpp b/src/lib_cxx/project/SourceGroupCxxEmpty.cpp new file mode 100644 index 00000000..0eb5f7fe --- /dev/null +++ b/src/lib_cxx/project/SourceGroupCxxEmpty.cpp @@ -0,0 +1,106 @@ +#include "project/SourceGroupCxxEmpty.h" + +#include "data/indexer/IndexerCommandCxxManual.h" +#include "settings/ApplicationSettings.h" +#include "utility/utility.h" +#include "Application.h" + +SourceGroupCxxEmpty::SourceGroupCxxEmpty(std::shared_ptr settings) + : m_settings(settings) +{ +} + +SourceGroupCxxEmpty::~SourceGroupCxxEmpty() +{ +} + +SourceGroupType SourceGroupCxxEmpty::getType() const +{ + return m_settings->getType(); // may be either C or Cpp +} + +std::vector> SourceGroupCxxEmpty::getIndexerCommands( + std::set* filesToIndex, bool fullRefresh) +{ + std::shared_ptr appSettings = ApplicationSettings::getInstance(); + + std::vector systemHeaderSearchPaths; + utility::append(systemHeaderSearchPaths, m_settings->getHeaderSearchPathsExpandedAndAbsolute()); + utility::append(systemHeaderSearchPaths, appSettings->getHeaderSearchPathsExpanded()); + + // Add the source paths as HeaderSearchPaths as well, so clang will also look here when searching include files. + for (const FilePath& sourcePath: m_settings->getSourcePathsExpandedAndAbsolute()) + { + if (sourcePath.isDirectory()) + { + systemHeaderSearchPaths.push_back(sourcePath); + } + } + + std::vector frameworkSearchPaths; + utility::append(frameworkSearchPaths, m_settings->getFrameworkSearchPathsExpandedAndAbsolute()); + utility::append(frameworkSearchPaths, appSettings->getFrameworkSearchPathsExpanded()); + + std::vector compilerFlags; + { + const std::string targetFlag = m_settings->getTargetFlag(); + if (!targetFlag.empty()) + { + compilerFlags.push_back(targetFlag); + } + } + + utility::append(compilerFlags, m_settings->getCompilerFlags()); + + std::set indexedPaths; + for (const FilePath& p : m_settings->getSourcePathsExpandedAndAbsolute()) + { + if (p.exists()) + { + indexedPaths.insert(p); + } + } + + std::set excludedPaths; + for (const FilePath& p: m_settings->getExcludePathsExpandedAndAbsolute()) + { + if (p.exists()) + { + excludedPaths.insert(p); + } + } + + const std::set& sourceFilePathsToIndex = (fullRefresh ? getAllSourceFilePaths() : getSourceFilePathsToIndex()); + + std::vector> indexerCommands; + for (const FilePath& sourcePath: sourceFilePathsToIndex) + { + if (filesToIndex->find(sourcePath) != filesToIndex->end()) + { + indexerCommands.push_back(std::make_shared( + sourcePath, + indexedPaths, + excludedPaths, + m_settings->getStandard(), + systemHeaderSearchPaths, + frameworkSearchPaths, + compilerFlags, + m_settings->getShouldApplyAnonymousTypedefTransformation() + )); + + filesToIndex->erase(sourcePath); + } + } + + return indexerCommands; +} + +std::shared_ptr SourceGroupCxxEmpty::getSourceGroupSettingsCxx() +{ + return m_settings; +} + +std::vector SourceGroupCxxEmpty::getAllSourcePaths() const +{ + return m_settings->getSourcePathsExpandedAndAbsolute(); +} \ No newline at end of file diff --git a/src/lib_cxx/project/SourceGroupCxxEmpty.h b/src/lib_cxx/project/SourceGroupCxxEmpty.h new file mode 100644 index 00000000..e844103d --- /dev/null +++ b/src/lib_cxx/project/SourceGroupCxxEmpty.h @@ -0,0 +1,28 @@ +#ifndef SOURCE_GROUP_CXX_EMPTY_H +#define SOURCE_GROUP_CXX_EMPTY_H + +#include +#include + +#include "project/SourceGroupCxx.h" +#include "settings/SourceGroupSettingsCxxEmpty.h" + +class SourceGroupCxxEmpty: public SourceGroupCxx +{ +public: + SourceGroupCxxEmpty(std::shared_ptr settings); + virtual ~SourceGroupCxxEmpty(); + + virtual SourceGroupType getType() const; + + virtual std::vector> getIndexerCommands( + std::set* filesToIndex, bool fullRefresh); + +private: + virtual std::shared_ptr getSourceGroupSettingsCxx(); + virtual std::vector getAllSourcePaths() const; + + std::shared_ptr m_settings; +}; + +#endif // SOURCE_GROUP_CXX_EMPTY_H diff --git a/src/lib_cxx/project/SourceGroupFactoryModuleC.cpp b/src/lib_cxx/project/SourceGroupFactoryModuleC.cpp deleted file mode 100644 index 1fde5cdf..00000000 --- a/src/lib_cxx/project/SourceGroupFactoryModuleC.cpp +++ /dev/null @@ -1,30 +0,0 @@ -#include "project/SourceGroupFactoryModuleC.h" - -#include "project/SourceGroupCxx.h" -#include "settings/SourceGroupSettingsCxx.h" - -SourceGroupFactoryModuleC::~SourceGroupFactoryModuleC() -{ -} - -bool SourceGroupFactoryModuleC::supports(SourceGroupType type) const -{ - switch (type) - { - case SOURCE_GROUP_C_EMPTY: - return true; - default: - break; - } - return false; -} - -std::shared_ptr SourceGroupFactoryModuleC::createSourceGroup(std::shared_ptr settings) -{ - std::shared_ptr sourceGroup; - if (std::shared_ptr cxxSettings = std::dynamic_pointer_cast(settings)) - { - sourceGroup = std::shared_ptr(new SourceGroupCxx(cxxSettings)); - } - return sourceGroup; -} diff --git a/src/lib_cxx/project/SourceGroupFactoryModuleC.h b/src/lib_cxx/project/SourceGroupFactoryModuleC.h deleted file mode 100644 index 130c8225..00000000 --- a/src/lib_cxx/project/SourceGroupFactoryModuleC.h +++ /dev/null @@ -1,14 +0,0 @@ -#ifndef SOURCE_GROUP_FACTORY_MODULE_C_H -#define SOURCE_GROUP_FACTORY_MODULE_C_H - -#include "project/SourceGroupFactoryModule.h" - -class SourceGroupFactoryModuleC: public SourceGroupFactoryModule -{ -public: - virtual ~SourceGroupFactoryModuleC(); - virtual bool supports(SourceGroupType type) const; - virtual std::shared_ptr createSourceGroup(std::shared_ptr settings); -}; - -#endif // SOURCE_GROUP_FACTORY_MODULE_C_H diff --git a/src/lib_cxx/project/SourceGroupFactoryModuleCpp.cpp b/src/lib_cxx/project/SourceGroupFactoryModuleCpp.cpp deleted file mode 100644 index bf88f7ae..00000000 --- a/src/lib_cxx/project/SourceGroupFactoryModuleCpp.cpp +++ /dev/null @@ -1,31 +0,0 @@ -#include "project/SourceGroupFactoryModuleCpp.h" - -#include "project/SourceGroupCxx.h" -#include "settings/SourceGroupSettingsCxx.h" - -SourceGroupFactoryModuleCpp::~SourceGroupFactoryModuleCpp() -{ -} - -bool SourceGroupFactoryModuleCpp::supports(SourceGroupType type) const -{ - switch (type) - { - case SOURCE_GROUP_CPP_EMPTY: - case SOURCE_GROUP_CXX_CDB: - return true; - default: - break; - } - return false; -} - -std::shared_ptr SourceGroupFactoryModuleCpp::createSourceGroup(std::shared_ptr settings) -{ - std::shared_ptr sourceGroup; - if (std::shared_ptr cxxSettings = std::dynamic_pointer_cast(settings)) - { - sourceGroup = std::shared_ptr(new SourceGroupCxx(cxxSettings)); - } - return sourceGroup; -} diff --git a/src/lib_cxx/project/SourceGroupFactoryModuleCpp.h b/src/lib_cxx/project/SourceGroupFactoryModuleCpp.h deleted file mode 100644 index 89d49e07..00000000 --- a/src/lib_cxx/project/SourceGroupFactoryModuleCpp.h +++ /dev/null @@ -1,14 +0,0 @@ -#ifndef SOURCE_GROUP_FACTORY_MODULE_CPP_H -#define SOURCE_GROUP_FACTORY_MODULE_CPP_H - -#include "project/SourceGroupFactoryModule.h" - -class SourceGroupFactoryModuleCpp: public SourceGroupFactoryModule -{ -public: - virtual ~SourceGroupFactoryModuleCpp(); - virtual bool supports(SourceGroupType type) const; - virtual std::shared_ptr createSourceGroup(std::shared_ptr settings); -}; - -#endif // SOURCE_GROUP_FACTORY_MODULE_CPP_H diff --git a/src/lib_cxx/project/SourceGroupFactoryModuleCxx.cpp b/src/lib_cxx/project/SourceGroupFactoryModuleCxx.cpp new file mode 100644 index 00000000..a39e0605 --- /dev/null +++ b/src/lib_cxx/project/SourceGroupFactoryModuleCxx.cpp @@ -0,0 +1,38 @@ +#include "project/SourceGroupFactoryModuleCxx.h" + +#include "project/SourceGroupCxxCdb.h" +#include "project/SourceGroupCxxEmpty.h" +#include "settings/SourceGroupSettingsCxxCdb.h" +#include "settings/SourceGroupSettingsCxxEmpty.h" + +SourceGroupFactoryModuleCxx::~SourceGroupFactoryModuleCxx() +{ +} + +bool SourceGroupFactoryModuleCxx::supports(SourceGroupType type) const +{ + switch (type) + { + case SOURCE_GROUP_C_EMPTY: + case SOURCE_GROUP_CPP_EMPTY: + case SOURCE_GROUP_CXX_CDB: + return true; + default: + break; + } + return false; +} + +std::shared_ptr SourceGroupFactoryModuleCxx::createSourceGroup(std::shared_ptr settings) +{ + std::shared_ptr sourceGroup; + if (std::shared_ptr cxxSettings = std::dynamic_pointer_cast(settings)) + { + sourceGroup = std::shared_ptr(new SourceGroupCxxCdb(cxxSettings)); + } + else if (std::shared_ptr cxxSettings = std::dynamic_pointer_cast(settings)) + { + sourceGroup = std::shared_ptr(new SourceGroupCxxEmpty(cxxSettings)); + } + return sourceGroup; +} diff --git a/src/lib_cxx/project/SourceGroupFactoryModuleCxx.h b/src/lib_cxx/project/SourceGroupFactoryModuleCxx.h new file mode 100644 index 00000000..87f8bff6 --- /dev/null +++ b/src/lib_cxx/project/SourceGroupFactoryModuleCxx.h @@ -0,0 +1,14 @@ +#ifndef SOURCE_GROUP_FACTORY_MODULE_CXX_H +#define SOURCE_GROUP_FACTORY_MODULE_CXX_H + +#include "project/SourceGroupFactoryModule.h" + +class SourceGroupFactoryModuleCxx: public SourceGroupFactoryModule +{ +public: + virtual ~SourceGroupFactoryModuleCxx(); + virtual bool supports(SourceGroupType type) const; + virtual std::shared_ptr createSourceGroup(std::shared_ptr settings); +}; + +#endif // SOURCE_GROUP_FACTORY_MODULE_CXX_H diff --git a/src/lib_gui/CMakeLists.txt b/src/lib_gui/CMakeLists.txt index 1eaddcb4..adf7fd90 100644 --- a/src/lib_gui/CMakeLists.txt +++ b/src/lib_gui/CMakeLists.txt @@ -188,8 +188,6 @@ add_files( qt/window/project_wizzard/QtProjectWizzardContentProjectData.h qt/window/project_wizzard/QtProjectWizzardContentSelect.cpp qt/window/project_wizzard/QtProjectWizzardContentSelect.h - qt/window/project_wizzard/QtProjectWizzardContentSimple.cpp - qt/window/project_wizzard/QtProjectWizzardContentSimple.h qt/window/project_wizzard/QtProjectWizzardContentSourceGroupData.cpp qt/window/project_wizzard/QtProjectWizzardContentSourceGroupData.h qt/window/project_wizzard/QtProjectWizzardContentSummary.cpp diff --git a/src/lib_gui/qt/window/project_wizzard/QtProjectWizzard.cpp b/src/lib_gui/qt/window/project_wizzard/QtProjectWizzard.cpp index 8470e054..90324e42 100644 --- a/src/lib_gui/qt/window/project_wizzard/QtProjectWizzard.cpp +++ b/src/lib_gui/qt/window/project_wizzard/QtProjectWizzard.cpp @@ -16,12 +16,14 @@ #include "qt/window/project_wizzard/QtProjectWizzardContentPaths.h" #include "qt/window/project_wizzard/QtProjectWizzardContentProjectData.h" #include "qt/window/project_wizzard/QtProjectWizzardContentSelect.h" -#include "qt/window/project_wizzard/QtProjectWizzardContentSimple.h" #include "qt/window/project_wizzard/QtProjectWizzardContentSourceGroupData.h" #include "qt/window/project_wizzard/QtProjectWizzardContentSummary.h" #include "qt/window/project_wizzard/QtProjectWizzardContentVS.h" -#include "settings/SourceGroupSettingsCxx.h" -#include "settings/SourceGroupSettingsJava.h" +#include "settings/SourceGroupSettingsCxxEmpty.h" +#include "settings/SourceGroupSettingsCxxCdb.h" +#include "settings/SourceGroupSettingsJavaEmpty.h" +#include "settings/SourceGroupSettingsJavaGradle.h" +#include "settings/SourceGroupSettingsJavaMaven.h" #include "utility/messaging/type/MessageLoadProject.h" #include "utility/messaging/type/MessageStatus.h" #include "utility/ResourcePaths.h" @@ -85,8 +87,8 @@ void QtProjectWizzard::newProjectFromCDB(const FilePath& filePath, const std::ve cancelSourceGroup(); - std::shared_ptr sourceGroupSettings = - std::make_shared(utility::getUuidString(), SOURCE_GROUP_CXX_CDB, m_projectSettings.get()); + std::shared_ptr sourceGroupSettings = + std::make_shared(utility::getUuidString(), m_projectSettings.get()); sourceGroupSettings->setCompilationDatabasePath(filePath); sourceGroupSettings->setSourcePaths(headerPaths); m_newSourceGroupSettings = sourceGroupSettings; @@ -388,51 +390,39 @@ void QtProjectWizzard::selectedSourceGroupChanged(int index) summary->addContent(content); summary->addSpace(); - if (group->getType() == SOURCE_GROUP_JAVA_EMPTY || group->getType() == SOURCE_GROUP_JAVA_MAVEN) + if (std::shared_ptr settingsJava = std::dynamic_pointer_cast(group)) { - bool isMaven = false; - std::shared_ptr javaSettings = - std::dynamic_pointer_cast(group); - if (javaSettings) - { - isMaven = javaSettings->getMavenProjectFilePathExpandedAndAbsolute().exists(); - } - summary->addContent(new QtProjectWizzardContentLanguageAndStandard(group, this)); summary->addSpace(); - if (isMaven) - { - summary->addContent(new QtProjectWizzardContentPathSourceMaven(group, this)); - summary->addSpace(); - summary->addContent(new QtProjectWizzardContentPathDependenciesMaven(group, this)); - } - else + if (std::shared_ptr settingsJavaEmpty = std::dynamic_pointer_cast(group)) { summary->addContent(new QtProjectWizzardContentPathsSource(group, this)); summary->addSpace(); summary->addContent(new QtProjectWizzardContentPathsClassJava(group, this)); } + else if (std::shared_ptr settingsJavaGradle = std::dynamic_pointer_cast(group)) + { + summary->addContent(new QtProjectWizzardContentPathSourceGradle(group, this)); + summary->addSpace(); + summary->addContent(new QtProjectWizzardContentPathDependenciesGradle(group, this)); + } + else if (std::shared_ptr settingsJavaMaven = std::dynamic_pointer_cast(group)) + { + summary->addContent(new QtProjectWizzardContentPathSourceMaven(group, this)); + summary->addSpace(); + summary->addContent(new QtProjectWizzardContentPathDependenciesMaven(group, this)); + } summary->addSpace(); summary->addContent(new QtProjectWizzardContentExtensions(group, this)); summary->addSpace(); summary->addContent(new QtProjectWizzardContentPathsExclude(group, this)); } - else + else if (std::shared_ptr settingsCxx = std::dynamic_pointer_cast(group)) { - const bool isCDB = group->getType() == SOURCE_GROUP_CXX_CDB; - - if (isCDB) - { - summary->addContent(new QtProjectWizzardContentPathCDB(group, this)); - summary->addContent(new QtProjectWizzardContentCDBSource(group, this)); - summary->addSpace(); - - summary->addContent(new QtProjectWizzardContentPathsCDBHeader(group, this)); - summary->addSpace(); - } - else + bool isCDB = false; + if (std::shared_ptr settingsCxxEmpty = std::dynamic_pointer_cast(group)) { summary->addContent(new QtProjectWizzardContentLanguageAndStandard(group, this)); summary->addSpace(); @@ -443,16 +433,20 @@ void QtProjectWizzard::selectedSourceGroupChanged(int index) summary->addContent(new QtProjectWizzardContentExtensions(group, this)); summary->addSpace(); } + else if (std::shared_ptr settingsCxxCdb = std::dynamic_pointer_cast(group)) + { + isCDB = true; + + summary->addContent(new QtProjectWizzardContentPathCDB(group, this)); + summary->addContent(new QtProjectWizzardContentCDBSource(group, this)); + summary->addSpace(); + + summary->addContent(new QtProjectWizzardContentPathsCDBHeader(group, this)); + summary->addSpace(); + } summary->addContent(new QtProjectWizzardContentPathsHeaderSearch(group, this, isCDB)); - std::shared_ptr cxxSettings = std::dynamic_pointer_cast(group); - if (!isCDB && cxxSettings && cxxSettings->getHasDefinedUseSourcePathsForHeaderSearch()) - { - summary->addSpace(); - summary->addContent(new QtProjectWizzardContentSimple(group, this)); - } - summary->addContent(new QtProjectWizzardContentPathsHeaderSearchGlobal(this)); summary->addSpace(); @@ -526,15 +520,26 @@ void QtProjectWizzard::duplicateSelectedSourceGroup() } std::shared_ptr oldSourceGroup = m_allSourceGroupSettings[m_sourceGroupList->currentRow()]; - std::shared_ptr newSourceGroup; - if (oldSourceGroup->getType() == SOURCE_GROUP_JAVA_EMPTY || oldSourceGroup->getType() == SOURCE_GROUP_JAVA_MAVEN) + std::shared_ptr newSourceGroup; + switch (oldSourceGroup->getType()) { - newSourceGroup = std::make_shared(*dynamic_cast(oldSourceGroup.get())); - } - else - { - newSourceGroup = std::make_shared(*dynamic_cast(oldSourceGroup.get())); + case SOURCE_GROUP_JAVA_EMPTY: + newSourceGroup = std::make_shared(*dynamic_cast(oldSourceGroup.get())); + break; + case SOURCE_GROUP_JAVA_MAVEN: + newSourceGroup = std::make_shared(*dynamic_cast(oldSourceGroup.get())); + break; + case SOURCE_GROUP_JAVA_GRADLE: + newSourceGroup = std::make_shared(*dynamic_cast(oldSourceGroup.get())); + break; + case SOURCE_GROUP_C_EMPTY: + case SOURCE_GROUP_CPP_EMPTY: + newSourceGroup = std::make_shared(*dynamic_cast(oldSourceGroup.get())); + break; + case SOURCE_GROUP_CXX_CDB: + newSourceGroup = std::make_shared(*dynamic_cast(oldSourceGroup.get())); + break; } newSourceGroup->setId(utility::getUuidString()); @@ -613,7 +618,7 @@ void QtProjectWizzard::selectedProjectType(SourceGroupType sourceGroupType) { case SOURCE_GROUP_C_EMPTY: case SOURCE_GROUP_CPP_EMPTY: - m_newSourceGroupSettings = std::make_shared(sourceGroupId, sourceGroupType, m_projectSettings.get()); + m_newSourceGroupSettings = std::make_shared(sourceGroupId, sourceGroupType, m_projectSettings.get()); if (applicationSettingsContainVisualStudioHeaderSearchPaths()) { std::vector flags; @@ -625,22 +630,25 @@ void QtProjectWizzard::selectedProjectType(SourceGroupType sourceGroupType) emptySourceGroup(); break; case SOURCE_GROUP_CXX_CDB: - m_newSourceGroupSettings = std::make_shared(sourceGroupId, sourceGroupType, m_projectSettings.get()); + m_newSourceGroupSettings = std::make_shared(sourceGroupId, m_projectSettings.get()); emptySourceGroupCDB(); break; case SOURCE_GROUP_CXX_VS: - m_newSourceGroupSettings = - std::make_shared(sourceGroupId, SOURCE_GROUP_CXX_CDB, m_projectSettings.get()); + m_newSourceGroupSettings = std::make_shared(sourceGroupId, m_projectSettings.get()); emptySourceGroupCDBVS(); break; case SOURCE_GROUP_JAVA_EMPTY: - m_newSourceGroupSettings = std::make_shared(sourceGroupId, sourceGroupType, m_projectSettings.get()); + m_newSourceGroupSettings = std::make_shared(sourceGroupId, m_projectSettings.get()); emptySourceGroup(); break; case SOURCE_GROUP_JAVA_MAVEN: - m_newSourceGroupSettings = std::make_shared(sourceGroupId, sourceGroupType, m_projectSettings.get()); + m_newSourceGroupSettings = std::make_shared(sourceGroupId, m_projectSettings.get()); sourcePathsJavaMaven(); break; + case SOURCE_GROUP_JAVA_GRADLE: + m_newSourceGroupSettings = std::make_shared(sourceGroupId, m_projectSettings.get()); + sourcePathsJavaGradle(); + break; case SOURCE_GROUP_UNKNOWN: break; } @@ -786,7 +794,7 @@ void QtProjectWizzard::sourcePathsJava() void QtProjectWizzard::sourcePathsJavaMaven() { - std::dynamic_pointer_cast(m_newSourceGroupSettings)->setMavenDependenciesDirectory( + std::dynamic_pointer_cast(m_newSourceGroupSettings)->setMavenDependenciesDirectory( FilePath("./sourcetrail_dependencies/" + utility::replace(m_projectSettings->getProjectName(), " ", "_") + "/" + m_newSourceGroupSettings->getId() + "/maven") ); @@ -803,6 +811,25 @@ void QtProjectWizzard::sourcePathsJavaMaven() window->updateSubTitle("Indexed Paths"); } +void QtProjectWizzard::sourcePathsJavaGradle() +{ + std::dynamic_pointer_cast(m_newSourceGroupSettings)->setGradleDependenciesDirectory( + FilePath("./sourcetrail_dependencies/" + utility::replace(m_projectSettings->getProjectName(), " ", "_") + "/" + m_newSourceGroupSettings->getId() + "/gradle") + ); + + QtProjectWizzardWindow* window = createWindowWithSummary( + [this](QtProjectWizzardWindow* window, QtProjectWizzardContentSummary* summary) + { + summary->addContent(new QtProjectWizzardContentPathSourceGradle(m_newSourceGroupSettings, window)); + summary->addSpace(); + summary->addContent(new QtProjectWizzardContentPathDependenciesGradle(m_newSourceGroupSettings, window)); + } + ); + + connect(window, &QtProjectWizzardWindow::next, this, &QtProjectWizzard::advancedSettingsJava); + window->updateSubTitle("Indexed Paths"); +} + void QtProjectWizzard::advancedSettingsCxx() { QtProjectWizzardWindow* window = createWindowWithSummary( diff --git a/src/lib_gui/qt/window/project_wizzard/QtProjectWizzard.h b/src/lib_gui/qt/window/project_wizzard/QtProjectWizzard.h index 5a33e6de..b4f62445 100644 --- a/src/lib_gui/qt/window/project_wizzard/QtProjectWizzard.h +++ b/src/lib_gui/qt/window/project_wizzard/QtProjectWizzard.h @@ -97,6 +97,7 @@ private slots: void sourcePathsJava(); void sourcePathsJavaMaven(); + void sourcePathsJavaGradle(); void advancedSettingsCxx(); void advancedSettingsJava(); diff --git a/src/lib_gui/qt/window/project_wizzard/QtProjectWizzardContentCDBSource.cpp b/src/lib_gui/qt/window/project_wizzard/QtProjectWizzardContentCDBSource.cpp index e26139a9..2d8e7a17 100644 --- a/src/lib_gui/qt/window/project_wizzard/QtProjectWizzardContentCDBSource.cpp +++ b/src/lib_gui/qt/window/project_wizzard/QtProjectWizzardContentCDBSource.cpp @@ -1,7 +1,7 @@ #include "qt/window/project_wizzard/QtProjectWizzardContentCDBSource.h" #include "data/indexer/IndexerCommandCxxCdb.h" -#include "settings/SourceGroupSettingsCxx.h" +#include "settings/SourceGroupSettingsCxxCdb.h" #include "utility/file/FilePath.h" QtProjectWizzardContentCDBSource::QtProjectWizzardContentCDBSource( @@ -35,14 +35,12 @@ void QtProjectWizzardContentCDBSource::load() const FilePath projectPath = m_settings->getProjectFileLocation(); std::vector excludePaths = m_settings->getExcludePathsExpandedAndAbsolute(); - std::shared_ptr cxxSettings = std::dynamic_pointer_cast(m_settings); - if (cxxSettings) + if (std::shared_ptr cxxSettings = std::dynamic_pointer_cast(m_settings)) { FilePath cdbPath = cxxSettings->getCompilationDatabasePathExpandedAndAbsolute(); if (!cdbPath.empty() && cdbPath.exists()) { - std::vector filePaths = - IndexerCommandCxxCdb::getSourceFilesFromCDB(cdbPath); + std::vector filePaths = IndexerCommandCxxCdb::getSourceFilesFromCDB(cdbPath); for (FilePath& path : filePaths) { diff --git a/src/lib_gui/qt/window/project_wizzard/QtProjectWizzardContentCrossCompilationOptions.cpp b/src/lib_gui/qt/window/project_wizzard/QtProjectWizzardContentCrossCompilationOptions.cpp index fca81e77..5364a00b 100644 --- a/src/lib_gui/qt/window/project_wizzard/QtProjectWizzardContentCrossCompilationOptions.cpp +++ b/src/lib_gui/qt/window/project_wizzard/QtProjectWizzardContentCrossCompilationOptions.cpp @@ -4,8 +4,7 @@ #include #include -#include "settings/SourceGroupSettings.h" -#include "settings/SourceGroupSettingsCxx.h" +#include "settings/SourceGroupSettingsCxxEmpty.h" #include "utility/logging/logging.h" QtProjectWizzardContentCrossCompilationOptions::QtProjectWizzardContentCrossCompilationOptions( @@ -61,7 +60,7 @@ void QtProjectWizzardContentCrossCompilationOptions::populate(QGridLayout* layou QLabel* label = new QLabel("Architecture:"); m_arch = new QComboBox(); - std::vector archTypes = SourceGroupSettingsCxx::getAvailableArchTypes(); + std::vector archTypes = SourceGroupSettingsCxxEmpty::getAvailableArchTypes(); std::sort(archTypes.begin(), archTypes.end()); for (size_t i = 0; i < archTypes.size(); i++) { @@ -77,7 +76,7 @@ void QtProjectWizzardContentCrossCompilationOptions::populate(QGridLayout* layou QLabel* label = new QLabel("Vendor:"); m_vendor = new QComboBox(); - std::vector vendorTypes = SourceGroupSettingsCxx::getAvailableVendorTypes(); + std::vector vendorTypes = SourceGroupSettingsCxxEmpty::getAvailableVendorTypes(); std::sort(vendorTypes.begin() + 1, vendorTypes.end()); for (size_t i = 0; i < vendorTypes.size(); i++) { @@ -92,7 +91,7 @@ void QtProjectWizzardContentCrossCompilationOptions::populate(QGridLayout* layou QLabel* label = new QLabel("OS:"); m_sys = new QComboBox(); - std::vector osTypes = SourceGroupSettingsCxx::getAvailableOsTypes(); + std::vector osTypes = SourceGroupSettingsCxxEmpty::getAvailableOsTypes(); std::sort(osTypes.begin() + 1, osTypes.end()); for (size_t i = 0; i < osTypes.size(); i++) { @@ -107,7 +106,7 @@ void QtProjectWizzardContentCrossCompilationOptions::populate(QGridLayout* layou QLabel* label = new QLabel("Environment:"); m_abi = new QComboBox(); - std::vector environmentTypes = SourceGroupSettingsCxx::getAvailableEnvironmentTypes(); + std::vector environmentTypes = SourceGroupSettingsCxxEmpty::getAvailableEnvironmentTypes(); std::sort(environmentTypes.begin() + 1, environmentTypes.end()); for (size_t i = 0; i < environmentTypes.size(); i++) { @@ -129,7 +128,7 @@ void QtProjectWizzardContentCrossCompilationOptions::populate(QGridLayout* layou void QtProjectWizzardContentCrossCompilationOptions::load() { - if (std::shared_ptr cxxSettings = std::dynamic_pointer_cast(m_sourceGroupSettings)) + if (std::shared_ptr cxxSettings = std::dynamic_pointer_cast(m_sourceGroupSettings)) { m_useTargetOptions->setChecked(cxxSettings->getTargetOptionsEnabled()); m_arch->setCurrentText(QString::fromStdString(cxxSettings->getTargetArch())); @@ -143,7 +142,7 @@ void QtProjectWizzardContentCrossCompilationOptions::load() void QtProjectWizzardContentCrossCompilationOptions::save() { - if (std::shared_ptr cxxSettings = std::dynamic_pointer_cast(m_sourceGroupSettings)) + if (std::shared_ptr cxxSettings = std::dynamic_pointer_cast(m_sourceGroupSettings)) { cxxSettings->setTargetOptionsEnabled(m_useTargetOptions->isChecked()); cxxSettings->setTargetArch(m_arch->currentText().toStdString()); diff --git a/src/lib_gui/qt/window/project_wizzard/QtProjectWizzardContentPath.cpp b/src/lib_gui/qt/window/project_wizzard/QtProjectWizzardContentPath.cpp index 9d475cd2..89659755 100644 --- a/src/lib_gui/qt/window/project_wizzard/QtProjectWizzardContentPath.cpp +++ b/src/lib_gui/qt/window/project_wizzard/QtProjectWizzardContentPath.cpp @@ -10,11 +10,13 @@ #include "qt/element/QtLocationPicker.h" #include "qt/view/QtDialogView.h" #include "settings/ApplicationSettings.h" -#include "settings/SourceGroupSettingsCxx.h" -#include "settings/SourceGroupSettingsJava.h" +#include "settings/SourceGroupSettingsCxxCdb.h" +#include "settings/SourceGroupSettingsJavaMaven.h" +#include "settings/SourceGroupSettingsJavaGradle.h" #include "utility/file/FileManager.h" #include "utility/messaging/type/MessageStatus.h" #include "utility/ScopedFunctor.h" +#include "utility/utilityGradle.h" #include "utility/utilityMaven.h" QtProjectWizzardContentPath::QtProjectWizzardContentPath(std::shared_ptr settings, QtProjectWizzardWindow* window) @@ -140,21 +142,21 @@ void QtProjectWizzardContentPathCDB::populate(QGridLayout* layout, int& row) void QtProjectWizzardContentPathCDB::load() { - std::shared_ptr cxxSettings = - std::dynamic_pointer_cast(m_settings); - if (cxxSettings) + std::shared_ptr settings = + std::dynamic_pointer_cast(m_settings); + if (settings) { - m_picker->setText(QString::fromStdString(cxxSettings->getCompilationDatabasePath().str())); + m_picker->setText(QString::fromStdString(settings->getCompilationDatabasePath().str())); } } void QtProjectWizzardContentPathCDB::save() { - std::shared_ptr cxxSettings = - std::dynamic_pointer_cast(m_settings); - if (cxxSettings) + std::shared_ptr m_settings = + std::dynamic_pointer_cast(m_settings); + if (m_settings) { - cxxSettings->setCompilationDatabasePath(FilePath(m_picker->getText().toStdString())); + m_settings->setCompilationDatabasePath(FilePath(m_picker->getText().toStdString())); } } @@ -200,30 +202,30 @@ void QtProjectWizzardContentPathSourceMaven::populate(QGridLayout* layout, int& void QtProjectWizzardContentPathSourceMaven::load() { - std::shared_ptr javaSettings = std::dynamic_pointer_cast(m_settings); - if (javaSettings) + std::shared_ptr settings = std::dynamic_pointer_cast(m_settings); + if (settings) { - m_picker->setText(QString::fromStdString(javaSettings->getMavenProjectFilePath().str())); - m_shouldIndexTests->setChecked(javaSettings->getShouldIndexMavenTests()); + m_picker->setText(QString::fromStdString(settings->getMavenProjectFilePath().str())); + m_shouldIndexTests->setChecked(settings->getShouldIndexMavenTests()); } } void QtProjectWizzardContentPathSourceMaven::save() { - std::shared_ptr javaSettings = std::dynamic_pointer_cast(m_settings); - if (javaSettings) + std::shared_ptr settings = std::dynamic_pointer_cast(m_settings); + if (settings) { - javaSettings->setMavenProjectFilePath(FilePath(m_picker->getText().toStdString())); - javaSettings->setShouldIndexMavenTests(m_shouldIndexTests->isChecked()); + settings->setMavenProjectFilePath(FilePath(m_picker->getText().toStdString())); + settings->setShouldIndexMavenTests(m_shouldIndexTests->isChecked()); } } std::vector QtProjectWizzardContentPathSourceMaven::getFileNames() const { - std::shared_ptr javaSettings = std::dynamic_pointer_cast(m_settings); + std::shared_ptr settings = std::dynamic_pointer_cast(m_settings); const FilePath mavenPath = ApplicationSettings::getInstance()->getMavenPath(); - const FilePath mavenProjectRoot = javaSettings->getMavenProjectFilePathExpandedAndAbsolute().parentDirectory(); + const FilePath mavenProjectRoot = settings->getMavenProjectFilePathExpandedAndAbsolute().parentDirectory(); std::vector list; std::shared_ptr dialogView = Application::getInstance()->getDialogView(); @@ -251,7 +253,7 @@ std::vector QtProjectWizzardContentPathSourceMaven::getFileNames() const std::vector sourceDirectories = utility::mavenGetAllDirectoriesFromEffectivePom( mavenPath, mavenProjectRoot, - javaSettings->getShouldIndexMavenTests() + settings->getShouldIndexMavenTests() ); FileManager fileManager; @@ -277,6 +279,7 @@ std::vector QtProjectWizzardContentPathSourceMaven::getFileNames() return list; } + QtProjectWizzardContentPathDependenciesMaven::QtProjectWizzardContentPathDependenciesMaven( std::shared_ptr settings, QtProjectWizzardWindow* window ) @@ -292,18 +295,149 @@ QtProjectWizzardContentPathDependenciesMaven::QtProjectWizzardContentPathDepende void QtProjectWizzardContentPathDependenciesMaven::load() { - std::shared_ptr javaSettings = std::dynamic_pointer_cast(m_settings); - if (javaSettings) + std::shared_ptr settings = std::dynamic_pointer_cast(m_settings); + if (settings) { - m_picker->setText(QString::fromStdString(javaSettings->getMavenDependenciesDirectory().str())); + m_picker->setText(QString::fromStdString(settings->getMavenDependenciesDirectory().str())); } } void QtProjectWizzardContentPathDependenciesMaven::save() { - std::shared_ptr javaSettings = std::dynamic_pointer_cast(m_settings); - if (javaSettings) + std::shared_ptr settings = std::dynamic_pointer_cast(m_settings); + if (settings) { - javaSettings->setMavenDependenciesDirectory(FilePath(m_picker->getText().toStdString())); + settings->setMavenDependenciesDirectory(FilePath(m_picker->getText().toStdString())); + } +} + + +QtProjectWizzardContentPathSourceGradle::QtProjectWizzardContentPathSourceGradle( + std::shared_ptr settings, QtProjectWizzardWindow* window +) + : QtProjectWizzardContentPath(settings, window) +{ + setTitleString("Gradle Project File (build.gradle)"); + setHelpString( + "Enter the path to the main build.gradle file of your Gradle project.
" + "
" + "You can make use of environment variables with ${ENV_VAR}." + ); + setFileEndings({ ".gradle" }); +} + +void QtProjectWizzardContentPathSourceGradle::populate(QGridLayout* layout, int& row) +{ + QtProjectWizzardContentPath::populate(layout, row); + m_picker->setPickDirectory(false); + m_picker->setFileFilter("Gradle Build File (build.gradle)"); + + QPushButton* filesButton = addFilesButton("show source files", nullptr, row); + m_shouldIndexTests = new QCheckBox("Should Index Tests"); + + QHBoxLayout* hlayout = new QHBoxLayout(); + hlayout->setContentsMargins(0, 0, 0, 0); + hlayout->addWidget(m_shouldIndexTests); + hlayout->addStretch(); + hlayout->addWidget(filesButton); + + layout->addLayout(hlayout, row, QtProjectWizzardWindow::BACK_COL); + row++; +} + +void QtProjectWizzardContentPathSourceGradle::load() +{ + std::shared_ptr settings = std::dynamic_pointer_cast(m_settings); + if (settings) + { + m_picker->setText(QString::fromStdString(settings->getGradleProjectFilePath().str())); + m_shouldIndexTests->setChecked(settings->getShouldIndexGradleTests()); + } +} + +void QtProjectWizzardContentPathSourceGradle::save() +{ + std::shared_ptr settings = std::dynamic_pointer_cast(m_settings); + if (settings) + { + settings->setGradleProjectFilePath(FilePath(m_picker->getText().toStdString())); + settings->setShouldIndexGradleTests(m_shouldIndexTests->isChecked()); + } +} + +std::vector QtProjectWizzardContentPathSourceGradle::getFileNames() const +{ + std::shared_ptr settings = std::dynamic_pointer_cast(m_settings); + + const FilePath gradleProjectRoot = settings->getGradleProjectFilePathExpandedAndAbsolute().parentDirectory(); + + std::vector list; + + std::shared_ptr dialogView = Application::getInstance()->getDialogView(); + + ScopedFunctor scopedFunctor([&dialogView]() { + dialogView->hideUnknownProgressDialog(); + }); + + std::dynamic_pointer_cast(dialogView)->setParentWindow(m_window); + { + dialogView->showUnknownProgressDialog("Preparing Project", "Gradle\nFetching Source Directories"); + const std::vector sourceDirectories = utility::gradleGetAllSourceDirectories( + gradleProjectRoot, + settings->getShouldIndexGradleTests() + ); + + FileManager fileManager; + fileManager.update( + sourceDirectories, + m_settings->getExcludePathsExpandedAndAbsolute(), + m_settings->getSourceExtensions() + ); + + const FilePath projectPath = m_settings->getProjectFileLocation(); + + for (FilePath path : fileManager.getAllSourceFilePaths()) + { + if (projectPath.exists()) + { + path = path.relativeTo(projectPath); + } + + list.push_back(path.str()); + } + } + + return list; +} + + +QtProjectWizzardContentPathDependenciesGradle::QtProjectWizzardContentPathDependenciesGradle( + std::shared_ptr settings, QtProjectWizzardWindow* window +) + : QtProjectWizzardContentPath(settings, window) +{ + setTitleString("Intermediate Dependencies Directory"); + setHelpString( + "This directory is used to temporarily download and store the dependencies (e.g. .jar files) of the Gradle project while it is indexed.
" + "
" + "You can make use of environment variables with ${ENV_VAR}." + ); +} + +void QtProjectWizzardContentPathDependenciesGradle::load() +{ + std::shared_ptr settings = std::dynamic_pointer_cast(m_settings); + if (settings) + { + m_picker->setText(QString::fromStdString(settings->getGradleDependenciesDirectory().str())); + } +} + +void QtProjectWizzardContentPathDependenciesGradle::save() +{ + std::shared_ptr settings = std::dynamic_pointer_cast(m_settings); + if (settings) + { + settings->setGradleDependenciesDirectory(FilePath(m_picker->getText().toStdString())); } } diff --git a/src/lib_gui/qt/window/project_wizzard/QtProjectWizzardContentPath.h b/src/lib_gui/qt/window/project_wizzard/QtProjectWizzardContentPath.h index 2aeb9efb..3e960bcf 100644 --- a/src/lib_gui/qt/window/project_wizzard/QtProjectWizzardContentPath.h +++ b/src/lib_gui/qt/window/project_wizzard/QtProjectWizzardContentPath.h @@ -95,4 +95,37 @@ public: virtual void save() override; }; + +class QtProjectWizzardContentPathSourceGradle + : public QtProjectWizzardContentPath +{ + Q_OBJECT +public: + QtProjectWizzardContentPathSourceGradle(std::shared_ptr settings, QtProjectWizzardWindow* window); + + // QtProjectWizzardContent implementation + virtual void populate(QGridLayout* layout, int& row) override; + + virtual void load() override; + virtual void save() override; + + virtual std::vector getFileNames() const override; + +private: + QCheckBox* m_shouldIndexTests; +}; + + +class QtProjectWizzardContentPathDependenciesGradle + : public QtProjectWizzardContentPath +{ + Q_OBJECT +public: + QtProjectWizzardContentPathDependenciesGradle(std::shared_ptr settings, QtProjectWizzardWindow* window); + + // QtProjectWizzardContent implementation + virtual void load() override; + virtual void save() override; +}; + #endif // QT_PROJECT_WIZZARD_CONTENT_PATH_H diff --git a/src/lib_gui/qt/window/project_wizzard/QtProjectWizzardContentPaths.cpp b/src/lib_gui/qt/window/project_wizzard/QtProjectWizzardContentPaths.cpp index 6263e826..09f43d42 100644 --- a/src/lib_gui/qt/window/project_wizzard/QtProjectWizzardContentPaths.cpp +++ b/src/lib_gui/qt/window/project_wizzard/QtProjectWizzardContentPaths.cpp @@ -13,7 +13,7 @@ #include "qt/view/QtDialogView.h" #include "qt/window/QtSelectPathsDialog.h" #include "settings/ApplicationSettings.h" -#include "settings/SourceGroupSettingsCxx.h" +#include "settings/SourceGroupSettingsCxxCdb.h" #include "settings/SourceGroupSettingsJava.h" #include "utility/CompilationDatabase.h" #include "utility/file/FileManager.h" @@ -269,7 +269,7 @@ void QtProjectWizzardContentPathsCDBHeader::buttonClicked() if (!m_filesDialog) { - FilePath cdbPath = dynamic_cast(m_settings.get())->getCompilationDatabasePathExpandedAndAbsolute(); + FilePath cdbPath = dynamic_cast(m_settings.get())->getCompilationDatabasePathExpandedAndAbsolute(); // TODO: remove this cast if (!cdbPath.exists()) { QMessageBox msgBox; diff --git a/src/lib_gui/qt/window/project_wizzard/QtProjectWizzardContentSelect.cpp b/src/lib_gui/qt/window/project_wizzard/QtProjectWizzardContentSelect.cpp index 86df9460..8c2c6ccb 100644 --- a/src/lib_gui/qt/window/project_wizzard/QtProjectWizzardContentSelect.cpp +++ b/src/lib_gui/qt/window/project_wizzard/QtProjectWizzardContentSelect.cpp @@ -35,6 +35,7 @@ void QtProjectWizzardContentSelect::populate(QGridLayout* layout, int& row) sourceGroupInfos[LANGUAGE_CPP].push_back(SourceGroupInfo(SOURCE_GROUP_CXX_VS)); sourceGroupInfos[LANGUAGE_JAVA].push_back(SourceGroupInfo(SOURCE_GROUP_JAVA_EMPTY)); sourceGroupInfos[LANGUAGE_JAVA].push_back(SourceGroupInfo(SOURCE_GROUP_JAVA_MAVEN)); + sourceGroupInfos[LANGUAGE_JAVA].push_back(SourceGroupInfo(SOURCE_GROUP_JAVA_GRADLE)); // define which icons should be used for which kind of source group m_sourceGroupTypeIconName[SOURCE_GROUP_C_EMPTY] = "empty_icon"; @@ -43,6 +44,7 @@ void QtProjectWizzardContentSelect::populate(QGridLayout* layout, int& row) m_sourceGroupTypeIconName[SOURCE_GROUP_CXX_VS] = "vs_icon"; m_sourceGroupTypeIconName[SOURCE_GROUP_JAVA_EMPTY] = "empty_icon"; m_sourceGroupTypeIconName[SOURCE_GROUP_JAVA_MAVEN] = "mvn_icon"; + m_sourceGroupTypeIconName[SOURCE_GROUP_JAVA_GRADLE] = "empty_icon"; // Todo: make and use gradle icon here // define descriptions for each kind of Source Group m_sourceGroupTypeDescriptions[SOURCE_GROUP_C_EMPTY] = "Create a new Sourcetrail Source Group by defining which C files will be indexed."; @@ -54,7 +56,8 @@ void QtProjectWizzardContentSelect::populate(QGridLayout* layout, int& row) "Note: Requires a running Visual Studio instance with the " "Visual Studio plugin installed."; m_sourceGroupTypeDescriptions[SOURCE_GROUP_JAVA_EMPTY] = "Create a new Sourcetrail Source Group by defining which Java files will be indexed."; - m_sourceGroupTypeDescriptions[SOURCE_GROUP_JAVA_MAVEN] = "Create a new Source Group from an existing Maven project."; + m_sourceGroupTypeDescriptions[SOURCE_GROUP_JAVA_MAVEN] = "Create a new Source Group from an existing Maven project."; + m_sourceGroupTypeDescriptions[SOURCE_GROUP_JAVA_GRADLE] = "Create a new Source Group from an existing Gradle project."; QVBoxLayout* vlayout = new QVBoxLayout(); vlayout->setContentsMargins(0, 30, 0, 0); diff --git a/src/lib_gui/qt/window/project_wizzard/QtProjectWizzardContentSimple.cpp b/src/lib_gui/qt/window/project_wizzard/QtProjectWizzardContentSimple.cpp deleted file mode 100644 index 98ff572b..00000000 --- a/src/lib_gui/qt/window/project_wizzard/QtProjectWizzardContentSimple.cpp +++ /dev/null @@ -1,52 +0,0 @@ -#include "qt/window/project_wizzard/QtProjectWizzardContentSimple.h" - -#include -#include - -#include "settings/SourceGroupSettingsCxx.h" - -QtProjectWizzardContentSimple::QtProjectWizzardContentSimple(std::shared_ptr settings, QtProjectWizzardWindow* window) - : QtProjectWizzardContent(window) - , m_settings(settings) - , m_checkBox(nullptr) -{ -} - -void QtProjectWizzardContentSimple::populate(QGridLayout* layout, int& row) -{ - m_title = createFormLabel("Lazy Include Search (deprecated)"); - layout->addWidget(m_title, row, QtProjectWizzardWindow::FRONT_COL); - - m_checkBox = new QCheckBox("Search included files within the project paths"); - layout->addWidget(m_checkBox, row, QtProjectWizzardWindow::BACK_COL); - - addHelpButton( - "If enabled Sourcetrail also uses the project paths and their subdirectories when resolving #include directives.
" - "
" - "Use this option when you know that the project is self contained but don't know which paths to " - "specify as include paths.
" - "
" - "Warning: This slows down indexing speed.
" - "
" - "Deprecated: This option will be removed in future versions.", layout, row); - - row++; -} - -void QtProjectWizzardContentSimple::load() -{ - std::shared_ptr cxxSettings = std::dynamic_pointer_cast(m_settings); - if (cxxSettings) - { - m_checkBox->setChecked(cxxSettings->getUseSourcePathsForHeaderSearch()); - } -} - -void QtProjectWizzardContentSimple::save() -{ - std::shared_ptr cxxSettings = std::dynamic_pointer_cast(m_settings); - if (cxxSettings) - { - cxxSettings->setUseSourcePathsForHeaderSearch(m_checkBox->isChecked()); - } -} diff --git a/src/lib_gui/qt/window/project_wizzard/QtProjectWizzardContentSimple.h b/src/lib_gui/qt/window/project_wizzard/QtProjectWizzardContentSimple.h deleted file mode 100644 index 0c0a97f9..00000000 --- a/src/lib_gui/qt/window/project_wizzard/QtProjectWizzardContentSimple.h +++ /dev/null @@ -1,31 +0,0 @@ -#ifndef QT_PROJECT_WIZZARD_CONTENT_SIMPLE_H -#define QT_PROJECT_WIZZARD_CONTENT_SIMPLE_H - -#include "qt/window/project_wizzard/QtProjectWizzardContent.h" - -class QCheckBox; -class QButtonGroup; -class SourceGroupSettings; - -class QtProjectWizzardContentSimple - : public QtProjectWizzardContent -{ - Q_OBJECT - -public: - QtProjectWizzardContentSimple(std::shared_ptr settings, QtProjectWizzardWindow* window); - - // QtProjectWizzardContent implementation - virtual void populate(QGridLayout* layout, int& row) override; - - virtual void load() override; - virtual void save() override; - -private: - std::shared_ptr m_settings; - - QCheckBox* m_checkBox; - QLabel* m_title; -}; - -#endif // QT_PROJECT_WIZZARD_CONTENT_SIMPLE_H diff --git a/src/lib_java/CMakeLists.txt b/src/lib_java/CMakeLists.txt index 05edd67f..f7ed474a 100644 --- a/src/lib_java/CMakeLists.txt +++ b/src/lib_java/CMakeLists.txt @@ -16,11 +16,21 @@ add_files( data/parser/java/JavaEnvironmentFactory.cpp data/parser/java/JavaEnvironmentFactory.h - project/SourceGroupJava.cpp - project/SourceGroupJava.h project/SourceGroupFactoryModuleJava.cpp project/SourceGroupFactoryModuleJava.h + project/SourceGroupJava.cpp + project/SourceGroupJava.h + project/SourceGroupJavaEmpty.cpp + project/SourceGroupJavaEmpty.h + project/SourceGroupJavaGradle.cpp + project/SourceGroupJavaGradle.h + project/SourceGroupJavaMaven.cpp + project/SourceGroupJavaMaven.h + utility/utilityJava.cpp + utility/utilityJava.h + utility/utilityGradle.cpp + utility/utilityGradle.h utility/utilityMaven.cpp utility/utilityMaven.h ) diff --git a/src/lib_java/data/parser/java/JavaEnvironment.cpp b/src/lib_java/data/parser/java/JavaEnvironment.cpp index e1c4b667..df541eea 100644 --- a/src/lib_java/data/parser/java/JavaEnvironment.cpp +++ b/src/lib_java/data/parser/java/JavaEnvironment.cpp @@ -22,6 +22,21 @@ bool JavaEnvironment::callStaticVoidMethod(std::string className, std::string me return false; } +bool JavaEnvironment::callStaticVoidMethod(std::string className, std::string methodName, const std::string& arg1, const std::string& arg2, const std::string& arg3) +{ + jclass javaClass = getJavaClass(className); + jmethodID javaMethodId = getJavaStaticMethod(javaClass, methodName, "(Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;)V"); + if (javaMethodId != nullptr) + { + jstring jarg1 = m_env->NewStringUTF(arg1.c_str()); + jstring jarg2 = m_env->NewStringUTF(arg2.c_str()); + jstring jarg3 = m_env->NewStringUTF(arg3.c_str()); + m_env->CallStaticVoidMethod(javaClass, javaMethodId, jarg1, jarg2, jarg3); + return true; + } + return false; +} + bool JavaEnvironment::callStaticVoidMethod(std::string className, std::string methodName, int arg1, std::string arg2, std::string arg3, std::string arg4, int arg5) { jclass javaClass = getJavaClass(className); @@ -39,11 +54,11 @@ bool JavaEnvironment::callStaticVoidMethod(std::string className, std::string me return false; } -bool JavaEnvironment::callStaticMethod(std::string className, std::string methodName, std::string& ret, std::string arg1) +bool JavaEnvironment::callStaticStringMethod(std::string className, std::string methodName, std::string& ret, const std::string& arg1) { jclass javaClass = getJavaClass(className); - jmethodID javaMethodId = getJavaStaticMethod(javaClass, methodName, "(Ljava/lang/String;)Ljava/lang/String;"); - if(javaMethodId != nullptr) + jmethodID javaMethodId = getJavaStaticMethod(javaClass, methodName, "(Ljava/lang/String;)Ljava/lang/String;"); + if (javaMethodId != nullptr) { jstring jarg1 = m_env->NewStringUTF(arg1.c_str()); jstring jret = (jstring)m_env->CallStaticObjectMethod(javaClass, javaMethodId, jarg1); @@ -58,6 +73,26 @@ bool JavaEnvironment::callStaticMethod(std::string className, std::string method return false; } +bool JavaEnvironment::callStaticStringMethod(std::string className, std::string methodName, std::string& ret, const std::string& arg1, const std::string& arg2) +{ + jclass javaClass = getJavaClass(className); + jmethodID javaMethodId = getJavaStaticMethod(javaClass, methodName, "(Ljava/lang/String;Ljava/lang/String;)Ljava/lang/String;"); + if (javaMethodId != nullptr) + { + jstring jarg1 = m_env->NewStringUTF(arg1.c_str()); + jstring jarg2 = m_env->NewStringUTF(arg2.c_str()); + jstring jret = (jstring)m_env->CallStaticObjectMethod(javaClass, javaMethodId, jarg1, jarg2); + if (jret) + { + const char *buffer = m_env->GetStringUTFChars(jret, JNI_FALSE); + ret = std::string(buffer); + m_env->ReleaseStringUTFChars(jret, buffer); + return true; + } + } + return false; +} + std::string JavaEnvironment::toStdString(jstring s) { const char *nativeString = m_env->GetStringUTFChars(s, 0); diff --git a/src/lib_java/data/parser/java/JavaEnvironment.h b/src/lib_java/data/parser/java/JavaEnvironment.h index 2da48d7e..6e8647ca 100644 --- a/src/lib_java/data/parser/java/JavaEnvironment.h +++ b/src/lib_java/data/parser/java/JavaEnvironment.h @@ -33,8 +33,10 @@ public: ~JavaEnvironment(); bool callStaticVoidMethod(std::string className, std::string methodName); + bool callStaticVoidMethod(std::string className, std::string methodName, const std::string& arg1, const std::string& arg2, const std::string& arg3); bool callStaticVoidMethod(std::string className, std::string methodName, int arg1, std::string arg2, std::string arg3, std::string arg4, int arg5); - bool callStaticMethod(std::string className, std::string methodName, std::string& ret, std::string arg1); + bool callStaticStringMethod(std::string className, std::string methodName, std::string& ret, const std::string& arg1); + bool callStaticStringMethod(std::string className, std::string methodName, std::string& ret, const std::string& arg1, const std::string& arg2); std::string toStdString(jstring s); jstring toJString(std::string s); diff --git a/src/lib_java/data/parser/java/JavaParser.cpp b/src/lib_java/data/parser/java/JavaParser.cpp index ac6502ae..329ac9a9 100644 --- a/src/lib_java/data/parser/java/JavaParser.cpp +++ b/src/lib_java/data/parser/java/JavaParser.cpp @@ -11,65 +11,9 @@ #include "utility/file/FileSystem.h" #include "utility/text/TextAccess.h" #include "utility/ResourcePaths.h" +#include "utility/utilityJava.h" #include "utility/utilityString.h" -std::vector JavaParser::getRequiredJarNames() -{ - std::vector jarNames = { - - "java-indexer.jar", - "org.eclipse.core.commands-3.8.1.jar", - "org.eclipse.core.contenttype-3.5.100.jar", - "org.eclipse.core.expressions-3.5.100.jar", - "org.eclipse.core.filesystem-1.6.1.jar", - "org.eclipse.core.jobs-3.8.0.jar", - "org.eclipse.core.resources-3.11.1.jar", - "org.eclipse.core.runtime-3.12.0.jar", - "org.eclipse.equinox.app-1.3.400.jar", - "org.eclipse.equinox.common-3.8.0.jar", - "org.eclipse.equinox.preferences-3.6.1.jar", - "org.eclipse.equinox.registry-3.6.100.jar", - "org.eclipse.jdt.core-3.12.3.jar", - "org.eclipse.osgi-3.11.3.jar", - "org.eclipse.text-3.6.0.jar" - }; - return jarNames; -} - -std::string JavaParser::prepareJavaEnvironment() -{ - std::string errorString; - - if (!JavaEnvironmentFactory::getInstance()) - { -#ifdef _WIN32 - const std::string separator = ";"; -#else - const std::string separator = ":"; -#endif - - std::string classPath = ""; - { - const std::vector jarNames = getRequiredJarNames(); - for (size_t i = 0; i < jarNames.size(); i++) - { - if (i != 0) - { - classPath += separator; - } - classPath += ResourcePaths::getJavaPath().str() + jarNames[i]; - } - } - - JavaEnvironmentFactory::createInstance( - classPath, - errorString - ); - } - - return errorString; -} - void JavaParser::clearCaches() { std::shared_ptr factory = JavaEnvironmentFactory::getInstance(); @@ -90,7 +34,7 @@ JavaParser::JavaParser(std::shared_ptr client, std::shared_ptr 0) { LOG_ERROR(errorString); diff --git a/src/lib_java/data/parser/java/JavaParser.h b/src/lib_java/data/parser/java/JavaParser.h index 8848a2ef..359700bc 100644 --- a/src/lib_java/data/parser/java/JavaParser.h +++ b/src/lib_java/data/parser/java/JavaParser.h @@ -32,9 +32,6 @@ class FileRegister; class JavaParser: public Parser { public: - static std::vector getRequiredJarNames(); - // returns: error message - static std::string prepareJavaEnvironment(); static void clearCaches(); JavaParser(std::shared_ptr client, std::shared_ptr fileRegister); diff --git a/src/lib_java/project/SourceGroupFactoryModuleJava.cpp b/src/lib_java/project/SourceGroupFactoryModuleJava.cpp index 9246126c..d2987096 100644 --- a/src/lib_java/project/SourceGroupFactoryModuleJava.cpp +++ b/src/lib_java/project/SourceGroupFactoryModuleJava.cpp @@ -1,6 +1,11 @@ #include "project/SourceGroupFactoryModuleJava.h" -#include "project/SourceGroupJava.h" +#include "project/SourceGroupJavaEmpty.h" +#include "project/SourceGroupJavaGradle.h" +#include "project/SourceGroupJavaMaven.h" +#include "settings/SourceGroupSettingsJavaEmpty.h" +#include "settings/SourceGroupSettingsJavaGradle.h" +#include "settings/SourceGroupSettingsJavaMaven.h" SourceGroupFactoryModuleJava::~SourceGroupFactoryModuleJava() { @@ -11,6 +16,7 @@ bool SourceGroupFactoryModuleJava::supports(SourceGroupType type) const switch (type) { case SOURCE_GROUP_JAVA_EMPTY: + case SOURCE_GROUP_JAVA_GRADLE: case SOURCE_GROUP_JAVA_MAVEN: return true; default: @@ -22,9 +28,17 @@ bool SourceGroupFactoryModuleJava::supports(SourceGroupType type) const std::shared_ptr SourceGroupFactoryModuleJava::createSourceGroup(std::shared_ptr settings) { std::shared_ptr sourceGroup; - if (std::shared_ptr javaSettings = std::dynamic_pointer_cast(settings)) + if (std::shared_ptr javaSettings = std::dynamic_pointer_cast(settings)) { - sourceGroup = std::shared_ptr(new SourceGroupJava(javaSettings)); + sourceGroup = std::shared_ptr(new SourceGroupJavaEmpty(javaSettings)); + } + else if (std::shared_ptr javaSettings = std::dynamic_pointer_cast(settings)) + { + sourceGroup = std::shared_ptr(new SourceGroupJavaGradle(javaSettings)); + } + else if (std::shared_ptr javaSettings = std::dynamic_pointer_cast(settings)) + { + sourceGroup = std::shared_ptr(new SourceGroupJavaMaven(javaSettings)); } return sourceGroup; } diff --git a/src/lib_java/project/SourceGroupJava.cpp b/src/lib_java/project/SourceGroupJava.cpp index 6bdec23f..184a168c 100644 --- a/src/lib_java/project/SourceGroupJava.cpp +++ b/src/lib_java/project/SourceGroupJava.cpp @@ -6,18 +6,14 @@ #include "data/parser/java/JavaEnvironment.h" #include "data/parser/java/JavaParser.h" #include "settings/ApplicationSettings.h" -#include "utility/file/FileManager.h" -#include "utility/file/FileSystem.h" +#include "settings/SourceGroupSettingsJava.h" #include "utility/messaging/type/MessageStatus.h" #include "utility/text/TextAccess.h" #include "utility/ScopedFunctor.h" -#include "utility/utility.h" -#include "utility/utilityMaven.h" -#include "utility/utilityString.h" +#include "utility/utilityJava.h" #include "Application.h" -SourceGroupJava::SourceGroupJava(std::shared_ptr settings) - : m_settings(settings) +SourceGroupJava::SourceGroupJava() { } @@ -25,58 +21,22 @@ SourceGroupJava::~SourceGroupJava() { } -SourceGroupType SourceGroupJava::getType() const -{ - return m_settings->getType(); -} - bool SourceGroupJava::prepareIndexing() { if (!prepareJavaEnvironment()) { return false; } - - if (!prepareMavenData()) - { - return false; - } - return true; } -void SourceGroupJava::fetchAllSourceFilePaths() -{ - std::vector sourcePaths; - if (m_settings->getMavenProjectFilePathExpandedAndAbsolute().exists()) - { - std::shared_ptr dialogView = Application::getInstance()->getDialogView(); - dialogView->showUnknownProgressDialog("Preparing Project", "Maven\nFetching Source Directories"); - - const FilePath mavenPath(ApplicationSettings::getInstance()->getMavenPath()); - const FilePath projectRootPath = m_settings->getMavenProjectFilePathExpandedAndAbsolute().parentDirectory(); - sourcePaths = utility::mavenGetAllDirectoriesFromEffectivePom(mavenPath, projectRootPath, m_settings->getShouldIndexMavenTests()); - - dialogView->hideUnknownProgressDialog(); - } - else - { - sourcePaths = m_settings->getSourcePathsExpandedAndAbsolute(); - } - - m_sourceFilePathsToIndex.clear(); - FileManager fileManager; - fileManager.update(sourcePaths, m_settings->getExcludePathsExpandedAndAbsolute(), m_settings->getSourceExtensions()); - m_allSourceFilePaths = fileManager.getAllSourceFilePaths(); -} - std::vector> SourceGroupJava::getIndexerCommands( std::set* filesToIndex, bool fullRefresh) { std::vector classPath = getClassPath(); std::set indexedPaths; - for (const FilePath& p: m_settings->getSourcePathsExpandedAndAbsolute()) + for (const FilePath& p: getSourceGroupSettings()->getSourcePathsExpandedAndAbsolute()) { if (p.exists()) { @@ -85,7 +45,7 @@ std::vector> SourceGroupJava::getIndexerCommands } std::set excludedPaths; - for (const FilePath& p: m_settings->getExcludePathsExpandedAndAbsolute()) + for (const FilePath& p: getSourceGroupSettings()->getExcludePathsExpandedAndAbsolute()) { if (p.exists()) { @@ -110,9 +70,14 @@ std::vector> SourceGroupJava::getIndexerCommands return indexerCommands; } +std::shared_ptr SourceGroupJava::getSourceGroupSettings() +{ + return getSourceGroupSettingsJava(); +} + bool SourceGroupJava::prepareJavaEnvironment() { - const std::string errorString = JavaParser::prepareJavaEnvironment(); + const std::string errorString = utility::prepareJavaEnvironment(); if (errorString.size() > 0) { @@ -139,55 +104,20 @@ bool SourceGroupJava::prepareJavaEnvironment() return true; } -bool SourceGroupJava::prepareMavenData() -{ - if (m_settings && m_settings->getMavenProjectFilePathExpandedAndAbsolute().exists()) - { - const FilePath mavenPath = ApplicationSettings::getInstance()->getMavenPath(); - const FilePath projectRootPath = m_settings->getMavenProjectFilePathExpandedAndAbsolute().parentDirectory(); - - std::shared_ptr dialogView = Application::getInstance()->getDialogView(); - dialogView->showUnknownProgressDialog("Preparing Project", "Maven\nGenerating Source Files"); - - ScopedFunctor dialogHider([&dialogView](){ - dialogView->hideUnknownProgressDialog(); - }); - - bool success = utility::mavenGenerateSources(mavenPath, projectRootPath); - - if (!success) - { - const std::string dialogMessage = - "Sourcetrail was unable to locate Maven on this machine.\n" - "Please make sure to provide the correct Maven Path in the preferences."; - - MessageStatus(dialogMessage, true, false).dispatch(); - Application::getInstance()->handleDialog(dialogMessage); - } - - if (success) - { - dialogView->showUnknownProgressDialog("Preparing Project", "Maven\nExporting Dependencies"); - - success = utility::mavenCopyDependencies( - mavenPath, projectRootPath, m_settings->getMavenDependenciesDirectoryExpandedAndAbsolute() - ); - } - - return success; - } - - return true; -} - std::vector SourceGroupJava::getClassPath() { LOG_INFO("Retrieving classpath for indexer commands"); + std::vector classPath = doGetClassPath(); + LOG_INFO("Found " + std::to_string(classPath.size()) + " paths for classpath."); + return classPath; +} +std::vector SourceGroupJava::doGetClassPath() +{ std::vector classPath; - for (const FilePath& classpath: m_settings->getClasspathExpandedAndAbsolute()) + for (const FilePath& classpath : getSourceGroupSettingsJava()->getClasspathExpandedAndAbsolute()) { if (classpath.exists()) { @@ -196,31 +126,16 @@ std::vector SourceGroupJava::getClassPath() } } - if (m_settings->getUseJreSystemLibrary()) + if (getSourceGroupSettingsJava()->getUseJreSystemLibrary()) { - for (const FilePath& systemLibraryPath: ApplicationSettings::getInstance()->getJreSystemLibraryPathsExpanded()) + for (const FilePath& systemLibraryPath : ApplicationSettings::getInstance()->getJreSystemLibraryPathsExpanded()) { LOG_INFO("Adding JRE system library path to classpath: " + systemLibraryPath.str()); classPath.push_back(systemLibraryPath); } } - if (m_settings->getMavenDependenciesDirectoryExpandedAndAbsolute().exists()) - { - std::vector mavenJarPaths = FileSystem::getFilePathsFromDirectory( - m_settings->getMavenDependenciesDirectoryExpandedAndAbsolute(), - utility::createVectorFromElements(".jar") - ); - - for (const FilePath& mavenJarPath: mavenJarPaths) - { - LOG_INFO("Adding jar to classpath: " + mavenJarPath.str()); - } - - utility::append(classPath, mavenJarPaths); - } - - for (const FilePath& rootDirectory: fetchRootDirectories()) + for (const FilePath& rootDirectory : fetchRootDirectories()) { if (rootDirectory.exists()) { @@ -228,7 +143,6 @@ std::vector SourceGroupJava::getClassPath() classPath.push_back(rootDirectory); } } - LOG_INFO("Found " + std::to_string(classPath.size()) + " paths for classpath."); return classPath; } @@ -250,7 +164,7 @@ std::set SourceGroupJava::fetchRootDirectories() std::shared_ptr textAccess = TextAccess::createFromFile(filePath); std::string packageName = ""; - javaEnvironment->callStaticMethod("com/sourcetrail/JavaIndexer", "getPackageName", packageName, textAccess->getText()); + javaEnvironment->callStaticStringMethod("com/sourcetrail/JavaIndexer", "getPackageName", packageName, textAccess->getText()); if (packageName.empty()) { diff --git a/src/lib_java/project/SourceGroupJava.h b/src/lib_java/project/SourceGroupJava.h index 469cedbb..59887442 100644 --- a/src/lib_java/project/SourceGroupJava.h +++ b/src/lib_java/project/SourceGroupJava.h @@ -3,33 +3,34 @@ #include #include +#include -#include "settings/SourceGroupSettingsJava.h" #include "project/SourceGroup.h" +class SourceGroupSettingsJava; + class SourceGroupJava: public SourceGroup { public: - SourceGroupJava(std::shared_ptr settings); + SourceGroupJava(); virtual ~SourceGroupJava(); - virtual SourceGroupType getType() const; - virtual bool prepareIndexing(); - virtual void fetchAllSourceFilePaths(); - virtual std::vector> getIndexerCommands( std::set* filesToIndex, bool fullRefresh); +protected: + virtual std::vector doGetClassPath(); + private: + virtual std::shared_ptr getSourceGroupSettingsJava() = 0; + + virtual std::shared_ptr getSourceGroupSettings(); bool prepareJavaEnvironment(); - bool prepareMavenData(); std::vector getClassPath(); std::set fetchRootDirectories(); - - std::shared_ptr m_settings; }; #endif // SOURCE_GROUP_JAVA_H diff --git a/src/lib_java/project/SourceGroupJavaEmpty.cpp b/src/lib_java/project/SourceGroupJavaEmpty.cpp new file mode 100644 index 00000000..7fd51689 --- /dev/null +++ b/src/lib_java/project/SourceGroupJavaEmpty.cpp @@ -0,0 +1,27 @@ +#include "project/SourceGroupJavaEmpty.h" + +#include "settings/SourceGroupSettingsJavaEmpty.h" + +SourceGroupJavaEmpty::SourceGroupJavaEmpty(std::shared_ptr settings) + : m_settings(settings) +{ +} + +SourceGroupJavaEmpty::~SourceGroupJavaEmpty() +{ +} + +SourceGroupType SourceGroupJavaEmpty::getType() const +{ + return SOURCE_GROUP_JAVA_EMPTY; +} + +std::shared_ptr SourceGroupJavaEmpty::getSourceGroupSettingsJava() +{ + return m_settings; +} + +std::vector SourceGroupJavaEmpty::getAllSourcePaths() const +{ + return m_settings->getSourcePathsExpandedAndAbsolute(); +} diff --git a/src/lib_java/project/SourceGroupJavaEmpty.h b/src/lib_java/project/SourceGroupJavaEmpty.h new file mode 100644 index 00000000..e1e8cd84 --- /dev/null +++ b/src/lib_java/project/SourceGroupJavaEmpty.h @@ -0,0 +1,26 @@ +#ifndef SOURCE_GROUP_JAVA_EMPTY_H +#define SOURCE_GROUP_JAVA_EMPTY_H + +#include +#include + +#include "project/SourceGroupJava.h" + +class SourceGroupSettingsJavaEmpty; + +class SourceGroupJavaEmpty: public SourceGroupJava +{ +public: + SourceGroupJavaEmpty(std::shared_ptr settings); + virtual ~SourceGroupJavaEmpty(); + + virtual SourceGroupType getType() const; + +private: + virtual std::shared_ptr getSourceGroupSettingsJava(); + virtual std::vector getAllSourcePaths() const; + + std::shared_ptr m_settings; +}; + +#endif // SOURCE_GROUP_JAVA_EMPTY_H diff --git a/src/lib_java/project/SourceGroupJavaGradle.cpp b/src/lib_java/project/SourceGroupJavaGradle.cpp new file mode 100644 index 00000000..febc3cbd --- /dev/null +++ b/src/lib_java/project/SourceGroupJavaGradle.cpp @@ -0,0 +1,108 @@ +#include "project/SourceGroupJavaGradle.h" + +#include "component/view/DialogView.h" +#include "settings/ApplicationSettings.h" +#include "utility/file/FileSystem.h" +#include "utility/messaging/type/MessageStatus.h" +#include "utility/ScopedFunctor.h" +#include "utility/utility.h" +#include "utility/utilityGradle.h" +#include "Application.h" + +SourceGroupJavaGradle::SourceGroupJavaGradle(std::shared_ptr settings) + : m_settings(settings) +{ +} + +SourceGroupJavaGradle::~SourceGroupJavaGradle() +{ +} + +SourceGroupType SourceGroupJavaGradle::getType() const +{ + return SOURCE_GROUP_JAVA_GRADLE; +} + +bool SourceGroupJavaGradle::prepareIndexing() +{ + if (!SourceGroupJava::prepareIndexing()) + { + return false; + } + + if (!prepareGradleData()) + { + return false; + } + + return true; +} + +std::vector SourceGroupJavaGradle::doGetClassPath() +{ + std::vector classPath = SourceGroupJava::doGetClassPath(); + + if (m_settings->getGradleDependenciesDirectoryExpandedAndAbsolute().exists()) + { + std::vector gradleJarPaths = FileSystem::getFilePathsFromDirectory( + m_settings->getGradleDependenciesDirectoryExpandedAndAbsolute(), + {".jar"} + ); + + for (const FilePath& gradleJarPath : gradleJarPaths) + { + LOG_INFO("Adding jar to classpath: " + gradleJarPath.str()); + } + + utility::append(classPath, gradleJarPaths); + } + + return classPath; +} + +std::shared_ptr SourceGroupJavaGradle::getSourceGroupSettingsJava() +{ + return m_settings; +} + +std::vector SourceGroupJavaGradle::getAllSourcePaths() const +{ + std::vector sourcePaths; + if (m_settings->getGradleProjectFilePathExpandedAndAbsolute().exists()) + { + std::shared_ptr dialogView = Application::getInstance()->getDialogView(); + dialogView->showUnknownProgressDialog("Preparing Project", "Gradle\nFetching Source Directories"); + + const FilePath projectRootPath = m_settings->getGradleProjectFilePathExpandedAndAbsolute().parentDirectory(); + sourcePaths = utility::gradleGetAllSourceDirectories(projectRootPath, m_settings->getShouldIndexGradleTests()); + + dialogView->hideUnknownProgressDialog(); + } + return sourcePaths; +} + +bool SourceGroupJavaGradle::prepareGradleData() +{ + if (m_settings && m_settings->getGradleProjectFilePathExpandedAndAbsolute().exists()) + { + const FilePath projectRootPath = m_settings->getGradleProjectFilePathExpandedAndAbsolute().parentDirectory(); + + std::shared_ptr dialogView = Application::getInstance()->getDialogView(); + + ScopedFunctor dialogHider([&dialogView]() { + dialogView->hideUnknownProgressDialog(); + }); + + dialogView->showUnknownProgressDialog("Preparing Project", "Gradle\nExporting Dependencies"); + + bool success = utility::gradleCopyDependencies( + projectRootPath, + m_settings->getGradleDependenciesDirectoryExpandedAndAbsolute(), + m_settings->getShouldIndexGradleTests() + ); + + return success; + } + + return true; +} diff --git a/src/lib_java/project/SourceGroupJavaGradle.h b/src/lib_java/project/SourceGroupJavaGradle.h new file mode 100644 index 00000000..242dfa40 --- /dev/null +++ b/src/lib_java/project/SourceGroupJavaGradle.h @@ -0,0 +1,29 @@ +#ifndef SOURCE_GROUP_JAVA_GRADLE_H +#define SOURCE_GROUP_JAVA_GRADLE_H + +#include +#include + +#include "settings/SourceGroupSettingsJavaGradle.h" +#include "project/SourceGroupJava.h" + +class SourceGroupJavaGradle : public SourceGroupJava +{ +public: + SourceGroupJavaGradle(std::shared_ptr settings); + virtual ~SourceGroupJavaGradle(); + virtual SourceGroupType getType() const; + virtual bool prepareIndexing(); + +protected: + virtual std::vector doGetClassPath(); + +private: + virtual std::shared_ptr getSourceGroupSettingsJava(); + virtual std::vector getAllSourcePaths() const; + bool prepareGradleData(); + + std::shared_ptr m_settings; +}; + +#endif // SOURCE_GROUP_JAVA_GRADLE_H diff --git a/src/lib_java/project/SourceGroupJavaMaven.cpp b/src/lib_java/project/SourceGroupJavaMaven.cpp new file mode 100644 index 00000000..22d40958 --- /dev/null +++ b/src/lib_java/project/SourceGroupJavaMaven.cpp @@ -0,0 +1,124 @@ +#include "project/SourceGroupJavaMaven.h" + +#include "component/view/DialogView.h" +#include "settings/ApplicationSettings.h" +#include "utility/file/FileSystem.h" +#include "utility/messaging/type/MessageStatus.h" +#include "utility/ScopedFunctor.h" +#include "utility/utility.h" +#include "utility/utilityMaven.h" +#include "Application.h" + +SourceGroupJavaMaven::SourceGroupJavaMaven(std::shared_ptr settings) + : m_settings(settings) +{ +} + +SourceGroupJavaMaven::~SourceGroupJavaMaven() +{ +} + +SourceGroupType SourceGroupJavaMaven::getType() const +{ + return SOURCE_GROUP_JAVA_MAVEN; +} + +bool SourceGroupJavaMaven::prepareIndexing() +{ + if (!SourceGroupJava::prepareIndexing()) + { + return false; + } + + if (!prepareMavenData()) + { + return false; + } + + return true; +} + +std::vector SourceGroupJavaMaven::doGetClassPath() +{ + std::vector classPath = SourceGroupJava::doGetClassPath(); + + if (m_settings && m_settings->getMavenDependenciesDirectoryExpandedAndAbsolute().exists()) + { + std::vector mavenJarPaths = FileSystem::getFilePathsFromDirectory( + m_settings->getMavenDependenciesDirectoryExpandedAndAbsolute(), + utility::createVectorFromElements(".jar") + ); + + for (const FilePath& mavenJarPath : mavenJarPaths) + { + LOG_INFO("Adding jar to classpath: " + mavenJarPath.str()); + } + + utility::append(classPath, mavenJarPaths); + } + + return classPath; +} + +std::shared_ptr SourceGroupJavaMaven::getSourceGroupSettingsJava() +{ + return m_settings; +} + +std::vector SourceGroupJavaMaven::getAllSourcePaths() const +{ + std::vector sourcePaths; + if (m_settings && m_settings->getMavenProjectFilePathExpandedAndAbsolute().exists()) + { + std::shared_ptr dialogView = Application::getInstance()->getDialogView(); + dialogView->showUnknownProgressDialog("Preparing Project", "Maven\nFetching Source Directories"); + + const FilePath mavenPath(ApplicationSettings::getInstance()->getMavenPath()); + const FilePath projectRootPath = m_settings->getMavenProjectFilePathExpandedAndAbsolute().parentDirectory(); + sourcePaths = utility::mavenGetAllDirectoriesFromEffectivePom(mavenPath, projectRootPath, m_settings->getShouldIndexMavenTests()); + + dialogView->hideUnknownProgressDialog(); + } + return sourcePaths; +} + +bool SourceGroupJavaMaven::prepareMavenData() +{ + if (m_settings && m_settings->getMavenProjectFilePathExpandedAndAbsolute().exists()) + { + const FilePath mavenPath = ApplicationSettings::getInstance()->getMavenPath(); + const FilePath projectRootPath = m_settings->getMavenProjectFilePathExpandedAndAbsolute().parentDirectory(); + + std::shared_ptr dialogView = Application::getInstance()->getDialogView(); + dialogView->showUnknownProgressDialog("Preparing Project", "Maven\nGenerating Source Files"); + + ScopedFunctor dialogHider([&dialogView](){ + dialogView->hideUnknownProgressDialog(); + }); + + bool success = utility::mavenGenerateSources(mavenPath, projectRootPath); + + if (!success) + { + const std::string dialogMessage = + "Sourcetrail was unable to locate Maven on this machine.\n" + "Please make sure to provide the correct Maven Path in the preferences."; + + MessageStatus(dialogMessage, true, false).dispatch(); + Application::getInstance()->handleDialog(dialogMessage); + } + + if (success) + { + dialogView->showUnknownProgressDialog("Preparing Project", "Maven\nExporting Dependencies"); + + success = utility::mavenCopyDependencies( + mavenPath, projectRootPath, m_settings->getMavenDependenciesDirectoryExpandedAndAbsolute() + ); + } + + return success; + } + + return true; +} diff --git a/src/lib_java/project/SourceGroupJavaMaven.h b/src/lib_java/project/SourceGroupJavaMaven.h new file mode 100644 index 00000000..d1f689c7 --- /dev/null +++ b/src/lib_java/project/SourceGroupJavaMaven.h @@ -0,0 +1,29 @@ +#ifndef SOURCE_GROUP_JAVA_MAVEN_H +#define SOURCE_GROUP_JAVA_MAVEN_H + +#include +#include + +#include "settings/SourceGroupSettingsJavaMaven.h" +#include "project/SourceGroupJava.h" + +class SourceGroupJavaMaven: public SourceGroupJava +{ +public: + SourceGroupJavaMaven(std::shared_ptr settings); + virtual ~SourceGroupJavaMaven(); + virtual SourceGroupType getType() const; + virtual bool prepareIndexing(); + +protected: + virtual std::vector doGetClassPath(); + +private: + virtual std::shared_ptr getSourceGroupSettingsJava(); + virtual std::vector getAllSourcePaths() const; + bool prepareMavenData(); + + std::shared_ptr m_settings; +}; + +#endif // SOURCE_GROUP_JAVA_MAVEN_H diff --git a/src/lib_java/utility/utilityGradle.cpp b/src/lib_java/utility/utilityGradle.cpp new file mode 100644 index 00000000..95236be5 --- /dev/null +++ b/src/lib_java/utility/utilityGradle.cpp @@ -0,0 +1,93 @@ +#include "utility/utilityGradle.h" + +#include + +#include "data/parser/java/JavaEnvironment.h" +#include "data/parser/java/JavaEnvironmentFactory.h" +#include "settings/ApplicationSettings.h" +#include "utility/logging/logging.h" +#include "utility/ResourcePaths.h" +#include "utility/utilityJava.h" +#include "utility/utilityString.h" + +namespace +{ + void setJavaHomeVariableIfNotExists() + { + if (getenv("JAVA_HOME") == nullptr) + { + const FilePath javaPath(ApplicationSettings::getInstance()->getJavaPath()); + const FilePath javaHomePath = javaPath.parentDirectory().parentDirectory().parentDirectory(); + + LOG_WARNING("Environment variable \"JAVA_HOME\" not found on system. Setting value to \"" + javaHomePath.str() + "\" for this process."); + + putenv(const_cast(("JAVA_HOME=" + javaHomePath.str()).c_str())); + } + } +} + +namespace utility +{ + bool gradleCopyDependencies(const FilePath& projectDirectoryPath, const FilePath& outputDirectoryPath, bool addTestDependencies) + { + const std::string gradleInitScriptPath = ResourcePaths::getJavaPath().str() + "gradle/init.gradle"; + + setJavaHomeVariableIfNotExists(); + utility::prepareJavaEnvironment(); + + std::shared_ptr javaEnvironment = JavaEnvironmentFactory::getInstance()->createEnvironment(); + bool success = javaEnvironment->callStaticVoidMethod("com/sourcetrail/gradle/InfoRetriever", "copyCompileLibs", projectDirectoryPath.str(), gradleInitScriptPath, outputDirectoryPath.str()); + + if (success && addTestDependencies) + { + success = javaEnvironment->callStaticVoidMethod("com/sourcetrail/gradle/InfoRetriever", "copyTestCompileLibs", projectDirectoryPath.str(), gradleInitScriptPath, outputDirectoryPath.str()); + } + + return success; + } + + std::vector gradleGetAllSourceDirectories(const FilePath& projectDirectoryPath, bool addTestDirectories) + { + const std::string gradleInitScriptPath = ResourcePaths::getJavaPath().str() + "gradle/init.gradle"; + + setJavaHomeVariableIfNotExists(); + utility::prepareJavaEnvironment(); + + std::set uncheckedDirectories; + { + std::shared_ptr javaEnvironment = JavaEnvironmentFactory::getInstance()->createEnvironment(); + { + std::string mainSrcDirs = ""; + javaEnvironment->callStaticStringMethod("com/sourcetrail/gradle/InfoRetriever", "getMainSrcDirs", mainSrcDirs, projectDirectoryPath.str(), gradleInitScriptPath); + for (const std::string mainSrcDir : utility::splitToVector(mainSrcDirs, ";")) + { + uncheckedDirectories.insert(mainSrcDir); + } + } + + if (addTestDirectories) + { + std::string testSrcDirs = ""; + javaEnvironment->callStaticStringMethod("com/sourcetrail/gradle/InfoRetriever", "getTestSrcDirs", testSrcDirs, projectDirectoryPath.str(), gradleInitScriptPath); + for (const std::string testSrcDir : utility::splitToVector(testSrcDirs, ";")) + { + uncheckedDirectories.insert(testSrcDir); + } + } + } + + std::vector directories; + for (const std::string& uncheckedDirectory: uncheckedDirectories) + { + FilePath uncheckedDirectoryPath(uncheckedDirectory); + if (uncheckedDirectoryPath.exists()) + { + directories.push_back(uncheckedDirectoryPath); + } + } + + LOG_INFO("Found " + std::to_string(directories.size()) + " of " + std::to_string(uncheckedDirectories.size()) + " directories on system."); + + return directories; + } +} diff --git a/src/lib_java/utility/utilityGradle.h b/src/lib_java/utility/utilityGradle.h new file mode 100644 index 00000000..1b04c8ef --- /dev/null +++ b/src/lib_java/utility/utilityGradle.h @@ -0,0 +1,14 @@ +#ifndef UTILITY_GRADLE_H +#define UTILITY_GRADLE_H + +#include + +class FilePath; + +namespace utility +{ + bool gradleCopyDependencies(const FilePath& projectDirectoryPath, const FilePath& outputDirectoryPath, bool addTestDependencies); + std::vector gradleGetAllSourceDirectories(const FilePath& projectDirectoryPath, bool addTestDirectories); +} + +#endif // UTILITY_GRADLE_H diff --git a/src/lib_java/utility/utilityJava.cpp b/src/lib_java/utility/utilityJava.cpp new file mode 100644 index 00000000..f374320b --- /dev/null +++ b/src/lib_java/utility/utilityJava.cpp @@ -0,0 +1,68 @@ +#include "utility/utilityGradle.h" + +#include "data/parser/java/JavaEnvironment.h" +#include "data/parser/java/JavaEnvironmentFactory.h" +#include "utility/ResourcePaths.h" + +namespace utility +{ + std::vector getRequiredJarNames() + { + std::vector jarNames = { + + "gradle-tooling-api-4.2.jar", + "java-indexer.jar", + "org.eclipse.core.commands-3.8.1.jar", + "org.eclipse.core.contenttype-3.5.100.jar", + "org.eclipse.core.expressions-3.5.100.jar", + "org.eclipse.core.filesystem-1.6.1.jar", + "org.eclipse.core.jobs-3.8.0.jar", + "org.eclipse.core.resources-3.11.1.jar", + "org.eclipse.core.runtime-3.12.0.jar", + "org.eclipse.equinox.app-1.3.400.jar", + "org.eclipse.equinox.common-3.8.0.jar", + "org.eclipse.equinox.preferences-3.6.1.jar", + "org.eclipse.equinox.registry-3.6.100.jar", + "org.eclipse.jdt.core-3.12.3.jar", + "org.eclipse.osgi-3.11.3.jar", + "org.eclipse.text-3.6.0.jar", + "slf4j-api-1.7.10.jar", + "slf4j-simple-1.7.10.jar" + }; + return jarNames; + } + + std::string prepareJavaEnvironment() + { + std::string errorString; + + if (!JavaEnvironmentFactory::getInstance()) + { +#ifdef _WIN32 + const std::string separator = ";"; +#else + const std::string separator = ":"; +#endif + + std::string classPath = ""; + { + const std::vector jarNames = getRequiredJarNames(); + for (size_t i = 0; i < jarNames.size(); i++) + { + if (i != 0) + { + classPath += separator; + } + classPath += ResourcePaths::getJavaPath().str() + "lib/" + jarNames[i]; + } + } + + JavaEnvironmentFactory::createInstance( + classPath, + errorString + ); + } + + return errorString; + } +} diff --git a/src/lib_java/utility/utilityJava.h b/src/lib_java/utility/utilityJava.h new file mode 100644 index 00000000..bea49579 --- /dev/null +++ b/src/lib_java/utility/utilityJava.h @@ -0,0 +1,15 @@ +#ifndef UTILITY_JAVA_H +#define UTILITY_JAVA_H + +#include +#include + +class FilePath; + +namespace utility +{ + std::vector getRequiredJarNames(); + std::string prepareJavaEnvironment(); +} + +#endif // UTILITY_JAVA_H diff --git a/src/test/JavaIndexSampleProjectsTestSuite.h b/src/test/JavaIndexSampleProjectsTestSuite.h index acd6f839..9cad7eda 100644 --- a/src/test/JavaIndexSampleProjectsTestSuite.h +++ b/src/test/JavaIndexSampleProjectsTestSuite.h @@ -12,6 +12,7 @@ #include "utility/file/FileRegister.h" #include "utility/text/TextAccess.h" #include "utility/utility.h" +#include "utility/utilityJava.h" #include "utility/utilityPathDetection.h" #include "utility/utilityString.h" @@ -196,14 +197,14 @@ private: #endif std::string classPath = ""; { - const std::vector jarNames = JavaParser::getRequiredJarNames(); + const std::vector jarNames = utility::getRequiredJarNames(); for (size_t i = 0; i < jarNames.size(); i++) { if (i != 0) { classPath += separator; } - classPath += "../app/data/java/" + jarNames[i]; + classPath += "../app/data/java/lib/" + jarNames[i]; } } diff --git a/src/test/JavaParserTestSuite.h b/src/test/JavaParserTestSuite.h index c3d659a2..c220de57 100644 --- a/src/test/JavaParserTestSuite.h +++ b/src/test/JavaParserTestSuite.h @@ -1,15 +1,16 @@ #include "cxxtest/TestSuite.h" -#include "settings/ApplicationSettings.h" -#include "utility/utilityPathDetection.h" -#include "utility/text/TextAccess.h" -#include "utility/utility.h" - #include "data/parser/java/JavaEnvironmentFactory.h" #include "data/parser/java/JavaParser.h" #include "helper/TestParserClient.h" +#include "settings/ApplicationSettings.h" +#include "utility/utilityPathDetection.h" +#include "utility/text/TextAccess.h" +#include "utility/utility.h" +#include "utility/utilityJava.h" + class JavaParserTestSuite: public CxxTest::TestSuite { public: @@ -1175,14 +1176,14 @@ private: #endif std::string classPath = ""; { - const std::vector jarNames = JavaParser::getRequiredJarNames(); + const std::vector jarNames = utility::getRequiredJarNames(); for (size_t i = 0; i < jarNames.size(); i++) { if (i != 0) { classPath += separator; } - classPath += "../app/data/java/" + jarNames[i]; + classPath += "../app/data/java/lib/" + jarNames[i]; } }