How do I create a new Google App Engine project in IntelliJ 12 which works? - google-app-engine

I'll begin by saying that I have no prior GAE experience - I'm trying to get GAE working in IntelliJ 12 but having issues, was wondering if anyone could have a look over what I'm doing and tell me if there's anything wonky here.
Steps:
Create Java project in IntelliJ with JDK 1.7.0_51. Click Next.
Select Web Application > Google App Engine on desired techs page
with path to appengine-java-sdk-1.8.9. Click Finish.
Copy files from appengine-java-sdk-1.8.9/demos/new_project_template/ to project
directory
I now have a main directory structure like:
.
├── COPYING
├── build.xml
├── html
│   └── index.html
├── src
│   ├── META-INF
│   │   └── jdoconfig.xml
│   ├── WEB-INF
│   │   ├── appengine-web.xml
│   │   └── web.xml
│   ├── log4j.properties
│   ├── logging.properties
│   └── org
│   └── example
│   └── HelloAppEngineServlet.java
├── test.iml
└── web
├── WEB-INF
│   ├── appengine-web.xml
│   └── web.xml
└── index.jsp
Running this will run the webserver with the index.jsp in the web directory.
A few questions around this - should there be a 'web' and an 'html' directory? Why are there two WEB-INF directories and should they both be the same? Should I manually edit both of them each time I update one?
If I then follow the instructions at https://developers.google.com/appengine/docs/java/gettingstarted/creating it mentions a 'war' folder - I confess that I'm confused about the 'war', 'web' and 'html' folders - I think somewhere I've also seen referenced a 'www' folder. Do these folder names actually matter?
Following the tutorial I create a guestbook folder within the 'src' folder and make the java file. When I enter the info in the web.xml (both of them) I get an error for the line
<servlet-name>guestbook</servlet-name>
"A field of identity constraint 'web-app-servlet-name-uniqueness' matched element 'web-app', but this element does not have a simple type"
To top that off - guestbook.GuestbookServlet doesn't resolve.
There has to be a simpler way of getting this running in Intellij - can anyone help me?

Unfortunately, IntelliJ does not make this process simple. It seems like they expect you to use Maven to handle a lot of this. But this makes things a lot harder on people trying to get started with GAE on IntelliJ.
Your project is a mess right now. You have combined things that IntelliJ added for your web module with some of the files from the demo projects. So to start, remove your files and remove your web module from IntelliJ.
Now go back to the demo folder that you want to use, it should include the COPYING, build.xml, and a src and war dir. Copy all of those to your project. Then go into project structure->modules and import module. This will allow IntelliJ to detect your web module and avoid creating duplicate files and dirs.
You also need to configure your Application Server under Settings->IDE Settings->Application Servers. Add a Google App Engine Dev Server and specify your SDK directory.
Then go back to your Project Structure->Module->Dependencies and add a Library. Select the Application Server Library that you just defined. If your project uses more advanced features of GAE, you will need to go to Project Structure->Artifacts and add the libraries to your artifact.
Also for the settings on the Artifact, you need to create an 'exploded war' definition that points to your war dir.
There is likely more configuration needed... but I can't think of it all right now. Let me know what you get stuck on next and I can try to help.

IntelliJ IDEA 14 Ultimate has integrated GAE support. How comprehensive this is I'm not totally sure yet. I'll update this answer shortly with more details.
https://www.jetbrains.com/idea/features/google_app_engine.html

Related

How can I get my Heroku variables in my react folder?

I have a react application using the MERN (mongo, express, react, node) stack on heroku.
I have some environment variables stored in Heroku that get read into the root of my project. However the actual react application is nested within a folder of the project. Here is the file structure
.
├── client (react app)
│ ├── node_modules
│ ├── package.json
│ ├── public
│ └── src
├── controllers
├── routes
├── models
├── server.js
├── node_modules
├── package.json
└── .env
My environment variables are named REACT_APP_AUTH0_CLIENT_ID, REACT_APP_AUTH0_DOMAIN, and REACT_APP_MONGODB_URI. These environment variables are available in the server.js file at the root of the project. However they are not available in the client folder (my react app). How can I set this up so the environment variables from Heroku flow through the entire project?
FYI if I add a .env file within the client folder I can access those variables. It seems like react is unable to access environment variables outside the actual react application.
Here is what I have in the package.json at the project root:
Any help would be greatly appreciated!

React project fails to use node modules in a git submodule

I have a Javascript (typescript) project that I am using as a git submodule in a react project (also typescript).
This all works fine... until I make use of any node module in the git submodule. I tried using, for example, the node modules "moment" and "faker", but I am almost certain that it does not have anything to do with these specific node modules.
Importing for example "moment" in the submodule:
import moment from 'moment';
using it:
moment().format('DD/MM/YYYY');
and running the main react project leads to this error:
Failed to compile.
./src/project_core/node_modules/moment/moment.js
Line 5:37: 'define' is not defined no-undef
Line 5:50: 'define' is not defined no-undef
Removing moment().format('DD/MM/YYYY'); solves it.
If I just run some tests directly in the submodule and make use of for example "moment", it always works. I can use the node modules. It looks like something goes wrong once the main project uses the node modules in the git submodule.
This is how my react project looks like. As you can see the submodule project_core is added in the src folder of the main project.
├── build
│   ├── assets
│   └── static
│   ├── css
│   └── js
├── node_modules
├── public
│   └── assets
└── src
├── project_core
│   ├── node_modules
│   ├── src
│   └── tests
├── ui
├── api
└── utils
I know... I read everywhere that using git submodules is not recommended. I, however, just want to experiment with git submodules to learn from it.
It looks like you have a node module inside a node module. This probably confuses your bundler and produces the import errors. Try removing the package.json and node_modules from your project core subdirectory and see if the imports work correctly. If you want to make your core directory a library think about actually having it as a npm dependency instead of a submodule. You could still reference a git commit hash in the dependency.

How to include ThrowTheSwitch/Unity in a C project?

I would like to use ThrowTheSwitch Unity for my unit tests in several projects so I have this generic structure:
.
├── README.md
├── Makefile
├── src
│   ├── ...
│   └── main.c
└── test
   ├── vendor
   │   ├── unity.c
   │   └── unity.h
   └── test_main.c
To include unity I could use different approach:
Git Submodules
pros: git only, one single source of truth
cons: get all the unity repository while only 3 files are required
Git Submodules with sparse checkout
pros: only get what I need
cons: need some hack to enable the sparse-checkout
Git Subtree
pros: safe if no internet available
cons: keep local copies of unity in the history
Wget from a release
pros: very simple, very effective
cons: dependency on wget and tar and internet (no local cache)
Local copy of unity
pros: most simple solution, effective
cons: not SSOT, all similar projects will have their local copy of unity, lost track of which unity version is synced.
It seems none of the above method is perfect and I don't know which one to choose. The best solution would be to have a simple package manager with a package.json file that list my dependencies and their versions.
Is there any other/better solution?

electron Failed to load resource: net::ERR_FILE_NOT_FOUND

I have simple problem but I can't seem to get the correct path right. everything seems to be OK, followed tutorial from here
I have file structure like here.
.
├── Makefile
├── README.md
├── app
│   ├── electron.html
├── app.js
├── bower.json
├── bower_components
│   ├── Chart.js
I tried loading some local resources in electron.html my local resources
<script src="../bower_components/angular-route/angular-route.min.js"></script>
but..
Failed to load resource: net::ERR_FILE_NOT_FOUND
file:///bower_components/angular-route/angular-route.min.js
how do I load the local resources?
thanks to electron 1.0 btw. I wanted to try it out fast though..

Standard directory structure for a React project (or component library)?

I'm trying to find out the right folder structure for my React project.
This is the typical webapp structure that I currently use:
app/
scripts/
app.jsx
Component.jsx
__tests__/
Component-test.jsx
styles/
main.scss
_other.scss
index.html
favicon.ico
dist/, dev-build/
(almost the same structure as /app)
docs/
Component.md
node_modules/
(all the 3rd party libraries and plugins)
package.json
gulpfile.js
.eslintrc
various other configs
I find it very far from perfect. Structure like this made sense in the times of MVC and similar) frameworks, but it doesn't make much sense when it comes to React components, because component-related stuff is spread across app/scripts/Component.jsx, app/scripts/__tests__/Component-test.jsx, styles/_other.scss and docs/Component.md. For more complex component it gets even worse, because they need data mocks, both for unit tests and the docs page.
I think that restructuring the project to have one directory per component would already help a lot:
some/path/Component/
index.jsx
readme.md
mockData.json
test.jsx
style.scss
But I still can't figure out the details. I'd like my code to be runnable with Node, webpack and/or browserify. I'd like to be able to develop components live in the style guide. I'd like to be able to run all my unit tests at once. The list goes on.
Is there any industry standard (best practice) for structuring React projects? Could you provide a good structure example? I'm tired of structuring it on my own and then seeing maintenance problems, I feel I could avoid all this by following an industry standard.
I understand that the question is very broad but I believe that answering it well will be a great benefit for the community.
I've came up with this structure and it works pretty well
Create react app provides the following structure :
.
├── index.html
├── node_modules
├── package.json
├── README.md
└── src
├── App.css
├── App.js
├── App.test.js
├── favicon.ico
├── index.css
├── index.js
└── logo.svg

Resources