use outside repository in intellij-idea - intellij-idea

I'm wondering if it's possible to use a folder/package/repository in multiple project at the same time without simply copy paste it.
For example :
Project 1 has Package A & B
Project 2 has Package A & C
Project 3 has Package A & D
Can I take the A Package outside of my 3 projects and create a link to this folder inside my 3 packages like a library & look like this
Folder A
Project 1 has Package B and a link to A
Project 2 has Package C and a link to A
Project 3 has Package D and a link to A
So my Package B,C & D that are using objects from A without issue but If I want to make a change on A in don't have to copy/paste or push/pull on the all the other projects that use A

You are asking for code-reuse. The code you put into a dedicated package is some kind of library that you'd like to use in different projects. As indicated in #duffymo's comment you should split this code you want to re-use into a dedicated project, and include this project as a library. For that you can use systems like Maven, or just create a JAR file and manually add it to the classpath.
In other words, before you find a (crude) way to make things work, please take a step back and consider a "good" solution.

Related

Java - project dependency and current\relative working directory

I have two project where one is depended on the other, i.e. project A depends on project B, and the two projects reside in different directories.
In the independent project, i.e. project B, there is a class which holds a code that tries to access directories and files with respect to independent project directory. Since the depended project, i.e. project A, instantiate an object from the independent project, when the object execute System.getProperty("user.dir") it returns the execution directory, i.e. the directory of the dependent project; the same holds for new File(".").getAbsolutePath().
I would like to solve the issue in generic way, i.e. I wish to avoid the need to pass as an argument the path, rather, I wish the use relative directories programatically.
Any guidance\clues?
P.S. not sure if it is relevant, but I am using Eclipse as my IDE.
UPDATE
This should hold...
final String clsName = getClass().getName() + ".class";
System.out.println(getClass().getResource(clsName));
I'd use the class-loader instead of using paths directly. In eclipse, and in an deployment situation both projects resources should be in the classpath.
ProjectA
example.png
ProjectB
foo.txt
Something like this should be able to load a resource from either project A or B.
URL url = getClass().getResource("/example.png"); // get URL
InputStream stream = getClass().getResource("/foo.txt").openStream(); // open a stream

msbuild & wix - multiple installers?

I'm working with an application framework that has multiple products. It has a single installer and plugins are included/excluded based on build-server configuration.
I would like to change my build process so that multiple msi files are produced from a single build (one for each product, based on the framework). Is that possible ?
I was strugling the same problem.
I had 2 different builds from 1 wxs file, and for 4 configurations from 1 build. e.g. build=server\client,conf=debug\release,platf=x86\x64.
My issue: to cerate a solution with projects, numbered by the variable of build (in my case there was 2 projects, for server and for client separate). every project needs to be based on one wxs file, and build properties need to be different. I used the standard env variables on Configuration and Platform, and used my own variable Build. I've done in that way. If u need more biulds, create more projects, use more variables...
P.S. If u find the better way, plz contact me.

Adding specific references from a NuGet Package

I have created a package with a bunch of assemblies that we will provide to our users. I want our users to be able to pick and add only references they need from within the package to a project. The user should be able to add this package at a solution level and then pick the references to be added to each project from the package added. Is this possible with NuGet?
Example:
MyPackage - contain foo.dll, bar.dll, bla.dll
User installs package "MyPackage" to solution
Project 1 - select and add reference foo.dll, bar.dll
Project 2 - select and add reference bla.dll
Currently, every reference of the package is added to every project. This is not the desired setup. I want only the selected references added. Is there a way to do this with Nuget?
NuGet is not designed to work this way. Packages are whole delivery units. Our recommendation in this scenario would be to package the individual assemblies according to how you want them individually installable.

TFS 2010: Perform different builds and command line task in sequence?

my build process with TFS 2010 should perform different task one after the other like:
Build 1st project in solution
Execute MSBuild via command line (to publish the project)
Execute a 3rd party tool via command line (to obfuscate the binaries)
Build a 2nd project in the solution (an InstallShield project)
How can I achieve this? I can define several project in the Build Definition but how can I invoke several command line task between these build steps? And the MSBuildArguments in the Build Definition: Are these arguments for every msbuild call for each project/solution?
Thanks
Konrad
At first, you need to add in your build definition the distinct *.*proj instead of one big *.sln - or (even better) construct more than one *.sln & order them to get build in the build definition. So you could organize a Project1.sln, Project2.sln etc that are only used from the Build.
In addition to that, you would have to make changes in the build process template to get this.By default you get something like that, that executes each set project/solution within a bigger foreach:
A good way would be to enhance this as a sequence, where all your custom action are set as InvokeProcess activities:
Obviously, you would have to insert here a flow control, so that Publish & Dotfuscator execute the first time (where Project1.sln gets build), while ISDEV executes the second time (where Project2.sln gets build). In the sample below I used a switch & packed Publish & Dotfuscator in a new Sequence.
Finally, you would have to have a counter of some sort. The most immediate option is to set a new Int32 Variable with default == 1 and increase it by hand during execution. In the sample below this is done in the lower Assign:
This final override of Complie the Project, along with a changed Build Definition should get what you 're after.
The team build definition takes a list of sln's and msbuild project files. You can put simply split your InstallShield project out into it's own solution ( most developers won't have a copy of InstallShield anyways likely ) and write an msbuild targets file for steps 2 and 3. Then just tell your build definition to build solution 1, the targets file and solution 2.
You could also choose to put the stuff in the targets file in a postbuild event for one of the projects in solution 1.
I wouldn't do this in workflow.

Using multiple Source control folders in a single build definition TFS 2010

In the Workspace tab
Source Control Folder: I am picking only two locations from my entire team project. I do not want to pick the entire team project because it has 20 projects.
I only need two project locations for the build.
$/TeamProject/ABCProj.SVC
$/TeamProject/ABCProj.UI
Build Agent Folder, If i specify the same $(SourceDir) for both the Source control folder locations($/TeamProject/ABCProj.SVC, $/TeamProject/ABCProj.UI)
above, I am unable to save the build definition.
I am getting an error when saving the Build definition
"$(SourceDir) can only be mapped one time in a given workspace"
Can any one please suggest a solution.
You'll have to map your version control folders to different source directories, for example:
$/TeamProject/ABCProj.SVC -> $(SourceDir)/ABCProj.SVC
$/TeamProject/ABCProj.UI -> $(SourceDir)/ABCProj.UI
Alternatively, you can just map $/TeamProject to $(SourceDir) and cloak all subprojects you don't want to get the sources for.