Mill Build Tool - Install dependencies without compiling source code - java

I'm using the Mill Build Tool for a Scala project, which uses a build.sc file to list specific dependencies for different modules within the project. Now, I'm trying to dockerize the project and would like to install the dependencies in the image before having to copy over the entire repository. I want to avoid this, so that the dependencies don't have to be installed every time I make a small change in the source code. Is there any simple way of doing this? Thanks!
Here's a similar post for sbt: sbt only fetch dependencies

Updated answer:
Since mill 0.9.3 there is support to easily prepare offline work.
See pull request #951 for details.
In short, you can use the prepareOffline target to fetch dependencies in advance.
mill __.prepareOffline
Original answer:
There is currently no easy and straight forward way of doing this. Although you can force the resolution of all compile dependencies by running mill __.compileClasspath, but this will also trigger the compilation of all inter-module dependencies.
As a work around you could try to generate IntelliJ IDEA project files, which will also trigger dependency resolution. Afterwards you can delete the generated directories (.idea/ and .idea_modules/).
Technically, it is quite simple to introduce a new fetchIvyDeps target for exactly that purpose, but it's not there yet. You might want to open a feature request or create a pull request.

Related

Android studio can't edit library

I downloaded this library and i extracted the rar into my app\libs folder.
Then I added compile 'com.github.lzyzsd:circleprogress:1.1.0#aar' to my build gradle as it says, and clicked on sync.
Then I noticed that the max is set to 100 (in file DonutProgress.java).
I changed it to 5, clicked on sync again but nothing changed.
After few hours of trying I decided to completely remove the extracted folder from my app\libs and sync again to see what happens.
Surprisingly, everything was still working like library was still there.
Can someone explain me what's happening here, I have to edit it but it seems whatever I do to the library doesn't affect the app.
It seems like it's using another library from totally different folder, I don't know, I tried searching for DonutProgress on my computer but didn't find anything that seems useful.
Please help.
When you add compile 'com.github.lzyzsd:circleprogress:1.1.0#aar' to your build.gradle dependencies, you are telling Gradle to go fetch this library from a repository when you build.
For most Android apps, this means that when you do a build, Gradle will go and download the library (in this case a .aar) from jCenter. This is good because it means you no longer need to manage the JARs (or other library files) yourself.
If you want to use a custom version of that library, then you should not add that dependency to your Gradle build script. Instead you should add it as either a module or a local dependency (e.g. compile files('libs/custom_library_name.aar')).

Analyzing library dependencies for .Net / NuGet projects with SonarQube Plugin

We are analyzing several Projects in SonarQube -> Java and also .Net Projects.
For Java / Maven Projects its no Problem to see the Library dependencies -> Which component uses which Library. There is even a dependency browser built-in in the Sonar core.
For .Net Projects we use NuGet for the dependency Management. In Sonar its not possible to see which Component uses which Library with the specific version for .Net / NuGet Projects. Now we want to know which Library is used in which Component and vice versa. And that's why I'm writing a plugin that shows me the the NuGet dependencies.
There are two possibilities:
1. Solution: The easy way
I write a Plugin that parses the "repositories.config" and the appropriate "packages.config" Files, persists this information into the database and then show them in a widget.
2. Solution: The elegant way
I write a plugin which reads the NuGet information from the "repositories.config" and the appropriate "packages.config" files and perstist this information the same way like the maven information is perstisted too in the database. Then also the built-in dependency browser would find the NuGet dependencies.
So:
A question for Solution 1:
What would be the best way to persist the dependency information? A String Measure for each project with a JSON containing the dependency information?
A question for Solution 2: (And this is my main question here)
Do you know how / where this data is persisted in the Sonar database for maven projects? It would take me a lot of time trying to reenigneer the whole sonar source code. Maybe someone has an idea how i can find this information faster or maybe you have even other ideas to solve my problem.
The goal would also be to share this plugin to the community.
Thank you!
Regards
Cédric

How to get all transitive dependencies programatically

I have seen many posts on this, but let me say that i am not trying to write a plugin.
I am making a project analyser which needs to find out resolved dependencies with their path.
Given a pom.xml(in a project) i want to find out all the dependencies(transitive too) with their paths and if possible the missing dependencies too.
Getting a version independent solution would be bonus.
PS: Every answer is suggesting to use exec to run the command on cli, i am already using this and want to find a better approach of doing this.
You could use the maven dependency plugin. The two that I have used and found very helpful I've mentioned below:
dependency:tree
Displays a tree structure of the entire dependencies both direct and transitive used. Be sure to use the verbose mode.
Link
dependency:list
Displays all dependencies used in a project in a list fashion. I personally do not find this that handy at times when I need to know what are transitives and which are direct for licensing purpose. But it has its place when you just need to know what you are using or detecting duplicate libraries with different versions.
Link
In addition there is also analyze, when reading the documentation it seems quite handy but I would need to try this out and I will.
dependency:analyze
Use mvn dependency:tree. For programmatic access simply use the java Process api.
http://maven.apache.org/plugins/maven-dependency-plugin/tree-mojo.html
Java Process with Input/Output Stream
Also Maven plugins are simple java classes. You can download the dependency:tree plugin's code and use it/modify it to your taste.

Info about version dependancies of enterprise java libraries

I am new to enterprise application developement and trying to create a REST server with Spring REST, JPA taking to mySQL database and Javascript on the client side. As I see loads of opensource libraries doing specific task, I started off with using 'maven project' with different 'arch type' (which is nothing but predefined POM with relevent libraries as I understand) provided by Eclipse. But I often run into version mismatch issues, in many cases found specific solution to that perticular libraries in StackOverflow or other sites.
Hence I started looking for a information these version dependancies such as, this version of JPA works with that version of Hibernate library and so on. I checked maven repository of major libraries, I did not find such information so far.
My queries are:
Where can I find these information about the versions dependancies?
Are these pre defined POM in eclipse reliable? Who owns them, where can I get last modified dates on these maven 'arch types'? (I find the ones I choose having fairly old version of libraries).
If I have to start off on my own creating a Maven dependacies, where will I get information about what are the dependent libraries, for example, if I need spring MVC, for sure it needs java servlet library. I am worried becuase the maven 'spring-mvc-jap' arch type whooping 50 libaries as dependancies.(Coming from embeded domain, I find to too hard to digest :D). So not sure if it is the right way.
Please correct if I am missing anything in my understanding.
You can find this information, if you are using maven and some IDE you can go to the dependancy and make click un > and this will show the librarys used for this dependancy or if you want to use the console you have http://maven.apache.org/plugins/maven-dependency-plugin/examples/resolving-conflicts-using-the-dependency-tree.html this will show the same that the IDE.
After normally in the documentation of the library used, you can find some doc about the dependancy about this.
Other solution is get the .jar and use 7zip to see the POM and know the dependancy used.
And for finish my answer if the IDE tell you that you dont have x dependancy normally you have to add this because any of the other dependancy used have it (they used only for the compiling task), but sometime somes projet change a lots of code between the version .a to .b so you will have some problem using the version .b, at this moment i didnt find one good and easy way to fix this, only using the way that i told you (only if i found some problem in the compilation)
3> I am not sure how it works in eclipse but in IntelliJ IDEA when you start using some class without proper dependency IDEA suggest you to add proper dependency automatically. The same approach should be in eclipse.

Using multiple projects in Eclipse with Play framework 2.1.x

I have an existing project in Eclipse (let's call it "NotPlayProj") which has a lot of java code still under development. I made a new eclipse project using play 2.1.0 (let's call it "PlayProj"). My goal is to use code from NotPlayProj in PlayProj and have both Eclipse and the Play compiler notice changes in either project.
If I go into the properties for PlayProj and add NotPlayProj via the Project tab, then method completion and inclusion works within eclipse, but the Play compile doesn't see the result. I've looked at Play modules and those don't seem to do what I want.
Is there any way to do this, ideally without modifying the NotPlayProj?
Edit ---
I've looked at http://www.playframework.com/documentation/2.0/SBTDependencies which shows how to export a jar from NotPlayProj into the PlayProj/lib directory, but this requires a manual export for each time NotPlayProject changes. I suspect that the Managed dependency section is supposed to cover this, but I've never used SBT before and am therefore probably missing something basic.
What you need is continuous integration.
Have a look at Jenkins: http://jenkins-ci.org/
You should setup a Continuous integration server and customize the builds you need.
Example:
You have your PlayProj running in some server, it needs to be able to use some of the latest classes from the other project called NoPlayProj.
Rebuild is a must, things such as downtime zero are difficult to achieve(At least I don't think this is what you are asking for either).
The steps you need to automate with Jenkins are:
1 - Build and deploy the latest version of NoPlayProj which is located in some repositorium
2 - Build and deploy the latest version of PlayProj which is located in some repositorium and also is contains your last commit where you updated the dependency that exist with NoPlayProj
A not very complex build and deployment instructions can be configured in Jenkins. This should speed you up a bit.
Also another suggestion would be to mavenize both projects if possible, this will help you manage the dependencies easier.
Just to clarify one thing, you said: My goal is to use code from NotPlayProj in PlayProj and have both Eclipse and the Play compiler notice changes in either project.
Well the order in which you execute the builds will be dependent in what you want to do as long as you update the dependency before you commit the code.
One last thing, if you don't want to deploy you don't have to do so you can create the Jenkins jobs, in such ways that you only build. With Jenkins you can do a lot of stuff, also you could execute some help scripts of your own that can provide you additional functionality.
I hope this was useful.
To let Eclipse see changes in NotPlayProj when working with PlayProj, it's enough to change configuration of PlayProj. Properties-> Java build path -> Projects -> Add NotPlayProj as dependency.
There is no straightforward way to let Play compiler handle dependencies, until you package it as jar. Consider configuration of simple ant task (External tools configuration -> Ant build ), which will copy your jar file. Task can be triggered by pressing the key or button.
With managed dependencies, every time you made change in NotPlayProj, you have to manually rebuild it. To let Ivy/Maven put dependency in your local repository. After that Play will take latest snapshot from your local repository.
Both approaches requires some efforts. Maybe you can take a look at Python scripts, which run Play, maybe it's enough to extend classpath with NotPlayProj when executing play start
Though I've never used the play framework, I would think that there is a format that both the play framework and eclipse understand and that is Maven. Look at http://www.playframework.com/modules/maven-head/home

Categories

Resources