I see https://github.com/JetBrains/MPS-extensions publishes releases via GitHub, however it does not look convenient for integration of the artifacts to a MPS-based project.
What if my project is built via MPS and it depends on MPS-extensions? It would be great if there was a way to automatically download proper extensions artifact via command line (e.g. ./gradlew downloadExtensions)
The following worked for me:
build.gradle (see https://github.com/Hardella/ide61131/blob/8088fbd9bcc2780f5772856a962fbfe6954b3e50/build.gradle ):
repositories {
maven { url 'https://projects.itemis.de/nexus/content/repositories/mbeddr' }
mavenCentral()
}
configurations {
mpsExtensions
}
dependencies {
mpsExtensions "de.itemis.mps:extensions:2018.2.+"
}
task resolve_extensions(type: Copy) {
dependsOn configurations.mpsExtensions
from {
configurations.mpsExtensions.resolve().collect { zipTree(it) }
}
into "lib"
}
Then ./gradlew resolve_extensions downloads and unpacks mps-extensions into lib/de.itemis.mps.extensions/... folder.
Then it can be plugged to MPS instance via Preferences -> Build, Execution, Deployment -> Project Libraries / Global Libraries.
The following .mps/libraries.xml configures the library as Project Library:
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="ProjectLibraryManager">
<option name="libraries">
<map>
<entry key="mps-extensions">
<value>
<Library>
<option name="name" value="mps-extensions" />
<option name="path" value="$PROJECT_DIR$/lib/de.itemis.mps.extensions" />
</Library>
</value>
</entry>
</map>
</option>
</component>
</project>
Related
Our C++ project uses MSBuild to build on Windows and GNU make on *nix. I'm trying to recreate the functionality of the following single line of GNU make in MSBuild:
GENN_PATH:=$(abspath $(dir $(shell which genn-buildmodel.sh))../userproject/include)
Essentially setting a variable to a path relative to an executable in the path. However, this is proving to be a battle to implement in MSBuild...
The following are the (hopefully) pertinent sections from my vcxproj. For testing purposes I am first setting the variable I want to override to something obvious:
<?xml version="1.0" encoding="utf-8"?>
<Project DefaultTargets="Build" ToolsVersion="12.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
...
<PropertyGroup Label="Configuration">
...
<GeNNUserProject>UNDEFINED</GeNNUserProject>
</PropertyGroup>
Then, in my ClCompile item definitions, I am adding the value of this property to the additional include directories
<ItemDefinitionGroup>
<ClCompile>
...
<AdditionalIncludeDirectories>include;$(GeNNUserProject)</AdditionalIncludeDirectories>
</ClCompile>
...
</ItemDefinitionGroup>
In order to find this path, I'm using the where command and redirecting it's output to a property. Then, from this, I'm finding the include directory and printing it out - this works!
<Target Name="FindUserProjects">
<Exec Command="where genn-buildmodel.bat" ConsoleToMsBuild="true">
<Output TaskParameter="ConsoleOutput" PropertyName="GeNNBuildModelPath" />
</Exec>
<PropertyGroup>
<GeNNUserProject>$([System.IO.Path]::GetFullPath($([System.IO.Path]::GetDirectoryName($(GeNNBuildModelPath)))\..\userproject\include))</GeNNUserProject>
</PropertyGroup>
<Message Text="MAGIC GENN-FINDING! $(GeNNBuildModelPath) -> $(GeNNUserProject)"/>
</Target>
I've tried a variety of ways of making this a dependency of ClCompile including setting the Target as BeforeTargets="PrepareForBuild" and the following:
<PropertyGroup>
<BeforeClCompileTargets>
FindUserProjects;
$(BeforeClCompileTargets);
</BeforeClCompileTargets>
</PropertyGroup>
</Project>
Whatever I do, my custom target runs but the property is not being overriden. Google suggests that if properties are overriden in depencies they should be visible from targets and from digging into Microsoft.CPP*.targets this is what setting BeforeClCompileTargets is doing.
The problem here was not that the target wasn't setting the property, it's that the AdditionalIncludeDirectories item metadata was being set from the original value. The solution is to set this directly from the target instead:
<ItemGroup>
<ClCompile>
<AdditionalIncludeDirectories>%(AdditionalIncludeDirectories);$([System.IO.Path]::GetFullPath($([System.IO.Path]::GetDirectoryName($(GeNNBuildModelPath)))\..\userproject\include))</AdditionalIncludeDirectories>
</ClCompile>
</ItemGroup>
I have a web application in Visual Studio 2012. I publish this website to IIS using publish profiles (.pubxml).
<Project ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<PropertyGroup>
<WebPublishMethod>MSDeploy</WebPublishMethod>
<LastUsedBuildConfiguration>Release</LastUsedBuildConfiguration>
<LastUsedPlatform>Any CPU</LastUsedPlatform>
<ExcludeApp_Data>False</ExcludeApp_Data>
<MSDeployServiceURL>server</MSDeployServiceURL>
<DeployIisAppPath>site</DeployIisAppPath>
<RemoteSitePhysicalPath />
<SkipExtraFilesOnServer>False</SkipExtraFilesOnServer>
<MSDeployPublishMethod>WMSVC</MSDeployPublishMethod>
<EnableMSDeployBackup>True</EnableMSDeployBackup>
<UserName>domain\username</UserName>
</PropertyGroup>
<ItemGroup>
<MSDeployParameterValue Include="MyParam">
<ParameterValue>MyValue</ParameterValue>
</MSDeployParameterValue>
...
</ItemGroup>
</Project>
Beside I setup a CI to build a package with msbuild and then use it to publish to the different environnement using msdeploy. Both in 2 separates steps, so I can reuse the same package multiple times.
To do this I need to use a SetParameters.xml with a different syntax than the publish profil used by VS.
<?xml version="1.0" encoding="utf-8"?>
<parameters>
<setParameter name="IIS Web Application Name" value="site" />
<setParameter name="MyParam" value="MyValue" />
...
</parameters>
Is there a way to share the parameters configuration in a single file so I can maintain only one file ?
I see this answers from 2014 but I can't managed to make it works.
I've researched this and can't find a way to override the SetParameters file when publish via VisualStudio. It doesn't look like the MSBuild tasks support this.
The best alternative I can offer is to use the commandline instead of right click publish. You can create the MSDeploy package by calling the Package target:
C:\Windows\Microsoft.NET\Framework\v4.0.30319\MSBuild /t:Package /p:PublishProfile=<profile-name>
And then deploy using MSDeploy.exe:
"C:\Program Files (x86)\IIS\Microsoft Web Deploy V3\msdeploy.exe" -verb:sync -source:package=WebApplication7.zip -dest:manifest=WebApplication7.DestManifest.xml -setParamFile:SetParameters.custom.xml
The following blog posts has more details:
https://dotnetcatch.com/2016/02/25/the-anatomy-of-a-webdeploy-package/
Disclaimer: Ant Noob!
I'm trying to get the groovy task running in ant. Works so far:
<project>
<taskdef name="groovy"
classname="org.codehaus.groovy.ant.Groovy"
classpath="C:/Local/groovy-2.4.5/lib/groovy-ant-2.4.5.jar;C:/Local/groovy-2.4.5/lib/groovy-2.4.5.jar"/>
<echo message="Hello!"/>
<groovy>
println "Hello from Groovy!"
</groovy>
</project>
What I can't get behind (even reading this and related entries) is what I need to do to my Ant installation (Windows) to make the script run like so, without the taskdef or any other reference in my project specific build file:
<project>
<echo message="Hello!"/>
<groovy> <!-- Would be nice if I could treat this like a built-in -->
println "Hello from Groovy!"
</groovy>
</project>
You'll need to put all Groovy dependencies (groovy-ant.jar, groovy.jar, etc) on the classpath that is read by Ant. The easiest way is to store them under ANT_HOME/lib. Or you can pass them using the -lib option on the command line.
Then you would still have to tell Ant about the path of the antlib. You can use the antlib namespace mechanism described in the documentation page. You specify the package that contains the antlib.xml in the namespace URI, in this case org.codehaus.groovy:
<project xmlns:groovy="antlib:org.codehaus.groovy">
<echo message="Hello!"/>
<groovy:groovy>
println "Hello from Groovy!"
</groovy:groovy>
</project>
Note that you can still use taskdef without referencing the Jar file if it is placed (with its dependencies) in ANT_HOME/lib. You just reference the path of the antlib resource in the Jar. In this case you can do without the namespace URI:
<project>
<taskdef resource="org/codehaus/groovy/antlib.xml"/>
<echo message="Hello!"/>
<groovy>
println "Hello from Groovy!"
</groovy>
</project>
we are developing portal application using JSR-286 portlet inside liferay tomcat.We are creating our portlet extending Generic Portlet.Now I want to apply logs on doView() and doModify() methods using AspectJ. I tried with Spring AspectJ. But Spring AspectJ works only on spring managed beans.
any luck
I resolved above problem.
here are some solution to get it done.
Create an Aspect
#Aspect
public class TestAspect {
TestAspect (){
System.out.println("TestAspect Initialized");
}
#Pointcut( "execution(public void doView*(javax.portlet.RenderRequest,javax.portlet.RenderResponse) throws java.io.IOException, javax.portlet.PortletException)" )
private void testDoView() {
}
#Around("testDoView()")
public void logAround(ProceedingJoinPoint joinPoint)
{
System.out.println("AROUND ADVICE START");
try{
joinPoint.proceed(joinPoint.getArgs());
}catch(PortletException portletException){
System.out.println("[AROUND ADVICE] :"+portletExceptionio.getMessgae());
}catch(IOException ioException){
System.out.println("[AROUND ADVICE] :"+ioException.getMessgae());
}
catch(Throwable throwable){
System.out.println("[AROUND ADVICE] :"+throwable.getMessage();
}
System.out.println("AROUND ADVICE EXIT");
}
}
some *.jar files are AspectJ binaries:
aspectjrt.jar - necessary in runtime for correct aspects processing;
aspectjtools.jar - contains implementation of aspectj compiler;
aspectjweaver.jar - bridge between aspectj logic and java instrumentation;
1.In command line enviroment (with Ant-build.xml)
**There are three ways to inject instructions implied by AspectJ aspects:**
<project name="aspectj-example" xmlns:aspectj="antlib:org.aspectj">
<property name="src.dir" value="src/main/java"/>
<property name="resource.dir" value="src/main/resources"/>
<property name="target.dir" value="target"/>
<property name="classes.dir" value="${target.dir}/classes"/>
<taskdef uri="antlib:org.aspectj"
resource="org/aspectj/antlib.xml"
classpath="${resource.dir}/aspectjtools.jar"/>
<path id="aspectj.libs">
<fileset dir="${resource.dir}"/>
</path>
<target name="clean">
<delete dir="${target.dir}"/>
<mkdir dir="${target.dir}"/>
<mkdir dir="${classes.dir}"/>
</target>
way 1: compile-time weaving
<target name="compile-time" depends="clean">
<aspectj:iajc source="1.5" srcdir="${src.dir}" classpathref="aspectj.libs" destDir="${classes.dir}"/>
<java classname="com.aspectj.TestTarget" fork="true">
<classpath>
<path refid="aspectj.libs"/>
<pathelement path="${classes.dir}"/>
</classpath>
</java>
</target>
way 2: post-compile weaving
<target name="post-compile" depends="clean">
<echo message="Compiling..."/>
<javac debug="true" srcdir="${src.dir}" classpathref="aspectj.libs" destdir="${classes.dir}"/>
<echo message="Weaving..."/>
<aspectj:iajc classpathref="aspectj.libs" inpath="${classes.dir}" aspectpath="${src.dir}" outJar="${classes.dir}/test.jar"/>
</target>
way 3: load-time weaving
<target name="load-time" depends="clean">
<echo message="Compiling..."/>
<javac debug="true" srcdir="${src.dir}" classpathref="aspectj.libs" destdir="${classes.dir}"/>
</target>
</project>
2.In Ecilpse (IDE environment)
select your project,than select configure->convert to AspectJ Project.
I created a new template, which I can use. However it only uses some project settings
I made a project with a working libSDL hi world example. I exported as a template, but template doesn't save some of my settings: ( It 'saves' them, but new projects ignore them. )
Ignored settings:
include header folders:
for .h files
for .lib files
linker args: SDLmain.lib SDL.lib
windows subsystem: /SUBSYSTEM:WINDOWS
Here's the saved /template/sdl/sdl.vcxproj file, and the settings actually appear in it yet they are ignored.
<?xml version="1.0" encoding="utf-8"?>
<Project DefaultTargets="Build" ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<ItemGroup Label="ProjectConfigurations">
<ProjectConfiguration Include="Debug|Win32">
<Configuration>Debug</Configuration>
<Platform>Win32</Platform>
</ProjectConfiguration>
<ProjectConfiguration Include="Release|Win32">
<Configuration>Release</Configuration>
<Platform>Win32</Platform>
</ProjectConfiguration>
</ItemGroup>
<PropertyGroup Label="Globals">
<ProjectGuid>{8DDA73A6-86DD-4B03-BA9B-54BE878B648C}</ProjectGuid>
<RootNamespace>$safeprojectname$</RootNamespace>
</PropertyGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.Default.props" />
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'" Label="Configuration">
<ConfigurationType>Application</ConfigurationType>
<UseDebugLibraries>true</UseDebugLibraries>
<PlatformToolset>v110</PlatformToolset>
<CharacterSet>MultiByte</CharacterSet>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'" Label="Configuration">
<ConfigurationType>Application</ConfigurationType>
<UseDebugLibraries>false</UseDebugLibraries>
<PlatformToolset>v110</PlatformToolset>
<WholeProgramOptimization>true</WholeProgramOptimization>
<CharacterSet>MultiByte</CharacterSet>
</PropertyGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.props" />
<ImportGroup Label="ExtensionSettings">
</ImportGroup>
<ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
</ImportGroup>
<ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
</ImportGroup>
<PropertyGroup Label="UserMacros" />
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
<IncludePath>C:\cpp_libs\SDL-1.2.15\include;$(IncludePath)</IncludePath>
<ReferencePath>C:\cpp_libs\SDL-1.2.15\lib\x86;$(ReferencePath)</ReferencePath>
<LibraryPath>C:\cpp_libs\SDL-1.2.15\lib\x86;$(LibraryPath)</LibraryPath>
<SourcePath>C:\cpp_libs\SDL-1.2.15\include;$(SourcePath)</SourcePath>
</PropertyGroup>
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
<ClCompile>
<WarningLevel>Level3</WarningLevel>
<Optimization>Disabled</Optimization>
</ClCompile>
<Link>
<GenerateDebugInformation>true</GenerateDebugInformation>
</Link>
</ItemDefinitionGroup>
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
<ClCompile>
<WarningLevel>Level3</WarningLevel>
<Optimization>MaxSpeed</Optimization>
<FunctionLevelLinking>true</FunctionLevelLinking>
<IntrinsicFunctions>true</IntrinsicFunctions>
</ClCompile>
<Link>
<GenerateDebugInformation>true</GenerateDebugInformation>
<EnableCOMDATFolding>true</EnableCOMDATFolding>
<OptimizeReferences>true</OptimizeReferences>
<AdditionalDependencies>SDLmain.lib;SDL.lib;%(AdditionalDependencies)</AdditionalDependencies>
<SubSystem>Windows</SubSystem>
</Link>
</ItemDefinitionGroup>
<ItemGroup>
<ClCompile Include="Source.cpp" />
</ItemGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
<ImportGroup Label="ExtensionTargets">
</ImportGroup>
</Project>
It's likely that the project system is actually removing these items as the file is being created: when you create a new project, Visual Studio runs a wizard in the background which can affect what actually ends up in the newly-created .vcxproj file.
These wizards are specific to the project type so you can actually supply your own via the <WizardExtension> element in the .vstemplate file. Of course by overriding the project creation logic, you may lose certain functionality/behaviour (unless there's a way of inheriting the original wizard's base assembly).
Alternately, a solution which I've used in the past is to create a VSPackage which handles the SolutionEvents_ProjectAdded method (in DTE.SolutionEvents). This method gets called whenever a new project is created or added to the solution, so you could potentially use that to set your project up as needed.
Note that you would need a way to ensure that it only affects projects of your specific type; a flag in the .vcxproj template file would do this.