How to share code between Maven modules so IntelliJ IDEA recognises it? - actionscript-3

I have got a library project (written in ActionScript), that has two build outputs: One is made by including library A, the other is made by including library B.
My goal is to mavenize this library, and I've come up with the following solution:
I have a multi module Maven project that looks like this:
myLib-Mobile
\- pom.xml
myLib-Web
\- pom.xml
src
\- main
\- actionScript
...code is here
pom.xml
The parent pom.xml holds everything except the one dependency that changes based on the build target (and the FlexMojos compiler, since one needs to be built with AIR the other with Flash). Since the code is not at the usual location I define it this way in the pom files of the children:
<build>
<sourceDirectory>../src/main/actionscript</sourceDirectory>
...
This works fine if I build it in the console, but when I import this as a Maven project in IntelliJ, it does not find the source files - it seems to me that IntelliJ cannot handle if the <sourceDirectory> tag has a reference to the parent directory. The only workaround I found was to manually specify the content root in the project settings.
Anyone knows a better solution? Maybe using modules is not the way to go?

Related

Partial Views in a Razor Class Library aren't found

I have a simple RCL with following structure:
/Pages
/Shared/
_Footer.cshtml
The content is very simple:
<h3> _Footer.cshtml partial view.</h3>
I also have a ASP.NET Core Web App project with same folder structure:
/Pages
_ViewImports.cshtml
-ViewStart.cshtml
/Shared
_Layout.cshtml
Somewhere in the layout file I make a reference to the partial view:
<partial name="_Footer" />
Here is the problem:
If I add a Project Reference of RCL to the Web App, the partial view is found and pages render fine.
If I make a Nuget package from the RCL, add it to a local Nuget source and add a reference to the package, the partial view won't be found.
The partial view '_Footer' was not found. The following locations were searched: /Pages/_Footer.cshtml /Pages/Shared/_Footer.cshtml /Views/Shared/_Footer.cshtml
What could be the difference between adding a project reference and Nuget reference? I've verified the Nuget package does contain both the Class Lib's default and views assemblies.
I found it works if you use dotnet pack instead of nuget pack. Note for dotnet pack package information is now read from csproj instead of nuget spec file.
In my case I wasn't even able to make it work in the scenario the op said it does work:
If I add a Project Reference of RCL to the Web App, the partial view
is found and pages render fine.
I was just getting the standard error message that the partial view was not found (even if the searched paths were correct).
After some head banging I solved this problem by adding the following xml block to both .csproj files:
RCL: e.g. RazorUIClassLib.csproj
Web App: e.g. WebApp1.csproj
<ItemGroup>
<PackageReference Include="Microsoft.AspNetCore.App" />
</ItemGroup>
I had the same problem, the solved writing the full path from the library Area, for example:
In the library i have:
Areas/Footer/Pages/_footer.cshtml
with my UI Proyect i called it like: <partial name="~/Areas/Footer/Pages/_footer.cshtml" model="My Model instance"/>
I hope it can help you
According to the docs (https://learn.microsoft.com/en-us/aspnet/core/razor-pages/sdk), I think you can use IncludeRazorContentInPack to include your .cshtml files in a NuGet package (it defaults to false).

Monodevelop fails to build, can't find Microsoft.DiaSymReader.Native.x86.dll'

I am trying to build a web api project using monodevelop on a mac. The thing is that after a few hiccups (explained in a question that turned out to be so messy I have just deleted) I get to the point of getting this error
/Users/myuser/git/LiveData/LiveData/CSC: Error CS0041: Unexpected error writing debug information -- 'Windows PDB writer is not available -- could not find Microsoft.DiaSymReader.Native.x86.dll' (CS0041) (LiveData)
In a windows machine the same project builds using visual studio targeting mono 4.5.
When I click on the error it tells me that /Users/myuser/git/LiveData/LiveData/CSC doesn't exist
Another thing is that in the folder structure of the solution there's a package folder (not the one inside the project) and inside this one I have a folder called Microsoft.Net.Compilers 1.3.2 that has inside another folder called "tools" that contains among other things csc.exe and the dll thta can't be found.
I have tried to install the dll directly in the project using nuget but even if it was installed the build showed me the same error
Thanks,
As for workaround for now you can just limit usage of Microsoft.Net.Compilers to Release configuration (edit *.csproj file):
<Import Project="..\packages\Microsoft.Net.Compilers.1.3.2\build\Microsoft.Net.Compilers.props" Condition="'$(Configuration)' == 'Release' And Exists('..\packages\Microsoft.Net.Compilers.1.3.2\build\Microsoft.Net.Compilers.props')" />
take a look at beginning of condition:
'$(Configuration)' == 'Release'
This way I can build and debug locally and build my project ie. in appharbor.
Building the project in release configuration should fix it!
This might not be completely related but may be helpful in some ways. Regarding the issue on 'could not find Microsoft.DiaSymReader.Native.x86.dll', have a look at this issue on GitHub: https://github.com/dotnet/cli/issues/3016
It seems like the solution is either:
Dependency to Microsoft.NETCore.Platforms needed for RID graph which
was missing. Any package which has transitive dependency on it (like
NETStandard.Library) could also make things work.
Adding dependency to "Microsoft.NETCore.Platforms": "1.0.1-" or
"NETStandard.Library":"1.5.0-" make it work.
adding Microsoft.NETCore.Platforms works as well

Google maps classes not showing in Import-Package in MANIFEST.MF

I'm using the maven-bundle-plugin and trying to bundle Google maps dependency.
<plugin>
<groupId>org.apache.felix</groupId>
<artifactId>maven-bundle-plugin</artifactId>
<extensions>true</extensions>
<configuration>
<instructions>
<Bundle-ClassPath>*;scope=compile|runtime</Bundle-ClassPath>
<Embed-Dependency>*;scope=compile|runtime</Embed-Dependency>
<Embed-Directory>OSGI-INF/lib</Embed-Directory>
<Import-Package>
*
</Import-Package>
<_exportcontents>
*
</_exportcontents>
</instructions>
</configuration>
</plugin>
When I inspect the JAR (Manifest.MF) I can see com.google.maps.model in Export-Package but not in Import-Package. How can I get it in the Import-Package as well?
This question is linked to a previously unresolved question How to import a class from third party jar file in an OSGi component
Well, there shouldn't be anything in the Import-Package here, as you're not importing the google maps classes, you are embedding them. You're packing the google jar inside your own bundle, and Import-Package applies only when you want to use those classes exported from another bundle.
As of the other question, I'm not entirely sure (I don't use the maven bundle plugin at all) but the 'exportcontents *' seems suspect, exporting too much can lead to subtle problems.
I'd say start by exporting nothing and add packages as needed.
If you are embedding the jar in your bundle and want to access its classes, use the Include-Resource instruction, it has an option to unroll a JAR resource (see # option)

Using mysql JDBC in the OSGi framework

I have a huge problem with getting a connection to a Database within my OSGi Application. I searched for 3 days an couldn't find a good solution. Just not working and old stuff. I'm using Bndtools for creating my Bundles.
Can anyone please help I'am very desperate.
Thanks
The most probable cause of this error seems that the package of the class being used is not present in the Import-package directive of the bundle's manifest.mf.
In OSGi environment, each bundle has its own classloader. So, each class will be loaded only once during the application life span. Whenever a class is being used outside of a bundle, the package the class resides in needs to be present in the Export-package attribute of its jar's manifest.mf.
Any client bundle which requires this package/class, should add the entry in its Import-package attribute of its manifest.mf file.
If you are using maven, you can use maven-bundle-plugin. This plugin will take care of generating appropriate manifest import and export headers by scanning the dependencies present in your project's pom.xml.

Intellij IDEA 11 Run Configuration Classpath Problems

I am using IDEA 11 and need to run a class with a main method but with additional classpath entries - both xml files and jars. I have tried adding them as Global Libraries, as additional source content roots, and as regular additional libraries, however none of these seem to pick up the xml files and so when I execute the run config I get FileNotFoundExceptions.
Please can anyone suggest something else as the printed classpath in the console never contains any of my custom definitions.
If I can't solve this I may have to resort to learning Eclipse just to get stuff done. This is making me a little crazy. I have tried all the suggestions I could find on SO but no luck so far.
Did you check the answers to the similar questions?
How load xml files, in IntelliJ IDEA
Intellij - how do I add a text file to the resources
Add a properties file to IntelliJ's classpath
Java - setting classpath
If it still doesn't work, please share a sample project via Dropbox.