Nuke Build Pack 'conflicting assets with same path' exception - blazor-webassembly

this is my first question. I'm new to Nuke and am using it to automate my solution build. I'm packing my solution and getting an error 1 of my 3 projects. I'm trying to pack the nuget packages of my WebAssembly project after compiling in the Build.cs file using:
[Parameter("Configuration to build - Default is 'Debug' (local) or 'Release' (server)")]
readonly Configuration Configuration = IsLocalBuild ? Configuration.Debug : Configuration.Release;
[Solution(GenerateProjects = true)] readonly Solution Solution;
AbsolutePath ArtifactsDirectory => RootDirectory / "artifacts";
Target Pack => _ => _
.DependsOn(Compile)
.Executes(() =>
{
DotNetPack(s => s
.SetProject(Solution.BookStoreApp_Blazor_WebAssembly_UI)
.SetOutputDirectory(ArtifactsDirectory)
.SetIncludeSymbols(true)
.SetConfiguration(Configuration)
.EnableNoRestore()
.EnableNoBuild());
});
But I get this the error:
[ERR] Pack: C:\Program Files\dotnet\sdk\6.0.300\Sdks\Microsoft.NET.Sdk.Razor\targets\Microsoft.NET.Sdk.Razor.StaticWebAssets.targets(907,5): error : Conflicting assets with the same path '/wwwroot/service-worker-assets.js' for content root paths 'C:\Users\patob\source\repos\BookStoreApp\BookStoreApp.Blazor.WebAssembly.UI\obj\Debug\net6.0\service-worker-assets.js.build' and 'C:\Users\patob\source\repos\BookStoreApp\BookStoreApp.Blazor.WebAssembly.UI\obj\Debug\net6.0\service-worker-assets.js'. [C:\Users\patob\source\repos\BookStoreApp\BookStoreApp.Blazor.WebAssembly.UI\BookStoreApp.Blazor.WebAssembly.UI.csproj]
I'm not sure how to fix this issue, I've tried deleting the 'service-worker-assets.js.build' file but it doesn't fix the problem. I would love some help.
Thanks

Related

SBT: How to Dockerize a fat jar?

I'm building a Docker image with a fat jar. I use the sbt-assembly plugin to build the jar, and the sbt-native-packager to build the Docker image. I'm not very familiar with SBT and am running into the following issues.
I'd like to declare a dependency on the assembly task from the docker:publish task, such that the fat jar is created before it's added to the image. I did as instructed in the doc, but it's not working. assembly doesn't run until I invoke it.
publish := (publish dependsOn assembly).value
One of the steps in building the image is copying the fat jar. Since assembly plugin creates the jar in target/scala_whatever/projectname-assembly-X.X.X.jar, I need to know the exact scala_whatever and the jar name. assembly seems to have a key assemblyJarName but I'm not sure how to access it. I tried the following which fails.
Cmd("COPY", "target/scala*/*.jar /app.jar")
Help!
Answering my own questions, the following works:
enablePlugins(JavaAppPackaging, DockerPlugin)
assemblyMergeStrategy in assembly := {
case x => {
val oldStrategy = (assemblyMergeStrategy in assembly).value
val strategy = oldStrategy(x)
if (strategy == MergeStrategy.deduplicate)
MergeStrategy.first
else strategy
}
}
// Remove all jar mappings in universal and append the fat jar
mappings in Universal := {
val universalMappings = (mappings in Universal).value
val fatJar = (assembly in Compile).value
val filtered = universalMappings.filter {
case (file, name) => !name.endsWith(".jar")
}
filtered :+ (fatJar -> ("lib/" + fatJar.getName))
}
dockerRepository := Some("username")
import com.typesafe.sbt.packager.docker.{Cmd, ExecCmd}
dockerCommands := Seq(
Cmd("FROM", "username/spark:2.1.0"),
Cmd("WORKDIR", "/"),
Cmd("COPY", "opt/docker/lib/*.jar", "/app.jar"),
ExecCmd("ENTRYPOINT", "/opt/spark/bin/spark-submit", "/app.jar")
)
I completely overwrite the docker commands because the defaults add couple of scripts that I don't need because I overwrite the entrypoint as well. Also, the default workdir is /opt/docker which is not where I want to put the fat jar.
Note that the default commands are shown by show dockerCommands in sbt console.

SBT Subprojects do not recognize plugin commands

I'm having an issue with getting SBT Subprojects to recognize commands provided by plugins. I have the following plugin source:
object DemoPlugin extends AutoPlugin {
override lazy val projectSettings = Seq(commands += demoCommand)
lazy val demoCommand =
Command.command("demo") { (state: State) =>
println("Demo Plugin!")
state
}
}
Which is used by a project configured as follows:
lazy val root = project in file(".")
lazy val sub = (project in file("sub")).
enablePlugins(DemoPlugin).
settings(
//...
)
The plugin is, of course, listed in project/plugins.sbt. However, when I open up sbt in the project, I see the following:
> sub/commands
[info] List(sbt.SimpleCommand#413d2cd1)
> sub/demo
[error] Expected ':' (if selecting a configuration)
[error] Not a valid key: demo (similar: doc)
[error] sub/demo
Even stranger, using consoleProject, I can see that the command in the project is the one defined by DemoPlugin!
scala> (commands in sub).eval.map { c => c.getClass.getMethod("name").invoke(c) }
res0: Seq[Object] = List(demo)
I'm looking to be able to type sub/demo, and have it perform the demo command. Any help would be much appreciated!
Commands aren't per-project. They only work for the top-level project.
It's also recommended to try and use tasks, or if needed input tasks where you might want to use a command.
If you really need a command, there's a way to have a sort of "holder" task, see the answer to Can you access a SBT SettingKey inside a Command?

ZendFramework 2 - PHPUnit - command line works, NetBeans states "No tests executed"

I seem to have a slight problem with executing PHPUnit tests for own modules in the Zend Framework 2.
OS: Mac OS 10.8.3
Zend Framework 2.1.4
PHPUnit Version 3.7.19 (installed via pear)
PHP Version 5.3.15 (xdebug enabled, version 2.1.3)
I followed the instructions of the Zend guideline, to create the module "Album" (http://framework.zend.com/manual/2.1/en/user-guide/modules.html)
Instead of putting the unit tests into the module folders, I want to have them all in one centralized folder. This is the base structure of my application:
-config
-data
-module
-public
-tests
--Modules
---Album
----AlbumTest.php
--Bootstrap.php
--phpunit.xml
-vendor
...(license, readme, composers and init_autoloader.php)
-> The test for the Module Album resides in a folder "Modules/Album" in "tests". The folder "tests" contains also the Bootstrap.php and phpunit.xml.
Here is the content of the files:
Bootstrap.php
<?php
/*
* Set error reporting to the level to which Zend Framework code must comply.
*/
error_reporting( E_ALL | E_STRICT );
/*
* The first run required me to fix some constants
*/
defined('TESTS_ZEND_FORM_RECAPTCHA_PUBLIC_KEY') || define('TESTS_ZEND_FORM_RECAPTCHA_PUBLIC_KEY', 'public key');
defined('TESTS_ZEND_FORM_RECAPTCHA_PRIVATE_KEY') || define('TESTS_ZEND_FORM_RECAPTCHA_PRIVATE_KEY', 'private key');
defined('TESTS_ZEND_LDAP_PRINCIPAL_NAME') || define('TESTS_ZEND_LDAP_PRINCIPAL_NAME', 'someUser#example.com');
defined('TESTS_ZEND_LDAP_ALT_USERNAME') || define('TESTS_ZEND_LDAP_ALT_USERNAME', 'anotherUser');
chdir(dirname(__DIR__));
/*
* autoload the application
*/
include __DIR__ . '/../init_autoloader.php';
Zend\Mvc\Application::init(include 'config/test.config.php');
phpunit.xml
<phpunit bootstrap="./Bootstrap.php" colors="true">
<testsuites>
<testsuite name="Zend Module Tests">
<directory>./Modules</directory>
</testsuite>
</testsuites>
</phpunit>
AlbumTest.php
<?php
namespace AlbumTest\Model;
use Album\Model\Album;
use PHPUnit_Framework_TestCase;
/**
* #category Module
* #package Album
* #subpackage UnitTests
* #group Module_Album
*/
class AlbumTest extends PHPUnit_Framework_TestCase {
public function testAlbumInitialState() {
$album = new Album();
$this->assertNull($album->artist, '"artist" should initially be null');
$this->assertNull($album->id, '"id" should initially be null');
$this->assertNull($album->title, '"title" should initially be null');
}
public function testExchangeArraySetsPropertiesCorrectly() {
$album = new Album();
$data = array('artist' => 'some artist',
'id' => 123,
'title' => 'some title');
$album->exchangeArray($data);
$this->assertSame($data['artist'], $album->artist, '"artist" was not set correctly');
$this->assertSame($data['id'], $album->id, '"id" was not set correctly');
$this->assertSame($data['title'], $album->title, '"title" was not set correctly');
}
public function testExchangeArraySetsPropertiesToNullIfKeysAreNotPresent() {
$album = new Album();
$album->exchangeArray(array('artist' => 'some artist',
'id' => 123,
'title' => 'some title'));
$album->exchangeArray(array());
$this->assertNull($album->artist, '"artist" should have defaulted to null');
$this->assertNull($album->id, '"id" should have defaulted to null');
$this->assertNull($album->title, '"title" should have defaulted to null');
}
public function testGetArrayCopyReturnsAnArrayWithPropertyValues() {
$album = new Album();
$data = array('artist' => 'some artist',
'id' => 123,
'title' => 'some title');
$album->exchangeArray($data);
$copyArray = $album->getArrayCopy();
$this->assertSame($data['artist'], $copyArray['artist'], '"artist" was not set correctly');
$this->assertSame($data['id'], $copyArray['id'], '"id" was not set correctly');
$this->assertSame($data['title'], $copyArray['title'], '"title" was not set correctly');
}
public function testInputFiltersAreSetCorrectly() {
$album = new Album();
$inputFilter = $album->getInputFilter();
$this->assertSame(3, $inputFilter->count());
$this->assertTrue($inputFilter->has('artist'));
$this->assertTrue($inputFilter->has('id'));
$this->assertTrue($inputFilter->has('title'));
}
}
NetBeans knows, where to find the phpunit binaries:
(I wanted to post images here, don't have the reputation though :), I will try to explain it)
The paths to are configured in the options - php - unit testing
/usr/local/pear/bin/phpunit and
/usr/local/pear/bin/phpunit-skelgen
In the properties of the project I set the "Use XML Configuration" and pasted the path to the phpunit.xml. I also checked "Ask for Test Groups Before Running Tests" - I gave the test above the group "Module_Album" - like this I make sure, that PHPUnit finds the right test.
I right click on Project and choose "Test", it shows me the group "Module_Album", I check it and click "Ok". It runs something, tells me it located the right phpunit.xml ("Configuration read from FULL_PATH/tests/phpunit.xml"). After running, it tells me, that it didn't execute any tests.
This is the full output in NetBeans:
PHPUnit 3.7.19 by Sebastian Bergmann.
Configuration read from FULL_PATH/tests/phpunit.xml
Time: 9 seconds, Memory: 348.25Mb
[2KNo tests executed!
[2K
Generating code coverage report in Clover XML format ... done
Anyway, I can do the same successfully via shell (terminal). It doesn't matter, if I directly mount the tests directory and run phpunit, use the full path to the phpunit binary (to make sure, that I don't use different version), specifying the full path of the phpunit.xml, and so on. Here are some samples:
phpunit
phpunit -c FULL_PATH/tests/phpunit.xml
/usr/local/pear/bin/phpunit -c FULL_PATH/tests/phpunit.xml
All of these commands give me, what I expect:
PHPUnit 3.7.19 by Sebastian Bergmann.
Configuration read from FULL_PATH/tests/phpunit.xml
.....
Time: 0 seconds, Memory: 12.75Mb
OK (5 tests, 16 assertions)
I don't get, why this works in shell but not via NetBeans
NetBeans uses 350MB, while in shell it uses only 12.75MB
In case I remove the option "Ask for Test Groups Before Running Tests", it seems to try running all ZendTests. Don't know how this is possible, from the phpunit.xml it should not find them.
Any help is appreciated, thanks!
I finally figured out, what is going on. I ran previously the ZendTests with the phpunit.xml, which is inside vendor/zendframework/zendframework/tests
For some reason NetBeans saves the testfile-directory, which it finds in the first test run and doesn't release them, if the a different phpunit.xml is chosen. I had to change the path of my "new" tests directory via "Right click on project" - "Properties" - "Sources" - "Test Folder".
Now NetBeans runs the test and gives exactly the same output like CLI.

Puppet syncing dir

Still does not work
In/etc/puppet/manifests/site.pp
file { "/home/render/installation/":
ensure => "directory",
owner => "render",
group => "render",
recurse => "true",
mode => "0750",
source => "puppet:///files/installation/",
}
Dir still is empty on client
ls /etc/puppet/files/installation/
1 2 3 4 5
On puppet client in log
Mar 21 12:28:12 lw-003 puppet-agent[28098]: (/File[/home/render/installation/]) Failed to generate additional resources using 'eval_generate: Error 400 on SERVER: Not authorized to call search on /file_metadata/files/installation with {:checksum_type=>"md5", :recurse=>true, :links=>"manage"}
Mar 21 12:28:12 lw-003 puppet-agent[28098]: (/File[/home/render/installation/]) Could not evaluate: Error 400 on SERVER: Not authorized to call find on /file_metadata/files/installation Could not retrieve file metadata for puppet:///files/installation: Error 400 on SERVER: Not authorized to call find on /file_metadata/files/installation
Mar 21 12:28:12 lw-003 puppet-agent[28098]: Finished catalog run in 0.28 seconds
I had the same issue and found this question on Google. I had to change the path to the files for the manifests (modulename/manifests/init.pp):
"puppet:///files/installation/",
to:
"puppet:///modules/files/installation/",
The notation without /modules/ was deprecated in 2.7 and no longer supported in newer versions:
DEPRECATION NOTICE: Files found in modules without specifying 'modules' in file path will be deprecated in the next major release. Please fix module 'modulename' when no 0.24.x clients are present
try this example,
file {
"/scratch/usern/testmod" :
ensure => directory,
source => "puppet:///files/testmod",
recurse => true,
owner => "usern",
group => "groupn",
mode => "0775",
backup => false,
}
You have to specify 'files' and if you are doing a recursive copy, specify 'recurse => true'. That might be the solution to your problem.
the 'fileserver.conf' should look something like the following :
]# cat /etc/puppet/fileserver.conf
[files]
path /etc/puppet/files
allow *

Defining custom classpath for a jar manifest in gradle

I'm trying to define a jar task for all sub projects (about 30). I tried the following task:
jar {
destinationDir = file('../../../../_temp/core/modules')
archiveName = baseName + '.' + extension
metaInf {
from 'ejbModule/META-INF/' exclude 'MANIFEST.MF'
}
def manifestClasspath = configurations.runtime.collect { it.getName() }.join(',')
manifest {
attributes("Manifest-Version" : "1.0",
"Created-By" : vendor,
"Specification-Title" : appName,
"Specification-Version" : version,
"Specification-Vendor" : vendor,
"Implementation-Title" : appName,
"Implementation-Version" : version,
"Implementation-Vendor" : vendor,
"Main-Class" : "com.dcx.epep.Start",
"Class-Path" : manifestClasspath
)
}
}
My problem is, that the dependencies between the sub projects are not included in the manifest's classpath. I tried changing the runtime configuration to a compile configuration but that results in the following error.
What went wrong: A problem occurred evaluating project ':EskoordClient'.
You can't change a configuration which is not in unresolved state!
That is my complete build file for project EskoordClient:
dependencies {
compile project(':ePEPClient')
}
Most of my sub projects build files only define the projects dependencies. 3rd party lib dependencies are defined in the build file of the super project.
Is there a possibility to include all needed classpath entries (3rd party libraries and other projects) to a manifest classpath in a superproject for all subprojects.
This is how I got it to work. Get Project dependencies only using the call:
getAllDependencies().withType(ProjectDependency)
then adding the contents of each project's libsDir to my Class-Path manifest entry.
jar {
manifest {
attributes 'Main-Class': 'com.my.package.Main'
def manifestCp = configurations.runtime.files.collect {
File file = it
"lib/${file.name}"
}.join(' ')
configurations.runtime.getAllDependencies().withType(ProjectDependency).each {dep->
def depProj = dep.getDependencyProject()
def libFilePaths = project(depProj.path).libsDir.list().collect{ inFile-> "lib/${inFile}" }.join(' ')
logger.info"Adding libs from project ${depProj.name}: [- ${libFilePaths} -]"
manifestCp += ' '+libFilePaths
}
logger.lifecycle("")
logger.lifecycle("---Manifest-Class-Path: ${manifestCp}")
attributes 'Class-Path': manifestCp
}
}

Resources