I'd like to use the IntelliJ IDEA IDE to develop some app using Processing 3. How can I do that ?
There are only tutorials on how to use Processing 2, but I think things have changed enough so that those tutorials do not work anymore.
Thank you
It's hard to answer general "how do I do this" type questions. Stack Overflow is designed more for "I tried X, expected Y, but got Z instead" type questions. You'll have much better luck if you try something out and post an MCVE along with a specific question if you get stuck. You say you think things have changed enough so that those tutorials don't work anymore- could you test that assumption by trying it out?
Because those tutorials will still work. A few things have changed, such as the removal of the ability to embed a PApplet directly into a Swing application. But 90% of the rest of the tutorials should work fine.
Step 1: Add the Processing library to your classpath. This includes the core and any JOGL dependencies you need.
Step 2: Create a class that extends PApplet and add your code there.
Step 3: Call PApplet.main("YourSketchNameHere"); to launch your sketch.
Here is a little example that shows those steps:
import processing.core.PApplet;
public class ProcessingTest extends PApplet{
public void settings(){
size(200, 200);
}
public void draw(){
background(0);
ellipse(mouseX, mouseY, 20, 20);
}
public static void main(String... args){
PApplet.main("ProcessingTest");
}
}
Please try something out and post a specific question if you get stuck. Good luck.
Shameless self-promotion: I wrote a tutorial on using Processing as a Java library, available here.
I up voted Kevin's answer but also went ahead and created a gradle project that you can use with or without an IDE or processing.
Git Commit to processing project
Edit
doesn't work for video libraries. i tried to get the libraries needed but that is not my best area and have resorted to use P3 for those projects.
The easiest way for me is to create a new maven project and add proessing through maven.
After that you create your class that extends PApplet (I named it Main).
In Run > Edit Configuratins add the main class name and the same name for program arguments.
Create a maven project in Intellij. In one folder (example "libs") you put all libs which are probably not yet available via mavencentral, but with the help of maven you can handle the installation automatically.
libs
Then inside the pom.xml you add a maven-install-plugin, which will install your libs for you inside your local repository.
<profiles>
<profile>
<id>Assembly Gui</id>
<activation>
<activeByDefault>true</activeByDefault>
</activation>
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-install-plugin</artifactId>
<version>${maven-install-plugin.version}</version>
<executions>
<execution>
<id>install-controlP5-lib</id>
<goals>
<goal>install-file</goal>
</goals>
<phase>validate</phase>
<configuration>
<groupId>sojamo.de</groupId>
<artifactId>controlP5</artifactId>
<version>${controlP5.version}</version>
<packaging>jar</packaging>
<file>${basedir}/libs/controlP5-2.3.0.jar</file>
<generatePom>true</generatePom>
</configuration>
</execution>
<execution>
<id>install-appleJar-lib</id>
<goals>
<goal>install-file</goal>
</goals>
<phase>validate</phase>
<configuration>
<groupId>processing.org</groupId>
<artifactId>appleJar</artifactId>
<version>${appleJar.version}</version>
<packaging>jar</packaging>
<file>${basedir}/libs/apple.jar</file>
<generatePom>true</generatePom>
</configuration>
</execution>
</executions>
</plugin>
Note that both libs are "installed" during the "validate" phase, so the order is
clean
validate (here your processing libs are installed)
compile (and here they can be retrieved later from your local repo)
test
...
Because the maven-install-plugin was inserted as a profile (active as default), you can switch it off inside Intellij for saving a bit of time during builds once it runned at least once.
Profiles in Intellij
Download the .jar files from their official site
keep in mind that the Maven version is outdated
Create any Java (or Kotlin) project in IntelliJ
for this tutorial I've used Maven
Inside IntelliJ, go to File > Project Structure
or pressCTRL + ALT + SHIFT + S at the same time
Inside Project Settings > Libraries: Click Plus icon
navigate to the downloaded folders
Add everything inside processing-X.Y.Z/core/library
for other dependencies, look into modes library
e.g.: for SVG export, add processing-X.Y.Z/modes/java/libraries/svg/library
To make it easier to use Processing within an external IDE, I implemented a rudimentary wrapper. This will avoid the necessity to inject the Processing-Object to each created class that want to use Processing methods.
Have a look: Using Processing within external IDE
Related
I am upgrading the swagger and related versions to swagger2.
While doing maven clean install getting the below error.
Failed to execute goal org.apache.maven.plugins:maven-compiler-plugin:3.1:compile (default-compile) on project : Compilation failure[ERROR] cannot access javax.annotation.concurrent.NotThreadSafe.
plugin from POM.xml which is throwing exception:
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.1</version>
<configuration>
<source>1.8</source>
<target>1.8</target>
</configuration>
</plugin>
I could see javax.annotation-api 1.3.1 maven dependency in my pom.xml. Still class file for javax.annotation.concurrent.NotThreadSafe not found
Please don't suggest the solutions given in https://stackoverflow.com/questions/42525139/maven-build-compilation-error-failed-to-execute-goal-org-apache-maven-plugins/49299241 or any other stack overflow links. Since I have tried all but no progress.
Ok so after spending a full day to sort this out, I have found the systematic approach to it. Here it goes:
1. As we all know, class file not found error is when compiler is not able to find the class itself. So when you add some dependency, cross check in your repository jar, if class is present there or not(you will find on google that many dependencies claimed for the class, though it wasn't there in any)
2. To confirm if the class is present,
a. Go to the repository directory of the jar file.
b. And run command : jar tf {jar_file_name}.jar
c. It will list out the classes present in the jar file.
3. In this way you can add the exact desired dependency required.
Note: this solution is generic for all the class not found error.
I am running maven build and storing files in Artifactory. One issue I am facing is when ever I try a -snapshot version it overwrites the binary in Artifactory. I tried using the Maven build number plugin, but running in to issues.I reffered to this
http://blog.codehangover.com/track-every-build-number-with-maven/
Describing below What I did?
Updated the masterpom.xml with following line.
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>buildnumber-maven-plugin</artifactId>
<version>1.0-beta-3</version>
<executions>
<execution>
<phase>validate</phase>
<goals>
<goal>create</goal>
</goals>
</execution>
</executions>
<configuration>
<doCheck>false</doCheck>
<doUpdate>false</doUpdate>
<format>${version}.{0,number}</format>
<items>
<item>buildNumber</item>
</items>
</configuration>
</plugin>
Now I update the pom of ear and webproject as below
<build>
<finalName>${project.artifactId}-${project.version}.${buildNumber}</finalName>
</build>
When I ran mvn clean install, ear and war got generated but when i checked the war inside the ear I am finding it as some thing like war-1.0-SNAPSHOT-null.war. I believe the war and ear couldn't get the buildNumber parameter. I was able to successfully generate the buildNUmber.property files and was able to increment the number by running the buildnumber:create plugin. Here are my questions
What I am doing wrong here and why the buildNumber parameter is not picked.
Also I want to generate all the binaries including jars in the following format binary-version-Snapshot.${buildNumber}. So Do i need to update pom of each file or any other way to update this?
Also we are using Hudson builds for Continous Integration and we want to separate developers builds with Hudson Build number. How can we achieve this if we don't want to checkin the buildNumber.properties after the Hudson build.
To get unique snapshots use the uniqueVersion flag (see James Lorenzen's Blog). If you use the maven goal deploy:deploy-file the uniqueVersion flag is true by default. At my company we have the following policy. Only "official" snapshots go to the repository. A "official" snapshot is one that was build on our reference system (our Jenkins ci server). We don't need the unique feature for snapshots, since we let Jenkins archive the artifacts. This way we can always go back to a certain version if we would like too by using Jenkins. If the build breaks the snapshot will not be deployed to the repo.
To your 2nd question; my understanding is that you need to update every pom file. But since it is a one time change, it shouldn't be too much of a burden.
I am not completely understanding your 3rd question ("... separate developers builds with Hudson Build number..."). In case you want to add the build number for every build done by Hudson, you have several options.
You can add a string as classifier while deploying. Maven will add that classifier in the filename (artifactID-version-classifier.jar - e.g. my.company.calendar-0.0.1-Snapshot-Hudson.jar). The artifact will be retrieved by adding the classifier to the dependency.
add another parameter to your maven call - outputfilename (${project.build.finalName}, see maven docu)
changing your version string to something like
I am using the maven-eclipse-plugin to configure my eclipse workspace with the configure-workspace goal of the plugin.
I need to perform some additional setup within the workspace that standard eclipse plugins do not appear to accomplish. Setup MAVEN_HOME and setup an external build tool for example. I have some corporately built plugins that can perform these tasks. What I would like to do is bind the execution of this plugin to the execution of eclipse:workspace-configure.
I have tried to do this by:
<executions>
<execution>
<goals>
<goal>eclipse:configure-workspace</goal>
</goals>
</execution>
</executions>
But have had no luck. Is this possible?
I am using the maven-eclipse-plugin to configure my eclipse workspace with the configure-workspace goal of the plugin.
The goal eclipse:configure-workspace doesn't do much things, it just adds the classpath variable M2_REPO to Eclipse.
What I would like to do is bind the execution of this plugin to the execution of eclipse:workspace-configure
Not possible, you can only bind a plugin goal to a phase. Your best option is IMO to create an init script that would call the goals sequentially.
You can't bind an maven plugin to an other. You can configure to run one plugin after an other. For example to run the eclipse plugin first and you coperate after that. You need to define them directly within the same phase. On the other hand the example you give can't really work cause you're trying to bind a goal which with the plugin name. You have to use the configure-workspace only in the goal.
I'm trying to write a pom.xml that will allow me to run a command locally and fetch all dependencies that my jruby Rails app has. I'm seeing two different configs though and I'm not totally sure which to use (as I'm not a java person whatsoever)
First, many Pom's i'm seeing just have a tag under the root of the pom.xml that list all dependencies. This doesn't however have any information about where these are stored etc... so I feel like this isn't what I want (I need to copy them to my rails lib dir)
Second option, I'm seeing in the mvn docs is to use the maven-dependency-plugin, which seems more like what i'm looking for. I assume then that my outputDirectory would be something like lib
So I don't fully understand what the purpose of the first option's dependency list is for. All I want is mvn to copy my jars locally (and then eventually when my CI server does a deploy). Can someone point me in the right direction?
First Option
<project>
<dependencies>
<dependency>
<groupId>commons-lang</groupId>
<artifactId>commons-lang</artifactId>
<version>2.4</version>
</dependency>
</project>
Second Option
<project>
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-dependency-plugin</artifactId>
<configuration>
<artifactItems>
<artifactItem>
<groupId>[ groupId ]</groupId>
<artifactId>[ artifactId ]</artifactId>
<version>[ version ]</version>
<type>[ packaging ]</type>
<classifier> [classifier - optional] </classifier>
<overWrite>[ true or false ]</overWrite>
<outputDirectory>[ output directory ]</outputDirectory>
<destFileName>[ filename ]</destFileName>
</artifactItem>
</artifactItems>
<!-- other configurations here -->
</configuration>
</plugin>
</plugins>
</build>
</project>
First, many Pom's i'm seeing just have a tag under the root of the pom.xml that list all dependencies. This doesn't however have any information about where these are stored etc... so I feel like this isn't what I want (I need to copy them to my rails lib dir)
This is the traditional way to declare and use dependencies on a Java project. Dependencies declared under the <dependencies> element are downloaded from a "remote repository" and installed to your "local repository" (in ~/.m2/repository by default) and artifacts are then handled from there. Maven projects (at least the Java ones) don't use a local lib/ folder for their dependencies.
Second option, I'm seeing in the mvn docs is to use the maven-dependency-plugin, which seems more like what i'm looking for. I assume then that my outputDirectory would be something like lib
The maven dependency plugin allows to interact with artifacts and to copy/unpack them from the local or remote repositories to a specified location. So it can be used to get some dependencies and copy them in lets say a lib/ directory indeed. Actually, it has several goals allowing to do this:
dependency:copy takes a list of artifacts defined in the plugin
configuration section and copies them
to a specified location, renaming them
or stripping the version if desired.
This goal can resolve the artifacts
from remote repositories if they don't
exist in local.
dependency:copy-dependencies takes the list of project direct
dependencies and optionally transitive
dependencies and copies them to a
specified location, stripping the
version if desired. This goal can also
be run from the command line.
The first goal would use the setup you described in your second option. The second goal would use the standard project dependencies that you described in your first option. Both approaches would work.
The problem here is that I don't know exactly what a JRuby Rails app is, what the development workflow is, how to build such an app, etc so I don't know exactly what you need to do and, consequently, what would be the best way to implement that with Maven.
So I googled a bit and found this post that shows another approach based on OS commands (using the maven exec plugin) and has a complete pom.xml doing some other things. Maybe you should look at it and use it as a starting point instead of reinventing everything. This is my suggestion actually.
I'm looking for a Maven2 reporting plugin for Simian and the closest thing to such a reporting I found is this. The problem is, the documentation for it appears to be for Maven 1 instead. Why is a Maven 1 plugin stored in a Maven 2 repository? I suppose that means I can use it... but how to use? The site mentions reporting but if I don't have a src/main/site, does that mean I can't use it? I was kinda hoping for something like mvn simian:simian similar to mvn checkstyle:checkstyle and mvn pmd:pmd. I don't want to generate site just for the reports. Sites take too long to generate when all I want is a quite xml report.
The Simian plugin listed on central is actually for Maven 1 (if you inspect the contents you'll see a project.xml and a plugin.jelly). So that explains why it doesn't work. This is rubbish and should be removed in my opinion.
As far as I can make out there isn't a publically available Maven 2 plugin, this may have something to do with the licence (Simian isn't open source).
As an alternative, have a look at PMD's CPD plugin, it may not be as fully featured as simian but I know it works in a Maven 2 build and detects copypasta pretty well.
To configure PMD, add something like the following to your POM:
<reporting>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-pmd-plugin</artifactId>
<version>2.4</version>
</plugin>
</plugins>
</reporting>