How can I add Snapshot and test variations to my ivy.xml - configuration

I'm using ant+ivy+nexus to build and publish my java OSGi projects (just good old jars if you're unfamiliar with OSGi). After the usual mind-melting period one has when engaging with new tech I've got a mostly functional system. But, I now have two dimensions of artifact variation: snapshot/release and main/test.
The main/test dimension speaks for itself really. The snapshot/release is essential for publishing into nexus in a maven-friendly way. (Extremely useful for integration with open-source OSGi runtimes). So, I have the following artifacts on a per-project basis, and I have many many projects:
project-revision.xml (bp)
project-test-revision.xml (b)
project-revision-SNAPSHOT.xml (bp)
project-test-revision-SNAPSHOT.xml (b)
b = successfully building
p = successfully publishing
(I haven't yet got the test stuff publishing correctly)
It's taken me a while to get that far without duplicating code everywhere in my build scripts, but I've managed it... with one big caveat. For the SNAPSHOT branch I append "-SNAPSHOT" to all revisions. In ant I manage to achieve this programatically, but for ivy I'm using a duplicated ivy.xml; ivy-SNAPSHOT.xml. This has
<info ... revision="x.x-SNAPSHOT">
Notice the -SNAPSHOT. Without this I could never get my
<ivy:deliver>
<ivy:resolve>
<ivy:publish>
chain of commands to correctly publish artifact and maven pom. (Remember I have a requirement to make this maven friendly... I'll be damned if I actually end up using maven to build it mind!)
Now I'm stuck introducing the test/main dimension. I'm ideally looking to publish
project-test-revision(-SNAPSHOT).jar
(Note the optional snapshot). I really don't want to do this by specifying
<info ... module="project-test" ... >
as opposed to <info ... module="project" ... > in yet another ivy file. If I went this route (like I've already started) then I simply end up with loads of ivy-Option1-Option2...-OptionN.xml files. With each new two-value variation doubling the number of build and ivy files. That's crap. There's got to be a better way. I just can't find it.
If you have managed to successfully get ivy publishing artifacts with embellished names from one ivy file, would you mind posting the configuration snippets that achieve this? Would be extremely useful. (Don't forget maven won't know about configurations so I need to get the variations into the filename and pom).
Many thanks
Alastair

Ok, update: I've now got the artifact publishing. I struggled a little while I had the test conf extending the default conf. I'd get a complaint during publishing that the default configuration artifacts weren't present... something I don't care about while only publishing the test case. By making them independent but overlapping I get back fine-grain control of what to publish.
BUT!!!!! There's no viable test pom - that's NOT publishing yet. Well, actually it does publish, but it contains data for the non-test case. So this is still not maven friendly. If anyone has suggestions on this that'd be great.
either way, the code I'm now using, in case it helps you too:
ivy.xml:
<info
organisation="MY_ORGANISATION"
module="MY_PROJECT"
status="integration"
revision="1.0-SNAPSHOT">
</info>
<configurations>
<conf name="default" description="Default compilation configuration; main classes only" visibility="public"/>
<conf name="test" description="Test-inclusive compilation configuration. Don't forget to also add Default compilation configuration where needed. This does not extend default conf" visibility="public"/>
</configurations>
<publications>
<artifact name="MY_PROJECT type="jar" ext="jar" conf="default"/>
<artifact name="MY_PROJECT type="pom" ext="pom" conf="default"/>
<artifact name="MY_PROJECT-test" type="jar" ext="jar" conf="test"/>
<artifact name="MY_PROJECT-test" type="pom" ext="pom" conf="test"/>
</publications>
<dependencies>
<dependency org="MY_ORGANISATION" name="ANOTHER_PROJECT" rev="1.0-SNAPSHOT" transitive="true" conf="*"/>
<dependency org="junit" name="junit" rev="[4,)" transitive="true" conf="test->*"/>
</dependencies>
build.xml:
<property name="project.generated.ivy.file" value="SNAPSHOT_OR_RELEASE_IVY_XML_FILE" />
<property name="ivy.publish.status" value="RELEASE_OR_INTEGRATION" />
<property name="project.qualifier" value="-SNAPSHOT_OR_EMPTY" />
<property name="ivy.configuration" value="DEFAULT_OR_TEST" />
<target name="publish" depends="init-publish">
<ivy:deliver
deliverpattern="${project.generated.ivy.file}"
organisation="${project.organisation}"
module="${project.artifact}"
status="${ivy.publish.status}"
revision="${project.revision}${project.qualifier}"
pubrevision="${project.revision}${project.qualifier}"
conf="${ivy.configuration}"
/>
<ivy:resolve conf="${ivy.configuration}" />
<ivy:makepom
ivyfile="${project.generated.ivy.file}"
pomfile="${project.pom.file}"
/>
<ivy:publish
resolver="${ivy.omnicache.publisher}"
module="${project.artifact}"
organisation="${project.organisation}"
revision="${project.revision}${project.qualifier}"
pubrevision="${project.revision}${project.qualifier}"
pubdate="now"
overwrite="true"
publishivy="true"
status="${ivy.publish.status}"
artifactspattern="${project.artifact.dir}/[artifact]-[revision](-[classifier]).[ext]"
conf="${ivy.configuration}"
/>
</target>

Related

Use Corona renderer for rendering models in Autodesk Forge

We are trying to use forge to render 360 view images for furniture models. Unfortunately, we need to use corona plugin for it. But while attaching dll files like we see in documentation - we still see an issue.
[08/17/2021 15:07:15] 8/17/2021 15:07:15 PM; DLL <t:\aces\applications\7b3e91f490aad59bb1502fc04a07ae97.ngrdh8rpmufavx5peithdvrycazwjxfq.renderall_1629212808[1].package\renderingtools.bundle\content\2021\CoronaMax2021.dlr> failed to initialize properly - not loading.
[08/17/2021 15:07:15] 8/17/2021 15:07:15 PM; DLL <t:\aces\applications\7b3e91f490aad59bb1502fc04a07ae97.ngrdh8rpmufavx5peithdvrycazwjxfq.renderall_1629212808[1].package\renderingtools.bundle\content\2021\CoronaMaxUtils2021.dlt> failed to initialize properly - not loading.
[08/17/2021 15:07:30] 8/17/2021 15:07:30 PM; Initializing Python version: 3.7.6
[08/17/2021 15:07:30] 8/17/2021 15:07:30 PM; WARNING Missing dll: coronamaxutils2021.dlt - CoronaMtl
[08/17/2021 15:07:30] 8/17/2021 15:07:30 PM; WARNING Missing dll: coronamaxutils2021.dlt - CoronaLayeredMtl
[08/17/2021 15:07:31] 8/17/2021 15:07:31 PM; WARNING Missing dll: coronamaxutils2021.dlt - CoronaColor
[08/17/2021 15:07:31] 8/17/2021 15:07:31 PM; WARNING Missing dll: coronamax2021.dlr - CoronaRenderer
[08/17/2021 15:07:32] 8/17/2021 15:07:32 PM; MAXScript ExecuteMAXScriptScript Exception: -- Runtime error: Unable to open renderer, possible recursion; Error occurred in anonymous codeblock; filename: t:\aces\applications\7b3e91f490aad59bb1502fc04a07ae97.ngrdh8rpmufavx5peithdvrycazwjxfq.renderall_1629212808[1].package\renderingtools.bundle\content\RenderingTools.ms; position: 442; line: 15
And nothing renders, obviously. I include plugin files as described in the docs.
<?xml version="1.0" encoding="utf-8"?>
<ApplicationPackage SchemaVersion="1.0" AutodeskProduct="3ds Max" ProductType="Application" ProductCode="3ds Max Rendering Tools Plugin" UpgradeCode="My UpgradeCode">
<CompanyDetails />
<Components Description="post-start-up scripts parts">
<RuntimeRequirements OS="Win64" Platform="3ds Max" SeriesMin="2020" SeriesMax="2023" />
<ComponentEntry AppName="RenderingTools" Version="1.0.0" ModuleName="./Content/RenderingTools.ms" />
</Components>
<Components Description="plugins parts">
<RuntimeRequirements OS="Win64" Platform="3ds Max" SeriesMin="2020" SeriesMax="2021" />
<ComponentEntry AppName="CoronaRenderer" ModuleName="./Content/2021/CoronaMax2021.dlr" />
<ComponentEntry AppName="CoronaUtils" ModuleName="./Content/2021/CoronaMaxUtils2021.dlt" />
</Components>
<Components Description="light icon paths parts">
<RuntimeRequirements OS="Win64" Platform="3ds Max" SeriesMin="2020" SeriesMax="2021" />
<ComponentEntry ModuleName="./Content/2021/UI/Icons/" />
</Components>
<Components Description="dark icon paths parts">
<RuntimeRequirements OS="Win64" Platform="3ds Max" SeriesMin="2020" SeriesMax="2021" />
<ComponentEntry ModuleName="./Content/2021/UI/IconsDark/" />
</Components>
</ApplicationPackage>
First, Corona is a third party render and from a licnesing perspective, you might want to double-check this is acceptable use case. Especially if they use some sort of "online" licensing, as the Design Automation environment will not allow the module to check for licensing via the internet. As long as it can be automated (without any UI interactions required) and licensing is not an issue, it could work.
Next, I would suggest to first try getting it working with a built-in 3ds Max renderer just for the steps (perhaps ART or Arnold). Do not worry about materials, etc, but get your script working without corona to be sure you have the automation worked out.
Then, you could try to work out the Corona issues (and no guarantees it can work because again it is a third party tool.) It might be obvious, but to be sure... From the ApplicationPackage it appears to be setup like an app store bundle. For 3ds Max Design Automation, you would need to also be sending all the necessary modules, and make sure the path is setup correctly to find them in your app bundle zip. An example for that is here: https://learnforge.autodesk.io/#/designautomation/appbundle/engines/max (see the PackageContents section). Note that similarly the app bundle is setup to load from a "contents" folder, but the modules must also be provided in the app bundle zip in the correct location. Another example is provided here: https://github.com/kevinvandecar/design.automation.3dsmax-csharp-meshoptimizer (use the deploy01 branch). You can find this example's bundle here: https://github.com/kevinvandecar/design.automation.3dsmax-csharp-meshoptimizer/tree/deploy01/forgesample/wwwroot/bundles. Note that the zip contains the folder structure and all the needed modules for the plugin.
Design Automation will not load interface plugins, i.e. anything with icons, forms, user interactions.
From the output, the CoronaMax2021.dlr is failing to load.

netstandard 2.0 does not have AppDomain.CurrentDomain.SetupInformation.ConfigurationFile

I have just upgraded a net451 classic dotnet project to multi-target project using net461/netstandard2.0 with reasonable success.
Did however come across this compiler error for net461 when it comes to gaining access legacy configuration files via:
AppDomain.CurrentDomain.SetupInformation.ConfigurationFile
This appears to not be a thing in netstandard2.0 :) Anyone know of any work arounds or good solutions?
Add the ConfigurationManager as a NuGet
<ItemGroup Condition="'$(TargetFramework)' == 'netstandard2.0'">
<PackageReference Include="System.Configuration.ConfigurationManager" Version="4.5.0" />
</ItemGroup>
Use ConfigurationManager in C#
var configFile = ConfigurationManager.OpenExeConfiguration(ConfigurationUserLevel.None);
Log4NetLogger.Configure(configFile.FilePath);
According to this article, which I found when looking for replacement for PlatformServices.Default.Application.ApplicationBasePath, it should be either of:
AppDomain.CurrentDomain.SetupInformation.ApplicationName
Assembly.GetEntryAssembly().GetName().Name
Just like you, I've just found out that the first one does not exist in recent 2.0 so I'll be using the GetEntryAssembly name..
..however keep in mind that GetEntryAssembly may be null when used i.e. from within a test runner like xUnit, or probably will be wrong if your appcode is ran from another not-yours hosting/startup module, etc - so that is not a perfect replacement.

Sonar jacoco coverage without running junit

I've following setup in my build.xml for running jacoco:
<formatter type="xml" />
<batchtest todir="${reports.junit.xml.dir}">
<fileset dir="${test.dir}">
<include name="**/*.java" />
</fileset>
</batchtest>
</junit>
</jacoco:coverage>
But when I run this it's giving me :
[junit] Test FAILED
Now developers are working on fixing the junits, but I need to know if "without" running junits can I still show how much is the unit test coverage in sonar ?
To answer your question, no you can't get coverage data without running the unit tests. However, you can get coverage data even if the unit tests fail. You just need to keep unit test failure from failing the build & thereby preempting the output of the coverage report.
It looks like the default value of the <junit> tag attribute haltonfailure is off. So either remove your on or turn it off explicitly.

Azure role configuration management

I don't see how Windows Azure lets you vary the configuration of an application when you have no choice but to hold configuration settings in web.config (or app.config).
For example...
Quite often projects will make use of a 3rd party library that makes heavy use of web.config. The use of web.config may involve connection strings, app settings or custom configuration sections. A good example of this is ELMAH. A web.config file for ELMAH might look like the following:
<configuration>
<configSections>
<sectionGroup name="elmah">
<section name="security" requirePermission="false" type="Elmah.SecuritySectionHandler, Elmah" />
<section name="errorLog" requirePermission="false" type="Elmah.ErrorLogSectionHandler, Elmah" />
</sectionGroup>
</configSections>
<connectionStrings>
<add
name="MyElmahDatabase"
providerName="System.Data.SqlClient"
connectionString="Server=tcp:myServer.database.windows.net,1433;Database=myDB;User ID=user#myServer;Password=password;Trusted_Connection=False;Encrypt=True;Connection Timeout=30" />
</connectionStrings>
<elmah>
<security allowRemoteAccess="1" />
<errorLog type="Elmah.SqlErrorLog, Elmah" connectionStringName="MyElmahDatabase" />
</elmah>
</configuration>
There are a couple of problems here:
There is no way for me to update or vary whether remote access is enabled between Service Configurations.
There is no way for me to update or vary the ELMAH connection string between Service Configurations.
This is because the web.config is packaged as is into the .cspkg file and ELMAH will not look at the Service Configuration settings (which are the only way I can vary configuration settings between Service Configurations).
I can think of many other examples where this is a problem...
Any data access frameworks that look directly at the connection strings section.
Any custom configuration settings I need to create.
...to name just two.
Am I missing something or is this a significant gap in the configuration management offered by Windows Azure?
EDIT
From the answer and comments below, it looks like this is something that is not well supported. I think that managing multiple solution build configurations to support different configuration profiles is a very weak solution. I should not have to rebuild the solution for each configuration profile I need (there will likely be quite a few). Compilation is not equal to configuration.
I was wondering if there was a way to modify the .cspkg file as it is just a zip file. According to this documentation you can on Linux.
I've looked at the manifest in the .cspkg file and it looks like this:
<PackageManifest version="2">
<Encryption keytype="1" />
<Contents hashtype="1">
<Item name="MyApp.Web.UI_<GUID>.cssx" hash="AED69299C5F89E060876BC16BD3D6DE5130F6E62FFD2B752BAF293435339B7E2" uri="/MyApp.Web.UI_<GUID>.cssx" />
<Item name="MyApp.Web.Services_<GUID>.cssx" hash="7AC81AFF642E4345173C8470C32A41118A4E3CFD4185B82D0ADA44B71057192D" uri="/MyApp.Web.Services_<GUID>.cssx" />
<Item name="SMPackage_<GUID>.csmx" hash="B5E6B83B62AF64C7C11CAC1A394ABBF15D7DB7667A773C5284CE5BE95C5834E9" uri="/SMPackage_<GUID>.csmx" />
<Item name="SDPackage_<GUID>.csdx" hash="F34B7C02A551D82BAD96881E2DA9447D0014D49B47CCB3840475BDC575234A7D" uri="/SDPackage_<GUID>.csdx" />
<Item name="NamedStreamPackage_<GUID>.csnsx" hash="FA2B5829FF5D9B2D69DCDDB0E5BDEE6B8B0BC09FFBF37DAEEE41CF3F3F4D0132" uri="/NamedStreamPackage_<GUID>.csnsx" />
</Contents>
<NamedStreams>
<Stream name="RequiredFeatures/MyApp.Web.Services/1.0" />
<Stream name="RequiredFeatures/MyApp.Web.UI/1.0" />
<Stream name="SupportData/MyApp.Web.Services/1.0" />
<Stream name="SupportData/MyApp.Web.UI/1.0" />
</NamedStreams>
</PackageManifest>
Unfortunately, if I re-compute the hash of the unchanged "MyApp.Web.UI_.cssx" file, my hash is different from the one in the manifest.
Hash from manifest: AED69299C5F89E060876BC16BD3D6DE5130F6E62FFD2B752BAF293435339B7E2
My calculated hash: E3B0C44298FC1C149AFBF4C8996FB92427AE41E4649B934CA495991B7852B855
Note that I have not yet changed the file, so the hash should be the same.
This suggests I'm calculating it wrong. My method was as follows:
class Program
{
static void Main(string[] args)
{
using (FileStream fs = new FileStream(args[0], FileMode.Open))
{
ComputeHash(new SHA256Managed(), fs);
}
}
private static void ComputeHash(HashAlgorithm hashAlgorithm, Stream stream)
{
byte[] hash = hashAlgorithm.ComputeHash(stream);
string hashString = BitConverter.ToString(hash);
Console.WriteLine(hashString.Replace("-", string.Empty));
Console.WriteLine();
}
}
The documentation link above, suggests it is straightforward to re-calculate the hash (on Linux anyway).
Does anyone know how to re-compute the hashes?
Passing a Stream to ComputeHash() ends up with a different hash as compared to using the byte[] overload. I don't know why.
Try something like:
private static void ComputeHash(HashAlgorithm hashAlgorithm, Stream stream)
{
BinaryReader reader = new BinaryReader(stream)
byte[] hash = hashAlgorithm.ComputeHash( reader.ReadBytes( (int)stream.Length ) );
string hashString = BitConverter.ToString(hash);
Console.WriteLine(hashString.Replace("-", string.Empty));
Console.WriteLine();
}
This will give you the hash you're after.
As you've probably already discovered, on linux you can get the digest with
openssl dgst -sha256 /path/to/file
I you have items in your web.config that you want to change depending on how it's being built, there is a solution that is outside of Azure that you can use. You can use Web.config transforms. These transforms are tied to your build configuration not your service configuration, but your service configurations a likely closely tied to your build configurations anyway (...Local.csfg -> Debug, ...Cloud.csfg -> Release). If the default build configurations don't work for you, just create the ones you need.
If you want to use different service definitions per service configuration, then it's not supported by the UI, but you can mess around with the build process to make it work

Spring integration delayer element

I'm trying to configure my spring integration and want to use the element, which basically sits between a retryFilter and a queue.
All works fine if I go straight from the retryFilter to the queue, however, as soon as I put the delayer element in between them, the config file fails to be loaded (as happens when there is an error in it).
Config for this section is as follows:
<!-- Retry filter -->
<filter
input-channel="retryChannel"
ref="retryFilter"
method="doRetry"
output-channel="queueChannel" />
<channel id="delayChannel" />
<delayer input-channel="delayChannel" default-delay="10000" output-channel="queueChannel"/>
<channel id="queueChannel">
<queue capacity="100" />
</channel>
<poller id="poller" default="true">
<interval-trigger interval="1000"/>
</poller>
Any help greatly appreciated.
Dave
I've tried out your sample and got it working fine on Spring Integration 2.0.0.BUILD-SNAPSHOT. You can see my commit here:
http://github.com/iwein/Spring-Integration-Sandbox/commit/c274a12f057b6750dcf18663486a99970368e68e
There are a couple of things I changed:
channel renames (in, out) instead of
longer names
filter outputs to
delayer input, instead of passing by
the delayer
Are you using an older version of Spring Integration perhaps?
You can check out my little gradle project ( http://github.com/iwein/Spring-Integration-Sandbox/tree/master/quick-samples/router-test/) which could help you experiment. If you still can't get it working it would be good if you shared a stacktrace and the exact version you are using.