Building Maven Plugin - API to resolve maven properties - maven-plugin

I am creating a plugin that reads information from the pom and I'm encountering some properties such as ${basedir} etc when it comes to the elements that specifies directories. I was wondering if Maven have a API that I can use where I can just pass on that properties and they can resolve it for me.
preferably not having to run another plugin first. Its possible to do the crude way but was just wondering if there's anything "fancier" that i could use.
thanks!

Declare a property which maven will inject the MavenProject model into:
/** #parameter default-value="${project}" */
private org.apache.maven.project.MavenProject mavenProject;
Then you can access properties via getProperties() as described here:
http://docs.codehaus.org/display/MAVENUSER/Mojo+Developer+Cookbook#MojoDeveloperCookbook-StoringProperties
You'll also need to declare a dependency on org.apache.maven:maven-project:${version of maven} in your mojo's POM.
I hope that was what you were asking about...
-tim

Related

thorntail uberjar : reference an external module

i am quite struggeling on an implementation :
i am trying to make a generic uberjar, totally agnostic of the target environment.
In the meantime, i am referencing in my jboss-deployment.xml a module named configuration.
i would like that my uberjar generates a reference to this external module which is outside the jar, let's say /home/user/modules/configuration
I tried to use the additionalModules property of the thorntail plugin to reference this module, but nothing is working.
How do you do this guys ?
having a generic uberjar
having a module externalized to the uberjar which contains the environment needs
Regards,
Guillaume

Could not load extension class org.apache.cxf.ws.policy.AssertionBuilderRegistryImpl

I'm running junit on a class that is configured for cxf. I get this error
Caused by: org.apache.cxf.bus.extension.ExtensionException: Could not load extension class org.apache.cxf.ws.policy.AssertionBuilderRegistryImpl.
when I ask Spring to retrieve the instance on he class. maven dependency includes cxf 2.7.4 (cxf-rt-ws-policy-2.7.4.jar) and I see neethi 3.0.2.jar is also included. Another post mentioned an issue if neethi 2.x was used with cxf 2.x. but this is not my case.
Use mvn dependency:tree to find out which dependency also has the org.apache.neethi:neethi:{version}. In my case it was the org.wso2.carbon.core.
To fix this I added the neethi dependency needed, first in my dependency pom tree.

how to run ngStorage with typeScript

is it possible to include ngStorage within typeScript? I get TS2304 error but I can't find .d.ts file at definitelyTyped I could include.
I wanna store tokens which I use in REST requests. Any other suggestions on this? I couldn't make it working with $sessionStorage either. Apparently I don't have enough knowledge about typeScript, I might not include something I should have.
Thanks in advance.
Short Answer
Yes!
Longer answer
Yes you can use ngStorage with TypeScript.
Being that TypeScript is a superset of JavaScript, so anything you can do in JavaScript you can do in TypeScript (Note there are some differences, but not in regards to using other libraries). If you are unable to find a .d.ts file for this module then you have two choices to use it.
Specify the type of any of the services/factories to have a type of any
Create your own .d.ts to represent this module, or at least the pieces of it that you are using
If you decide to head down the route of #2, it would be nice for the community to submit a pull request to the definitely typed repo to include the definition you created.
A one year old question. But just to update, there is a .d.ts file available for ngStorage.
Run the below command and off you go.
tsd install ngStorage --save --resolve

Sencha Cmd v3 build error when implementing Bryntum Scheduler

Using Cmd 3.0.0.141, I have successfully generated a workspace and an Ext app in that workspace. The application builds correctly until I attempt to integrate the Bryntum Scheduler, where I encounter an error when I try to build:
"Failed to resolve dependency Sch.panel.SchedulerTree for file ExtCalendar.view.Tree"
the app is very simple at this point, uses Ext.application and follows the MVC pattern where I have a view defined "ExtCalendar.view.Tree" that extends 'Sch.panel.SchedulerTree". I also have models and stores that extend Bryntum classes as well, so I assume the compiler will trip over those as well, since it can't see the Sch namespace.
I've added a 'js' path to my app.json that points to the bryntum js file where 'Sch.panel.SchedulerTree' comes from. I've tried to run the 'refresh' command with the same results (Failed to resolve...). I've regenerated the bootstrap.js file manually using 'compile', but nothing from the Sch namespace ever gets added to it, despite the Brytum lib file being in the classpath.
What do I need to do in order to successfully run the 'build' command with libs like this?
Or, do I need to take a more granular approach using the 'compile' command?
With the help of the nice folks on the Sencha forums, I was able to resolve my build issues. The solution, for me, involved a shim. I added an external shim.js file to my index with as many //#require and //#define directives as needed in order to resolve the dependency issues.
According to the nice folks at Bryntum, once I upgrade from the free-trial version of the Bryntum Scheduler, I will be able to get rid of the shim and simply rely on the sencha.cfg classpath pointing at the Bryntum src.
Also, as an aside, the app.json file is not used in ExtJS apps, its inclusion in the generated files was a bug in build 141 of Cmd v3.
See this thread for more detail.

Jersey linking support with Google App Engine issue

I didn't manage to use the Jersey linking support with Google App Engine, I'm getting these exceptions when trying to access the application :
Caused by: javax.el.ELException: Could not find expression factory class
...
Caused by: java.lang.ClassNotFoundException: de.odysseus.el.ExpressionFactoryImpl
As specified in the documentation, I put this in the Jersey servlet section of the web.xml :
<init-param>
<param-name>com.sun.jersey.spi.container.ContainerResponseFilters</param-name>
<param-value>com.sun.jersey.server.linking.LinkFilter</param-value>
</init-param>
I also add the jersey-server-linking-1.13.jar to the WEB-INF/lib directory of my project.
I tried to add el-api.jar first, then juel-2.1.0.jar to the WEB-INF/lib directory but I'm still getting these errors.
I'd like to know if someone could give me some hints about the way to deal with this. When I don't use the Jersey linking jar, everything is working as expected.
I had a similar problem with my GAE app. It was working fine with el-api and el-impl but started asking for de.odysseus.el.ExpressionFactoryImpl as development progressed. I made the switch but when I added JUEL to my pom.xml, I got the same error as John Prince (java.security.AccessControlException).
The solution for GAE users is to use JUEL 2.2.7.
At the time of this writing, 2.2.7 is not available in maven central. However, you can find it on
<repository>
<id>repo-id</id>
<name>repo-name</name>
<url>https://oss.sonatype.org/content/repositories/snapshots/</url>
</repository>
and link with whatever you need from
<dependency>
<groupId>de.odysseus.juel</groupId>
<artifactId>juel-api</artifactId>
<version>2.2.7-SNAPSHOT</version>
</dependency>
<dependency>
<groupId>de.odysseus.juel</groupId>
<artifactId>juel-impl</artifactId>
<version>2.2.7-SNAPSHOT</version>
</dependency>
<dependency>
<groupId>de.odysseus.juel</groupId>
<artifactId>juel-spi</artifactId>
<version>2.2.7-SNAPSHOT</version>
</dependen
Source: https://github.com/beckchr/juel/issues/73
The issue is due to de.odysseus.el.ExpressionFactoryImpl class not being found. I will assume that you have added the jars as you have mentioned to the WEB-INF\lib folder.
I would suggest that you view the JAR files via theProject Explorer , simple expand them in Eclipse and see if you can find the de.odysseus.el.ExpressionFactoryImpl class in ny of the JAR files that you have added.
I "solved" the problem by adding "juel" and "juel-impl" as dependencies of my project (we're using Maven; if you're doing it manually, you might have to figure out exactly what those projects contain).
However, as soon as I did that, I started getting a different exception:
java.security.AccessControlException: access denied (java.io.FilePermission C:\Program Files (x86)\Java\jdk1.6.0_33\jre\lib\el.properties read)
at java.security.AccessControlContext.checkPermission(AccessControlContext.java:374)
at java.security.AccessController.checkPermission(AccessController.java:546)
at java.lang.SecurityManager.checkPermission(SecurityManager.java:532)
at com.google.appengine.tools.development.DevAppServerFactory$CustomSecurityManager.checkPermission(DevAppServerFactory.java:289)
...
I'm pretty sure that's because it's running afoul of GAE restrictions.
I noticed in the original ClassNotFound exception it was trying to use the URLClassLoader; I'm also wondering if that problem was ultimately a GAE issue as well.
At this point, it seems like Jersey linking support isn't compatible with GAE.
This issue is (or rather was) due to a missing implementation of the Unified Expression Language. The EL API defines a static method that looks up an implementation of the ExpressionFactory class. There are various ways to define which implementation is to be used:
Use the Services API (as detailed in the JAR specification). If a resource with the name of META-INF/services/javax.el.ExpressionFactory exists, then its first line, if present, is used as the UTF-8 encoded name of the implementation class.
Use the properties file "lib/el.properties" in the JRE directory. If this file exists and it is readable by the java.util.Properties.load(InputStream) method, and it contains an entry whose key is "javax.el.ExpressionFactory", then the value of that entry is used as the name of the implementation class.
Use the javax.el.ExpressionFactory system property. If a system property with this name is defined, then its value is used as the name of the implementation class.
Use a platform default implementation.
(Source: http://docs.oracle.com/javaee/7/api/javax/el/ExpressionFactory.html#newInstance())
App Engine appears to have defined JUEL as default implementation but does not provide the respective packages.
In order to solve this, you need to (1) provide EL API and implementation packages and (2) use one of the above ways to link it. See https://stackoverflow.com/a/19814199/2099217 for details.

Resources