I'm trying to use a library project with my Google AppEngine project as a project on build path.
Is there a way to get that included in the AppEngine project without having to copy the entire source or make a jar ?
I only use a small portion of the library so it seems like overkill to copy the whole jar and a lot of work to find the dependencies within the source to get only the parts I'm using.
I added an ant project builder that copies the class files from the dependent project.
The ant file resides in the gae project and copies the class files from the referenced project.
Here's the ant:
<?xml version="1.0" encoding="UTF-8"?>
<project name="CommonsCopy" default="copy" basedir=".">
<target name="copy">
<copy todir="war/WEB-INF/classes">
<fileset dir="../Commons/bin" includes="**/*.class">
</fileset>
</copy>
</target>
</project>
I named it 'CommonsCopyBuilder.xml' as it copies code from a commons project.
This will copy the files to the appropriate location just before running the project.
You are not going to like this answer, but No.
In order to include the library as a dependency in the project once deployed the required library must be found in your WEB-INF/lib directory as a jar. This is going to require you to you to create a jar based on the library you want to use. The other option is to do just as you said pull the dependent source into your project and use it from there.
During development you can make the library project a dependency of your app engine project by doing the following:
Under Project->Properties->Java Build Path->Projects Tab
select the "Add.." button to add a subproject to your build.
Note: This will not address the the running in a production environment.
I managed to do this by creating the libary project is a "Web Fragment Project" and adding it to the "Deployment Assembly" in the project properties of the app engine project.
However, the app engine project does not seem to work with non-trivial dependency structures. In my case, I had two app engine modules within an EAR, both depending on the libary project. However, the Google plugin only bundled the library project with one of the modules, never with both at the same time despite identical configurations. Obviously a bug.
My work-around was to add a linked source folder to the app engine projects, pointing to the source folder of the library project. Ugly, but it does the job.
Related
Following this community tutorial for setting up ktor in GCP AppEngine, I additionally modified the 'webapp' folder to be a full react-based SPA. Running npm start in the webapp directory works fine, as does running ./gradlew appengineRun in the outer directory. But when trying to deploy, it complains that I have >10k files. Without details, it seems the node_modules are most likely to blame.
Looking online for several hours, the old solution was to add a 'skipFiles' section to app.yaml, and the newer solution is to create a .gcloudignore file. In both, listing node_modules should cause them to not be deployed. But, with the tutorial I'm following, I don't have an app.yaml file - it's apparently being constructed from the various .xml configs as part of the staging step of the appEngine gradle plugin. I can create the .gcloudignore file, but it doesn't get pushed to the deploy staging folder (called 'build/staged-app'). Even manually placing it there, it doesn't build properly because then there is a skipFiles and .gcloudignore, which can't coexist.
I feel there is some 1 line change to make this work, but I have no idea what it might be. I've tried creating app.yaml files in the project with overridden settings, but the deploy step doesn't pick them up - it just always generates one from scratch it seems.
Any idea how I can get this to work? Am I doing something fundamentally wrong perhaps?
You do not have an app.yaml file becuaseu you are using the App Engine Gradle Plugin.
EDIT
It seems you have to follow exclude syntax using <exclude> elements. In a pattern, * represents zero or more of any character in a file or dir name, and ** represents zero or more dirs in a path. Files matching this element will not be uploaded when you deploy your AppEngine app.
An <include> element overrides the default behavior of including all files. An <exclude> element applies after all patterns (as well as the default if no explicit <include> is provided).
The following example demonstrates how to designate all .png files as static files (except those in the data/ directory and all of its subdirectories):
<static-files>
<include path="/**.png" />
<exclude path="/data/**.png" />
</static-files>
You can use this with your path node_modules
I'm working at the moment on an JSF Project project. Everything is working fine. Creating .war-file, deploying it.
What I actually want is, to create a executable JAR-file for a single Class. In this Class I have a Main-method that sends an email after executing it.
I the past I have worked with Eclipse. And that was very easy.
Now I am working with Netbeans. I have red a lot of posts with the information to clean and build the project. Next to that checking the .dist folder for the JAR-files.
I have either the .dist folder, or any JAR-files in my Project folder for that correlate file.
How can I easily create that JAR-file in Netbeans?
Assuming you are using a native NetBeans project rather than Maven:
The build artefact of a project is defined by it's project type. A JSB/Web project is always build into a WAR file.
If there is one class in your project that you want to put into a JAR file, the clean solution would be to create a new "Java" project with that class (as your class clearly has no dependencies to your Web Application this should work).
For such a project NetBeans will automatically create a runnable JAR file if you configure the main method.
In your JSF project you can simply include that project as a library. If you enable "Build projects on classpath", the jar will automatically be build when you build the web application.
Another approach would be to customize the Ant script NetBeans uses internally and add a target that builds your executable JAR file from that single class.
Details on how to customize the IDE generated Ant script can be found in the manual:
https://docs.oracle.com/netbeans/nb82/netbeans/NBDAG/create_japps.htm#CHDDAHEB
I have a bundle up and running in Servicemix. I went to my company's repository and downloaded the corresponding JAR to my local machine. I extracted that JAR and found out that this JAR had only one folder META-INF.
Inside this folder, there is a Manifest.mf file and my resources such as Spring configuration file and Camel Context file.
there I got my first question: where are the source files of this JAR i.e. JAVA classes and all. Only thing I saw there was manifest file, pom.xml, another pom properties file and couple of other configuration files for spring and camel.
this led to my next step. I had a local copy of this project in my workspace as well. I build this project locally and found the JAR in target directory of the project.
Now following steps might seem silly but anyway I did little experiment. I extracted this JAR which I found in target and extracted it to see the content. I believed it was a bundle because I used maven-bundle-plugin and there is no way you could tell by looking at a JAR that its just a JAR or an OSGI bundle. ok so I extracted the JAR and guess what this time it did have the compiled java classes.
this is not the end, I did something silly again. I removed the compiled classes from this JAR and made it exactly same as which I copied from my Company's central repository. Now I used a JDK's JAR creation utility to create a JAR.
Now I have two JARS:
one which I downloaded from company's central repo.
another one which I created myself. it has exactly same content as the other one. I even used the same manifest.mf while creating this JAR. (Since I knew Manifest is the backbone of an oSGI Bundle).
I secure copied this bundle in my server's home directory. and finally, I installed this Bundle/JAR in Servicemix using :
install file:path_to_JAR/JAR_FILE_NAME.
it got installed successfully. but when I tried to start this bundle. it could not start. by using display-exception, I saw the exception : it wasnt able to load the beans and could not
initialize the Application Context followed by a more specific exception "ClassNotFound" exception. I understand that it wasnt able to find the classes defined in my application context. BUT WHYYYYYYYYYY?
I did exactly same steps and I checked it multiple times. if mine could not start, why the earlier one is up and running.
It might sound silly for others who have worked in OSGI environment, But now I am starting to re consider especially ServiceMix.
Thanks for any suggestion.
This is nothing about OSGi, it's more something about your application.
As I don't know your project I just can do some assumptions.
First the jar you got from the Company Repository is most likely an "older" version and not the same as your local sources. With Servicemix it's quite possible to just have blueprint or spring xmls in your bundle cause those are valid resources a Camel-Blueprint/Spring extender are able to pick up. Those XMLs are interpreted and if those only make use of standard Camel Components there is no reason to have a single Class inside your bundle.
Now back to your newly created Bundle, obviously you have some new "Code" in your camel-xml which requires not only standard Camel classes but also some Processes you created on your own, now those classes need to stay in the Bundle!
Best just deploy the newly created Bundle with all it's classes. You should rather check what has changed in the camel xml files.
I'm trying out intellij to see what it is like to develop/maintain google app engine projects. I've used the GAE plugin for eclipse for a couple of years and it usually worked flawlessly for me but I've heard a lot about intellij recently so I wanted to see what I was missing.
I've read many sites that describe step-by-step how to create new GAE projects in intellij but none that describe how to do so for existing projects. I'm struggling with I imagine is some intellij 101 topics. I have a few questions that I'm bundling together here:
I added the Web/GAE facet to the project and specified the appropriate GAE SDK directory and appengine account info. What's the right way to associate the right SDK jars with my project?
IntelliJ recognized my maven imports and added them to my External Libraries, things like apache commons, slf4j, etc. How do these jars make their way into the (exploded war) artifact I created for the project? Are they automatically copied there after a successful compile?
I'm using JDO so I downloaded the DataNucleus plugin. How do I wire it up so it enhances my classes?
Thanks in advance.
File - Project Structure - Modules - AppEngine: at the right side is "Path to AppEngine SDK install directory". Click button right to it to select dir via file selector. This is the right way - here Intellij will use all the needed jars in your project, no need to add GAE jars by hand .
File - Project Structure - Artifacts: you should have a war artifact here. Create one if it's not there (+). Jars used in the project should be in "Available Elements" pane. You can add jars (if not added automatically) by drag-n-dropping them between panes. Yes, jars will be copied into war if they are in the left pane showing the contents of the package.
File - Project Structure - Modules - AppEngine: check the "Run enhancer for the following classes.." and select your classes/packages.
I wrote a Maven Plugin that creates some XML files on the classpath of my project. The Maven Project is fairly complex and has one master project with many sub projects (think services for a larger application).
The plugin takes a directory argument in the pom.xml, which is something relative to the classpath like this:
<docDestination>src/main/webapp/static/</docDestination>
However, when I try to access this folder via new File(docDestination), the resulting directory depends on the project (or sub-project) from which I ran the mvn install command that triggered the plugin.
The plugin is only specified in the pom.xml of one of the sub-projects, but if I run mvn-install from the parent it creates the XML files in the src/main/... folder of the parent application. How do I get the plugin to use the filesystem of the project in which it is declared rather than the filesystem of the parent project?
I should note that if I navigate to the sub-project in Terminal and run mvn install in that directory the files are created in the right place, which explains the title of my post.
Use the ${basedir} variable:
<docDestination>${basedir}/src/main/webapp/static</docDestination>
This should use the basedir currently used by the respective module (regardless of whether this is the top-level or a sub-module).