Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
We don’t allow questions seeking recommendations for books, tools, software libraries, and more. You can edit the question so it can be answered with facts and citations.
Closed 4 years ago.
Improve this question
Problem:
I have a large, old, disorganized java project from the early 2000s.
The project is built using ant.
There is no dependency management, everything is handled by storing jars locally.
The compile and package targets for the build script are very broad, and mostly just compile and subsequently package the entire project, shuffling environment specific properties files around as needed.
At some point during the lifespan of the project, a few separate build targets were introduced, to enable a web interface for admin tooling and the like.
However, because there is no dependency management, and because the buildscript isn't very selective, the current process is packaging up the entire web application and deploying it along with the admin tools, with a very minimal list of differences between the two.
I am currently embarking on attempting to bring sanity to the codebase by deprecating and re-factoring the ant buildfiles and introducing build/deployment automation by way of CI tooling.
As a part of the next phase of this effort, I would like to attempt to refactor the project structure and the buildfiles to only package what it needs to package in the war files for the admin tools and production web-application, respectively, and hopefully, only compile one pass instead of several.
To solve this problem it seems likely that I will need to build a list of dependencies for a given JSP, or at least a list of java classes. Manually doing legwork to track some stuff down is hardly beneath me, but the scope of the project is large enough that without some automated assistance I have no hope of ever completing the task in a reasonable timeframe.
I have yet to find a solution to this that doesn't involve a hefty software license or a project that is already using Maven.
Given that Eclipse can take an arbitrary method from an arbitrary file of source in this project and find me the resource on the file-system that corresponds, it seems as though this must not be an unsolvable engineering quandary -
Does there exist a free (as in beer, ideally also as in software) solution to generating a dependency graph (or similar) for a project like this?
Failing that, can the good citizens of stack overflow suggest a different approach to my problem I may not have considered?
I see that this question is considered a duplicate.
In hopes of boosting someone's future google search results:
jdeps will recursively print dependencies for a given class name, class file, or jar to stdout, is probably the least cost solution for solving this exact problem, and comes pre-packaged with JDK 8 and above.
I found that buried 10 answers deep on a 4 year old question that was asked prior to the existence of the utility in question, on an answer that received 0 upvotes, so, I feel re-posting it here may be of potential value for future users of the site.
Related
Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
We don’t allow questions seeking recommendations for books, tools, software libraries, and more. You can edit the question so it can be answered with facts and citations.
Closed 9 months ago.
The community reviewed whether to reopen this question 9 months ago and left it closed:
Opinion-based Update the question so it can be answered with facts and citations by editing this post.
Improve this question
Before starting on a new Java Open Source Framework (e.g. ProjectReactor) or a including a new Open Source Library (e.g. Jackson), I would like to know how popular and stable these dependencies are. In particular I would like to know how many times have these been downloaded. With many maven repositories (Nexus, Artifactory) in play, is there a way to get this information? E.g. if I go to maven central and search for these dependencies, I don't see #downloads?
With JavaScript libraries, this is so much easier. All I need is to go to https://www.npmjs.com and search for the package. It shows the #downloads right there.
If there is no easy way to get #downloads, what are the possible metrics by which I can assess whether a Java library is suitable to use?
Edit:
Some people suggested to use "Usages" in the maven central. But that is the count of how many times this dependency has been used by other maven projects in the maven central. IMHO that doesn't always give a good indication about how many times that library was used in enterprise or other non-open-source projects. Why does maven central not expose #download for everyone? Or maybe there is a way to get this information that I don't know of.
mvnrepository.com has the number of usages by other projects.
e.g. for Hamcrest
Used By 7,059 artifacts
Careful, this website isn't affiliated with Apache. I'm not sure how they get those stats but they probably build the graph themselves.
This blog post states that individual project owners can see download statistics, but I would infer from that that it's not public information. The post is 12 years old though so it may have changed since then.
Of course, there's always number of GitHub stars, which is a metric that's applicable for any language.
Closed. This question is opinion-based. It is not currently accepting answers.
Want to improve this question? Update the question so it can be answered with facts and citations by editing this post.
Closed 2 years ago.
Improve this question
I don't get why would anyone want to use tools like Gradle or Maven, I mean what do they even do? I tried to understand and use them but that got me no where they just unnecessarily complicate things and create a lot of what seems to be absolutely useless files.
So, why bother at all and use these tools and what are they good for?
First of all Gradle and Maven are great tools for managing your dependencies and also giving you the option to simplify your build process. Without these tools you would have to manually download *.jar files. And copy them somewhere in your project folder.
And if you want to update, you would have to open the website again, download it and replace your existing JAR.
Quite often JARs themself have dependencies, so you would have to manually download them as well.
I can understand that the setup of Maven / Gradle at first can be time consuming, but it's usually worth the time since you just have to declare: I need package com.example.package in version 1.2.3 and you just have to run a simple install command and they will take care of downloading everything needed.
Secondly, you can declare commands describing how to run your tests and they will usually take care of your tests not getting mixed up with your final and compiled package.
Also this is good for collaboration because once this config is shared, every developer can use it without going much of a hassle of configuring your development environment. Another good point is that it is independent of any IDE, so your project is not an IntelliJ or Eclipse project and everyone can use the IDE/editor they prefer.
Basically the idea is: You configure it once and then you can enjoy the automatism.
However, if your project is really small and relying on only a few dependencies you might not need it.
Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
We don’t allow questions seeking recommendations for books, tools, software libraries, and more. You can edit the question so it can be answered with facts and citations.
Closed 4 years ago.
Improve this question
I come from a web-development background and have frequently worked on projects that use Lerna for handling multiple packages from the same repository in JavaScript. As it stands now, I need to recreate some of those projects in Java, and need to know how to do it without using Lerna, and using Gradle as our build tool.
My questions are about how to handle a large repository with multiple packages in Java:
Edit: Rewording the question to fit in the guidelines. Keeping the old questions below in strike through so old answers make more sense.
Do I need to use a separate tool to help manage packages in Java like Lerna does for JavaScript, or can a build tool such as Maven or Gradle handle that on its own.
If two teams are using different build tools, is it more prone to cause problems for their various contributions?
Is maintaining multiple Java packages within one repository viable in the first place?
Are there any packages or plugins that already do this in Java? (I was unable to find any.)
Will solutions likely cause problems between teams using different build tools for their various contributions? (ex: Maven and Gradle)
Is maintaining multiple Java packages within one repository viable in the first place?
Is there anything I am fundamentally failing to understand while asking this? Am I headed in the wrong direction for finding a solution?
At this point in time, the de-facto standard for Java project management seems to be a combination of gradle and maven (via a gradle plugin).
The combination of these two eliminates the need for tooling such as Lerna, as they allow local dependencies to be configured out of the box.
After setting up a multi-project build, you can add sibling projects as dependencies like so:
dependencies {
compile project(':sibling')
}
If you use an IDE such as Intellij IDEA for instance which supports gradle, it will create the initial directory structure for you when you create a gradle project, and configure new modules that you create via its UI. It might be a good idea to play with this for a little bit in order to get a grasp of how it's all wired up.
Java handles packages on the language level very well. I don't understand the question. You can create different packages/modules/etc. in any project. For build management with dependencies use Maven or Gradle.
Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
We don’t allow questions seeking recommendations for books, tools, software libraries, and more. You can edit the question so it can be answered with facts and citations.
Closed 7 years ago.
Improve this question
I am looking for a tool which verifies that a set of java source files (not the byte code) follows a set of predefined rules.
For example, if we have a predefined rule which says any method contains an assertion, the method name must have the suffix "xxxTest". In order to keep the code clean, all the developers must follow these rules/conventions. Of course code reviewing would solve this problem however there should be a way to automate these simple code style checking.
In addition, the developer should be able to run this tool locally on his change-set before committing.
To solve this problem, I started to write my own verifier using the javaparser which will be executed using a gradle task. However in order to avoid re-inventing the wheel, I was wondering if there are existing tools which allows me to do this or even close (may be I can contribute to it)!
UPDATE:
I am aware of CheckStyle and Sonar for static analysis. However I need to run this tool on the CI (ex, Jenkins) as part of the build. So the build should fail if the convention is not applied.
You can test JArchitect and its powerful query language CQLinq.
For your specific need you can execute the folowing query
You can easily build this tool combined JavaParser and java-symbol-solver. The first one produces an AST of your source code and with the second one you can solve symbols (for example finding all the ancestors of a given class).
If your rules are simple enough you could probably get away just using JavaParser. That would be nice because JavaParser has very few dependencies and it is very mature and established.
Use a tool like Checkstyle.
It either allows you to configure a rule-set for your styleguide or you can write an extension.
There is also extensive support to integrate it into IDEs and build process.
Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
We don’t allow questions seeking recommendations for books, tools, software libraries, and more. You can edit the question so it can be answered with facts and citations.
Closed 5 years ago.
Improve this question
I've been trying to find a Java linter capable of running on the CLI that is separate from Eclipse that I can call as a commit hook for git or from our automated build script. Does such a thing exist?
Ideally it needs to check for unused imports and variables, that style guidelines are followed, exceptions are used properly, etc. Though some subset of those features would be better that what we have now - nothing!
SpotBugs (earlier Findbugs) for finding existing bugs. VERY GOOD!
PMD for finding patterns that can lead to bugs (e.g. unused variables)
Checkstyle to enforce coding standards and conventions (e.g. whitespace, Javadoc)
Error Prone hooks right into your application's compile step
clang-format supports java and may be available on your system already
All these tools have some overlapping rules. There are many other similar tools, but these are the most popular and supported.
Also, check out Sonar, which combines many of the other tools and provides a nice view for it too.
rules from Checkstyle, FindBugs, PMD, Clirr, fb-contrib.
Not sure exactly how to add it to a post-commit hook, but http://docs.codehaus.org/display/SONAR/Analyzing+with+Maven might be a good starting point (especially if you're using maven).
Maybe even consider using one of the approaches listed in http://docs.codehaus.org/display/SONAR/Continuous+Integration since it seems that you might be trying to look for better tooling for your whole team ("Though some subset of those features would be better that what we have now - nothing!"
This is EXACTLY what I am working on: a tool CLI-friendly to be used to check the quality of Java code. It has also an interactive modality. You can run single queries (to check for single warnings) or all queries together.
The tools is in its early stage but I am working on it almost every day. It is available here:
https://github.com/ftomassetti/effectivejava
Please let me know what do you think about it and feel free to ask questions.