Play framework 2.1 can't use custom modules - module

I'm not able to use a module which I created by myself. I do everything like the following description:
http://java.dzone.com/articles/writing-modules-play-2-get
But there are little changes which shouldn't have any influence of the functionality: I don't change the project-struktur and i create separates projects in different folders. I think I should describe my steps for using and creating my own module and perhaps anyone see my mistake:
I create one project with play new testapp (workspace/testapp). Then i create an other projekt with play new testmodul (workspace/testmodul). Then i go to the testmodul and delete the route-file and the content of the application.conf. Then i create a class called "Tester" with the method test. (a simple system.out) After that i exceute "clean", "compile" and "publish-local" in the testmodul-folder.
In my understanding the modul ist published in the local repository of play and every application which want to use this module will have access to the local repository version of the module.
Now I go to the testapp and create the dependencies in the Build.scala. After that i go to the default-Application.class and add the line "Tester.test();". Then I excecute the dependencies command and try to compile.
After that i get the error, "can't find symbol". It seemed to be that the testapp don't know the Tester.class and that means that the testapp don't know the module.
But I don't know why.
Has anybody an idea?
Edit:
Perhaps I should display my dependencie config of the testapp:
val appDependencies = Seq(
// Add your project dependencies here,
javaCore
,javaJdbc
,javaEbean
,"testmodul" % "testmodul_2.10" % "1.0-SNAPSHOT"
)
val main = play.Project(appName, appVersion, appDependencies).settings(
// Add your own project settings here
resolvers += "Local Play Repository" at "file://C:/play-2.1.0/repository/local"
)

I'm not sure why the solution above wasn't right, but i found a solution. I found out that in the documentation of the playframework "modules" called "subprojects" there I found how to include modules. (http://www.playframework.com/documentation/2.1.0/SBTSubProjects)
But I think the other way of "global" modules should also be possible.

Change this line
resolvers += "Local Play Repository" at "file://C:/play-2.1.0/repository/local"
To
resolvers += "Local Play Repository" at "file://play-2.1.0/repository/local"
Just remove the C:/ .It worked for me. Check this http://www.objectify.be/wordpress/?p=363.

Related

How to create a Kotlin console application with Gradle in Intellij IDEA

I found this tutorial from JetBrains: https://www.jetbrains.com/help/idea/create-your-first-kotlin-app.html?section=Gradle%20Kotlin
It is dated August 19th, 2020.
I am using the same IntelliJ IDEA version as in their documentation: 2020.2.
However, my project creation wizard looks quite different from theirs.
They provide this screenshot:
But for me, it looks like this:
and when I click on Next:
I don't see where I can choose the Console Application template, or Gradle.
I found a second tutorial - https://kotlinlang.org/docs/tutorials/jvm-get-started.html , which shows yet a third variation of the New Project wizard:
Are the tutorials out of date? Am I doing anything wrong? How do I create a Kotlin project, based on a console application template, with Gradle?
The wizard you have seems to be obsolete now. There was a brand-new one, released as a part of Kotlin 1.4 recently(see here). Most probably, the problem is caused by the Kotlin IDE plugin being outdated or something. Please try to delete in and re-install using the Preferences -> Plugins menu. Comment here with the results, please. I'd like to know if this would help.
Indeed it's quite weird, I've never seen the dialog to look like yours (mine looks like the one in the tutorials). However, choosing the template doesn't do anything special - it simply creates the main file, which you can do so yourself.
So create a new project with the "JVM/IDEA" option. If it already opens up a main.kt file, you don't need to do anything else. If it didn't, look in the src folder - you should see a folder named main with a folder named kotlin (with a blue icon instead of grey) inside - here's where you wanna create your main file (right click -> new kotlin file/class -> main.kt and make it a file, not a class). Finally, put this in the file:
fun main(args: Array<String>) {
println("Hello world!")
}
Note: if you don't have a kotlin folder, create the file in the folder with the blue icon (might even be src). Also, if this doesn't use Gradle (for some reason), create a Gradle project instead, and at the "Additional libraries and frameworks" option, uncheck Java and check Kotlin, then continue with creating main.kt if it isn't created.
You may create a Kotlin + gradle project from the terminal:
$mkdir myProject; cd myProject; gradle init
follow the tutorial.
And then start the Intellij & open the dir
You're good to go
Same process like this
The same happened to me but I figured out how to fix it:
Just disable Material Theme UI.

How to create subprojects inside Play with Intellij?

Currently I have the following Play project structure:
PlayApp
modules
common
sub_project_two
PlayApp is marked as a module, dependent on common.
modules is just a directory.
common is a sub project(also a play app).
sub_project_two is a sub project(also a play app), which is dependent on common.
Unfortunately I cannot just right click on "modules" and create new module(play app) and move on. Currently, I literally have to right click PlayApp and create the new module then move it to "modules", and it is running into dependency issues in Intellij and failing to import the classes inside "common".
What is the correct way of creating subprojects inside Intellij?
There is no any special way to create subprojects in Intellij. Subprojects are defined in sbt build file. Intellij will discover these projects and configure them as long as you have Scala plugin. I would imagine a following project structure in your build file:
lazy val PlayApp = Project("playApp", file(".")).aggregate(common, subProjectTwo)
lazy val common = Project("common", file("modules/common"))
lazy val subProjectTwo = Project("subProjectTwo", file("modules/sub_project_two"))
For more details visit: http://www.scala-sbt.org/0.13.5/docs/Getting-Started/Multi-Project.html

How to set up a multi-module project with equal hierarchy modules in IntelliJ?

I am wondering how to configure the following project layout in IntelliJ:
An Android application
A server back end feeding data to this application
Bean classes that are shared between back end and Android application
Initially, I wanted to create three modules on an equal hierarchy level. However, this does not seem to be possible with IntelliJ. I can only add new modules inside of the first module. I wonder if this is the way I am supposed to do it? Or is there a better way to do configure this project layout with IntelliJ? Do these hierarchies only represent folders?
I feel like I should make (3) a library module and add dependencies to (1) and (2). Since a module is defined as a discrete unit of functionality which you can compile, run, test and debug independently I feel like this is the right approach.
This is my first multi-module project in IntelliJ. Any explanation is appreciated!
When creating a new project you can use the Empty Project option on the first wizard step. When the project is created, add 3 modules in different folders under the Project Structure settings.
If you want to add them on a already initialized project, the trick from #CrazyCoder works, but you must not choose Empty Project, but instead Empty Module (in the Project Structure -> Modules dialog).
Then, choose the existing project.
Lastly, on the right side, the content root might be wrong. Set it to the root of your module.
Make sure the submodules are not on root level on the Project Structure -> Modules page. If they are, remove all expect the root module, delete the content root on the right, and add it again.

Adding Google Objective-C API 'GTL' to iPhone project

How to I add the Google Drive API to my iPhone project to I can use it?
So far, I have dragged the GTL project into my current app project (so that it is nested under my app project). Then, under my app target's build phases, I added GTL.framework, and then added GTL.framework to my 'Link binary with Libraries' (see attached pic). This throws the following error:
clang: error: no such file or directory: '/Users/xxx/Library/Developer/Xcode/DerivedData/Golf-hfbczyaemhyzgvbrtgdxqnlzeuaa/Build/Products/Debug-iphonesimulator/GTL/GTL'
How to I fix this?
I struggled with this exact issue for most of the day today, and I found it extremely frustrating. I have finally figured it all out so here is a straightforward step by step guide on how to add the Google API to an iOS7 project using XCode5, using ARC, without having to create Workspaces or any of that.
The answer provided by RawMean works well, but it gave me issues with ARC. I also didn't like the fact that you had to add project, create a workspace and then delete the project. So my solution will deal with both these issues.
Check out the code. To do this, you can just run svn checkout http://google-api-objectivec-client.googlecode.com/svn/trunk/ google-api-objectivec-client-read-only from your terminal. I will refer to this code as "Google's code".
Go to your project's Build Phases. Expand "Link Binary With Libraries" and add Security.framework and SystemConfiguration.framework. These two are required by Google's code.
Go to your project's Build Settings. Using the search box there, look for Other Linker Flags (make sure "All" is selected to the left of the search box). Add -ObjC -all_load.
Now search for User headers search path and add the full path to Goggle's /Source directory. Make sure you select recursive.
Using Finder, go to Google's /Source/OAuth2/Touch directory. Drag and drop GTMOAuth2ViewTouch.xib into your project.
Go back to Finder and go to Google's /Source directory. Drag and drop GTLCommon_Sources.m and GTLCommon_Networking.m into your project.
Now, you need to import the files for the services you want to use. In my case, I need to use Google Drive, so I'll add those. In finder, go to Google's /Source/Services/Drive/Generated directory. Drag and drop GTLDrive.h and GTLDrive_Sources.m into your project. If you want to use other services, go to their directory and import the appropriate .h and .m file.
For some reason, Google's code doesn't use ARC, so if you try to build right now, you will get ARC compile errors. So we need to disable ARC for Google's code only. To do this, go back to your project's Build Phases, but this time expand "Compile Sources". Make sure that GTLCommon_Sources.m and GTLCommon_Networking.m are there. Select them, press enter and type in -fno-objc-arc. This will disable ARC for both of them. Make sure you don't add this option for any other file (unless you know what you're doing).
You are done! Now, whenever you want to use Google's API, just import GTMOAuth2ViewControllerTouch.h and your service header. In my case, since I'm using Google Drive, I will also import GTLDrive.h.
I hope that helps and saves some people from pulling all their hair out.
I struggled with this error message as well. This is how I solved it:
Make sure you have added the folder for the service that you are using under GTLSource/Common/ (e.g., add the Drive folder for GoogleDrive).
Under GTL.xcodeproj (that you have already added to your workspace) find the GTLSource folder and drag it to your main project (Golf in your case). Done!
Now you can remove references to the GTL.xcodeproj that you have added to the workspace.
With this approach, you don't even need to add the libraries (so remove them from the list of linked libraries if you have added them).
The Google API documentation is nothing like Apple's documentation (it's not good).
I should also mention that I'm building an app for iOS and not MacOSX, but this should work for OSX as well.
Not only doing the above, but go under "[Project Name] Targets->Build Phases> Compile Sources" and click the + button. Then add all the .m files, for some reason most of the aren't automatically.
I also had to delete (the reference) to "GTLDrive_Souces.m" from the Drive folder, but I don't understand why i had to do that part.
Better to use Pod
How to install CocoaPods and setup with your Xcode project
for reference : [http://blogs.triffort.com/?p=309][1]
Open the pod file and add
pod 'Google-API-Client/Drive', '~> 1.0' save pod file and call pod install in terminal. Note:pod file you must give link_with
'Your_project_name', 'Your_project_nameTests' after this line only add
your library
this is does not really solve the problem of installing Google API's but in this repo I accessed Google Forms from an iOS app without using Google's API. https://github.com/goktugyil/QorumLogs
So you may skip the installing API part in some projects
Here is the tutorial of how to set it up:
https://github.com/goktugyil/QorumLogs/blob/master/Log%20To%20GoogleDocs.md
Heres the code to do it:
private static var googleFormLink: String!
private static var googleFormAppVersionField: String!
private static var googleFormUserInfoField: String!
private static var googleFormMethodInfoField: String!
private static var googleFormErrorTextField: String!
/// Setup Google Form links
static func setupOnlineLogs(#formLink: String, versionField: String, userInfoField: String, methodInfoField: String, textField: String) {
googleFormLink = formLink
googleFormAppVersionField = versionField
googleFormUserInfoField = userInfoField
googleFormMethodInfoField = methodInfoField
googleFormErrorTextField = textField
}
private static func sendError(#text: String) {
var url = NSURL(string: googleFormLink)
var postData = googleFormAppVersionField + "=" + text
postData += "&" + googleFormUserInfoField + "=" + "anothertext"
postData += "&" + googleFormMethodInfoField + "=" + "anothertext"
postData += "&" + googleFormErrorTextField + "=" + "anothertext"
var request = NSMutableURLRequest(URL: url!)
request.HTTPMethod = "POST"
request.setValue("application/x-www-form-urlencoded; charset=utf-8", forHTTPHeaderField: "Content-Type")
request.HTTPBody = postData.dataUsingEncoding(NSUTF8StringEncoding)
var connection = NSURLConnection(request: request, delegate: nil, startImmediately: true)
}

After adding new class file to App_Code, build action is Content instead of Compile

In VS2008, I am adding new classes to a web project.
When I right-click on App-Code -> Add -> New Item -> Class ...
The build action for the newly created item is set to content instead of compile. This seems like it would be a problem with the template. I've found several others through google who have run into this issue, but nobody seemed to have found a more permanent solution, other than "change it from content to compile after creation."
My question: Does anyone know of a fix for this, official or otherwise?
App_Code is a special folder meant for folder based projects.
This is just a hunch, but it might be that you have a project file based project, instead of a simple folder based one.