Can I run sbt new with a local template (not GitHub)? - scala

I work in a secure environment where developers are not allowed to git-clone from GitHub, or any other external repos.
I was able to download a g8 template (play-scala-seed) from GitHub as a zip file and I've unzipped it to a local folder. Can I use that local directory instead of a git repo?
My first attempt at this failed:
> dir .\play-scala-seed
Volume in drive C is OSDisk
Volume Serial Number is A074-A016
Directory of C:\workspace\play-scala-seed
03/22/2018 11:03 AM <DIR> .
03/22/2018 11:03 AM <DIR> ..
03/22/2018 11:01 AM <DIR> project
03/22/2018 10:57 AM <DIR> src
03/22/2018 11:03 AM <DIR> target
03/22/2018 10:57 AM 70 .gitignore
03/22/2018 10:57 AM 509 .travis.yml
03/22/2018 10:57 AM 453 build.sbt
03/22/2018 10:57 AM 439 LICENSE
03/22/2018 10:57 AM 1,166 README.md
5 File(s) 2,637 bytes
5 Dir(s) 220,172,980,224 bytes free
Even though I'm sure the template exists and in in a directory called "play-scala-seed", it's not accepted by the SBT new command:
> sbt new .\play-scala-seed
Template not found for: .\play-scala-seed
So how can I make sbt new use a local directory for a g8 template?
I'm running Windows (if that matters!)

When you use giter8 directly you just need to refer to your local template with the file:// prefix:
g8 file://play-scala-seed
As mentioned by #volia17, you can find it in the giter8 documentation: Testing templates locally.
But when you use sbt new, you need you template name (folder) to end with .g8. sbt can accept different types of templates and this way it knows that this is a giter8 template. So you can rename your template folder to play-scala-seed.g8:
sbt new file://play-scala-seed.g8
P.S. Using giter8 directly is much faster, because sbt new takes time to start (it loads global sbt plugins every time).

Related

How to install the Powershell Module MicrosoftPowerBIMgmt with offline?

I want to install the Powershell Module MicrosoftPowerBIMgmt with below command line:
Install-Module -Name MicrosoftPowerBIMgmt
However, the script is executed, but it may be limited by my network, the command line has been stuck in downloading the microsoftpowerbimgmt.profile file, and the progress is 0.
It seems that I can't use the command to complete the download. So I wonder if there is any other scheme to install this module?
Any advice is greatly appreciated.
By the way, my system is windows 10.
I decided to run the install you gave and checking the docs it shows that one of the commands is Get-PowerBIWorkspace. With that in mind, I decided to try this trick:
(Get-Command Get-PowerBIWorkspace).dll
Which gave this result:
C:\Program Files\WindowsPowerShell\Modules\MicrosoftPowerBIMgmt.Workspaces\1.2.1093\lib\netstandard2.0\Microsoft.PowerBI.Commands.Workspaces.dll
This told me to look in C:\Program Files\WindowsPowerShell\Modules\ for the module. Checking that location, I found the following folders were added:
09/17/2022 08:52 PM <DIR> MicrosoftPowerBIMgmt.Profile
09/17/2022 08:52 PM <DIR> MicrosoftPowerBIMgmt.Admin
09/17/2022 08:53 PM <DIR> MicrosoftPowerBIMgmt.Capacities
09/17/2022 08:53 PM <DIR> MicrosoftPowerBIMgmt.Data
09/17/2022 08:53 PM <DIR> MicrosoftPowerBIMgmt.Reports
09/17/2022 08:53 PM <DIR> MicrosoftPowerBIMgmt.Workspaces
09/17/2022 08:53 PM <DIR> MicrosoftPowerBIMgmt
Checking the folders show that the data is around 50 MB. Modules are usually entirely contained in the module folder with no external changes made to the system (such as registry changes, or other files placed elsewhere). Since this is Microsoft, that might not be the case.
If I was in your shoes, I would probably use xcopy, or use a copy method you are familiar with, to copy these folders to the module folder on the system where you want the MicrosoftPowerBIMgmt module installed.
If these folders truly contain everything that makes the modules work, and you copy them to the module folder that is normally found in $Env:PSModulePath, then you should be able to successfully run your script.

Why does wheel installation put shared objects in site-packages folder instead of package folder?

I've a python binary distribution [wheel] created via
python setup.py bdist_wheel
The wheel looks as follows
unzip -l dist/<package-name>-1.0.0-cp36-cp36m-linux_x86_64.whl
Archive: dist/<package-name>-1.0.0-cp36-cp36m-linux_x86_64.whl
Length Date Time Name
--------- ---------- ----- ----
2996432 2021-01-07 21:47 lib<xyz>.so
7821608 2021-01-07 21:48 lib<abc>.so
4414000 2021-01-07 21:48 <module>.cpython-36m-x86_64-linux-gnu.so
581 2021-01-07 20:05 <package-name>/__init__.py
636 2021-01-07 20:05 <package-name>/version.py
Upon installing the wheel, why do the *.so files get installed in site-package folder?
/opt/conda/lib/python3.6/site-packages/
While the other files get installed inside
/opt/conda/lib/python3.6/site-packages/<package-name>
Wheel is essentially a compressed form of package distribution. Hence it can be unzipped [like a zip file]. The entire directory structure inside the zipped wheel gets copied as is in the site-packages folder. This is the reason why
the shared libraries are stored inside site-packages and
rest of the package files [e.g. __init__.py are stored inside the package subfolder of the site-packages].
wheel gets unzipped in the site-packages folder essentially.

Sbt Assembly Include Conf Files inside the JAR

I'm using the sbt assembly plugin to create a JAR file and I have the following folder structure:
src
-main
-scala
-resources
-application.conf
Now, when I do
sbt clean assembly
I can see in the produced Jar file that the application.conf file is included. I have two questions:
Why is the inluded application.conf not inside the resources folder in the final Jar, but rather it is on the top level as shown below (the contents of the Jar)
drwxr-xr-x 3 joe staff 102B May 16 21:03 com/
-rw-r--r-- 1 joe staff 187B Mar 4 2016 library.properties
drwxr-xr-x 3 joe staff 102B May 16 21:03 typesafe/
How can I load this application.conf by setting a System.property? For example., I want to be able to load the application.conf by setting a System property like:
System.setProperty("config.file", "application.default.conf")
With this I could control from outside (while running the jar file), which config file to use. When I tried this, I got a NulPointerException:
val someConfigFile = Option(System.getProperty("config.file"))
ConfigFactory.parseURL(getClass.getResource(someConfigFile.get)) // NullPointerException happens here...
The answer to your first question is that the resources folder is like a src folder and so the content is copied, not the folder itself.
Here is what I needed to do so that the config file inside the jar could be loaded based on what I specify from outside!
val is = new InputStreamReader(getClass.getResourceAsStream(s"/$cfgFile"))
ConfigFactory.parseReader(is).resolve()

Perl .bundle files

On my OSX machine, deep within a jungle of lib directories, I was able to see this
-r-xr-xr-x 1 user users 45700 Feb 01 1:47 LibXSLT.bundle*
1) What are these .bundle files ?
2) Who creates them ? CPAN modules ?
3) If so, then can we control its generation via some Makefile artifact ?

Using tycho to materalize products results in missing .eclipseproduct file

I'm an Eclipse RCP developer who is using the tycho-p2-director-plugin to build an application.
The good news is that the assembly is generated and can be run successfully. The bad news is that one of the artifacts that I expect to be generated (the .eclipseproduct file) is not being generated.
I have tried to figure out what the deal with this file is - not only that it does not generate through Tycho, but it also does not generate when I use the Eclipse product export wizard. Based upon the documentation I found here, I expect that it would be.
I'm basically wondering about two things at this point, because I can't find any good documentation on where that .eclipseproduct file is supposed to come from / at what point it is supposed to get generated.
If it is generated during the tycho maven lifecycle, then I would expect to find the file under my target folder - which it is not. I have not found a way to have tycho statically include configuration files (besides config.ini), otherwise I would have used that method to attach a static .eclipseproduct file to the root of my install directory.
If this is something that should be generated by an installer, what is the mechanism using p2 such that you can accomplish this? I've considered including the .eclipseproduct file in my main P2 IU, but I'm unclear on whether that file would actually be copied into the root directory and how exactly that would be accomplished.
As you can tell, I haven't been able to find very much direction as to how getting this file included with my build would be accomplished. Any pointers in the right direction would be helpful. I can also include my product configuration files if necessary.
This should be a comment as it's only a partial answer, but it's too long.
It seems that .eclipseproduct is a file generated at build time, and not created by p2 at provisioning time:
To find this I provisioned a copy of Eclipse 4.2 using p2 director (for instructions I used the Installing a Complete product section of this page, updating the repository to the 4.2 site instead of using the 3.6 ones, and changed from using Windows paths to ones more suited for my mac).
I noticed on the file listing that the .eclipseproduct file seemed to be an unzipped artifact instead of a generated one since the time stamp was different:
$ ls -lA
total 304
-rw-r--r-- 1 myself group 60 Sep 14 18:13 .eclipseproduct
drwxr-xr-x 3 myself group 102 Nov 2 14:49 Eclipse.app
-rw-r--r-- 1 myself group 112366 Nov 2 14:49 artifacts.xml
...
This got me looking through the various caches in the ./p2 directory, and I found that there is an Installable Unit org.eclipse.platform_root which is a zip file containing licensing and the .eclipseproduct file...
:p2 $ zipinfo org.eclipse.equinox.p2.core/cache/binary/org.eclipse.platform_root_*
Archive: org.eclipse.equinox.p2.core/cache/binary/org.eclipse.platform_root_4.2.1.v20120814-120134-9JF7BHVGFyMveli1uX6aTH0q-eAap6PAgOP5mO 38125 5
-rw---- 2.0 fat 0 bl defN 14-Sep-12 18:13 readme/
-rw---- 2.0 fat 104173 bl defN 14-Sep-12 18:13 readme/readme_eclipse.html
-rw---- 2.0 fat 9051 bl defN 14-Sep-12 18:13 notice.html
-rw---- 2.0 fat 60 bl defN 14-Sep-12 18:13 .eclipseproduct
-rw---- 2.0 fat 16536 bl defN 14-Sep-12 18:13 epl-v10.html
5 files, 129820 bytes uncompressed, 37501 bytes compressed: 71.1%
I found the P2 IU information in the content.xml files found in the org.eclipse.equinox.p2.repository/cache/content*.jar files:
...
<unit id='org.eclipse.platform_root' version='4.2.1.v20120814-120134-9JF7BHVGFyMveli1uX6aTH0q-eAap6PAgOP5mO'>
<provides size='1'>
<provided namespace='org.eclipse.equinox.p2.iu' name='org.eclipse.platform_root' version='4.2.1.v20120814-120134-9JF7BHVGFyMveli1uX6aTH0q-eAap6PAgOP5mO'/>
</provides>
<artifacts size='1'>
<artifact classifier='binary' id='org.eclipse.platform_root' version='4.2.1.v20120814-120134-9JF7BHVGFyMveli1uX6aTH0q-eAap6PAgOP5mO'/>
</artifacts>
<touchpoint id='org.eclipse.equinox.p2.native' version='1.0.0'/>
<touchpointData size='1'>
<instructions size='2'>
<instruction key='install'>
unzip(source:#artifact, target:${installFolder});
</instruction>
<instruction key='uninstall'>
cleanupzip(source:#artifact, target:${installFolder});
</instruction>
</instructions>
</touchpointData>
</unit>
...
In short: when this IU is installed (as required by org.eclipse.platform.feature.group), p2 simply unzips the artifact with .eclipseproduct to the install folder. No transformations required. Therefore it must be generated before install time.
Edit: I also found it in the Eclipse Git Repositories but haven't figured out if this is the one that is turned into the IU mentioned above or not...